public class TLcdGXYBoundsPainter extends ALcdGXYAreaPainter implements ILcdGXYPainter, ILcdGXYEditor, ILcdGXYEditorProvider, ILcdGXYPathPainter
ILcdBounds
objects and enables visual editing of
ILcd2DEditableBounds
objects in an ILcdGXYView
.
This painter provides three paint modes to paint the body of an ILcdBounds
object. The mode
property can be set using the method setMode
and allows the bounds to be painted as:
|
||||
![]() |
|
![]() |
|
![]() |
An outlined bounds (OUTLINED ) |
|
A filled bounds (FILLED ) |
|
A filled and outlined bounds (OUTLINED_FILLED ) |
This painter defines the four corner points of the ILcdBounds
object as a handle of the
bounds. The following image clarifies the handle location, the corner points are represented by red
points.
One of the four corner points of the ILcdBounds
object can be returned on the condition
that it is touched. The point returned as a snap target is highlighted with the snapIcon
.
The visualization of the ILcdBounds
object is governed by the line style and fill style
set to this painter. Depending on the paint mode chosen one or both of these will be taken into account.
The anchor point of the ILcdBounds
object is located at the center point of the bounds,
calculated by boundsSFCT
.
Depending on the paint mode, a bounds is touched when either the contour, one of the corner points, or the internal area (when filled) of the bounds is touched.
This editor provides the following edit functionality for the different render modes:
RESHAPED
: a contour edge or a corner point is reshaped, depending on whether
they are touched. The images below illustrate the editing behavior. The small black arrow indicates
the path of the mouse cursor while reshaping the bounds. ![]() |
|
![]() |
Moving a corner point. | |
Moving a contour edge. |
TRANSLATED
: a corner point or the whole bounds is translated, depending on whether
a corner point, the contour or the interior is touched. The images below illustrate the editing behavior.
The small black arrow indicates the path of the mouse cursor while translating the bounds. ![]() |
|
![]() |
|
![]() |
Moving a corner point. | |
Moving the contour. | |
Moving the interior. |
When initializing a bounds via interaction through the view, 2
user interactions are required
to complete the initialization. The first will define the first corner point of the bounds and the second
will define the opposite corner point.
All points are accepted as snap target as long as:
ILcdBounds
object with the model to model
transformation
,ILcdBounds
object set to this painter.
This painter implementation supports caching for objects implementing ILcdCache
.
Caching can be turned on/off with the setPaintCache
method.
ILcdBounds
,
ILcd2DEditableBounds
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
CORNER_LOWER_LEFT
Constant value indicating the lower left corner of the
ILcdBounds . |
static int |
CORNER_LOWER_RIGHT
Constant value indicating the lower right corner of the
ILcdBounds . |
static int |
CORNER_UPPER_LEFT
Constant value indicating the upper left corner of the
ILcdBounds . |
static int |
CORNER_UPPER_RIGHT
Constant value indicating the upper right corner of the
ILcdBounds . |
static int |
FILLED
Draw the
ILcdBounds object as a filled bounds, only the area of
the bounds defined by the ILcdBounds is painted. |
static int |
OUTLINED
Draw the
ILcdBounds object as an outlined bounds, only the contour
of the bounds defined by the ILcdBounds is painted. |
static int |
OUTLINED_FILLED
Draw the
ILcdBounds object as an outlined and filled bounds, both
the area and the contour of the bounds defined by the ILcdBounds
are painted. |
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
BODY, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
Constructor and Description |
---|
TLcdGXYBoundsPainter()
Constructs a default
TLcdGXYBoundsPainter in the default mode OUTLINED and sets the display name to "Bounds". |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptSnapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Determines whether a snap target should be accepted or not.
|
boolean |
appendAWTPath(ILcdGXYContext aGXYContext,
int aRenderMode,
ILcdAWTPath aAWTPathSFCT)
Appends a discretized representation in view coordinates to the given path.
|
boolean |
appendGeneralPath(ILcdGXYContext aGXYContext,
int aRenderMode,
ILcdGeneralPath aGeneralPathSFCT)
Appends a discretized representation in world coordinates to the given path.
|
void |
boundsSFCT(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext,
ILcd2DEditableBounds aBoundsSFCT)
Computes the bounds of the representation of an
ILcdBounds in AWT coordinates. |
Object |
clone()
Makes
Object.clone() public. |
boolean |
edit(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
This implementation edits the
ILcdBounds object set to the painter. |
int |
getCreationClickCount()
Returns
2 as the number of required user interactions. |
Cursor |
getCursor(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Returns a
Cursor that clarifies the render mode and context this painter is operating
in. |
boolean |
getFillSelection()
Deprecated.
use
ALcdGXYAreaPainter.getSelectionMode() instead. |
ILcdGXYEditor |
getGXYEditor(Object aObject)
Returns this instance as editor for editing the specified
Object . |
int |
getMinimumEditDelta()
Returns the minimum pixel distance the input device (a mouse, for example) must move before editing the shape.
|
Object |
getObject()
Returns the object that can currently be painted or edited by this painter/editor.
|
boolean |
getPaintCache()
Returns whether caching is used when painting this painter's object.
|
ILcdIcon |
getSnapIcon()
Returns the icon that is used to paint snap target points of the object set to this painter.
|
boolean |
isTouched(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Depending on the rendering mode, returns whether the contour, one of the corner points, or the interior
of the bounds is touched.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
protected boolean |
linkToSnapTarget(Graphics aGraphics,
ILcd2DEditableBounds a2DEditableBoundsSFCT,
int aCornerIndex,
int aRenderMode,
ILcdGXYContext aGXYContext)
Sets the specified corner point at the given snap target, if the snap target is accepted.
|
void |
paint(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Displays the representation of the object in the given mode on the Graphics passed, taking into
account the context passed.
|
void |
setFillSelection(boolean aFillSelection)
Deprecated.
use
ALcdGXYAreaPainter.setSelectionMode(int) instead. |
void |
setMinimumEditDelta(int aDelta)
Sets the minimum pixel distance the input device (a mouse, for example) must move before editing the shape.
|
void |
setModelModelTransformationClass(Class aModel2ModelTransformationClass)
Sets the transformation class that should be used when snapping to points that are defined
in a different reference than the reference of this painter's object.
|
void |
setObject(Object aObject)
Sets the object to paint and edit.
|
void |
setPaintCache(boolean aPaintCache)
Turns caching of the representation of the object on or off.
|
void |
setSnapIcon(ILcdIcon aSnapIcon)
Sets the icon that marks snap targets of the object currently set to this painter.
|
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
protected void |
setupGraphicsForFill(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Called just before filling bounds on the specified
Graphics object. |
protected void |
setupGraphicsForLine(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Called just before painting a line on the specified
Graphics object. |
Object |
snapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns one of the bounds points of the
ILcdBounds object if it is
touched. |
boolean |
supportSnap(Graphics aGraphics,
ILcdGXYContext aGXYContext)
This implementation supports snapping, always returns
true . |
getEditMode, getFillStyle, getLineStyle, getMode, getSelectionMode, setEditMode, setFillStyle, setLineStyle, setMode, setSelectionMode
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getDisplayName, getGXYPainter, removePropertyChangeListener, setClassTraceOn, setDisplayName
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDisplayName
anchorPointSFCT, getDisplayName
addPropertyChangeListener, removePropertyChangeListener
public static final int CORNER_LOWER_LEFT
ILcdBounds
.public static final int CORNER_UPPER_LEFT
ILcdBounds
.public static final int CORNER_UPPER_RIGHT
ILcdBounds
.public static final int CORNER_LOWER_RIGHT
ILcdBounds
.public static final int OUTLINED
ILcdBounds
object as an outlined bounds, only the contour
of the bounds defined by the ILcdBounds
is painted.public static final int FILLED
ILcdBounds
object as a filled bounds, only the area of
the bounds defined by the ILcdBounds
is painted.public static final int OUTLINED_FILLED
ILcdBounds
object as an outlined and filled bounds, both
the area and the contour of the bounds defined by the ILcdBounds
are painted.public TLcdGXYBoundsPainter()
TLcdGXYBoundsPainter
in the default mode OUTLINED
and sets the display name to "Bounds".public void setTraceOn(boolean aTraceOn)
true
or false
as argument automatically turns
off tracing for all other class instances for which
setTraceOn
has not been called.
If the argument is false
then only the informative, warning
and error log messages are recorded.setTraceOn
in class ALcdGXYPainter
aTraceOn
- if true then all log messages are recorded for this
instance. If false, then only the informative, warning and
error log messages are recorded.public boolean isTraceOn()
true
if tracing is enabled for this class.isTraceOn
in class ALcdGXYPainter
public void setObject(Object aObject)
Sets the object to paint and edit. The object should be an instance of ILcdBounds
for painting and an instance of ILcd2DEditableBounds
for editing.
This painter/editor can be used to paint the object without using the edit functionality. This
method shall therefore only check if the object implements ILcdBounds
and shall throw
a ClassCastException
if it does not.
When this painter is used as editor with an object that does not implement the interface ILcd2DEditableBounds
, the edit
method shall throw the necessary exception.
setObject
in interface ILcdGXYEditor
setObject
in interface ILcdGXYPainter
aObject
- The object to paint and edit.ClassCastException
- when the object does not implement ILcdBounds
.getObject()
public final Object getObject()
getObject
in interface ILcdGXYEditor
getObject
in interface ILcdGXYPainter
setObject(Object)
public void setPaintCache(boolean aPaintCache)
ILcdCache
. By default, caching
is turned on.aPaintCache
- A flag indicating whether to use caching when painting an object.getPaintCache()
public boolean getPaintCache()
true
if caching is used to paint this painter's object, false
otherwise.setPaintCache(boolean)
public void setFillSelection(boolean aFillSelection)
ALcdGXYAreaPainter.setSelectionMode(int)
instead.OUTLINED
, FILLED
or OUTLINED_FILLED
. The default is false
.aFillSelection
- A flag indicating whether to paint the object filled when selected.getFillSelection()
public boolean getFillSelection()
ALcdGXYAreaPainter.getSelectionMode()
instead.ILcdGXYPainter.SELECTED
.ILcdGXYPainter.SELECTED
.setFillSelection(boolean)
public void setSnapIcon(ILcdIcon aSnapIcon)
paint
method is called with the render mode ILcdGXYPainter.SNAPS
.aSnapIcon
- The icon that should be used to paint snap target points.getSnapIcon()
public ILcdIcon getSnapIcon()
setSnapIcon(ILcdIcon)
public void setMinimumEditDelta(int aDelta)
aDelta
- the minimum pixel distance the input device should move in either the X or Y directionpublic int getMinimumEditDelta()
public Cursor getCursor(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
Returns a Cursor
that clarifies the render mode and context this painter is operating
in. When no specific Cursor
is required, null
is returned.
If one of the corner points is touched, the cursor reshaping is returned. In reshaping mode and if none of the corner points is touched but one of the sides is touched a resizing cursor is returned. Otherwise the default cursor is returned (translating).
getCursor
in interface ILcdGXYPainter
getCursor
in class ALcdGXYPainter
aGraphics
- The graphics on which the object is painted.aRenderMode
- The mode to render the object in.aGXYContext
- The context in which the object is rendered.null
if
no particular cursor is required.public ILcdGXYEditor getGXYEditor(Object aObject)
Object
. If this
Object
is not the same as the Object
set to this painter, the
setObject(Object)
method is called to update the object set to the painter.getGXYEditor
in interface ILcdGXYEditorProvider
aObject
- the object to be edited.Object
.public int getCreationClickCount()
2
as the number of required user interactions.getCreationClickCount
in interface ILcdGXYEditor
2
.public boolean isTouched(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
This implementation will use the specified paint mode
to determine how the object
is represented. Depending on the representation of the ILcdBounds
object, the object is touched
if the contour, one of the corner points, or its interior space (when it is painted filled) is touched.
The coordinate for which the check is done is derived from the context passed as argument.
isTouched
in interface ILcdGXYPainter
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context in which the object is rendered.boundsSFCT
public void paint(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
This implementation will use the specified render mode to determine how the object needs to be
rendered. In ILcdGXYPainter.CREATING
, ILcdGXYPainter.RESHAPING
and ILcdGXYPainter.TRANSLATING
mode, the object is
painted using the edit paint mode (ALcdGXYAreaPainter.getEditMode()
). The object is rendered as shown in
the images of the class documentation.
In the render mode ILcdGXYPainter.SELECTED
, the object is painted using the selection paint mode
(ALcdGXYAreaPainter.getSelectionMode()
). In all other render modes, the paint mode (ALcdGXYAreaPainter.getMode()
)
is used.
paint
in interface ILcdGXYPainter
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.public boolean edit(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
This implementation edits the ILcdBounds
object set to the painter. The object needs to
implement the interface ILcd2DEditableBounds
otherwise a ClassCastException
will be thrown.
In ILcdGXYEditor.TRANSLATED
render mode, the ILcdBounds
object is edited as follows:
In ILcdGXYEditor.RESHAPED
render mode, the ILcdBounds
object is edited as follows:
In the creation render modes, two user interactions are required. The first will define the first corner point of the bounds and the second will define the opposite corner point.
If, in all render modes, a snap target is found for a moved or created point, the snap target location is used for the moved/created point.
edit
in interface ILcdGXYEditor
aGraphics
- The graphics to edit the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.ClassCastException
- if the painter's object does not implement ILcd2DEditableBounds
.ILcdGXYContext
,
acceptSnapTarget
public void boundsSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
ILcdBounds
in AWT coordinates. The bounds
will include the corner handles depending on the painter mode passed.boundsSFCT
in interface ILcdGXYPainter
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.aBoundsSFCT
- The bounds to update.TLcdNoBoundsException
- if no bounds can be determined for the representation of the object. This can
be when the object does not have a representation in the given context, for example when it is located in
a part of the world which is not visible in the projection as set in the views world reference.isTouched
public boolean supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
true
.supportSnap
in interface ILcdGXYPainter
supportSnap
in class ALcdGXYPainter
aGraphics
- the graphics on which is worked.aGXYContext
- the context of the snapping.true
.public Object snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
Returns one of the bounds points of the ILcdBounds
object if it is
touched. If no point was touched, null
will be returned.
snapTarget
in interface ILcdGXYPainter
snapTarget
in class ALcdGXYPainter
aGraphics
- the graphics on which is worked.aGXYContext
- the context of the snapping.ILcdBounds
object if it is
touched, null
otherwise.supportSnap
public boolean appendAWTPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdAWTPath aAWTPathSFCT)
ILcdGXYPathPainter
appendAWTPath
in interface ILcdGXYPathPainter
aGXYContext
- the graphics contextaRenderMode
- the rendering modeaAWTPathSFCT
- the path to append topublic boolean appendGeneralPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdGeneralPath aGeneralPathSFCT)
ILcdGXYPathPainter
appendGeneralPath
in interface ILcdGXYPathPainter
aGXYContext
- the graphics contextaRenderMode
- the rendering modeaGeneralPathSFCT
- the path to append topublic void setModelModelTransformationClass(Class aModel2ModelTransformationClass)
Sets the transformation class that should be used when snapping to points that are defined
in a different reference than the reference of this painter's object. The transformation will
be instantiated and setup to transform points from the model of the snap layer to points in
the model which contains the current object of this painter. The default value is the TLcdGeoReference2GeoReference
class.
This property allows the painter to snap to points defined in a different model reference.
Instances of this specified class should implement ILcdModelModelTransformation
,
otherwise the snapping functionality to different model references will not work.
aModel2ModelTransformationClass
- the transformation used as described above.public boolean acceptSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
Determines whether a snap target should be accepted or not. A snap target is accepted if the following conditions are met:
ILcd2DEditableBounds
.ILcdPoint
whose coordinates are expressed in the
same coordinate system as the current objects coordinate system or the model to model
transformation can transform the point to a point in the objects coordinate system.0
. This enables snapping when creating a bounds.acceptSnapTarget
in interface ILcdGXYEditor
aGraphics
- the graphics on which the snap target should be checked.aGXYContext
- the context in which the snap target should be checked.true
if the above conditions are met, false
otherwise.setModelModelTransformationClass(Class)
protected void setupGraphicsForLine(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
Called just before painting a line on the specified Graphics
object. It can be
redefined in order to set specific Graphics
properties like Color
,
etc...
This implementation calls ILcdGXYPainterStyle.setupGraphics(java.awt.Graphics, java.lang.Object, int, com.luciad.view.gxy.ILcdGXYContext)
on the lineStyle property
if a line style has been set to this instance.
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.protected void setupGraphicsForFill(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
Called just before filling bounds on the specified Graphics
object. It can be
redefined in order to set specific Graphics
properties like Color
,
etc...
This implementation calls ILcdGXYPainterStyle.setupGraphics(java.awt.Graphics, java.lang.Object, int, com.luciad.view.gxy.ILcdGXYContext)
on the fillStyle property
if a fill style has been set to this instance.
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.protected boolean linkToSnapTarget(Graphics aGraphics, ILcd2DEditableBounds a2DEditableBoundsSFCT, int aCornerIndex, int aRenderMode, ILcdGXYContext aGXYContext)
CORNER_LOWER_LEFT
,
CORNER_LOWER_RIGHT
,CORNER_UPPER_LEFT
,CORNER_UPPER_RIGHT
).aGraphics
- The graphics to paint the object on.a2DEditableBoundsSFCT
- The bounds objects to be edited.aCornerIndex
- The corner index to set at the snap target.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.CORNER_LOWER_LEFT
,
CORNER_LOWER_RIGHT
,
CORNER_UPPER_LEFT
,
CORNER_UPPER_RIGHT
public Object clone()
ILcdCloneable
Makes Object.clone()
public.
java.lang.Object
, it can be implemented like this:
public Object clone() {
try {
return super.clone();
} catch ( CloneNotSupportedException e ) {
// Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
throw new RuntimeException( e );
}
}
clone
in interface ILcdCloneable
clone
in interface ILcdGXYEditorProvider
clone
in interface ILcdGXYPainterProvider
clone
in class ALcdGXYAreaPainter
Object.clone()