001: /*
002: * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of Substance Kirill Grouchnikov nor the names of
015: * its contributors may be used to endorse or promote products derived
016: * from this software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
020: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
021: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
022: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
025: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
027: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: */
030: package org.jvnet.substance;
031:
032: import java.awt.Component;
033: import java.awt.Graphics;
034:
035: import javax.swing.JComponent;
036: import javax.swing.plaf.ComponentUI;
037: import javax.swing.plaf.basic.BasicToolBarUI;
038:
039: import org.jvnet.lafwidget.layout.TransitionLayout;
040: import org.jvnet.substance.painter.decoration.DecorationAreaType;
041: import org.jvnet.substance.painter.decoration.SubstanceDecorationUtilities;
042:
043: /**
044: * UI for tool bars in <b>Substance</b> look and feel.
045: *
046: * @author Kirill Grouchnikov
047: */
048: public class SubstanceToolBarUI extends BasicToolBarUI {
049: /**
050: * Delegate for painting the background.
051: */
052: // private static SubstanceFillBackgroundDelegate backgroundDelegate = new
053: // SubstanceFillBackgroundDelegate();
054: /*
055: * (non-Javadoc)
056: *
057: * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent)
058: */
059: public static ComponentUI createUI(JComponent c) {
060: return new SubstanceToolBarUI();
061: }
062:
063: /*
064: * (non-Javadoc)
065: *
066: * @see javax.swing.plaf.basic.BasicToolBarUI#installDefaults()
067: */
068: @Override
069: protected void installDefaults() {
070: super .installDefaults();
071: SubstanceDecorationUtilities.setDecorationType(this .toolBar,
072: DecorationAreaType.TOOLBAR);
073: }
074:
075: /*
076: * (non-Javadoc)
077: *
078: * @see javax.swing.plaf.basic.BasicToolBarUI#uninstallDefaults()
079: */
080: @Override
081: protected void uninstallDefaults() {
082: SubstanceDecorationUtilities.clearDecorationType(this .toolBar);
083: super .uninstallDefaults();
084: }
085:
086: /*
087: * (non-Javadoc)
088: *
089: * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics,
090: * javax.swing.JComponent)
091: */
092: @Override
093: public void update(Graphics g, JComponent c) {
094: boolean isOpaque = TransitionLayout.isOpaque(c);
095: if (isOpaque) {
096: SubstanceFillBackgroundDelegate.GLOBAL_INSTANCE.update(g,
097: c, false);
098: } else {
099: super .update(g, c);
100: }
101:
102: // GhostPaintingUtils.paintGhostImages(c, g);
103: }
104:
105: /*
106: * (non-Javadoc)
107: *
108: * @see javax.swing.plaf.basic.BasicToolBarUI#setBorderToRollover(java.awt.Component)
109: */
110: @Override
111: protected void setBorderToRollover(Component c) {
112: }
113:
114: /*
115: * (non-Javadoc)
116: *
117: * @see javax.swing.plaf.basic.BasicToolBarUI#setBorderToNonRollover(java.awt.Component)
118: */
119: @Override
120: protected void setBorderToNonRollover(Component c) {
121: }
122:
123: /*
124: * (non-Javadoc)
125: *
126: * @see javax.swing.plaf.basic.BasicToolBarUI#setBorderToNormal(java.awt.Component)
127: */
128: @Override
129: protected void setBorderToNormal(Component c) {
130: }
131: }
|