KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jgoodies > looks > plastic > PlasticSplitPaneDivider


1 /*
2  * Copyright (c) 2001-2005 JGoodies Karsten Lentzsch. All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * o Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  *
10  * o Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * o Neither the name of JGoodies Karsten Lentzsch nor the names of
15  * its contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */

30
31 package com.jgoodies.looks.plastic;
32
33 import java.awt.Color JavaDoc;
34 import java.awt.Dimension JavaDoc;
35 import java.awt.Graphics JavaDoc;
36
37 import javax.swing.plaf.basic.BasicSplitPaneDivider JavaDoc;
38 import javax.swing.plaf.basic.BasicSplitPaneUI JavaDoc;
39
40
41 /**
42  * Paints a single drag symbol instead of many bumps.
43  *
44  * @author Karsten Lentzsch
45  * @version $Revision: 1.2 $
46  *
47  * @see PlasticSplitPaneUI
48  */

49 final class PlasticSplitPaneDivider extends BasicSplitPaneDivider JavaDoc {
50     
51     
52     PlasticSplitPaneDivider(BasicSplitPaneUI JavaDoc ui) {
53         super(ui);
54     }
55     
56     
57     public void paint(Graphics JavaDoc g) {
58         Dimension JavaDoc size = getSize();
59         Color JavaDoc bgColor = getBackground();
60
61         if (bgColor != null) {
62             g.setColor(bgColor);
63             g.fillRect(0, 0, size.width, size.height);
64         }
65         
66         /*
67         Object value = splitPane.getClientProperty("add3D");
68         if (value != null && value.equals(Boolean.TRUE)) {
69             Rectangle r = new Rectangle(0, 0, size.width, size.height);
70             FreebopUtils.addLight3DEffekt(g, r, true, false);
71         }
72         */

73         
74         //paintDragRectangle(g);
75
super.paint(g);
76     }
77     
78     /*
79     private void paintDragRectangle(Graphics g) {
80         Dimension size = getSize();
81         int xCenter = size.width / 2;
82         int yCenter = size.height / 2;
83         int x = xCenter - 2;
84         int y = yCenter - 2;
85         int w = 4;
86         int h = 4;
87
88         Color down = UIManager.getColor("controlDkShadow");
89         Color up = UIManager.getColor("controlHighlight");
90
91         g.translate(x, y);
92
93         g.setColor(down);
94         g.drawLine(0, 1, 0, h - 1); // left
95         g.drawLine(0, 0, w - 1, 0); // top
96
97         g.setColor(up);
98         g.drawLine(w - 1, 1, w - 1, h - 1);
99         g.drawLine(1, h - 1, w - 1, h - 1);
100
101         g.translate(-x, -y);
102
103         super.paint(g);
104     }
105     
106     
107     private void paintDragLines(Graphics g) {
108         Dimension size = getSize();
109         Color bgColor = getBackground();
110
111         if (bgColor != null) {
112             g.setColor(bgColor);
113             g.fillRect(0, 0, size.width, size.height);
114         }
115
116         int xCenter = size.width / 2;
117         int yCenter = size.height / 2;
118         int y0 = yCenter - 10;
119         int y1 = yCenter + 10;
120
121         Color dark = UIManager.getColor("controlDkShadow");
122         int bars = 3;
123
124         g.setColor(dark);
125         for (int i = 0; i < bars; i++) {
126             int x = 2 * i + xCenter - bars;
127             g.drawLine(x, y0, x, y1);
128         }
129
130         super.paint(g);
131     }
132     */

133 }
Popular Tags