T - The type of the painted objectpublic final class SimpleObjectPainter<T> extends Object implements Painter
Painter that allows setting an object
that should be painted with a delegate ObjectPainter| Constructor and Description |
|---|
SimpleObjectPainter(ObjectPainter<? super T> objectPainter)
Creates a new simple object painter using the given delegate
|
| Modifier and Type | Method and Description |
|---|---|
T |
getObject()
Returns the object that should be painted.
|
void |
paint(Graphics2D g,
AffineTransform worldToScreen,
double w,
double h)
Perform the painting operations on the given Graphics.
|
void |
setObject(T object)
Set the object that should be painted.
|
public SimpleObjectPainter(ObjectPainter<? super T> objectPainter)
objectPainter - The delegate ObjectPainterpublic void setObject(T object)
null, usually to indicate that nothing should
be painted.object - The objectpublic T getObject()
null.public void paint(Graphics2D g, AffineTransform worldToScreen, double w, double h)
PainterGraphics instance will be passed to
all painters. No painter should make any assumptions about the state of
the Graphics object. Changes in the given Graphics object will affect
painters that are called subsequently. This refers to configuration
settings, like the rendering hints, but also to the
transform of the Graphics.Viewer. If a painter modifies these settings, then it should
either restore the original settings afterwards, or create a local
copy of the Graphics object in order to avoid interferences with
other painters.
public void paint(
Graphics2D g, AffineTransform worldToScreen, double w, double h)
{
// Store the original transform
AffineTransform oldAT = g.getTransform();
// Perform custom transforms and painting
g.translate(100,100);
g.drawLine(10,20,30,40);
...
// Restore the original transform
g.setTransform(oldAT);
}
The AffineTransform that is passed to this method
may also be the same for multiple painters. Usually, the caller
should make sure that modifications of this transform do not
affect painters that are called subsequently, but in general,
it is not recommended to internally store or modify the given
affine transform object. paint in interface Painterg - The Graphics used for paintingworldToScreen - The world-to-screen transform. This transform
encapsulates the translation, rotation and scaling of the viewer
to which this painter belongs.w - The width of the area, in screen coordinates, in which
this painter operates. This is the screen size of the viewer to
which this painter belongs.h - The height of the area, in screen coordinates, in which
this painter operates. This is the screen size of the viewer to
which this painter belongs.Copyright © 2015. All rights reserved.