author | alexsch |
Wed, 05 Oct 2016 18:42:34 +0400 | |
changeset 41774 | e9156811f79c |
parent 25859 | 3317bb8137f4 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23632
cd7a34d12e8c
8033908: Fix serial lint warnings in com.sun.java.swing.plaf
darcy
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package com.sun.java.swing.plaf.motif; |
|
27 |
||
28 |
import java.awt.*; |
|
29 |
import java.awt.event.*; |
|
30 |
||
31 |
import java.io.*; |
|
32 |
import java.util.*; |
|
33 |
||
34 |
import javax.swing.*; |
|
35 |
import javax.swing.plaf.*; |
|
36 |
import javax.swing.tree.*; |
|
37 |
import javax.swing.plaf.basic.*; |
|
38 |
||
39 |
/** |
|
40 |
* Motif rendition of the tree component. |
|
41 |
* <p> |
|
42 |
* <strong>Warning:</strong> |
|
43 |
* Serialized objects of this class will not be compatible with |
|
44 |
* future Swing releases. The current serialization support is appropriate |
|
45 |
* for short term storage or RMI between applications running the same |
|
46 |
* version of Swing. A future release of Swing will provide support for |
|
47 |
* long term persistence. |
|
48 |
* |
|
49 |
* @author Jeff Dinkins |
|
50 |
*/ |
|
51 |
public class MotifTreeUI extends BasicTreeUI |
|
52 |
{ |
|
53 |
static final int HALF_SIZE = 7; |
|
54 |
static final int SIZE = 14; |
|
55 |
||
56 |
/** |
|
57 |
* creates a UI object to represent a Motif Tree widget |
|
58 |
*/ |
|
59 |
public MotifTreeUI() { |
|
60 |
super(); |
|
61 |
} |
|
62 |
||
63 |
public void installUI(JComponent c) { |
|
64 |
super.installUI(c); |
|
65 |
} |
|
66 |
||
67 |
// BasicTreeUI overrides |
|
68 |
||
69 |
protected void paintVerticalLine( Graphics g, JComponent c, int x, int top, int bottom ) |
|
70 |
{ |
|
71 |
if (tree.getComponentOrientation().isLeftToRight()) { |
|
72 |
g.fillRect( x, top, 2, bottom - top + 2 ); |
|
73 |
} else { |
|
74 |
g.fillRect( x - 1, top, 2, bottom - top + 2 ); |
|
75 |
} |
|
76 |
} |
|
77 |
||
78 |
protected void paintHorizontalLine( Graphics g, JComponent c, int y, int left, int right ) |
|
79 |
{ |
|
80 |
g.fillRect( left, y, right - left + 1, 2 ); |
|
81 |
} |
|
82 |
||
83 |
||
84 |
/** |
|
85 |
* The minus sign button icon. |
|
86 |
* <p> |
|
87 |
* <strong>Warning:</strong> |
|
88 |
* Serialized objects of this class will not be compatible with |
|
89 |
* future Swing releases. The current serialization support is appropriate |
|
90 |
* for short term storage or RMI between applications running the same |
|
91 |
* version of Swing. A future release of Swing will provide support for |
|
92 |
* long term persistence. |
|
93 |
*/ |
|
23632
cd7a34d12e8c
8033908: Fix serial lint warnings in com.sun.java.swing.plaf
darcy
parents:
5506
diff
changeset
|
94 |
@SuppressWarnings("serial") // Same-version serialization only |
2 | 95 |
public static class MotifExpandedIcon implements Icon, Serializable { |
96 |
static Color bg; |
|
97 |
static Color fg; |
|
98 |
static Color highlight; |
|
99 |
static Color shadow; |
|
100 |
||
101 |
public MotifExpandedIcon() { |
|
102 |
bg = UIManager.getColor("Tree.iconBackground"); |
|
103 |
fg = UIManager.getColor("Tree.iconForeground"); |
|
104 |
highlight = UIManager.getColor("Tree.iconHighlight"); |
|
105 |
shadow = UIManager.getColor("Tree.iconShadow"); |
|
106 |
} |
|
107 |
||
108 |
public static Icon createExpandedIcon() { |
|
109 |
return new MotifExpandedIcon(); |
|
110 |
} |
|
111 |
||
112 |
public void paintIcon(Component c, Graphics g, int x, int y) { |
|
113 |
g.setColor(highlight); |
|
114 |
g.drawLine(x, y, x+SIZE-1, y); |
|
115 |
g.drawLine(x, y+1, x, y+SIZE-1); |
|
116 |
||
117 |
g.setColor(shadow); |
|
118 |
g.drawLine(x+SIZE-1, y+1, x+SIZE-1, y+SIZE-1); |
|
119 |
g.drawLine(x+1, y+SIZE-1, x+SIZE-1, y+SIZE-1); |
|
120 |
||
121 |
g.setColor(bg); |
|
122 |
g.fillRect(x+1, y+1, SIZE-2, SIZE-2); |
|
123 |
||
124 |
g.setColor(fg); |
|
125 |
g.drawLine(x+3, y+HALF_SIZE-1, x+SIZE-4, y+HALF_SIZE-1); |
|
126 |
g.drawLine(x+3, y+HALF_SIZE, x+SIZE-4, y+HALF_SIZE); |
|
127 |
} |
|
128 |
||
129 |
public int getIconWidth() { return SIZE; } |
|
130 |
public int getIconHeight() { return SIZE; } |
|
131 |
} |
|
132 |
||
133 |
/** |
|
134 |
* The plus sign button icon. |
|
135 |
* <p> |
|
136 |
* <strong>Warning:</strong> |
|
137 |
* Serialized objects of this class will not be compatible with |
|
138 |
* future Swing releases. The current serialization support is appropriate |
|
139 |
* for short term storage or RMI between applications running the same |
|
140 |
* version of Swing. A future release of Swing will provide support for |
|
141 |
* long term persistence. |
|
142 |
*/ |
|
23632
cd7a34d12e8c
8033908: Fix serial lint warnings in com.sun.java.swing.plaf
darcy
parents:
5506
diff
changeset
|
143 |
@SuppressWarnings("serial") // Same-version serialization only |
2 | 144 |
public static class MotifCollapsedIcon extends MotifExpandedIcon { |
145 |
public static Icon createCollapsedIcon() { |
|
146 |
return new MotifCollapsedIcon(); |
|
147 |
} |
|
148 |
||
149 |
public void paintIcon(Component c, Graphics g, int x, int y) { |
|
150 |
super.paintIcon(c, g, x, y); |
|
151 |
g.drawLine(x + HALF_SIZE-1, y + 3, x + HALF_SIZE-1, y + (SIZE - 4)); |
|
152 |
g.drawLine(x + HALF_SIZE, y + 3, x + HALF_SIZE, y + (SIZE - 4)); |
|
153 |
} |
|
154 |
} |
|
155 |
||
156 |
public static ComponentUI createUI(JComponent x) { |
|
157 |
return new MotifTreeUI(); |
|
158 |
} |
|
159 |
||
160 |
/** |
|
161 |
* Returns the default cell renderer that is used to do the |
|
162 |
* stamping of each node. |
|
163 |
*/ |
|
164 |
public TreeCellRenderer createDefaultCellRenderer() { |
|
165 |
return new MotifTreeCellRenderer(); |
|
166 |
} |
|
167 |
||
168 |
} |