Lines 190-195
Link Here
|
190 |
} |
190 |
} |
191 |
|
191 |
|
192 |
/** |
192 |
/** |
|
|
193 |
* This method invokes Scene.validate method with a specific Graphics2D instance. This is useful for rendering a scene off-screen |
194 |
* without creating and showning the main scene view. See test.view.OffscreenRenderingTest example for usages. |
195 |
* <p> |
196 |
* Note: Do not call this method unless you know the consequences. The scene is going to be validated using the specified Graphics2D |
197 |
* instance even after the method call therefore it may break scene layout when your main scene view is finally created and shown. |
198 |
* @param graphics the graphics instance used for validation |
199 |
* @since 2.7 |
200 |
*/ |
201 |
public final void validate (Graphics2D graphics) { |
202 |
Graphics2D prevoiusGraphics = getGraphics (); |
203 |
setGraphics (graphics); |
204 |
validate (); |
205 |
setGraphics (prevoiusGraphics); |
206 |
} |
207 |
/** |
193 |
* Paints the whole scene into the graphics instance. The method calls validate before rendering. |
208 |
* Paints the whole scene into the graphics instance. The method calls validate before rendering. |
194 |
* @param graphics the Graphics2D instance where the scene is going to be painted |
209 |
* @param graphics the Graphics2D instance where the scene is going to be painted |
195 |
*/ |
210 |
*/ |
Lines 294-322
Link Here
|
294 |
|
309 |
|
295 |
Dimension preferredSize = rect != null ? rect.getSize () : new Dimension (); |
310 |
Dimension preferredSize = rect != null ? rect.getSize () : new Dimension (); |
296 |
preferredSize = new Dimension ((int) (preferredSize.width * zoomFactor), (int) (preferredSize.height * zoomFactor)); |
311 |
preferredSize = new Dimension ((int) (preferredSize.width * zoomFactor), (int) (preferredSize.height * zoomFactor)); |
297 |
if (! preferredSize.equals (component.getPreferredSize ())) { |
|
|
298 |
component.setPreferredSize (preferredSize); |
299 |
component.revalidate (); |
300 |
// repaintSatellite (); |
301 |
} |
302 |
|
303 |
Dimension componentSize = component.getSize (); |
304 |
componentSize.width = (int) (componentSize.width / zoomFactor); |
305 |
componentSize.height = (int) (componentSize.height / zoomFactor); |
306 |
Rectangle bounds = getBounds (); |
312 |
Rectangle bounds = getBounds (); |
|
|
313 |
if (component != null) { |
314 |
if (! preferredSize.equals (component.getPreferredSize ())) { |
315 |
component.setPreferredSize (preferredSize); |
316 |
component.revalidate (); |
317 |
bounds = getBounds (); |
318 |
// repaintSatellite (); |
319 |
} |
307 |
|
320 |
|
308 |
boolean sceneResized = false; |
321 |
Dimension componentSize = component.getSize (); |
309 |
if (bounds.width < componentSize.width) { |
322 |
componentSize.width = (int) (componentSize.width / zoomFactor); |
310 |
bounds.width = componentSize.width; |
323 |
componentSize.height = (int) (componentSize.height / zoomFactor); |
311 |
sceneResized = true; |
324 |
|
312 |
} |
325 |
boolean sceneResized = false; |
313 |
if (bounds.height < componentSize.height) { |
326 |
if (bounds.width < componentSize.width) { |
314 |
bounds.height = componentSize.height; |
327 |
bounds.width = componentSize.width; |
315 |
sceneResized = true; |
328 |
sceneResized = true; |
|
|
329 |
} |
330 |
if (bounds.height < componentSize.height) { |
331 |
bounds.height = componentSize.height; |
332 |
sceneResized = true; |
333 |
} |
334 |
if (sceneResized) |
335 |
resolveBounds (getLocation (), bounds); |
316 |
} |
336 |
} |
317 |
if (sceneResized) |
|
|
318 |
resolveBounds (getLocation (), bounds); |
319 |
|
320 |
if (! getLocation ().equals (preLocation) || ! bounds.equals (preBounds)) { |
337 |
if (! getLocation ().equals (preLocation) || ! bounds.equals (preBounds)) { |
321 |
Rectangle rectangle = convertLocalToScene (getBounds ()); |
338 |
Rectangle rectangle = convertLocalToScene (getBounds ()); |
322 |
if (repaintRegion == null) |
339 |
if (repaintRegion == null) |
Lines 363-369
Link Here
|
363 |
if (repaintRegion != null) { |
380 |
if (repaintRegion != null) { |
364 |
Rectangle r = convertSceneToView (repaintRegion); |
381 |
Rectangle r = convertSceneToView (repaintRegion); |
365 |
r.grow (1, 1); |
382 |
r.grow (1, 1); |
366 |
component.repaint (r); |
383 |
if (component != null) |
|
|
384 |
component.repaint (r); |
367 |
repaintSatellite (); |
385 |
repaintSatellite (); |
368 |
repaintRegion = null; |
386 |
repaintRegion = null; |
369 |
} |
387 |
} |