public class TLcdGXYPointListPainter extends ALcdGXYAreaPainter implements ILcdGXYPainter, ILcdGXYEditor, ILcdGXYEditorProvider, ILcdGXYPathPainter
ILcdPointList
objects (including ILcdComplexPolygon
) and enables
visual editing of ILcd2DEditablePointList
objects in an ILcdGXYView
.
This painter provides five paint modes to paint the body of an ILcdPointList
. The mode
property can be set using the method setMode
and allows the point list to be painted
as:
![]() |
|
![]() |
||
A set of points (POINT ) |
|
A polyline (POLYLINE ) |
||
|
||||
![]() |
|
![]() |
|
![]() |
An outlined polygon (POLYGON ) |
|
A filled polygon (FILLED ) |
|
A filled and outlined polygon (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. These properties are not taken into account when an object needs to
be painted in the paint mode POINT
or POLYLINE
.
Every point of the point list is regarded as a handle of the point list. The following image clarifies the handle location, the points are represented by red points.
POINT
, the points are more than only a
handle. They are also the only visible part of the shape and should therefore always be painted
independent of the rendering mode.
Every point of the point list can be returned on the condition that it is touched, see
getTouchedPoint
. The point returned as
a snap target is highlighted with the snapIcon
.
The visualization of the ILcdPointList
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.
When the ILcdPointList
is also an ILcdShape
, the anchor point is located at
the focus point of the shape. Otherwise the anchor point is located at the center point of the point list.
Depending on the paint mode, a point list is touched when either
a point of the point list, a segment of the point list, or the internal area of the point list is touched.
The methods
getTouchedPoint
,
getTouchedSegment
and
insidePolygon
provide information
on which part of the point list is being touched.
This editor provides the following edit functionality for the different render modes:
RESHAPED
: a point is added to the point list or removed from the
point list, depending on whether a point or a segment of the point list is touched.TRANSLATED
: a single point or the whole point list is translated,
depending on whether a point or a segment is touched. The images below illustrate the
editing behavior. The small black arrow indicates the path of the mouse cursor while
translating the point list. ![]() |
|
![]() |
|
![]() |
Moving a point. | |
Moving a segment. | |
Moving the interior. |
The number of points in a point list is not limited. When initializing a point list via interaction
through the view, a new point will be appended to the point list when calling
edit
with
either START_CREATION
, CREATING
or END_CREATION
mode.
All points are accepted as snap target as long as:
ILcdPointList
object with the model to model
transformation
,ILcdPointList
object set to
this painter.
This painter implementation supports caching for objects implementing ILcdCache
.
Caching can be turned on/off with the setPaintCache
method.
Modifier and Type | Field and Description |
---|---|
static int |
AREA
Deprecated.
use
FILLED instead |
static int |
COORDINATES_AVERAGE
Constant value indicating that the anchor point should be chosen as the location determined by
the average values of the x and y coordinates.
|
static int |
END_OF_CURVE
Constant value indicating that the anchor point should be chosen at the end of the curve
if ILcdCurve is implemented.
|
static int |
FILLED
Draw the
ILcdPointList object as a filled polygon, only the area of
the polygon defined by the ILcdPointList is painted. |
static int |
FIRST_POSSIBLE_POINT
Constant value indicating that the anchor point should be chosen at the location of the
first possible point.
|
static int |
FOCUS_POINT
Constant value indicating that the anchor point should be chosen as the focus point of the
point list if it implements ILcdShape.
|
static int |
INSIDE_POLYGON
Constant value indicating that the anchor point should be chosen inside the polygon.
|
static int |
MEDIAN_POINT
Constant value indicating that the anchor point should be chosen at the location of the point
with index ( ( getPointCount() - 1 ) / 2 ).
|
static int |
MIDDLE_OF_BOUNDS
Constant value indicating that the anchor point should be chosen in the middle of the
bounds, calculated by
boundsSFCT . |
static int |
MIDDLE_OF_CURVE
Constant value indicating that the anchor point should be chosen at the middle of the curve
if ILcdCurve is implemented.
|
static int |
OUTLINE_AREA
Deprecated.
use
OUTLINED_FILLED instead |
static int |
OUTLINED_FILLED
Draw the
ILcdPointList object as an outlined and filled polygon, both
the area and the contour of the polygon defined by the ILcdPointList
are painted. |
static int |
POINT
Draw the
ILcdPointList as a list of points. |
static int |
POLYGON
Draw the
ILcdPointList object as an outlined polygon, only the contour
of the polygon defined by the ILcdPointList is painted. |
static int |
POLYLINE
Draw the
ILcdPointList as a polyline. |
static int |
START_OF_CURVE
Constant value indicating that the anchor point should be chosen at the start of the curve
if ILcdCurve is implemented.
|
OUTLINED
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
BODY, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
Constructor and Description |
---|
TLcdGXYPointListPainter()
Constructs a default
TLcdGXYPointListPainter in the default mode POLYLINE and, as display name, the result of the method getModeName() is
used. |
TLcdGXYPointListPainter(int aDefaultMode)
Constructs a
TLcdGXYPointListPainter in the specified default mode and,
as display name, the result of the method getModeName() is used. |
TLcdGXYPointListPainter(String aDisplayName)
Constructs a default
TLcdGXYPointListPainter in the default mode POLYLINE and with the given display name. |
TLcdGXYPointListPainter(String aDisplayName,
int aDefaultMode)
Constructs a
TLcdGXYPointListPainter in the specified default mode and
with the given display name. |
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 aRenderMode,
ILcdGXYContext aGXYContext,
Point aPointSFCT)
Moves the specified
aPointSFCT to the anchor point of the ILcdPointList . |
void |
append2DPoint(ILcd2DEditablePointList a2DEditablePointList,
double aX,
double aY,
int aRenderMode,
ILcdGXYContext aGXYContext)
Appends a point to the end of the specified
ILcd2DEditablePointList . |
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)
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 aRenderMode,
ILcdGXYContext aGXYContext)
This implementation edits the retrieved ILcdPointList.
|
int |
getAnchorPointLocation()
Returns the location of the anchor point (by default: FOCUS_POINT).
|
int |
getCreationClickCount()
Returns the number of user interactions required to complete the initialization of an
ILcdPointList
object set to this editor. |
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.
|
int |
getMode()
Returns the default mode to decide how to paint an
ILcdPointList . |
protected String |
getModeName()
Returns the current default paint mode as a
String . |
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.
|
int |
getTouchedPoint(ILcdGXYContext aGXYContext)
Returns the index of the point in the
ILcdPointList object that has been touched according
to the screen (x,y) coordinates passed in the ILcdGXYContext , or -1 if none of
the points were touched. |
int |
getTouchedSegment(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Returns the index of the segment in the
ILcdPointList object that has been touched according
to the coordinates in the context, or -1 if none of the segments were touched. |
int |
getTouchedSegment(ILcdGXYPen aPen,
int aX,
int aY,
boolean includesHotPoints,
ILcdModelXYWorldTransformation aMWT,
ILcdGXYViewXYWorldTransformation aVWT)
Deprecated.
use
getTouchedSegment(Graphics, int, ILcdGXYContext) instead |
TLcdAWTPath.WindingRule |
getWindingRule()
Returns how the interior of self-intersecting polygons is determined.
|
void |
insert2DPoint(ILcd2DEditablePointList a2DEditablePointList,
int aIndex,
double aX,
double aY,
int aRenderMode,
ILcdGXYContext aGXYContext)
Inserts a point at the given index into the specified
ILcd2DEditablePointList . |
boolean |
insidePolygon(ILcdGXYContext aGXYContext)
Checks whether the current position of the mouse is on the inside of the point list set to this painter as
if it was rendered as in polygon mode.
|
boolean |
isMoveOnlyOnEdit()
Returns whether this painter only allows moving the shape as a whole.
|
boolean |
isTouched(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Depending on the render mode and paint mode, returns whether one of the handles (the source point list),
the painted point list or the interior of the point list 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,
ILcd2DEditablePointList aPointList,
int aPointIndex,
int aRenderMode,
ILcdGXYContext aGXYContext)
Edits the specified
ILcdPointList so that, if the snap target is accepted, the point
(specified by its index) snaps to this snap target. |
void |
move2DPoint(ILcd2DEditablePointList a2DEditablePointList,
int aIndex,
double aX,
double aY,
int aRenderMode,
ILcdGXYContext aGXYContext)
Moves the point at the given index in the specified
ILcd2DEditablePointList to
the given point in the 2D space. |
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 |
removePointAt(ILcd2DEditablePointList a2DEditablePointList,
int aIndex,
int aRenderMode,
ILcdGXYContext aGXYContext)
Removes the point at the given index from the specified
ILcd2DEditablePointList . |
protected int |
retrieveMinimalPointcount(int aPainterMode)
Returns the number of points the
ILcdPointList should retain when removing points. |
protected ILcdPointList |
retrievePointList(Object aObject)
Extracts an
ILcdPointList from the given object. |
void |
setAnchorPointLocation(int aAnchorPointLocation)
Sets the preferred anchor point location.
|
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 |
setMode(int aDefaultMode)
Sets the default mode to decide how to paint an
ILcdPointList . |
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 |
setMoveOnlyOnEdit(boolean aMoveOnlyOnEdit)
Sets whether this painter only allows moving the shape as a whole.
|
void |
setObject(Object aObject)
Sets the object to paint or 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 polygons 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. |
protected void |
setupGraphicsForPoint(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Called just before painting points on the specified
Graphics object. |
void |
setWindingRule(TLcdAWTPath.WindingRule aWindingRule)
Specifies how the interior of self-intersecting polygons is determined.
|
Object |
snapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns a point of the
ILcdPointList object if the point is touched. |
boolean |
supportSnap(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Supports snapping when the
ILcdPointList object set to this painter contains at least
one point. |
void |
translate2D(ILcd2DEditablePointList a2DEditablePointList,
double aDeltaX,
double aDeltaY,
int aRenderMode,
ILcdGXYContext aGXYContext)
Translates all the points of the specified
ILcd2DEditablePointList from their
current positions over the given translation vector in the 2D space. |
void |
translate2DPoint(ILcd2DEditablePointList a2DEditablePointList,
int aIndex,
double aDeltaX,
double aDeltaY,
int aRenderMode,
ILcdGXYContext aGXYContext)
Translates the point at the given index in the specified
ILcd2DEditablePointList
from its current position over the given translation vector in the 2D space. |
getEditMode, getFillStyle, getLineStyle, getSelectionMode, setEditMode, setFillStyle, setLineStyle, 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 POLYGON
ILcdPointList
object as an outlined polygon, only the contour
of the polygon defined by the ILcdPointList
is painted. This constant
has the same value as the constant ALcdGXYAreaPainter.OUTLINED
.public static final int FILLED
ILcdPointList
object as a filled polygon, only the area of
the polygon defined by the ILcdPointList
is painted.public static final int OUTLINED_FILLED
ILcdPointList
object as an outlined and filled polygon, both
the area and the contour of the polygon defined by the ILcdPointList
are painted.public static final int POINT
ILcdPointList
as a list of points.public static final int POLYLINE
ILcdPointList
as a polyline.public static final int AREA
FILLED
insteadILcdPointList
object as a filled polygon, only the area of
the polygon defined by the ILcdPointList
is painted.FILLED
,
Constant Field Valuespublic static final int OUTLINE_AREA
OUTLINED_FILLED
insteadILcdPointList
object as an outlined and filled polygon, both
the area and the contour of the polygon defined by the ILcdPointList
are painted.OUTLINED_FILLED
,
Constant Field Valuespublic static final int MIDDLE_OF_BOUNDS
boundsSFCT
.public static final int FOCUS_POINT
COORDINATES_AVERAGE
method is used.public static final int COORDINATES_AVERAGE
MIDDLE_OF_BOUNDS
method is used.public static final int FIRST_POSSIBLE_POINT
MIDDLE_OF_BOUNDS
method is used.public static final int MEDIAN_POINT
MIDDLE_OF_BOUNDS
method is used.public static final int MIDDLE_OF_CURVE
MIDDLE_OF_BOUNDS
method is used.public static final int START_OF_CURVE
MIDDLE_OF_BOUNDS
method is used.public static final int END_OF_CURVE
MIDDLE_OF_BOUNDS
method is used.public static final int INSIDE_POLYGON
MIDDLE_OF_BOUNDS
method is used instead.public TLcdGXYPointListPainter()
TLcdGXYPointListPainter
in the default mode POLYLINE
and, as display name, the result of the method getModeName()
is
used.public TLcdGXYPointListPainter(String aDisplayName)
TLcdGXYPointListPainter
in the default mode POLYLINE
and with the given display name.aDisplayName
- The display name for this painter, used for textual representation
of this painter.public TLcdGXYPointListPainter(int aDefaultMode)
Constructs a TLcdGXYPointListPainter
in the specified default mode and,
as display name, the result of the method getModeName()
is used.
The default paint mode should be one of the following values: POINT
, POLYLINE
, POLYGON
, FILLED
, OUTLINED_FILLED
.
aDefaultMode
- The default paint mode to paint ILcdPointList
objects.setMode(int)
,
ALcdGXYAreaPainter.setSelectionMode(int)
,
ALcdGXYAreaPainter.setEditMode(int)
public TLcdGXYPointListPainter(String aDisplayName, int aDefaultMode)
Constructs a TLcdGXYPointListPainter
in the specified default mode and
with the given display name.
The default paint mode should be one of the following values: POINT
, POLYLINE
, POLYGON
, FILLED
, OUTLINED_FILLED
.
aDisplayName
- The display name for this painter, used for textual representation
of this painter.aDefaultMode
- The default paint mode to paint ILcdPointList
objects.setMode(int)
,
ALcdGXYAreaPainter.setSelectionMode(int)
,
ALcdGXYAreaPainter.setEditMode(int)
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)
ILcdPointList
for painting and (optionally) an ILcd2DEditablePointList
for editing.
You can change how the ILcdPointList
is derived from the object by overriding
retrievePointList(java.lang.Object)
.setObject
in interface ILcdGXYEditor
setObject
in interface ILcdGXYPainter
aObject
- The object to paint and edit.ClassCastException
- when the object does not implement ILcdPointList
.getObject()
protected ILcdPointList retrievePointList(Object aObject)
ILcdPointList
from the given object.
The default implementation simply casts the object to an ILcdPointList
.
Re-define this method to obtain the ILcdPointList
by other means.ClassCastException
- when the point list cannot be derivedsetObject(java.lang.Object)
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 setMode(int aDefaultMode)
ILcdPointList
. The point list can
be painted as a set of individual points (POINT
), as a polyline (POLYLINE
),
as an outlined polygon (POLYGON
), as a filled polygon (FILLED
), or as a
filled and outlined polygon (OUTLINED_FILLED
).
As a side effect, this method will set the display name and initialize the line style
if no line style was defined. The display name is retrieved using the method getModeName()
.
This will also have an effect on the behavior of getCreationClickCount()
,
isTouched(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
, and edit(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
.setMode
in class ALcdGXYAreaPainter
aDefaultMode
- The default paint mode to paint ILcdPointList
objects.getMode()
,
ALcdGXYAreaPainter.setSelectionMode(int)
public int getMode()
ILcdPointList
. The object can
be painted as a set of individual points (POINT
), as a polyline (POLYLINE
),
as an outlined polygon (POLYGON
), as a filled polygon (FILLED
), or as a
filled and outlined polygon (OUTLINED_FILLED
).getMode
in class ALcdGXYAreaPainter
ILcdPointList
objects.setMode(int)
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 isMoveOnlyOnEdit()
setMoveOnlyOnEdit(boolean)
public void setMoveOnlyOnEdit(boolean aMoveOnlyOnEdit)
false
.aMoveOnlyOnEdit
- when set to true
this painter can only move a
ILcdPointList
when editing and not change its shape.isMoveOnlyOnEdit()
public void setFillSelection(boolean aFillSelection)
ALcdGXYAreaPainter.setSelectionMode(int)
instead.POLYGON
, 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 setMinimumEditDelta(int aDelta)
aDelta
- the minimum pixel distance the input device should move in either the X or Y directionpublic int getMinimumEditDelta()
public int getAnchorPointLocation()
public void setAnchorPointLocation(int aAnchorPointLocation)
aAnchorPointLocation
- one of MIDDLE_OF_BOUNDS
, COORDINATES_AVERAGE
,
FOCUS_POINT
, FIRST_POSSIBLE_POINT
,
MEDIAN_POINT
, MIDDLE_OF_CURVE
, START_OF_CURVE
,
END_OF_CURVE
, INSIDE_POLYGON
.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 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 TLcdAWTPath.WindingRule getWindingRule()
public void setWindingRule(TLcdAWTPath.WindingRule aWindingRule)
aWindingRule
- the winding rule to useprotected String getModeName()
String
. The method setMode(int)
calls this method to adjust the display name of this instance depending on new mode property.String
.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 polygons 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 void setupGraphicsForPoint(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
Called just before painting points on the specified Graphics
object.
It can be redefined in order to set specific Graphics
properties like
Color
, etc...
This implementation calls ILcdGXYPainterStyle.setupGraphics(Graphics,
Object, int, ILcdGXYContext)
on the lineStyle property if a line style has been set
to this instance.
Note that points are painted using the method ILcdGXYPen.drawHotPoint(com.luciad.shape.ILcdPoint, com.luciad.transformation.ILcdModelXYWorldTransformation, com.luciad.view.gxy.ILcdGXYViewXYWorldTransformation, java.awt.Graphics)
.
Therefore changes should be applied to the pen, not the graphics, since those are usually
disregarded by the pen.
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 void anchorPointSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException
Moves the specified aPointSFCT
to the anchor point of the ILcdPointList
. This implementation first finds an anchor point in model
coordinates and then transforms it into a view point.
See getAnchorPointLocation()
on how the anchor point is calculated.
anchorPointSFCT
in interface ILcdGXYPainter
anchorPointSFCT
in class ALcdGXYPainter
aGraphics
- The graphics to paint the object on.aRenderMode
- 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 ILcdPointList
object doesn't have
a valid anchor point, e.g. if it is always invisible in the current projection.paint
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.TRANSLATING
mode, the ILcdPointList
object is rendered as if
all points were moved along the same distance in view coordinates as passed in the context. In
ILcdGXYPainter.RESHAPING
mode, the object is painted with one point moved as defined in the context.
In ILcdGXYPainter.CREATING
mode, the object is painted as if the current mouse position is the last
point of the ILcdPointList
. In the above render modes, the object is painted using
the edit paint mode (ALcdGXYAreaPainter.getEditMode()
).
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 (getMode()
)
is used.
Note: when the paint mode is set to POINT
or POLYLINE
, the objects will
be painted as, respectively points and polylines. The selectionMode and editMode property are not
taken into account when finding the mode in which the object should be painted.
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 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 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 ILcdPointList
object,
the object is touched when
FILLED
,
ILcdGXYPainter.SELECTED
.
The method insidePolygon
determines whether the current mouse position
is located inside the ILcdPointList
object or not.
It is not possible to derive from this method which part of the point list has been touched.
To determine which part of the ILcdPointList
object is touched, the methods getTouchedPoint
and getTouchedSegment
will return
the required information.
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.getMode()
public boolean insidePolygon(ILcdGXYContext aGXYContext)
isTouched
when the painter is configured to render the point list in FILLED or OUTLINED_FILLED mode.aGXYContext
- the context that contains a.o. the mouse position and the transformations.public int getTouchedPoint(ILcdGXYContext aGXYContext)
Returns the index of the point in the ILcdPointList
object that has been touched according
to the screen (x,y) coordinates passed in the ILcdGXYContext
, or -1
if none of
the points were touched.
If more than one point of the ILcdPointList
object is touched, the index of the one
with the smaller index is returned.
aGXYContext
- The context in which the object is rendered.ILcdPointList
object that was touched,
-1
if none of the points were touched.public int getTouchedSegment(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
Returns the index of the segment in the ILcdPointList
object that has been touched according
to the coordinates in the context, or -1
if none of the segments were touched.
If more than one segment of the ILcdPointList
object is touched, the index of the one
with the smaller index is returned.
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.public final int getTouchedSegment(ILcdGXYPen aPen, int aX, int aY, boolean includesHotPoints, ILcdModelXYWorldTransformation aMWT, ILcdGXYViewXYWorldTransformation aVWT)
getTouchedSegment(Graphics, int, ILcdGXYContext)
instead
Returns the index of the segment in the ILcdPointList
object that has been touched according
to the specified screen (aX,aY) coordinates, or -1
if none of the segments were touched.
If more than one segment of the ILcdPointList
object is touched, the index of the one
with the smaller index is returned.
aPen
- the pen used to paint the segments on the screen.aX
- the x screen coordinateaY
- the y screen coordinateincludesHotPoints
- whether or not to include hot points.aMWT
- the model to world transformation to use to transform the world coordinate to a model coordinate.aVWT
- the view to world transformation to use to transform a view (screen) coordinate to a world coordinate.public void boundsSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
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 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 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)
Supports snapping when the ILcdPointList
object set to this painter contains at least
one point.
supportSnap
in interface ILcdGXYPainter
supportSnap
in class ALcdGXYPainter
aGraphics
- the graphics on which is worked.aGXYContext
- the context of the snapping.true
if the ILcdPointList
object contains at least one point,
false
otherwise.public Object snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
Returns a point of the ILcdPointList
object if the point 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.ILcdPointList
object if the point is touched, null
otherwise.supportSnap
public Cursor getCursor(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
Cursor
that clarifies the render mode and context this painter is operating
in. When no specific Cursor
is required, null
is returned.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 void removePointAt(ILcd2DEditablePointList a2DEditablePointList, int aIndex, int aRenderMode, ILcdGXYContext aGXYContext)
ILcd2DEditablePointList
.a2DEditablePointList
- the point list to remove a point from.aIndex
- a valid index in the list of ILcdPoint
objects.aRenderMode
- a mode which in this implementation isn't taken into account.aGXYContext
- a context which in this implementation isn't taken into account.protected int retrieveMinimalPointcount(int aPainterMode)
Returns the number of points the ILcdPointList
should retain when removing points.
In the POINT
paint mode, this is 1
, in the POLYLINE
paint mode,
it is 2
and in the different polygon paint modes, the minimal point count is
3
.
The method is used in the edit
method to prevent the user from removing too
many points from the ILcdPointList
.
aPainterMode
- the painter mode for which the point count is wanted.ILcdPointList
should retain when removing points.public void insert2DPoint(ILcd2DEditablePointList a2DEditablePointList, int aIndex, double aX, double aY, int aRenderMode, ILcdGXYContext aGXYContext)
Inserts a point at the given index into the specified ILcd2DEditablePointList
.
The specified coordinates are defined in the model reference.
a2DEditablePointList
- the point list to insert a point into.aIndex
- a valid index in the list of ILcdPoint
objects.aX
- the X-coordinate of the new point.aY
- the Y-coordinate of the new point.aRenderMode
- a mode which in this implementation isn't taken into account.aGXYContext
- a context which in this implementation isn't taken into account.public void append2DPoint(ILcd2DEditablePointList a2DEditablePointList, double aX, double aY, int aRenderMode, ILcdGXYContext aGXYContext)
Appends a point to the end of the specified ILcd2DEditablePointList
.
The specified coordinates are defined in the model reference.
a2DEditablePointList
- the point list to append a point to.aX
- the X-coordinate of the new point.aY
- the Y-coordinate of the new point.aRenderMode
- a mode which in this implementation isn't taken into account.aGXYContext
- a context which in this implementation isn't taken into account.public void translate2D(ILcd2DEditablePointList a2DEditablePointList, double aDeltaX, double aDeltaY, int aRenderMode, ILcdGXYContext aGXYContext)
Translates all the points of the specified ILcd2DEditablePointList
from their
current positions over the given translation vector in the 2D space. Only the first two
dimensions of the points are considered. The third dimension is left unchanged.
The specified translation coordinates are defined in the model reference.
a2DEditablePointList
- the point list to translate.aDeltaX
- the X-coordinate of the translation vector.aDeltaY
- the Y-coordinate of the translation vector.aRenderMode
- a mode which in this implementation isn't taken into account.aGXYContext
- a context which in this implementation isn't taken into account.public void move2DPoint(ILcd2DEditablePointList a2DEditablePointList, int aIndex, double aX, double aY, int aRenderMode, ILcdGXYContext aGXYContext)
Moves the point at the given index in the specified ILcd2DEditablePointList
to
the given point in the 2D space. Only the first two dimensions of the points are considered.
The third dimension is left unchanged.
The specified coordinates are defined in the model reference.
a2DEditablePointList
- the point list to move a point of.aIndex
- a valid index in the list of ILcdPoint
objects.aX
- the X-coordinate of the new point.aY
- the Y-coordinate of the new point.aRenderMode
- a mode which in this implementation isn't taken into account.aGXYContext
- a context which in this implementation isn't taken into account.public void translate2DPoint(ILcd2DEditablePointList a2DEditablePointList, int aIndex, double aDeltaX, double aDeltaY, int aRenderMode, ILcdGXYContext aGXYContext)
Translates the point at the given index in the specified ILcd2DEditablePointList
from its current position over the given translation vector in the 2D space. Only the first
two dimensions of the points are considered. The third dimension is left unchanged.
The specified translation coordinates are defined in the model reference.
a2DEditablePointList
- the point list to translate a point of.aIndex
- a valid index in the list of ILcdPoint
objects.aDeltaX
- the X-coordinate of the translation vector.aDeltaY
- the Y-coordinate of the translation vector.aRenderMode
- which in this implementation isn't taken into account.aGXYContext
- a context which in this implementation isn't taken into account.public boolean edit(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
This implementation edits the retrieved ILcdPointList.
The point list needs to implement the interface ILcd2DEditablePointList
.
In ILcdGXYEditor.TRANSLATED
render mode, the ILcdPointList
is edited as follows:
In ILcdGXYEditor.RESHAPED
render mode, the ILcdPointList
is edited as follows:
In the creation render modes, new points are created beneath the mouse pointer and added to
the ILcdPointList
.
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 point list does not implement ILcd2DEditablePointList
.ILcdGXYContext
,
acceptSnapTarget
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
.
ILcd2DEditablePointList
or an ILcdEditableComplexPolygon
with ILcd2DEditablePointList
instancesILcdPoint
whose coordinates are expressed in the
same coordinate system as the current object or the model to model
transformation can transform the point to a point in the objects coordinate system.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 boolean linkToSnapTarget(Graphics aGraphics, ILcd2DEditablePointList aPointList, int aPointIndex, int aRenderMode, ILcdGXYContext aGXYContext)
ILcdPointList
so that, if the snap target is accepted, the point
(specified by its index) snaps to this snap target. The method does nothing otherwise.aGraphics
- the Graphics on which to snap to the target.aPointList
- the point list to edit.aPointIndex
- the index of the point in the point list that should snap to the target.aRenderMode
- the mode in which the snapping occurs. The mode is not taken into account in this implementation.aGXYContext
- the context in which to snap to the target.true
if the specified point is snapped to the snap target, false
otherwise.public int getCreationClickCount()
ILcdPointList
object set to this editor. In the paint mode POINT
, only one click is required. For the other
modes, a negative number is returned, meaning that an unlimited number of points can be used.
The polyline mode returns -2
, whereas the polygon modes return -3
,
indicating a minimum click count of 2 and 3, respectively.getCreationClickCount
in interface ILcdGXYEditor
1
if the paint mode equals POINT
, -2
if the mode equals POLYLINE
,
-3
otherwise.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()