public class TLcdGXYGeoBufferPainter extends ALcdGXYAreaPainter implements ILcdGXYPainter, ILcdGXYEditor, ILcdGXYEditorProvider
ILcdGXYView
.
TLcdLonLatBuffer
, TLcdLonLatHeightBuffer
, ILcdVariableGeoBuffer
,
and ILcdGeoBuffer
with a base shape of the following types:
ILcdPoint
ILcdPolyline
ILcdPolygon
ILcdComplexPolygon
TLcdGeodeticPen
on the layer, its straightLineMode
property
should be disabled to ensure a correct visualization of the buffer axis.
This painter provides three paint modes to paint the body of a buffer. The mode
property can be set using the method setMode
and allows the buffer to be painted
as:
![]() |
|
![]() |
|
![]() |
An outlined buffer (OUTLINED ) |
|
A filled buffer (FILLED ) |
|
A filled and outlined buffer (OUTLINED_FILLED ) |
Objects that are selected or that are being edited, are painted as defined by the selectionMode and editMode properties, respectively. The same values as above can be used for both mode properties.
Every point of the buffer axis is regarded as a handle of the buffer. The following image clarifies the handle location, the handles are represented by red points.
ILcdVariableGeoBuffer
objects, additional circular handles are placed on every
point of the buffer axis, to control the width for every axis point.
Every point of the axis can be returned on the condition that
getTouchedPointAxis
,isDrawAxis()
) or the axis points
(see isDrawAxisPoints()
), or if snapping to invisible points is enabled
(see isSnapToInvisiblePoints()
).snapIcon
.
The visualization of a buffer 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 location of the anchor point can be set using setAnchorPointLocation(int)
to the
middle of the buffer's bounds or to the middle of the buffer itself. By default the anchor point
is located at the center point of the bounds, calculated by boundsSFCT
.
Depending on the paint mode, a buffer is touched when either the contour, one of the handles, the axis segments, or the internal area (when filled) of the buffer is touched.
TLcdLonLatBuffer
, TLcdLonLatHeightBuffer
,
ILcd2DEditableGeoBuffer
, or ILcd2DEditableVariableGeoBuffer
.
For the latter two interfaces, the base shape must be an ILcd2DEditableShape
or an ILcdEditableComplexPolygon
that contains only editable polygons.
This editor provides the following edit functionality for the different render modes:
RESHAPED
: a point is added to or removed from the buffer axis,
depending on whether an axis point or an axis segment of the buffer is touched,
or the width of the buffer is changed if the contour is touched. TRANSLATED
: a single axis point or the whole buffer is translated,
depending on whether an axis point, an axis segment or the filled interior of the buffer is touched.
For ILcdVariableGeoBuffer
objects, the width of the buffer can be adjusted for every
axis point by touching the respective contour handle.
When initializing a buffer via interaction through the view, a new point will be appended to the buffer axis
when calling edit
with
either START_CREATION
, CREATING
or END_CREATION
mode.
The number of points in the buffer axis is not limited. The initial width of a new buffer can be controlled
through setCreationBufferWidth
. If a negative
value is specified, the buffer width will be proportional to the length of the first buffer segment;
if a positive value is specified, the buffer width will be equal to the value.
All points are accepted as snap target as long as:
model to model
transformation
,
This painter implementation supports caching for objects implementing ILcdCache
.
Caching can be turned on/off with the setPaintCache
method.
The drawAxis
and drawAxisWhenSelected
properties define when the axis needs to be painted. If the axis is painted, it can
be touched, moved,...
The drawAxisPoints
and drawAxisPointsWhenSelected
properties define when the axis points needs to be painted. If the axis points are painted, they can
be touched, moved,...
Modifier and Type | Field and Description |
---|---|
static int |
FILLED
Draw the area defined by the buffer filled with the foreground color.
|
static int |
FOCUS_POINT
Constant value indicating that the anchor point should be chosen as the anchor point of the
geo buffer.
|
static int |
MIDDLE_OF_BOUNDS
Constant value indicating that the anchor point should be chosen in the middle of the buffer's
bounds, calculated by
boundsSFCT . |
static int |
MIDDLE_OF_BUFFER
Constant value indicating that the anchor point should be chosen in the middle of the
buffer's middle segment.
|
static int |
OUTLINED
Draw only the outline of the buffer.
|
static int |
OUTLINED_FILLED
Draw the buffer as an outlined and filled area.
|
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
Constructor and Description |
---|
TLcdGXYGeoBufferPainter()
Creates a new
TLcdGXYGeoBufferPainter and sets the display name
to "Buffer". |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptSnapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns whether the object set to the editor can be edited so that (part of) the object snaps to the object passed
as snap target in the context.
|
void |
anchorPointSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext,
Point aPointSFCT)
Moves the specified
aPointSFCT to the anchor point of the buffer, as specified
by getAnchorPointLocation() . |
void |
boundsSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext,
ILcd2DEditableBounds aBoundsSFCT)
Sets the supplied bounds (in view coordinates, pixels) so that it encompasses the representation of the object
in the given mode taking into account the given context.
|
Object |
clone()
Makes
Object.clone() public. |
boolean |
edit(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
This implementation edits
ILcd2DEditableGeoBuffer and ILcd2DEditableGeoBuffer
objects, otherwise a ClassCastException will be thrown. |
int |
getAnchorPointLocation()
Returns the location of the anchor point (by default: MIDDLE_OF_BOUNDS).
|
double |
getCreationBufferWidth()
Returns the buffer width set for creation of a new buffer.
|
int |
getCreationClickCount()
Returns the number of user interactions required to complete the initialization of an
ILcd2DEditableGeoBuffer or ILcd2DEditableVariableGeoBuffer object set to this editor. |
Cursor |
getCursor(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Returns a
Cursor that clarifies the render mode and context this painter is operating
in. |
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.
|
ILcdGXYPainterStyle |
getVisualAidLineStyle()
Returns the line style that is used to visualize visual aid lines when editing a
variable geo buffer.
|
boolean |
isDrawAxis()
Returns whether the axis of the buffer should be displayed.
|
boolean |
isDrawAxisPoints()
Returns whether the axis points of the buffer should be displayed.
|
boolean |
isDrawAxisPointsWhenSelected()
Returns whether the axis points of the buffer should be displayed when it is painted in selected mode.
|
boolean |
isDrawAxisWhenSelected()
Returns whether the axis of the buffer should be displayed when it is painted in selected mode.
|
boolean |
isSnapToInvisiblePoints()
Returns whether the painter allows snapping to the invisible points of the shape.
|
boolean |
isTouched(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Depending on the rendering mode, returns whether the contour, one of the axis points, axis
segments or the interior of the buffer is touched.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
paint(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Displays the representation of the object in the given mode on the Graphics passed, taking into
account the context passed.
|
void |
setAnchorPointLocation(int aAnchorPointLocation)
Sets the preferred anchor point location.
|
void |
setCreationBufferWidth(double aBufferWidth)
Sets the width of the buffer to be set at creation time.
|
void |
setDrawAxis(boolean aDrawAxis)
Sets whether the axis of the buffer should be displayed or not.
|
void |
setDrawAxisPoints(boolean aDrawAxisPoints)
Sets whether the axis points of the buffer should be displayed or not.
|
void |
setDrawAxisPointsWhenSelected(boolean aDrawAxisPointsWhenSelected)
Sets whether the axis points of the buffer should be displayed when it is painted in selected
mode or not.
|
void |
setDrawAxisWhenSelected(boolean aDrawAxisWhenSelected)
Sets whether the axis of the buffer should be displayed when it is painted in selected
mode or not.
|
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 |
setSnapToInvisiblePoints(boolean aSnapToInvisiblePoints)
Sets whether the other shapes can snap to invisible points of this shape.
|
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setVisualAidLineStyle(ILcdGXYPainterStyle aLineStyle)
Sets the line style that is used to visualize visual aid lines when editing a
variable geo buffer.
|
Object |
snapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns one of the axis or contour points of the buffer 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, firePropertyChangeEvent, firePropertyChangeEvent, getDisplayName, getGXYPainter, removePropertyChangeListener, setClassTraceOn, setDisplayName
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDisplayName
getDisplayName
addPropertyChangeListener, removePropertyChangeListener
public static final int OUTLINED
public static final int FILLED
public static final int OUTLINED_FILLED
public static final int MIDDLE_OF_BOUNDS
boundsSFCT
.public static final int FOCUS_POINT
MIDDLE_OF_BOUNDS
method is used
to calculate the anchor point.public static final int MIDDLE_OF_BUFFER
public TLcdGXYGeoBufferPainter()
TLcdGXYGeoBufferPainter
and sets the display name
to "Buffer".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. See the class javadoc for the supported objects. This painter/editor can be used to paint the object without using the edit functionality.
When this painter is used as editor with an object that does not implement one of the ILcd2DEditableGeoBuffer
/ILcd2DEditableGeoBuffer
interfaces, or its base shape is not
editable, the edit
method shall throw an exception.
setObject
in interface ILcdGXYEditor
setObject
in interface ILcdGXYPainter
aObject
- The object to paint and edit.IllegalArgumentException
- if the visualization of the object is not supportedgetObject()
public 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 setCreationBufferWidth(double aBufferWidth)
aBufferWidth
- the width of the buffer to be set at creation time.getCreationBufferWidth()
public double getCreationBufferWidth()
setCreationBufferWidth(double)
public void setDrawAxis(boolean aDrawAxis)
false
. This setting has an influence on the methods boundsSFCT
, isTouched
and snapping.aDrawAxis
- A flag indicating whether the axis of the buffer should be displayed or not.isDrawAxis()
public boolean isDrawAxis()
setDrawAxis(boolean)
public void setDrawAxisWhenSelected(boolean aDrawAxisWhenSelected)
true
. This setting has an influence
on the methods boundsSFCT
, isTouched
and snapping.aDrawAxisWhenSelected
- A flag indicating whether the axis of the buffer should be displayed
when it is painted in selected mode or not.isDrawAxisWhenSelected()
public boolean isDrawAxisWhenSelected()
setDrawAxisWhenSelected(boolean)
public void setDrawAxisPoints(boolean aDrawAxisPoints)
false
. This setting has an influence on the methods boundsSFCT
, isTouched
and snapping.aDrawAxisPoints
- A flag indicating whether the axis points of the buffer should be displayed or not.isDrawAxisPoints()
public boolean isDrawAxisPoints()
setDrawAxisPoints(boolean)
public void setDrawAxisPointsWhenSelected(boolean aDrawAxisPointsWhenSelected)
true
. This setting has an influence
on the methods boundsSFCT
, isTouched
and snapping.aDrawAxisPointsWhenSelected
- A flag indicating whether the axis points of the buffer should be displayed
when it is painted in selected mode or not.isDrawAxisPointsWhenSelected()
public boolean isDrawAxisPointsWhenSelected()
setDrawAxisPointsWhenSelected(boolean)
public void setSnapToInvisiblePoints(boolean aSnapToInvisiblePoints)
false
.aSnapToInvisiblePoints
- A flag indicating whether snapping to the invisible points is allowed.isSnapToInvisiblePoints()
public boolean isSnapToInvisiblePoints()
setSnapToInvisiblePoints(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 setVisualAidLineStyle(ILcdGXYPainterStyle aLineStyle)
aLineStyle
- the line style that is used to visualize visual aid lines when editing a
variable geo buffer.getVisualAidLineStyle()
public ILcdGXYPainterStyle getVisualAidLineStyle()
setVisualAidLineStyle(com.luciad.view.gxy.ILcdGXYPainterStyle)
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 aMode, ILcdGXYContext aGXYContext)
Cursor
that clarifies the render mode and context this painter is operating
in. When no specific Cursor
is required, null
is returned.
A non-null cursor is returned only if the mode is equal to ILcdGXYPainter.RESHAPING
or
ILcdGXYPainter.TRANSLATING
. The kind of cursor that is returned depends on location of the mouse.
In ILcdGXYPainter.RESHAPING
mode:
ILcdGXYPainter.TRANSLATING
mode:
isTouched(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
).getCursor
in interface ILcdGXYPainter
getCursor
in class ALcdGXYPainter
aGraphics
- The graphics on which the object is painted.aMode
- 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 boolean isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
This implementation will use the specified paint mode
to determine how
the object is represented. Depending on the representation of the buffer,
the object is touched if the contour, one of the axis points, one of the axis segments or,
when it is painted filled, its interior space 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.aMode
- The mode to render the object in.aGXYContext
- The context in which the object is rendered.boundsSFCT
public int getCreationClickCount()
ILcd2DEditableGeoBuffer
or ILcd2DEditableVariableGeoBuffer
object set to this editor. This implementation always
returns -2
, meaning that an unlimited number of points can be used.getCreationClickCount
in interface ILcdGXYEditor
-2
, meaning that an unlimited number of points can be used, with a minimum of two.public int getAnchorPointLocation()
MIDDLE_OF_BOUNDS
, FOCUS_POINT
, MIDDLE_OF_BUFFER
public void setAnchorPointLocation(int aAnchorPointLocation)
aAnchorPointLocation
- one of MIDDLE_OF_BOUNDS
, FOCUS_POINT
, MIDDLE_OF_BUFFER
public void anchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException
Moves the specified aPointSFCT
to the anchor point of the buffer, as specified
by getAnchorPointLocation()
.
anchorPointSFCT
in interface ILcdGXYPainter
anchorPointSFCT
in class ALcdGXYPainter
aGraphics
- The graphics to paint the object on.aMode
- The mode to render the object in.aGXYContext
- The context to render the object in.aPointSFCT
- The point that needs to be updated.TLcdNoBoundsException
- if the buffer doesn't have a valid anchor point,
e.g. if it is always invisible in the current projection.getAnchorPointLocation()
,
setAnchorPointLocation(int)
public void paint(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
This implementation will use the specified render mode to determine how the object needs to be rendered. The object is rendered as shown in the images of the class documentation.
paint
in interface ILcdGXYPainter
aGraphics
- The graphics to paint the object on.aMode
- The mode to render the object in.aGXYContext
- The context to render the object in.public boolean edit(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
This implementation edits ILcd2DEditableGeoBuffer
and ILcd2DEditableGeoBuffer
objects, otherwise a ClassCastException
will be thrown.
In ILcdGXYEditor.TRANSLATED
render mode, the buffer is edited as follows:
In ILcdGXYEditor.RESHAPED
render mode, the buffer is edited as follows:
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.aMode
- The editing mode, which contains either ILcdGXYEditor.TRANSLATED
or ILcdGXYEditor.RESHAPED
.aGXYContext
- The context to edit the buffer inClassCastException
- if the painter's object does not implement
ILcd2DEditableGeoBuffer
or ILcd2DEditableVariableGeoBuffer
.ILcdGXYContext
,
acceptSnapTarget
public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
ILcdGXYPainter
If this method returns without exception the bounds argument must encompass the representation of the object. A point outside the bounds will not be contained within the painted object.
The bounds returned in this method can be seen as the equivalent in the view space of the bounds in the model
space for ILcdBounded
objects.
boundsSFCT
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented in (see class documentation). For example, an object may be
represented differently in SELECTED mode compared to DEFAULT mode. The returned bounds of the representation
must take this different representation into account.aGXYContext
- the context for which the representation of the object is painted. It contains amongst others
the transformations from model to world and world to view.aBoundsSFCT
- the bounds that must be adapted to encompass the representation of the object in the given
mode and context. These bounds must not be taken into account when the method has thrown an exception.TLcdNoBoundsException
- if no bounds can be determined for the representation of the object.
This can happen 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 current view.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 axis or contour points of the buffer if it is touched. If none of the
axis or contour points are touched, null
is returned. Note that axis points are only returned
if they are drawn (see isDrawAxisPoints()
), if the axis is drawn (see isDrawAxis()
)
or when snapping to invisible points is enabled (see isSnapToInvisiblePoints()
).
snapTarget
in interface ILcdGXYPainter
snapTarget
in class ALcdGXYPainter
aGraphics
- the graphics on which is worked.aGXYContext
- the context of the snapping.ILcdPoint
that is touched, null
otherwise.supportSnap
public 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)
edit
method with this
context passed should edit the object so that (part of) the object snaps to the object passed
as snap target in the context.
The context contains information on the user interaction at hand: the current location of the
user interaction, given by its
X
and
Y
coordinates, and
the
distance in X direction
and
distance in Y direction
over which the user interaction is taking place.
For example, getX
and
getY
may contain the current mouse location while getDeltaX
and getDeltaY
contain the distance over which the mouse has been dragged.
The context also contains the candidate
snap target
and the
layer the snap target is contained in
.
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.isDrawAxisPoints()
or isDrawAxisPointsWhenSelected()
)
or when the axis itself is drawn (see isDrawAxis()
or isDrawAxisWhenSelected()
)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)
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()