001: /*
002: * Copyright 2005-2008 Kirill Grouchnikov, based on work by
003: * Sun Microsystems, Inc. All rights reserved.
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
018: */
019: package org.jvnet.substance.swingx;
020:
021: import java.awt.Graphics;
022: import java.awt.Graphics2D;
023:
024: import javax.swing.BorderFactory;
025: import javax.swing.JComponent;
026: import javax.swing.plaf.ComponentUI;
027:
028: import org.jdesktop.swingx.JXTaskPaneContainer;
029: import org.jdesktop.swingx.VerticalLayout;
030: import org.jdesktop.swingx.plaf.LookAndFeelAddons;
031: import org.jdesktop.swingx.plaf.basic.BasicTaskPaneContainerUI;
032: import org.jvnet.substance.painter.decoration.DecorationAreaType;
033: import org.jvnet.substance.painter.decoration.SubstanceDecorationUtilities;
034:
035: /**
036: * Substance-consistent UI delegate for {@link JXTaskPaneContainer}.
037: *
038: * @author Kirill Grouchnikov
039: */
040: public class SubstanceTaskPaneContainerUI extends
041: BasicTaskPaneContainerUI {
042: /**
043: * Background delegate.
044: */
045: private SubstanceSwingxFillBackgroundDelegate bgDelegate;
046:
047: public static ComponentUI createUI(JComponent c) {
048: return new SubstanceTaskPaneContainerUI();
049: }
050:
051: /**
052: * Creates a new UI delegate.
053: */
054: public SubstanceTaskPaneContainerUI() {
055: super ();
056: this .bgDelegate = new SubstanceSwingxFillBackgroundDelegate();
057: }
058:
059: /*
060: * (non-Javadoc)
061: *
062: * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneContainerUI#installUI(javax.swing.JComponent)
063: */
064: public void installUI(JComponent c) {
065: super .installUI(c);
066:
067: JXTaskPaneContainer taskPane = (JXTaskPaneContainer) c;
068: taskPane.setLayout(new VerticalLayout(14));
069: taskPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
070: // taskPane.putClientProperty(SubstanceLookAndFeel.PAINT_ACTIVE_PROPERTY,
071: // Boolean.TRUE);
072: // taskPane.setOpaque(false);
073: }
074:
075: /*
076: * (non-Javadoc)
077: *
078: * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneContainerUI#installDefaults()
079: */
080: @Override
081: protected void installDefaults() {
082: super .installDefaults();
083: this .taskPane.setBackgroundPainter(null);
084: SubstanceDecorationUtilities.setDecorationType(this .taskPane,
085: DecorationAreaType.GENERAL);
086: }
087:
088: /*
089: * (non-Javadoc)
090: *
091: * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneContainerUI#uninstallDefaults()
092: */
093: @Override
094: protected void uninstallDefaults() {
095: SubstanceDecorationUtilities.clearDecorationType(this .taskPane);
096: super .uninstallDefaults();
097: }
098:
099: /*
100: * (non-Javadoc)
101: *
102: * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneContainerUI#paint(java.awt.Graphics,
103: * javax.swing.JComponent)
104: */
105: @Override
106: public void paint(Graphics g, JComponent c) {
107: this .bgDelegate.paint(c, (Graphics2D) g, false);
108:
109: // if (TransitionLayout.isOpaque(c)) {
110: // this.bgDelegate.updateIfOpaque(g, c);
111: // }
112: // super.paint(g, c);
113: }
114: //
115: // /*
116: // * (non-Javadoc)
117: // *
118: // * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics,
119: // * javax.swing.JComponent)
120: // */
121: // @Override
122: // public void update(Graphics g, JComponent c) {
123: // super.update(g, c);
124: // GhostPaintingUtils.paintGhostImages(c, g);
125: // }
126: }
|