Class TLcdGXYPointListPainter
- All Implemented Interfaces:
ILcdCloneable
,ILcdPropertyChangeSource
,ILcdGXYEditor
,ILcdGXYEditorProvider
,ILcdGXYPainter
,ILcdGXYPainterProvider
,ILcdGXYPathPainter
,Serializable
,Cloneable
- Direct Known Subclasses:
TLcdGXYAISPointListPainter
,TLcdGXYRoundedPointListPainter
,TLcdMagneticNorthGXYPainter
,TLcdPOLPainter
,TLcdVPFPointListPainter
ILcdPointList
objects (including ILcdComplexPolygon
) and enables
visual editing of ILcd2DEditablePointList
objects in an ILcdGXYView
.
Painting an ILcdPointList
Body
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
.
Handles
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.
Note that, when the paint mode is set to
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.
Snap targets
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
.
Styling options
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.
Locating an ILcdPointList in a view
Anchor point of an ILcdPointList
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.
When is an ILcdPointList touched
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.
Visually editing and creating an ILcd2DEditablePointList
Modifying an ILcd2DEditablePointList
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.
Creating an ILcd2DEditablePointList
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.
Accepted snap targets
All points are accepted as snap target as long as:
- the point can be transformed to the reference of the
ILcdPointList
object with themodel to model transformation
, - the point is not the last point of the
ILcdPointList
object set to this painter.
Additional properties
Caching
This painter implementation supports caching for objects implementing ILcdCache
.
Caching can be turned on/off with the setPaintCache
method.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Deprecated.static final int
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 final int
Constant value indicating that the anchor point should be chosen at the end of the curve if ILcdCurve is implemented.static final int
Draw theILcdPointList
object as a filled polygon, only the area of the polygon defined by theILcdPointList
is painted.static final int
Constant value indicating that the anchor point should be chosen at the location of the first possible point.static final int
Constant value indicating that the anchor point should be chosen as the focus point of the point list if it implements ILcdShape.static final int
Constant value indicating that the anchor point should be chosen inside the polygon.static final int
Constant value indicating that the anchor point should be chosen at the location of the point with index ( ( getPointCount() - 1 ) / 2 ).static final int
Constant value indicating that the anchor point should be chosen in the middle of the bounds, calculated byboundsSFCT
.static final int
Constant value indicating that the anchor point should be chosen at the middle of the curve if ILcdCurve is implemented.static final int
Deprecated.useOUTLINED_FILLED
insteadstatic final int
Draw theILcdPointList
object as an outlined and filled polygon, both the area and the contour of the polygon defined by theILcdPointList
are painted.static final int
Draw theILcdPointList
as a list of points.static final int
Draw theILcdPointList
object as an outlined polygon, only the contour of the polygon defined by theILcdPointList
is painted.static final int
Draw theILcdPointList
as a polyline.static final int
Constant value indicating that the anchor point should be chosen at the start of the curve if ILcdCurve is implemented.Fields inherited from class com.luciad.view.gxy.painter.ALcdGXYAreaPainter
OUTLINED
Fields inherited from class com.luciad.view.gxy.ALcdGXYPainter
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
Fields inherited from interface com.luciad.view.gxy.ILcdGXYEditor
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
Fields inherited from interface com.luciad.view.gxy.ILcdGXYPainter
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
-
Constructor Summary
ConstructorDescriptionConstructs a defaultTLcdGXYPointListPainter
in the default modePOLYLINE
and, as display name, the result of the methodgetModeName()
is used.TLcdGXYPointListPainter
(int aDefaultMode) Constructs aTLcdGXYPointListPainter
in the specified default mode and, as display name, the result of the methodgetModeName()
is used.TLcdGXYPointListPainter
(String aDisplayName) Constructs a defaultTLcdGXYPointListPainter
in the default modePOLYLINE
and with the given display name.TLcdGXYPointListPainter
(String aDisplayName, int aDefaultMode) Constructs aTLcdGXYPointListPainter
in the specified default mode and with the given display name. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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 specifiedaPointSFCT
to the anchor point of theILcdPointList
.void
append2DPoint
(ILcd2DEditablePointList a2DEditablePointList, double aX, double aY, int aRenderMode, ILcdGXYContext aGXYContext) Appends a point to the end of the specifiedILcd2DEditablePointList
.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.clone()
MakesObject.clone()
public.boolean
edit
(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) This implementation edits the retrieved ILcdPointList.int
Returns the location of the anchor point (by default: FOCUS_POINT).int
Returns the number of user interactions required to complete the initialization of anILcdPointList
object set to this editor.getCursor
(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) Returns aCursor
that clarifies the render mode and context this painter is operating in.boolean
Deprecated.useALcdGXYAreaPainter.getSelectionMode()
instead.getGXYEditor
(Object aObject) Returns this instance as editor for editing the specifiedObject
.int
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 anILcdPointList
.protected String
Returns the current default paint mode as aString
.Returns the object that can currently be painted or edited by this painter/editor.boolean
Returns whether caching is used when painting this painter's object.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 theILcdPointList
object that has been touched according to the screen (x,y) coordinates passed in theILcdGXYContext
, or-1
if none of the points were touched.final int
getTouchedSegment
(ILcdGXYPen aPen, int aX, int aY, boolean includesHotPoints, ILcdModelXYWorldTransformation aMWT, ILcdGXYViewXYWorldTransformation aVWT) Deprecated.usegetTouchedSegment(Graphics, int, ILcdGXYContext)
insteadint
getTouchedSegment
(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) Returns the index of the segment in theILcdPointList
object that has been touched according to the coordinates in the context, or-1
if none of the segments were touched.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 specifiedILcd2DEditablePointList
.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
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
Deprecated.This method has been deprecated.protected boolean
linkToSnapTarget
(Graphics aGraphics, ILcd2DEditablePointList aPointList, int aPointIndex, int aRenderMode, ILcdGXYContext aGXYContext) Edits the specifiedILcdPointList
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 specifiedILcd2DEditablePointList
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 specifiedILcd2DEditablePointList
.protected int
retrieveMinimalPointcount
(int aPainterMode) Returns the number of points theILcdPointList
should retain when removing points.protected ILcdPointList
retrievePointList
(Object aObject) Extracts anILcdPointList
from the given object.void
setAnchorPointLocation
(int aAnchorPointLocation) Sets the preferred anchor point location.void
setFillSelection
(boolean aFillSelection) Deprecated.useALcdGXYAreaPainter.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 anILcdPointList
.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
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.protected void
setupGraphicsForFill
(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) Called just before filling polygons on the specifiedGraphics
object.protected void
setupGraphicsForLine
(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) Called just before painting a line on the specifiedGraphics
object.protected void
setupGraphicsForPoint
(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) Called just before painting points on the specifiedGraphics
object.void
setWindingRule
(TLcdAWTPath.WindingRule aWindingRule) Specifies how the interior of self-intersecting polygons is determined.snapTarget
(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns a point of theILcdPointList
object if the point is touched.boolean
supportSnap
(Graphics aGraphics, ILcdGXYContext aGXYContext) Supports snapping when theILcdPointList
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 specifiedILcd2DEditablePointList
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 specifiedILcd2DEditablePointList
from its current position over the given translation vector in the 2D space.Methods inherited from class com.luciad.view.gxy.painter.ALcdGXYAreaPainter
getEditMode, getFillStyle, getLineStyle, getSelectionMode, setEditMode, setFillStyle, setLineStyle, setSelectionMode
Methods inherited from class com.luciad.view.gxy.ALcdGXYPainter
addPropertyChangeListener, firePropertyChangeEvent, firePropertyChangeEvent, getDisplayName, getGXYPainter, removePropertyChangeListener, setClassTraceOn, setDisplayName
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.view.gxy.ILcdGXYEditor
getDisplayName
Methods inherited from interface com.luciad.view.gxy.ILcdGXYPainter
getDisplayName
Methods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
-
Field Details
-
POLYGON
public static final int POLYGONDraw theILcdPointList
object as an outlined polygon, only the contour of the polygon defined by theILcdPointList
is painted. This constant has the same value as the constantALcdGXYAreaPainter.OUTLINED
.- See Also:
-
FILLED
public static final int FILLEDDraw theILcdPointList
object as a filled polygon, only the area of the polygon defined by theILcdPointList
is painted.- Since:
- 1.4
- See Also:
-
OUTLINED_FILLED
public static final int OUTLINED_FILLEDDraw theILcdPointList
object as an outlined and filled polygon, both the area and the contour of the polygon defined by theILcdPointList
are painted.- Since:
- 1.4
- See Also:
-
POINT
public static final int POINTDraw theILcdPointList
as a list of points.- See Also:
-
POLYLINE
public static final int POLYLINEDraw theILcdPointList
as a polyline.- See Also:
-
AREA
public static final int AREADeprecated.useFILLED
insteadDraw theILcdPointList
object as a filled polygon, only the area of the polygon defined by theILcdPointList
is painted.- See Also:
-
OUTLINE_AREA
public static final int OUTLINE_AREADeprecated.useOUTLINED_FILLED
insteadDraw theILcdPointList
object as an outlined and filled polygon, both the area and the contour of the polygon defined by theILcdPointList
are painted.- See Also:
-
MIDDLE_OF_BOUNDS
public static final int MIDDLE_OF_BOUNDSConstant value indicating that the anchor point should be chosen in the middle of the bounds, calculated byboundsSFCT
.- See Also:
-
FOCUS_POINT
public static final int FOCUS_POINTConstant value indicating that the anchor point should be chosen as the focus point of the point list if it implements ILcdShape. If it does not implement ILcdShape, theCOORDINATES_AVERAGE
method is used.- See Also:
-
COORDINATES_AVERAGE
public static final int COORDINATES_AVERAGEConstant value indicating that the anchor point should be chosen as the location determined by the average values of the x and y coordinates. If this method cannot return an anchor point, theMIDDLE_OF_BOUNDS
method is used.- See Also:
-
FIRST_POSSIBLE_POINT
public static final int FIRST_POSSIBLE_POINTConstant value indicating that the anchor point should be chosen at the location of the first possible point. If the first point is invalid, then the second one is used, and so on... If no valid anchor point can be found, theMIDDLE_OF_BOUNDS
method is used.- See Also:
-
MEDIAN_POINT
public static final int MEDIAN_POINTConstant value indicating that the anchor point should be chosen at the location of the point with index ( ( getPointCount() - 1 ) / 2 ). If no valid anchor point can be found, theMIDDLE_OF_BOUNDS
method is used.- See Also:
-
MIDDLE_OF_CURVE
public static final int MIDDLE_OF_CURVEConstant value indicating that the anchor point should be chosen at the middle of the curve if ILcdCurve is implemented. If ILcdCurve is not implemented, or if no valid anchor point can be found, theMIDDLE_OF_BOUNDS
method is used.- See Also:
-
START_OF_CURVE
public static final int START_OF_CURVEConstant value indicating that the anchor point should be chosen at the start of the curve if ILcdCurve is implemented. If ILcdCurve is not implemented, or if no valid anchor point can be found, theMIDDLE_OF_BOUNDS
method is used.- See Also:
-
END_OF_CURVE
public static final int END_OF_CURVEConstant value indicating that the anchor point should be chosen at the end of the curve if ILcdCurve is implemented. If ILcdCurve is not implemented, or if no valid anchor point can be found, theMIDDLE_OF_BOUNDS
method is used.- See Also:
-
INSIDE_POLYGON
public static final int INSIDE_POLYGONConstant value indicating that the anchor point should be chosen inside the polygon. This method works when this painter uses the POLYGON painting mode. If no anchor point could be calculated, theMIDDLE_OF_BOUNDS
method is used instead.- See Also:
-
-
Constructor Details
-
TLcdGXYPointListPainter
public TLcdGXYPointListPainter()Constructs a defaultTLcdGXYPointListPainter
in the default modePOLYLINE
and, as display name, the result of the methodgetModeName()
is used. -
TLcdGXYPointListPainter
Constructs a defaultTLcdGXYPointListPainter
in the default modePOLYLINE
and with the given display name.- Parameters:
aDisplayName
- The display name for this painter, used for textual representation of this painter.
-
TLcdGXYPointListPainter
public TLcdGXYPointListPainter(int aDefaultMode) Constructs a
TLcdGXYPointListPainter
in the specified default mode and, as display name, the result of the methodgetModeName()
is used.The default paint mode should be one of the following values:
POINT
,POLYLINE
,POLYGON
,FILLED
,OUTLINED_FILLED
.- Parameters:
aDefaultMode
- The default paint mode to paintILcdPointList
objects.- See Also:
-
TLcdGXYPointListPainter
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
.- Parameters:
aDisplayName
- The display name for this painter, used for textual representation of this painter.aDefaultMode
- The default paint mode to paintILcdPointList
objects.- See Also:
-
-
Method Details
-
setTraceOn
public void setTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for this class instance. Calling this method with eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
then only the informative, warning and error log messages are recorded.- Overrides:
setTraceOn
in classALcdGXYPainter
- Parameters:
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.
-
isTraceOn
public boolean isTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrue
if tracing is enabled for this class.- Overrides:
isTraceOn
in classALcdGXYPainter
- Returns:
- true if tracing is enabled for this class, false otherwise.
-
setObject
Sets the object to paint or edit. This painter needs anILcdPointList
for painting and (optionally) anILcd2DEditablePointList
for editing. You can change how theILcdPointList
is derived from the object by overridingretrievePointList(java.lang.Object)
.- Specified by:
setObject
in interfaceILcdGXYEditor
- Specified by:
setObject
in interfaceILcdGXYPainter
- Parameters:
aObject
- The object to paint and edit.- Throws:
ClassCastException
- when the object does not implementILcdPointList
.- See Also:
-
retrievePointList
Extracts anILcdPointList
from the given object. The default implementation simply casts the object to anILcdPointList
. Re-define this method to obtain theILcdPointList
by other means.- Returns:
- the point list associated with the given object
- Throws:
ClassCastException
- when the point list cannot be derived- Since:
- 2022.0
- See Also:
-
getObject
Returns the object that can currently be painted or edited by this painter/editor.- Specified by:
getObject
in interfaceILcdGXYEditor
- Specified by:
getObject
in interfaceILcdGXYPainter
- Returns:
- the object that can currently be painted or edited by this painter/editor.
- See Also:
-
setPaintCache
public void setPaintCache(boolean aPaintCache) Turns caching of the representation of the object on or off. Caching greatly reduces the time to paint an object but requires more memory. The representation of an object can only be cached for objects which implementILcdCache
. By default, caching is turned on.- Parameters:
aPaintCache
- A flag indicating whether to use caching when painting an object.- See Also:
-
getPaintCache
public boolean getPaintCache()Returns whether caching is used when painting this painter's object.- Returns:
true
if caching is used to paint this painter's object,false
otherwise.- See Also:
-
setMode
public void setMode(int aDefaultMode) Sets the default mode to decide how to paint anILcdPointList
. 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 methodgetModeName()
. This will also have an effect on the behavior ofgetCreationClickCount()
,isTouched(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
, andedit(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
.- Overrides:
setMode
in classALcdGXYAreaPainter
- Parameters:
aDefaultMode
- The default paint mode to paintILcdPointList
objects.- See Also:
-
getMode
public int getMode()Returns the default mode to decide how to paint anILcdPointList
. 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
).- Overrides:
getMode
in classALcdGXYAreaPainter
- Returns:
- The default paint mode to paint
ILcdPointList
objects. - See Also:
-
setModelModelTransformationClass
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.- Parameters:
aModel2ModelTransformationClass
- the transformation used as described above.
-
isMoveOnlyOnEdit
public boolean isMoveOnlyOnEdit()Returns whether this painter only allows moving the shape as a whole. If false, other editing operations will be available as well.- Returns:
- whether this painter allows only moving the shape while editing.
- See Also:
-
setMoveOnlyOnEdit
public void setMoveOnlyOnEdit(boolean aMoveOnlyOnEdit) Sets whether this painter only allows moving the shape as a whole. If false, other editing operations will be available as well. By default, this value is set tofalse
.- Parameters:
aMoveOnlyOnEdit
- when set totrue
this painter can only move aILcdPointList
when editing and not change its shape.- See Also:
-
setFillSelection
public void setFillSelection(boolean aFillSelection) Deprecated.useALcdGXYAreaPainter.setSelectionMode(int)
instead.Determines whether the painter will fill the polygon when it is selected. This property is only valid when the default paint mode property is eitherPOLYGON
,FILLED
orOUTLINED_FILLED
. The default isfalse
.- Parameters:
aFillSelection
- A flag indicating whether to paint the object filled when selected.- See Also:
-
getFillSelection
public boolean getFillSelection()Deprecated.useALcdGXYAreaPainter.getSelectionMode()
instead.Returns whether the object is painted filled in the render modeILcdGXYPainter.SELECTED
.- Returns:
- whether the object is painted filled in the render mode
ILcdGXYPainter.SELECTED
. - See Also:
-
setMinimumEditDelta
public void setMinimumEditDelta(int aDelta) Sets the minimum pixel distance the input device (a mouse, for example) must move before editing the shape. A larger value ensures that the object easily "snaps" back in place, a small value allows fine editing.- Parameters:
aDelta
- the minimum pixel distance the input device should move in either the X or Y direction
-
getMinimumEditDelta
public int getMinimumEditDelta()Returns the minimum pixel distance the input device (a mouse, for example) must move before editing the shape. A larger value ensures that the object easily "snaps" back in place, a small value allows fine editing. The default value is 3 pixels.- Returns:
- the minimum pixel distance the input device should move in either the X or Y direction
-
getAnchorPointLocation
public int getAnchorPointLocation()Returns the location of the anchor point (by default: FOCUS_POINT). -
setAnchorPointLocation
public void setAnchorPointLocation(int aAnchorPointLocation) Sets the preferred anchor point location.- Parameters:
aAnchorPointLocation
- one ofMIDDLE_OF_BOUNDS
,COORDINATES_AVERAGE
,FOCUS_POINT
,FIRST_POSSIBLE_POINT
,MEDIAN_POINT
,MIDDLE_OF_CURVE
,START_OF_CURVE
,END_OF_CURVE
,INSIDE_POLYGON
.
-
getGXYEditor
Returns this instance as editor for editing the specifiedObject
. If thisObject
is not the same as theObject
set to this painter, thesetObject(Object)
method is called to update the object set to the painter.- Specified by:
getGXYEditor
in interfaceILcdGXYEditorProvider
- Parameters:
aObject
- the object to be edited.- Returns:
- this instance as editor for editing the specified
Object
.
-
setSnapIcon
Sets the icon that marks snap targets of the object currently set to this painter. This icon is painted when thepaint
method is called with the render modeILcdGXYPainter.SNAPS
.- Parameters:
aSnapIcon
- The icon that should be used to paint snap target points.- See Also:
-
getSnapIcon
Returns the icon that is used to paint snap target points of the object set to this painter.- Returns:
- the icon that is used to paint snap target points of the object set to this painter.
- See Also:
-
getWindingRule
Returns how the interior of self-intersecting polygons is determined. This affects isTouched behavior and the fills.- Returns:
- the winding rule to use
-
setWindingRule
Specifies how the interior of self-intersecting polygons is determined. This affects isTouched behavior and the fills.- Parameters:
aWindingRule
- the winding rule to use
-
getModeName
Returns the current default paint mode as aString
. The methodsetMode(int)
calls this method to adjust the display name of this instance depending on new mode property.- Returns:
- the current default paint mode as a
String
.
-
setupGraphicsForLine
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 specificGraphics
properties likeColor
, 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.- Parameters:
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.
-
setupGraphicsForFill
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 specificGraphics
properties likeColor
, 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.- Parameters:
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.
-
setupGraphicsForPoint
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 specificGraphics
properties likeColor
, 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.- Parameters:
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.
-
anchorPointSFCT
public void anchorPointSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException Moves the specified
aPointSFCT
to the anchor point of theILcdPointList
. 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.- Specified by:
anchorPointSFCT
in interfaceILcdGXYPainter
- Overrides:
anchorPointSFCT
in classALcdGXYPainter
- Parameters:
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.- Throws:
TLcdNoBoundsException
- if theILcdPointList
object doesn't have a valid anchor point, e.g. if it is always invisible in the current projection.- See Also:
-
paint
Displays the representation of the object in the given mode on the Graphics passed, taking into account the context passed.This implementation will use the specified render mode to determine how the object needs to be rendered. In
ILcdGXYPainter.TRANSLATING
mode, theILcdPointList
object is rendered as if all points were moved along the same distance in view coordinates as passed in the context. InILcdGXYPainter.RESHAPING
mode, the object is painted with one point moved as defined in the context. InILcdGXYPainter.CREATING
mode, the object is painted as if the current mouse position is the last point of theILcdPointList
. 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
orPOLYLINE
, 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.- Specified by:
paint
in interfaceILcdGXYPainter
- Parameters:
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.
-
appendAWTPath
Description copied from interface:ILcdGXYPathPainter
Appends a discretized representation in view coordinates to the given path.- Specified by:
appendAWTPath
in interfaceILcdGXYPathPainter
- Parameters:
aGXYContext
- the graphics contextaRenderMode
- the rendering modeaAWTPathSFCT
- the path to append to- Returns:
- true if a discretization of the shape could be successfully appended to the path
-
appendGeneralPath
public boolean appendGeneralPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdGeneralPath aGeneralPathSFCT) Description copied from interface:ILcdGXYPathPainter
Appends a discretized representation in world coordinates to the given path.- Specified by:
appendGeneralPath
in interfaceILcdGXYPathPainter
- Parameters:
aGXYContext
- the graphics contextaRenderMode
- the rendering modeaGeneralPathSFCT
- the path to append to- Returns:
- true if a discretization of the shape could be successfully appended to the path
-
isTouched
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.This implementation will use the specified
paint mode
to determine how the object is represented. Depending on the representation of theILcdPointList
object, the object is touched when- the painted point list is touched,
- its interior space is touched when the paint mode is
FILLED
, - the source point list is touched when the render mode is
ILcdGXYPainter.SELECTED
.
The method
insidePolygon
determines whether the current mouse position is located inside theILcdPointList
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 methodsgetTouchedPoint
andgetTouchedSegment
will return the required information.- Specified by:
isTouched
in interfaceILcdGXYPainter
- Parameters:
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.- Returns:
- whether one of the points, segments or the interior of the point list is touched.
- See Also:
-
insidePolygon
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. This method is called byisTouched
when the painter is configured to render the point list in FILLED or OUTLINED_FILLED mode.- Parameters:
aGXYContext
- the context that contains a.o. the mouse position and the transformations.- Returns:
- true if the mouse is positioned on the inside of the point list as if it is rendered as in polygon mode. False otherwise.
-
getTouchedPoint
Returns the index of the point in the
ILcdPointList
object that has been touched according to the screen (x,y) coordinates passed in theILcdGXYContext
, 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.- Parameters:
aGXYContext
- The context in which the object is rendered.- Returns:
- the index of the point in the
ILcdPointList
object that was touched,-1
if none of the points were touched.
-
getTouchedSegment
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.- Parameters:
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.- Returns:
- the index of the segment of the point list painted that was touched, -1 if none was touched.
-
getTouchedSegment
public final int getTouchedSegment(ILcdGXYPen aPen, int aX, int aY, boolean includesHotPoints, ILcdModelXYWorldTransformation aMWT, ILcdGXYViewXYWorldTransformation aVWT) Deprecated.usegetTouchedSegment(Graphics, int, ILcdGXYContext)
insteadReturns 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.- Parameters:
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.- Returns:
- the index of the segment of the point list painted that was touched, -1 if none was touched.
-
boundsSFCT
public void boundsSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException 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.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.- Specified by:
boundsSFCT
in interfaceILcdGXYPainter
- Parameters:
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.- Throws:
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.- See Also:
-
supportSnap
Supports snapping when the
ILcdPointList
object set to this painter contains at least one point.- Specified by:
supportSnap
in interfaceILcdGXYPainter
- Overrides:
supportSnap
in classALcdGXYPainter
- Parameters:
aGraphics
- the graphics on which is worked.aGXYContext
- the context of the snapping.- Returns:
true
if theILcdPointList
object contains at least one point,false
otherwise.
-
snapTarget
Returns a point of the
ILcdPointList
object if the point is touched. If no point was touched,null
will be returned.- Specified by:
snapTarget
in interfaceILcdGXYPainter
- Overrides:
snapTarget
in classALcdGXYPainter
- Parameters:
aGraphics
- the graphics on which is worked.aGXYContext
- the context of the snapping.- Returns:
- a point of the
ILcdPointList
object if the point is touched,null
otherwise. - See Also:
-
getCursor
Returns aCursor
that clarifies the render mode and context this painter is operating in. When no specificCursor
is required,null
is returned.- Specified by:
getCursor
in interfaceILcdGXYPainter
- Overrides:
getCursor
in classALcdGXYPainter
- Parameters:
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.- Returns:
- a cursor to indicate the type of operating mode and context. Returns
null
if no particular cursor is required.
-
removePointAt
public void removePointAt(ILcd2DEditablePointList a2DEditablePointList, int aIndex, int aRenderMode, ILcdGXYContext aGXYContext) Removes the point at the given index from the specifiedILcd2DEditablePointList
.- Parameters:
a2DEditablePointList
- the point list to remove a point from.aIndex
- a valid index in the list ofILcdPoint
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.
-
retrieveMinimalPointcount
protected int retrieveMinimalPointcount(int aPainterMode) Returns the number of points the
ILcdPointList
should retain when removing points. In thePOINT
paint mode, this is1
, in thePOLYLINE
paint mode, it is2
and in the different polygon paint modes, the minimal point count is3
.The method is used in the
edit
method to prevent the user from removing too many points from theILcdPointList
.- Parameters:
aPainterMode
- the painter mode for which the point count is wanted.- Returns:
- the number of points the
ILcdPointList
should retain when removing points.
-
insert2DPoint
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.
- Parameters:
a2DEditablePointList
- the point list to insert a point into.aIndex
- a valid index in the list ofILcdPoint
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.
-
append2DPoint
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.
- Parameters:
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.
-
translate2D
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.
- Parameters:
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.
-
move2DPoint
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.
- Parameters:
a2DEditablePointList
- the point list to move a point of.aIndex
- a valid index in the list ofILcdPoint
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.
-
translate2DPoint
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.
- Parameters:
a2DEditablePointList
- the point list to translate a point of.aIndex
- a valid index in the list ofILcdPoint
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.
-
edit
This implementation edits the retrieved ILcdPointList. The point list needs to implement the interface
ILcd2DEditablePointList
.In
ILcdGXYEditor.TRANSLATED
render mode, theILcdPointList
is edited as follows:- While touching a point, the point gets translated.
- While touching a segment, the object gets translated as a whole.
- While touching the interior and the selected object is painted as filled, the object gets translated as a whole.
In
ILcdGXYEditor.RESHAPED
render mode, theILcdPointList
is edited as follows:- While touching a point and moving the mouse pointer, the point gets translated.
- While touching a point and not moving the mouse pointer, the point gets removed.
- While touching a segment, a new point is added beneath the mouse pointer.
- While touching the interior, the object remains unchanged.
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.
- Specified by:
edit
in interfaceILcdGXYEditor
- Parameters:
aGraphics
- The graphics to edit the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.- Returns:
- true if the object has changed when this method returns, false otherwise.
- Throws:
ClassCastException
- if the painter's point list does not implementILcd2DEditablePointList
.- See Also:
-
acceptSnapTarget
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. If the snap target is accepted, a call to theedit
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
This editor can snap the current object to the given target if the following conditions are met:X
andY
coordinates, and thedistance in X direction
anddistance in Y direction
over which the user interaction is taking place. For example,getX
andgetY
may contain the current mouse location whilegetDeltaX
andgetDeltaY
contain the distance over which the mouse has been dragged. The context also contains the candidatesnap target
and thelayer the snap target is contained in
.- The current object is an
ILcd2DEditablePointList
or anILcdEditableComplexPolygon
withILcd2DEditablePointList
instances - the target to snap to is an
ILcdPoint
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. - One of the current point list's points is touched (in other words: you are translating a specific point of the pointlist) or the pointlist is empty.
- The touched point is not the last point of the current point list. If this is wanted, override this function and return true if the touched point is the last point.
- Specified by:
acceptSnapTarget
in interfaceILcdGXYEditor
- Parameters:
aGraphics
- the graphics on which the snap target should be checked.aGXYContext
- the context in which the snap target should be checked.- Returns:
true
if the above conditions are met,false
otherwise.- See Also:
- The current object is an
-
linkToSnapTarget
protected boolean linkToSnapTarget(Graphics aGraphics, ILcd2DEditablePointList aPointList, int aPointIndex, int aRenderMode, ILcdGXYContext aGXYContext) Edits the specifiedILcdPointList
so that, if the snap target is accepted, the point (specified by its index) snaps to this snap target. The method does nothing otherwise.- Parameters:
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.- Returns:
true
if the specified point is snapped to the snap target,false
otherwise.
-
getCreationClickCount
public int getCreationClickCount()Returns the number of user interactions required to complete the initialization of anILcdPointList
object set to this editor. In the paint modePOINT
, 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.- Specified by:
getCreationClickCount
in interfaceILcdGXYEditor
- Returns:
1
if the paint mode equalsPOINT
,-2
if the mode equalsPOLYLINE
,-3
otherwise.
-
clone
Description copied from interface:ILcdCloneable
Makes
When for example extending fromObject.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 ); } }
- Specified by:
clone
in interfaceILcdCloneable
- Specified by:
clone
in interfaceILcdGXYEditorProvider
- Specified by:
clone
in interfaceILcdGXYPainterProvider
- Overrides:
clone
in classALcdGXYAreaPainter
- Returns:
- a clone of this painter provider.
- See Also:
-
FILLED
instead