001: /*
002: * Copyright (c) 2001-2007 JGoodies Karsten Lentzsch. 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 JGoodies Karsten Lentzsch 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:
031: package com.jgoodies.looks.plastic;
032:
033: import java.awt.Color;
034: import java.awt.Graphics;
035:
036: import javax.swing.JButton;
037: import javax.swing.plaf.basic.BasicSplitPaneDivider;
038: import javax.swing.plaf.basic.BasicSplitPaneUI;
039:
040: /**
041: * Paints a single drag symbol instead of many bumps.
042: *
043: * @author Karsten Lentzsch
044: * @version $Revision: 1.4 $
045: *
046: * @see PlasticSplitPaneUI
047: */
048: final class PlasticSplitPaneDivider extends BasicSplitPaneDivider {
049:
050: PlasticSplitPaneDivider(BasicSplitPaneUI ui) {
051: super (ui);
052: }
053:
054: protected JButton createLeftOneTouchButton() {
055: JButton btn = super .createLeftOneTouchButton();
056: btn.setOpaque(false);
057: return btn;
058: }
059:
060: protected JButton createRightOneTouchButton() {
061: JButton btn = super .createRightOneTouchButton();
062: btn.setOpaque(false);
063: return btn;
064: }
065:
066: public void paint(Graphics g) {
067: if (splitPane.isOpaque()) {
068: Color bgColor = getBackground();
069: if (bgColor != null) {
070: g.setColor(bgColor);
071: g.fillRect(0, 0, getWidth(), getHeight());
072: }
073: }
074:
075: /*
076: Object value = splitPane.getClientProperty("add3D");
077: if (value != null && value.equals(Boolean.TRUE)) {
078: Rectangle r = new Rectangle(0, 0, size.width, size.height);
079: FreebopUtils.addLight3DEffekt(g, r, true, false);
080: }
081: */
082:
083: //paintDragRectangle(g);
084: super .paint(g);
085: }
086:
087: /*
088: private void paintDragRectangle(Graphics g) {
089: Dimension size = getSize();
090: int xCenter = size.width / 2;
091: int yCenter = size.height / 2;
092: int x = xCenter - 2;
093: int y = yCenter - 2;
094: int w = 4;
095: int h = 4;
096:
097: Color down = UIManager.getColor("controlDkShadow");
098: Color up = UIManager.getColor("controlHighlight");
099:
100: g.translate(x, y);
101:
102: g.setColor(down);
103: g.drawLine(0, 1, 0, h - 1); // left
104: g.drawLine(0, 0, w - 1, 0); // top
105:
106: g.setColor(up);
107: g.drawLine(w - 1, 1, w - 1, h - 1);
108: g.drawLine(1, h - 1, w - 1, h - 1);
109:
110: g.translate(-x, -y);
111:
112: super.paint(g);
113: }
114:
115:
116: private void paintDragLines(Graphics g) {
117: Dimension size = getSize();
118: Color bgColor = getBackground();
119:
120: if (bgColor != null) {
121: g.setColor(bgColor);
122: g.fillRect(0, 0, size.width, size.height);
123: }
124:
125: int xCenter = size.width / 2;
126: int yCenter = size.height / 2;
127: int y0 = yCenter - 10;
128: int y1 = yCenter + 10;
129:
130: Color dark = UIManager.getColor("controlDkShadow");
131: int bars = 3;
132:
133: g.setColor(dark);
134: for (int i = 0; i < bars; i++) {
135: int x = 2 * i + xCenter - bars;
136: g.drawLine(x, y0, x, y1);
137: }
138:
139: super.paint(g);
140: }
141: */
142: }
|