Class TLcdGXYCircularArcPainter
- All Implemented Interfaces:
ILcdCloneable
,ILcdPropertyChangeSource
,ILcdGXYEditor
,ILcdGXYEditorProvider
,ILcdGXYPainter
,ILcdGXYPainterProvider
,ILcdGXYPathPainter
,Serializable
,Cloneable
ILcdCircularArcBy3Points
, ILcdCircularArcByBulge
and ILcdCircularArcByCenterPoint
objects and enables visual editing of ILcd2DEditableCircularArcBy3Points
,
ILcd2DEditableCircularArcByBulge
and ILcd2DEditableCircularArcByCenterPoint
objects in an ILcdGXYView
.
Painting an ILcdCircularArc
Body
The body of an ILcdCircularArc
object is painted as:
Handles
The defined handles depend on the type of circular arc that is set on this painter:
- For an
ILcdCircularArcBy3Points
object the 3 points are defined. - For an
ILcdCircularArcByBulge
object the start, end and mid point are defined. The chord and line from the midpoint to the chord is also indicated. - For an
ILcdCircularArcByCenterPoint
object the start and end point are defined.
Circular arc-by-3-points | Circular arc-by-bulge | Circular arc-by-center-point |
---|---|---|
Note that the center point of the circular arc is painted in
ILcdGXYPainter.HANDLES
mode depending on
the drawCenter
property. When painted, it can be used as a handle to edit
the object.
Snap targets
The defined snap targets depend on the type of circular arc that is set on this painter:
- For an
ILcdCircularArcBy3Points
object one of the 3 points can be returned. - For an
ILcdCircularArcByBulge
the start, end or mid point can be returned. - For an
ILcdCircularArcByCenterPoint
the start or end point can be returned.
isDrawCenter()
) or when snapping to invisible points is
enabled (see isSnapToInvisiblePoints()
), the center point can also be returned. The
point returned as a snap target is highlighted with the snapIcon
.
Styling options
The visualization of the ILcdCircularArc
object is governed by the line style set
to this painter (see setLineStyle(com.luciad.view.gxy.ILcdGXYPainterStyle)
).
Locating an ILcdCircularArc in a view
Anchor point of an ILcdCircularArc
The anchor point of the ILcdCircularArc
object is located at the center point of
the bounds, calculated by boundsSFCT
. Note that the center point of the
ILcdCircularArc
object is only taken into account when it is painted.
When is an ILcdCircularArc touched
Depending on the paint mode, a circular arc is touched when either the arc, the arc handles or the center point of the arc is touched. Note that the center point can only be touched if it is painted.
Visual bounds of an ILcdCircularArc
The bounds of the ILcdCircularArc
object contains the contour of the arc and the
center point if it is painted.
Visually editing and creating an editable ILcdCircularArc
Editing an editable ILcdCircularArc
This editor provides the following edit functionality for the different render modes:
RESHAPED
: reshaping is not supported.
TRANSLATED
: an arc handle or the whole arc is translated, depending on whether an arc handle or the arc segment is touched.
Note that, if the center point the arc is touched, the whole arc can be translated as if the arc segment was touched.
Creating an editable ILcdCircularArc
When initializing an arc via interaction through the view, 3 user interactions are required to complete the initialization.
- For an
ILcd2DEditableCircularArcBy3Points
the mouse clicks define the start, intermediate and end point (in this order). - For an
ILcd2DEditableCircularArcByBulge
the first 2 mouse clicks define the start, and end point (in this order) and the final mouse click defines the bulge factor. - For an
ILcd2DEditableCircularArcByCenterPoint
the first mouse clicks defines the center point, the second mouse click defines the radius and start angle and the final mouse click defines arc angle.
Accepted snap targets
All points are accepted as snap target as long as:
- the point can be transformed to the reference of the
ILcdArc
object with themodel to model transformation
, - the point is not the center point of the
ILcdArc
object set to this painter.
Accepted snap targets
All points are accepted as snap target as long as:
- the point can be transformed to the reference of the
ILcdCircularArc
object with themodel to model transformation
, - the point is not the center point of the
ILcdCircularArc
object set to this painter. - the point is not the mid point of the
ILcdCircularArcByBulge
object set to this painter. - the point is not the start or end point of the
ILcdCircularArcByCenterPoint
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.
Drawing the center point
The drawCenter
and drawCenterWhenSelected
properties define when the center point needs to be painted. If the center point is painted, it can
be touched, moved,...
- Since:
- 9.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enumeration describing if an arc-by-center should be created clockwise or counterclockwise. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Constant value indicating the body of the arc segment.static final int
Constant value indicating that the intermediate point of the arc segment of the arc is touched (only valid for an ILcd2DEditableCircularArcBy3Points).static final int
Constant value indicating that the midpoint of the arc segment of the arc is touched (only valid for an ILcd2DEditableCircularArcByBulge).static final int
Constant value indicating the center point of the arc.static final int
Constant value indicating the end of the circular arc segment.static final int
Constant value indicating that the anchor point should be chosen as the arc's focus point.static final int
Constant value indicating that the anchor point should be chosen in the middle of the arc's 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
Constant value indicating that the arc is not touched.static final int
Constant value indicating the start of the circular arc segment.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
-
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 aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) ImplementsILcdGXYPainter.anchorPointSFCT
.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 aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) Sets the supplied bounds (in view coordinates, pixels) so that it encompasses the representation of the object in the given mode taking into account the given context.clone()
MakesObject.clone()
public.boolean
edit
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Defines how an object shall be edited by this editor, taking into account the mode and the context passed.int
Returns the location of the anchor point (by default: MIDDLE_OF_BOUNDS).Returns the icon for the center point's default representation, used ifisDrawCenter()
returns true.Returns the icon for the center point's selected representation, used ifisDrawCenterWhenSelected()
returns true.int
Returns the number user interactions required to complete the initialization of an object set to this editor.Returns the orientation used while creatingILcdCircularArcByCenterPoint
objects.getCursor
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Override this method to return a cursor.getGXYEditor
(Object aObject) Finds anILcdGXYEditor
that can be used to edit the object passed.Returns the line style used for painting the contour of the shape.int
Returns the minimum pixel distance the input device (a mouse, for example) must move before editing the shape.Returns the Object for which the representation is currently being handled by this painter.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.boolean
Returns whether the center point of the arc should be displayed.boolean
Returns whether the center point of the arc should be displayed when it is painted in selected mode.boolean
Returns whether the painter allows snapping to the invisible points of the shape.boolean
isTouched
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Checks if the representation of the object in the given mode is touched at the location as defined in the supplied context.void
paint
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Displays the representation of the object in the given mode on the Graphics passed, taking into account the supplied context.protected void
paintEditingLabels
(Graphics aGraphics, ILcdCircularArc aCircularArc, int aTouchedLocation, ILcdGXYContext aGXYContext) Called by thepaint
method when editing a circular arc.void
setAnchorPointLocation
(int aAnchorPointLocation) Sets the preferred anchor point location.void
setCenterIcon
(ILcdIcon aIcon) Sets the icon for the center point's default representation, ifisDrawCenter()
returns true.void
Sets the icon for the center point's selected representation, ifisDrawCenterWhenSelected()
returns true.void
setCreationOrientation
(TLcdGXYCircularArcPainter.CreationOrientation aCreationOrientation) Sets the orientation used while creatingILcdCircularArcByCenterPoint
objects.void
setDrawCenter
(boolean aDrawCenter) Sets whether the center point of the arc should be displayed or not.void
setDrawCenterWhenSelected
(boolean aDrawCenterWhenSelected) Sets whether the center point of the arc should be displayed when it is painted in selected mode or not.void
setLineStyle
(ILcdGXYPainterStyle aLineStyle) Sets the line style to use when painting the contour of the shape.void
setMinimumEditDelta
(int aDelta) Sets the minimum pixel distance the input device (a mouse, for example) must move before editing the shape.void
setModelModelTransformationClass
(Class aModel2ModelTransformationClass) Sets the transformation class that should be used when snapping to points that are defined in a different reference than the reference of this painter's object.void
Sets the Object for which the representation shall be handled by this painter.void
setPaintCache
(boolean aPaintCache) Turns caching of the representation of the object on or off.void
setSnapIcon
(ILcdIcon aSnapIcon) Sets the icon that marks snap targets of the object currently set to this painter.void
setSnapToInvisiblePoints
(boolean aSnapToInvisiblePoints) Sets whether the other shapes can snap to invisible points of this shape.snapTarget
(Graphics aGraphics, ILcdGXYContext aGXYContext) Override this method to support snapping.boolean
supportSnap
(Graphics aGraphics, ILcdGXYContext aGXYContext) Override this method to support snapping.Methods inherited from class com.luciad.view.gxy.ALcdGXYPainter
addPropertyChangeListener, firePropertyChangeEvent, firePropertyChangeEvent, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn
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
-
NOT_TOUCHED
public static final int NOT_TOUCHEDConstant value indicating that the arc is not touched.- See Also:
-
ARC_BODY
public static final int ARC_BODYConstant value indicating the body of the arc segment.- See Also:
-
CENTER_POINT
public static final int CENTER_POINTConstant value indicating the center point of the arc.- See Also:
-
START_OF_CURVE
public static final int START_OF_CURVEConstant value indicating the start of the circular arc segment.- See Also:
-
END_OF_CURVE
public static final int END_OF_CURVEConstant value indicating the end of the circular arc segment.- See Also:
-
ARC_INTERMEDIATE_POINT
public static final int ARC_INTERMEDIATE_POINTConstant value indicating that the intermediate point of the arc segment of the arc is touched (only valid for an ILcd2DEditableCircularArcBy3Points).- See Also:
-
ARC_MID_POINT
public static final int ARC_MID_POINTConstant value indicating that the midpoint of the arc segment of the arc is touched (only valid for an ILcd2DEditableCircularArcByBulge).- 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 arc's bounds, calculated byboundsSFCT
.- See Also:
-
FOCUS_POINT
public static final int FOCUS_POINTConstant value indicating that the anchor point should be chosen as the arc's focus point. If this point cannot be calculated, theMIDDLE_OF_BOUNDS
method is used to calculate the anchor point.- 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:
-
-
Constructor Details
-
TLcdGXYCircularArcPainter
public TLcdGXYCircularArcPainter()
-
-
Method Details
-
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
-
setDrawCenter
public void setDrawCenter(boolean aDrawCenter) Sets whether the center point of the arc should be displayed or not. The default value of this property isfalse
. This setting has an influence on the methodsboundsSFCT
,isTouched
and snapping. Regardless of this setting, the center point is always displayed as a handle in HANDLES mode to allow editing.- Parameters:
aDrawCenter
- A flag indicating whether the center point should be displayed or not.- See Also:
-
isDrawCenter
public boolean isDrawCenter()Returns whether the center point of the arc should be displayed.- Returns:
- whether the center point of the arc should be displayed.
- See Also:
-
setDrawCenterWhenSelected
public void setDrawCenterWhenSelected(boolean aDrawCenterWhenSelected) Sets whether the center point of the arc should be displayed when it is painted in selected mode or not. The default value of this property istrue
. This setting has an influence on the methodsboundsSFCT
,isTouched
and snapping. Regardless of this setting, the center point is always displayed as a handle in HANDLES mode to allow editing.- Parameters:
aDrawCenterWhenSelected
- A flag indicating whether the center point should be displayed when it is painted in selected mode or not.- See Also:
-
isDrawCenterWhenSelected
public boolean isDrawCenterWhenSelected()Returns whether the center point of the arc should be displayed when it is painted in selected mode.- Returns:
- whether the center point of the arc should be displayed when it is painted in selected mode.
- See Also:
-
setCenterIcon
Sets the icon for the center point's default representation, ifisDrawCenter()
returns true.- Parameters:
aIcon
- the icon for the center point's default representation- See Also:
-
getCenterIcon
Returns the icon for the center point's default representation, used ifisDrawCenter()
returns true.- Returns:
- the icon for the center point's default representation
-
setCenterIconWhenSelected
Sets the icon for the center point's selected representation, ifisDrawCenterWhenSelected()
returns true.- Parameters:
aIcon
- the icon for the center point's selected representation- See Also:
-
getCenterIconWhenSelected
Returns the icon for the center point's selected representation, used ifisDrawCenterWhenSelected()
returns true.- Returns:
- the icon for the center point's selected representation
-
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:
-
setSnapToInvisiblePoints
public void setSnapToInvisiblePoints(boolean aSnapToInvisiblePoints) Sets whether the other shapes can snap to invisible points of this shape. The default value isfalse
.- Parameters:
aSnapToInvisiblePoints
- A flag indicating whether snapping to the invisible points is allowed.- See Also:
-
isSnapToInvisiblePoints
public boolean isSnapToInvisiblePoints()Returns whether the painter allows snapping to the invisible points of the shape.- Returns:
- whether the painter allows snapping to the invisible points of the shape.
- See Also:
-
setLineStyle
Sets the line style to use when painting the contour of the shape. Note that this property can be set tonull
.- Parameters:
aLineStyle
- the line style to use when painting the contour of the shape.- See Also:
-
getLineStyle
Returns the line style used for painting the contour of the shape. Note that this method can returnnull
.- Returns:
- the line style used for painting the contour of the shape.
- See Also:
-
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:
-
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.
-
setCreationOrientation
public void setCreationOrientation(TLcdGXYCircularArcPainter.CreationOrientation aCreationOrientation) Sets the orientation used while creating
ILcdCircularArcByCenterPoint
objects. The value passed should beTLcdGXYCircularArcPainter.CreationOrientation.CLOCKWISE
orTLcdGXYCircularArcPainter.CreationOrientation.COUNTER_CLOCKWISE
. The default value isTLcdGXYCircularArcPainter.CreationOrientation.COUNTER_CLOCKWISE
.This value will only be taken into account when creating an arc-by-center object.
- Parameters:
aCreationOrientation
- A flag indicating the orientation of the arc during creation.- See Also:
-
getCreationOrientation
Returns the orientation used while creatingILcdCircularArcByCenterPoint
objects.- Returns:
- the orientation used while creating arc-by-center objects.
- See Also:
-
getAnchorPointLocation
public int getAnchorPointLocation()Returns the location of the anchor point (by default: MIDDLE_OF_BOUNDS).- Returns:
- one of
MIDDLE_OF_BOUNDS
,FOCUS_POINT
,CENTER_POINT
,MIDDLE_OF_CURVE
,START_OF_CURVE
,END_OF_CURVE
.
-
setAnchorPointLocation
public void setAnchorPointLocation(int aAnchorPointLocation) Sets the preferred anchor point location.- Parameters:
aAnchorPointLocation
- one ofMIDDLE_OF_BOUNDS
,FOCUS_POINT
,CENTER_POINT
,MIDDLE_OF_CURVE
,START_OF_CURVE
,END_OF_CURVE
.
-
setObject
Description copied from interface:ILcdGXYPainter
Sets the Object for which the representation shall be handled by this painter.Setting the object on the painter may have an effect on the internal state of the painter, for example, the color to use.
When the object is set to a painter, the context parameter in subsequent calls to methods in this class must contain a layer that contains this object and for which the painter for this object is this painter.
- Specified by:
setObject
in interfaceILcdGXYEditor
- Specified by:
setObject
in interfaceILcdGXYPainter
- Parameters:
aObject
- the object for which the representation shall be handled by this painter.- See Also:
-
getObject
Description copied from interface:ILcdGXYPainter
Returns the Object for which the representation is currently being handled by this painter.- Specified by:
getObject
in interfaceILcdGXYEditor
- Specified by:
getObject
in interfaceILcdGXYPainter
- Returns:
- the Object for which the representation is currently being handled by this painter.
- See Also:
-
paint
Description copied from interface:ILcdGXYPainter
Displays the representation of the object in the given mode on the Graphics passed, taking into account the supplied context.The visual representation of an object depends on the context. Depending on the context (e.g. is the location covered by the view), an object may or may not have a representation. The context contains:
- transformations which allow to compute the location in view space of points and bounds given in model, space
- a pen which can connect points with a line or create arcs around a point,
- the view for which the object's representation must be painted. This can be useful when the painted object depends on the scale of the view, or the presence of other layers in the view.
- the current location(s) of the mouse or input device and the last location(s) the mouse or input device was pressed.
The mode passed in this method indicates what part of the object must be painted, whether it should be painted as selected or not, and whether user interaction (via mouse movements) must be taken into account.
When the mode passed contains either TRANSLATING, RESHAPING or CREATING, this method is also responsible for interpreting interaction on the representation of an object and modifying the representation of the object accordingly. The painter is not responsible for modifying the object itself, this is done by a corresponding
ILcdGXYEditor
. Implementations ofILcdGXYPainter
andILcdGXYEditor
interfaces must be consistent for an object: the painter must display the result of the user interaction on the object, while the editor is responsible for modifying the object as a result of the user interaction. A good practice to ensure a consistent implementation is to implement both theILcdGXYPainter
andILcdGXYEditor
interfaces in a single class.When the mode passed includes SNAPS, the part of the representation which corresponds to the object returned as snap target by the method
snapTarget
must be painted in order to provide the user with a visual indication of the snap target.The Graphics passed in this method can be different from the Graphics returned by a view due to techniques such as double buffering (as applied in Swing). Basic drawing operations must always be performed on the Graphics passed as an argument in this method.
- Specified by:
paint
in interfaceILcdGXYPainter
- Parameters:
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented in (see class documentation).aGXYContext
- theILcdGXYContext
the drawing depends on.
-
paintEditingLabels
protected void paintEditingLabels(Graphics aGraphics, ILcdCircularArc aCircularArc, int aTouchedLocation, ILcdGXYContext aGXYContext) Called by the
paint
method when editing a circular arc. It can draw labels indicating the values of properties being changed. For example, the coordinates of the center point of the arc, the start angle, etc ... This method is empty and therefore does not draw the labels but it can be redefined for specific needs.The
aTouchedLocation
argument indicates which part of the arc is being edited. This is one the following:START_OF_CURVE
,END_OF_CURVE
,ARC_INTERMEDIATE_POINT
,ARC_MID_POINT
,CENTER_POINT
,ARC_BODY
, .- Parameters:
aGraphics
- The graphics to paint the object on.aCircularArc
- The arc that is being edited.aTouchedLocation
- The part of the arc that is being edited.aGXYContext
- The context to render the object in.
-
boundsSFCT
public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException Description copied from interface:ILcdGXYPainter
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 on which the representation of the object is paintedaMode
- the mode the object is represented in (see class documentation). For example, an object may be represented differently in SELECTED mode compared to DEFAULT mode. The returned bounds of the representation must take this different representation into account.aGXYContext
- the context for which the representation of the object is painted. It contains amongst others the transformations from model to world and world to view.aBoundsSFCT
- the bounds that must be adapted to encompass the representation of the object in the given mode and context. These bounds must not be taken into account when the method has thrown an exception.- 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:
-
isTouched
Description copied from interface:ILcdGXYPainter
Checks if the representation of the object in the given mode is touched at the location as defined in the supplied context.The location that must be taken into account to check whether the representation is touched can be retrieved from the context passed with the methods
ILcdGXYContext.getX()
andILcdGXYContext.getY()
. If the check is part of an ongoing operation of user interaction, for example, when the mouse is being dragged, the location of the start of the operation can also be taken into account using the methodsILcdGXYContext.getDeltaX()
andILcdGXYContext.getDeltaY()
. The context contains the transformations required to convert this location into the equivalent location in model space. Implementations of this interface usually follow either of the following patterns:- transform the location of the interaction back to model space and compare the coordinates with the object in model space.
- transform the location to world space and compare with a world representation of the object. This forces the painter into caching a world representation of the object. Caching a view representation of an object is not very practical as it would have to change whenever the view's scale changes or when it is panned. A world representation of an object only changes when the view's XYWorldReference changes, which happens less frequently.
As the mode influences the way an object is represented, it must also be taken into account when checking whether that representation is being touched. When the mode contains CREATING, RESHAPING or TRANSLATING which indicate that the object must be represented in a state for an ongoing operation, the location of the start of the operation may be taken into account as mentioned above. The painting result can take into account multiple locations, to respond to, for example, multi-touch input. When the mode contains SELECTED, the painter should also check if the non-selected representation is touched, since these are always painted on top of each other.
The
boundsSFCT
is often used to speed up the performance of this method as a location outside these bounds can never touch the representation of the object.Note that this method does not give an indication of what part of the object is touched. It is up to the painter implementations to provide methods to make this distinction. The method does also not indicate what sensitivity must be applied when checking if an object is touched. It is up to the implementation to decide what should be the maximum distance between the location given in the context and the closest relevant point or area of the representation of the object.
- Specified by:
isTouched
in interfaceILcdGXYPainter
- Parameters:
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented inaGXYContext
- contains the location of the interaction and the transformations to convert this location into model coordinates- Returns:
- true if the representation of the object in the given mode is touched by the location as defined in the context passed, false otherwise
- See Also:
-
anchorPointSFCT
public void anchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException Description copied from class:ALcdGXYPainter
ImplementsILcdGXYPainter.anchorPointSFCT
.aPointSFCT
will be set to the center of the bounds calculated by boundsSFCT.- Specified by:
anchorPointSFCT
in interfaceILcdGXYPainter
- Overrides:
anchorPointSFCT
in classALcdGXYPainter
- Parameters:
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is painted in (see class documentation)aGXYContext
- the context for which the representation of the object is painted. It contains amongst others the transformations from model to world and world to view.aPointSFCT
- the point that has to be moved to the location of the anchor point of the representation of the object. This point must not be taken into account when the method has thrown a TLcdNoBoundsException.- Throws:
TLcdNoBoundsException
- if no anchor point can be determined for the representation of the object. This can be when the object does not have a representation in the given context, for example when it is located in a part of the world which is not visible in the projection as set in the views world reference.- See Also:
-
supportSnap
Description copied from class:ALcdGXYPainter
Override this method to support snapping. This implementation does not support snapping.- Specified by:
supportSnap
in interfaceILcdGXYPainter
- Overrides:
supportSnap
in classALcdGXYPainter
- Parameters:
aGraphics
- the Graphics on which the representation of the object is paintedaGXYContext
- the context in which this object is represented and in which the editing of an object occurs.- Returns:
false
.
-
snapTarget
Description copied from class:ALcdGXYPainter
Override this method to support snapping. This implementation does not support snapping.- Specified by:
snapTarget
in interfaceILcdGXYPainter
- Overrides:
snapTarget
in classALcdGXYPainter
- Parameters:
aGraphics
- the Graphics on which the representation of the object is paintedaGXYContext
- the context in which this object is represented and in which the editing of an object occurs.- Returns:
null
.- See Also:
-
getCursor
Description copied from class:ALcdGXYPainter
Override this method to return a cursor. This implementation returns null.- Specified by:
getCursor
in interfaceILcdGXYPainter
- Overrides:
getCursor
in classALcdGXYPainter
- Parameters:
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the rendering mode to return the cursor for.aGXYContext
- the context in which the rendering occurs.- Returns:
null
.
-
edit
Description copied from interface:ILcdGXYEditor
Defines how an object shall be edited by this editor, taking into account the mode and the context passed.The mode passed indicates how the interaction should be interpreted. It can be one of the following:
TRANSLATED
RESHAPED
START_CREATION
CREATING
END_CREATION
The first two modes designate that the object should be modified, the last three modes are passed when initializing an object. From an implementation point of view there is no difference between TRANSLATED and RESHAPED. These constants only differ in semantics. For
ILcdShape
objects TRANSLATED can be seen as the mode that will be passed when the shape as a whole is moved. RESHAPED is used more often for moving part of a shape.The context contains information on the user interaction at hand. The methods
getX
andgetY
contain the location(s) of the user interaction. The methodsgetDeltaX
andgetDeltaY
contain the distance(s) 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 editing behavior can take into account multiple locations, to respond to, for example, multi-touch input.When a snap target is accepted, the implementation of this method should take that fact into account when editing or initializing an object.
- Specified by:
edit
in interfaceILcdGXYEditor
- Parameters:
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- indicates how the user interaction should be interpreted. Is one of the following:TRANSLATED
,RESHAPED
,START_CREATION
,CREATING
,END_CREATION
.
aGXYContext
- contains information on the user interaction and the transformations to transform from view space to the object model space.- Returns:
- true if the object has changed when this method returns, false otherwise.
- See Also:
-
getCreationClickCount
public int getCreationClickCount()Description copied from interface:ILcdGXYEditor
Returns the number user interactions required to complete the initialization of an object set to this editor. For example, for a circle this can be two: one to determine the center point of the circle and one to determine the radius of the circle. A negative number indicates that there is no upper limit to the number of user interactions. For example, for a polyline this could be -2: it requires a minimum of two clicks to establish a polyline, but there is no upper limit on the number of polyline points.- Specified by:
getCreationClickCount
in interfaceILcdGXYEditor
- Returns:
- the number of user interactions required to initialize the object set to this editor.
-
acceptSnapTarget
Description copied from interface:ILcdGXYEditor
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
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
.- Specified by:
acceptSnapTarget
in interfaceILcdGXYEditor
- Parameters:
aGraphics
- the Graphics on which the representation of the object is paintedaGXYContext
- the context containing the information on the user interaction and the snap target.- 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.
- See Also:
-
getGXYEditor
Description copied from interface:ILcdGXYEditorProvider
Finds anILcdGXYEditor
that can be used to edit the object passed.The editor provider is responsible for setting the object to the editor before returning the editor. An implementation should therefore have the following structure:
public ILcdGXYEditor getGXYEditor(Object aObject) { ILcdGXYEditor editor = ... // find the editor for the object editor.setObject( aObject ); return editor; }
- Specified by:
getGXYEditor
in interfaceILcdGXYEditorProvider
- Parameters:
aObject
- the object to find an editor for- Returns:
- an editor that can be used to edit the object.
-
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
-
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 classALcdGXYPainter
- Returns:
- a clone of this painter provider.
- See Also:
-