50 |
import javax.accessibility.AccessibleRole; |
import javax.accessibility.AccessibleRole; |
51 |
|
|
52 |
/** |
/** |
53 |
* CellRendererPane |
* The CellRendererPane's purpose is to paint the cells of JList, JTable and |
54 |
|
* JTree. It intercepts the usual paint tree, so that we don't walk up and |
55 |
|
* repaint everything. |
56 |
|
* |
57 |
* @author Andrew Selkirk |
* @author Andrew Selkirk |
58 |
* @version 1.0 |
* @version 1.0 |
59 |
*/ |
*/ |
60 |
public class CellRendererPane extends Container implements Accessible |
public class CellRendererPane |
61 |
|
extends Container |
62 |
|
implements Accessible |
63 |
{ |
{ |
64 |
private static final long serialVersionUID = -7642183829532984273L; |
private static final long serialVersionUID = -7642183829532984273L; |
65 |
|
|
88 |
} |
} |
89 |
} |
} |
90 |
|
|
91 |
/** |
/** |
92 |
* accessibleContext |
* accessibleContext |
93 |
*/ |
*/ |
94 |
protected AccessibleContext accessibleContext = null; |
protected AccessibleContext accessibleContext = null; |
95 |
|
|
96 |
|
|
97 |
//------------------------------------------------------------- |
//------------------------------------------------------------- |
98 |
// Initialization --------------------------------------------- |
// Initialization --------------------------------------------- |
99 |
//------------------------------------------------------------- |
//------------------------------------------------------------- |
100 |
|
|
101 |
/** |
/** |
102 |
* Constructor CellRendererPane |
* Constructs a new CellRendererPane. |
103 |
*/ |
*/ |
104 |
public CellRendererPane() { |
public CellRendererPane() |
105 |
// TODO |
{ |
106 |
} // CellRendererPane() |
} // CellRendererPane() |
107 |
|
|
108 |
|
|
109 |
//------------------------------------------------------------- |
//------------------------------------------------------------- |
110 |
// Methods ---------------------------------------------------- |
// Methods ---------------------------------------------------- |
111 |
//------------------------------------------------------------- |
//------------------------------------------------------------- |
112 |
|
|
113 |
/** |
/** |
114 |
* writeObject |
* Should not be called. |
115 |
* @param stream TODO |
* |
116 |
* @exception IOException TODO |
* @param graphics not used here |
117 |
*/ |
*/ |
118 |
private void writeObject(ObjectOutputStream stream) throws IOException { |
public void update(Graphics graphics) |
119 |
// TODO |
{ |
120 |
} // writeObject() |
} // update() |
121 |
|
|
122 |
/** |
/** |
123 |
* update |
* Despite normal behaviour this does <em>not</em> cause the container |
124 |
* @param graphics TODO |
* to be invalidated. This prevents propagating up the paint tree. |
125 |
*/ |
*/ |
126 |
public void update(Graphics graphics) { |
public void invalidate() |
127 |
// TODO |
{ |
128 |
} // update() |
} // invalidate() |
129 |
|
|
130 |
/** |
/** |
131 |
* invalidate |
* Should not be called. |
132 |
*/ |
* |
133 |
public void invalidate() { |
* @param graphics not used here |
134 |
// TODO |
*/ |
135 |
} // invalidate() |
public void paint(Graphics graphics) |
136 |
|
{ |
137 |
/** |
} |
138 |
* paint |
|
139 |
* @param graphics TODO |
/** |
140 |
*/ |
* Overridden to check if a component is already a child of this Container. |
141 |
public void paint(Graphics graphics) { |
* If it's already a child, nothing is done. Otherwise we pass this to |
142 |
// TODO |
* <code>super.addImpl()</code>. |
143 |
} // paint() |
* |
144 |
|
* @param c the component to add |
145 |
/** |
* @param constraints not used here |
146 |
* addImpl |
* @param index not used here |
147 |
* @param c TODO |
*/ |
148 |
* @param constraints TODO |
protected void addImpl(Component c, Object constraints, int index) |
149 |
* @param index TODO |
{ |
150 |
*/ |
if (!isAncestorOf(c)) |
151 |
protected void addImpl(Component c, Object constraints, int index) { |
{ |
152 |
// TODO |
super.addImpl(c, constraints, index); |
153 |
} // addImpl() |
} |
154 |
|
} // addImpl() |
155 |
/** |
|
156 |
* paintComponent |
/** |
157 |
* @param graphics TODO |
* Paints the specified component <code>c</code> on the {@link Graphics} |
158 |
* @param c TODO |
* context <code>graphics</code>. The Graphics context is tranlated to |
159 |
* @param p TODO |
* (x,y) and the components bounds are set to (w,h). If |
160 |
* @param x TODO |
* <code>shouldValidate</code> |
161 |
* @param y TODO |
* is set to true, then the component is validated before painting. |
162 |
* @param w TODO |
* |
163 |
* @param h TODO |
* @param graphics the graphics context to paint on |
164 |
* @param shouldValidate TODO |
* @param c the component to be painted |
165 |
*/ |
* @param p the parent of the component |
166 |
public void paintComponent(Graphics graphics, Component c, |
* @param x the X coordinate of the upper left corner where c should |
167 |
Container p, int x, int y, int w, int h, |
be painted |
168 |
boolean shouldValidate) { |
* @param y the Y coordinate of the upper left corner where c should |
169 |
// TODO |
be painted |
170 |
} // paintComponent() |
* @param w the width of the components drawing area |
171 |
|
* @param h the height of the components drawing area |
172 |
/** |
* @param shouldValidate if <code>c</code> should be validated before |
173 |
* paintComponent |
* painting |
174 |
* @param graphics TODO |
*/ |
175 |
* @param c TODO |
public void paintComponent(Graphics graphics, Component c, |
176 |
* @param p TODO |
Container p, int x, int y, int w, int h, |
177 |
* @param x TODO |
boolean shouldValidate) |
178 |
* @param y TODO |
{ |
179 |
* @param w TODO |
// reparent c |
180 |
* @param h TODO |
addImpl(c, null, 0); |
181 |
*/ |
|
182 |
public void paintComponent(Graphics graphics, Component c, |
// translate to (x,y) |
183 |
Container p, int x, int y, int w, int h) { |
graphics.translate(x, y); |
184 |
// TODO |
|
185 |
} // paintComponent() |
// set bounds of c |
186 |
|
c.setBounds(0, 0, w, h); |
187 |
/** |
|
188 |
* paintComponent |
// validate if necessary |
189 |
* @param graphics TODO |
if (shouldValidate) |
190 |
* @param c TODO |
{ |
191 |
* @param p TODO |
c.validate(); |
192 |
* @param r TODO |
} |
193 |
*/ |
|
194 |
public void paintComponent(Graphics graphics, Component c, |
// paint component |
195 |
Container p, Rectangle r) { |
c.paint(graphics); |
196 |
// TODO |
|
197 |
} // paintComponent() |
// untranslate g |
198 |
|
graphics.translate(-x, -y); |
199 |
|
|
200 |
|
} // paintComponent() |
201 |
|
|
202 |
|
/** |
203 |
|
* Paints the specified component <code>c</code> on the {@link Graphics} |
204 |
|
* context <code>graphics</code>. The Graphics context is tranlated to (x,y) |
205 |
|
* and the components bounds are set to (w,h). The component is <em>not</em> |
206 |
|
* validated before painting. |
207 |
|
* |
208 |
|
* @param graphics the graphics context to paint on |
209 |
|
* @param c the component to be painted |
210 |
|
* @param p the parent of the component |
211 |
|
* @param x the X coordinate of the upper left corner where c should |
212 |
|
be painted |
213 |
|
* @param y the Y coordinate of the upper left corner where c should |
214 |
|
be painted |
215 |
|
* @param w the width of the components drawing area |
216 |
|
* @param h the height of the components drawing area |
217 |
|
*/ |
218 |
|
public void paintComponent(Graphics graphics, Component c, |
219 |
|
Container p, int x, int y, int w, int h) { |
220 |
|
|
221 |
|
paintComponent(graphics, c, p, x, y, w, h, false); |
222 |
|
|
223 |
|
} // paintComponent() |
224 |
|
|
225 |
|
/** |
226 |
|
* Paints the specified component <code>c</code> on the {@link Graphics} |
227 |
|
* context <code>g</code>. The Graphics context is tranlated to (r.x,r.y) and |
228 |
|
* the components bounds are set to (r.width,r.height). |
229 |
|
* The component is <em>not</em> |
230 |
|
* validated before painting. |
231 |
|
* |
232 |
|
* @param graphics the graphics context to paint on |
233 |
|
* @param c the component to be painted |
234 |
|
* @param p the component on which we paint |
235 |
|
* @param r the bounding rectangle of c |
236 |
|
*/ |
237 |
|
public void paintComponent(Graphics graphics, Component c, |
238 |
|
Container p, Rectangle r) |
239 |
|
{ |
240 |
|
|
241 |
|
paintComponent(graphics, c, p, r.x, r.y, r.width, r.height); |
242 |
|
|
243 |
|
} // paintComponent() |
244 |
|
|
245 |
/** |
/** |
246 |
* getAccessibleContext |
* getAccessibleContext <em>TODO</em> |
247 |
* @return AccessibleContext |
* @return AccessibleContext |
248 |
*/ |
*/ |
249 |
public AccessibleContext getAccessibleContext() |
public AccessibleContext getAccessibleContext() |