91 private static final int NO_LINE_STYLE = 0; |
91 private static final int NO_LINE_STYLE = 0; |
92 |
92 |
93 private int lineStyle = LEG_LINE_STYLE; |
93 private int lineStyle = LEG_LINE_STYLE; |
94 private PropertyChangeListener lineStyleListener = new LineListener(); |
94 private PropertyChangeListener lineStyleListener = new LineListener(); |
95 |
95 |
96 // Boilerplate |
96 /** |
|
97 * Constructs the {@code MetalTreeUI}. |
|
98 * |
|
99 * @param x a component |
|
100 * @return the instance of the {@code MetalTreeUI} |
|
101 */ |
97 public static ComponentUI createUI(JComponent x) { |
102 public static ComponentUI createUI(JComponent x) { |
98 return new MetalTreeUI(); |
103 return new MetalTreeUI(); |
99 } |
104 } |
100 |
105 |
101 public MetalTreeUI() |
106 /** |
102 { |
107 * Constructs the {@code MetalTreeUI}. |
|
108 */ |
|
109 public MetalTreeUI() { |
103 super(); |
110 super(); |
104 } |
111 } |
105 |
112 |
106 protected int getHorizontalLegBuffer() |
113 protected int getHorizontalLegBuffer() { |
107 { |
114 return 3; |
108 return 3; |
115 } |
109 } |
|
110 |
116 |
111 public void installUI( JComponent c ) { |
117 public void installUI( JComponent c ) { |
112 super.installUI( c ); |
118 super.installUI( c ); |
113 lineColor = UIManager.getColor( "Tree.line" ); |
119 lineColor = UIManager.getColor( "Tree.line" ); |
114 |
120 |
121 public void uninstallUI( JComponent c) { |
127 public void uninstallUI( JComponent c) { |
122 c.removePropertyChangeListener(lineStyleListener); |
128 c.removePropertyChangeListener(lineStyleListener); |
123 super.uninstallUI(c); |
129 super.uninstallUI(c); |
124 } |
130 } |
125 |
131 |
126 /** this function converts between the string passed into the client property |
132 /** |
127 * and the internal representation (currently and int) |
133 * Converts between the string passed into the client property |
128 * |
134 * and the internal representation (currently and int) |
129 */ |
135 * |
|
136 * @param lineStyleFlag a flag |
|
137 */ |
130 protected void decodeLineStyle(Object lineStyleFlag) { |
138 protected void decodeLineStyle(Object lineStyleFlag) { |
131 if ( lineStyleFlag == null || |
139 if ( lineStyleFlag == null || |
132 lineStyleFlag.equals(LEG_LINE_STYLE_STRING)){ |
140 lineStyleFlag.equals(LEG_LINE_STYLE_STRING)) { |
133 lineStyle = LEG_LINE_STYLE; // default case |
141 lineStyle = LEG_LINE_STYLE; // default case |
134 } else { |
142 } else { |
135 if ( lineStyleFlag.equals(NO_STYLE_STRING) ) { |
143 if ( lineStyleFlag.equals(NO_STYLE_STRING) ) { |
136 lineStyle = NO_LINE_STYLE; |
144 lineStyle = NO_LINE_STYLE; |
137 } else if ( lineStyleFlag.equals(HORIZ_STYLE_STRING) ) { |
145 } else if ( lineStyleFlag.equals(HORIZ_STYLE_STRING) ) { |
138 lineStyle = HORIZ_LINE_STYLE; |
146 lineStyle = HORIZ_LINE_STYLE; |
139 } |
147 } |
140 } |
148 } |
141 |
149 } |
142 } |
150 |
143 |
151 /** |
|
152 * Returns {@code true} if a point with X coordinate {@code mouseX} |
|
153 * and Y coordinate {@code mouseY} is in expanded control. |
|
154 * |
|
155 * @param row a row |
|
156 * @param rowLevel a row level |
|
157 * @param mouseX X coordinate |
|
158 * @param mouseY Y coordinate |
|
159 * @return {@code true} if a point with X coordinate {@code mouseX} |
|
160 * and Y coordinate {@code mouseY} is in expanded control. |
|
161 */ |
144 protected boolean isLocationInExpandControl(int row, int rowLevel, |
162 protected boolean isLocationInExpandControl(int row, int rowLevel, |
145 int mouseX, int mouseY) { |
163 int mouseX, int mouseY) { |
146 if(tree != null && !isLeaf(row)) { |
164 if(tree != null && !isLeaf(row)) { |
147 int boxWidth; |
165 int boxWidth; |
148 |
166 |
173 if (lineStyle == HORIZ_LINE_STYLE && !largeModel) { |
191 if (lineStyle == HORIZ_LINE_STYLE && !largeModel) { |
174 paintHorizontalSeparators(g,c); |
192 paintHorizontalSeparators(g,c); |
175 } |
193 } |
176 } |
194 } |
177 |
195 |
|
196 /** |
|
197 * Paints the horizontal separators. |
|
198 * |
|
199 * @param g an instance of {@code Graphics} |
|
200 * @param c a component |
|
201 */ |
178 protected void paintHorizontalSeparators(Graphics g, JComponent c) { |
202 protected void paintHorizontalSeparators(Graphics g, JComponent c) { |
179 g.setColor( lineColor ); |
203 g.setColor( lineColor ); |
180 |
204 |
181 Rectangle clipBounds = g.getClipBounds(); |
205 Rectangle clipBounds = g.getClipBounds(); |
182 |
206 |