public class TLcdGXYCompositeCurvePainter extends ALcdGXYPainter implements ILcdGXYPathPainter, ILcdGXYEditor, ILcdGXYEditorProvider, ILcdDeepCloneable
ILcdCompositeCurve
objects and enables visual editing of
ILcdCompositeCurve
objects in an ILcdGXYView
.
This painter provides support for painting an ILcdCompositeCurve
object. For each curve of the
composite curve, a painter is retrieved via the set
painter provider
.
The retrieved painter is then used to paint the corresponding ILcdCurve
object.
This painter does not define a handle for ILcdCompositeCurve
objects. However, the handles for
each individual ILcdCurve
object are defined by the corresponding painter for that curve.
This painter will process all ILcdCurve
objects in the ILcdCompositeCurve
object
and tries to retrieve a snap target for each curve using the corresponding painter. The first snap target
that is found, is used as snap target for this TLcdGXYCompositeCurvePainter
.
The visualization of the ILcdCompositeCurve
object is governed by the painter provider set to
this painter. The painter provider
is responsible for providing
a painter
to be used for painting each of the individual
ILcdCurve
objects contained in the ILcdCompositeCurve
object.
Note that this implementation assumes that a painter can be provided for each curve of the composite curve.
When the ILcdCompositeCurve
object only contains one ILcdCurve
object, the anchor
point of that object is used as anchor point for the composite curve. If more ILcdCurve
objects
are available, the center point of the bounds, calculated by boundsSFCT
, is used.
The ILcdCompositeCurve
object is touched when one of the ILcdCurve
objects in the
composite curve is touched.
This implementation translates either the touched handle or the entire composite curve for
ILcdGXYEditor.TRANSLATED
, and translates the touched sub curve if the user drags with
ILcdGXYEditor.RESHAPED
. Note that this behavior relies on the sub curve painter's
isTouched
method to distinguish between touching
the curve body
and the handles
.
Other edit operations are passed onto the first touched sub curve that is successfully edited.
For every shape that has to be edited, an
editor is retrieved via the set setCurveGXYEditorProvider(com.luciad.view.gxy.ILcdGXYEditorProvider)
. The retrieved editor
is then used to edit the corresponding ILcdCurve
object.
Similarly to the painter provider, the editor provider
is responsible
for providing an editor
to be used for editing the individual
ILcdCurve
objects contained in the ILcdCompositeCurve
object.
Note that this implementation assumes that an editor can be provided for each shape of the composite curve.
When initializing an ILcdCompositeCurve
object via interaction through the view, only the last curve
object is edited. The number of user interactions required to complete the initialization is defined by the
editor corresponding to the last ILcdCurve
object.
This painter accepts a snap target if at least one of the curve editors returned by the curve editor provider accepts the snap target.
ILcdGXYPainter
,
ILcdGXYEditor
,
ALcdGXYPainter
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
END_OF_CURVE
Constant value indicating that the anchor point should be chosen at the end point of the
curve.
|
static int |
FIRST_POSSIBLE_CURVE_ANCHOR_POINT
Constant value indicating that the anchor point should be chosen at the anchor point of the
first possible curve.
|
static int |
FOCUS_POINT
Constant value indicating that the anchor point should be chosen as the focus point of the
curve.
|
static int |
MIDDLE_OF_BOUNDS
Constant value indicating that the anchor point should be chosen in the middle of the
bounds, calculated by
boundsSFCT . |
static int |
MIDDLE_OF_CURVE
Constant value indicating that the anchor point should be chosen at the middle of the
curve.
|
static int |
ONE_CURVE_ANCHOR_POINT
Constant value indicating that the anchor point should be chosen as the anchor point of the
only curve in the composite curve.
|
static int |
START_OF_CURVE
Constant value indicating that the anchor point should be chosen at the start point of the
curve.
|
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
Constructor and Description |
---|
TLcdGXYCompositeCurvePainter()
Constructs a default
TLcdGXYCompositeCurvePainter and sets the display name to "CompositeCurve". |
TLcdGXYCompositeCurvePainter(ILcdGXYPainterProvider<ILcdGXYPathPainter> aCurveGXYPainterProvider,
ILcdGXYEditorProvider aCurveGXYEditorProvider)
Constructs a default
TLcdGXYCompositeCurvePainter with the specified painter and editor,
and sets the display name to "CompositeCurve". |
TLcdGXYCompositeCurvePainter(ILcdGXYPainterProvider<ILcdGXYPathPainter> aCurveGXYPainterProvider,
ILcdGXYEditorProvider aCurveGXYEditorProvider,
ILcdCurveConnectorProvider aCurveConnectorProvider)
Constructs a default
TLcdGXYCompositeCurvePainter with the specified painter, editor and
connector provider, and sets the display name to "CompositeCurve". |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptSnapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Determines whether a snap target should be accepted or not.
|
void |
anchorPointSFCT(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext,
Point aPointSFCT)
Moves the specified
aPointSFCT to the anchor point of the ILcdCompositeCurve
object. |
boolean |
appendAWTPath(ILcdGXYContext aGXYContext,
int aRenderMode,
ILcdAWTPath aAWTPathSFCT)
Appends a discretized representation in view coordinates to the given path.
|
boolean |
appendGeneralPath(ILcdGXYContext aGXYContext,
int aRenderMode,
ILcdGeneralPath aGeneralPathSFCT)
Appends a discretized representation in world coordinates to the given path.
|
void |
boundsSFCT(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext,
ILcd2DEditableBounds aBoundsSFCT)
Sets the supplied bounds (in view coordinates, pixels) so that it encompasses the representation of the object
in the given mode taking into account the given context.
|
Object |
clone()
Makes
Object.clone() public. |
Object |
clone(Map aObjectDictionary)
Returns a deep clone of this Object.
|
boolean |
edit(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
This implementation translates either the touched handle or the entire composite curve for
ILcdGXYEditor.TRANSLATED , and translates the touched sub curve if the user drags with
ILcdGXYEditor.RESHAPED . |
int |
getAnchorPointLocation()
Returns the location of the anchor point (by default: ONE_CURVE_ANCHOR_POINT).
|
int |
getCreationClickCount()
Returns the number of user interactions required to complete the initialization of the
ILcdCompositeCurve object set to this editor. |
Cursor |
getCursor(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Returns a
Cursor that clarifies the render mode and context this painter is operating
in. |
ILcdCurveConnectorProvider |
getCurveConnectorProvider()
Returns the curve provider used to provider a curve connector for each shape inside the composite curve.
|
ILcdGXYEditorProvider |
getCurveGXYEditorProvider()
Returns the editor provider used to provide an editor for each shape inside the composite curve.
|
ILcdGXYPainterProvider<ILcdGXYPathPainter> |
getCurveGXYPainterProvider()
Returns the painter provider used to provide a painter for each shape inside the composite curve.
|
ILcdGXYEditor |
getGXYEditor(Object aObject)
Returns this instance as editor for editing the specified
Object . |
ILcdGXYPainterStyle |
getLineStyle()
Returns the line style used for painting the outline of the object.
|
Object |
getObject()
Returns the Object for which the representation is currently being handled by this painter.
|
boolean |
isTouched(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Returns whether one of the
ILcdCurve objects inside the ILcdCompositeCurve object
is touched. |
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 |
setAnchorPointLocation(int aAnchorPointLocation)
Sets the preferred anchor point location.
|
void |
setCurveConnectorProvider(ILcdCurveConnectorProvider aCurveConnectorProvider)
Sets a connector provider to ensure connectivity during editing operations.
|
void |
setCurveGXYEditorProvider(ILcdGXYEditorProvider aCurveGXYEditorProvider)
Sets the editor provider used to provide an editor for each shape inside the composite curve.
|
void |
setCurveGXYPainterProvider(ILcdGXYPainterProvider<ILcdGXYPathPainter> aCurveGXYPainterProvider)
Sets the painter provider used to provide a painter for each shape inside the composite curve.
|
void |
setLineStyle(ILcdGXYPainterStyle aLineStyle)
Sets the line style to use when painting the outline of the object.
|
void |
setObject(Object aObject)
Sets the Object for which the representation shall be handled by this painter.
|
protected void |
setupGraphicsForLine(ILcdCompositeCurve aCurve,
Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Called just before painting the composite curve on the specified
Graphics object. |
Object |
snapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns the first snap target that was found by the painters of the shapes inside the
ILcdCompositeCurve object. |
boolean |
supportSnap(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Supports snapping when at least one of the painters of the shapes inside the
ILcdCompositeCurve
object supports snapping. |
addPropertyChangeListener, firePropertyChangeEvent, firePropertyChangeEvent, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDisplayName
addPropertyChangeListener, removePropertyChangeListener
getDisplayName
public static final int MIDDLE_OF_BOUNDS
boundsSFCT
.public static final int FOCUS_POINT
MIDDLE_OF_BOUNDS
method
is used.public static final int ONE_CURVE_ANCHOR_POINT
MIDDLE_OF_BOUNDS
method is used.public static final int FIRST_POSSIBLE_CURVE_ANCHOR_POINT
MIDDLE_OF_BOUNDS
method is used.public static final int START_OF_CURVE
MIDDLE_OF_BOUNDS
method
is used.public static final int MIDDLE_OF_CURVE
MIDDLE_OF_BOUNDS
method
is used.public static final int END_OF_CURVE
MIDDLE_OF_BOUNDS
method
is used.public TLcdGXYCompositeCurvePainter()
TLcdGXYCompositeCurvePainter
and sets the display name to "CompositeCurve".
The painter provider and the editor provider are not initialized and are required to be set using the
methods setCurveGXYPainterProvider(com.luciad.view.gxy.ILcdGXYPainterProvider)
and setCurveGXYEditorProvider(com.luciad.view.gxy.ILcdGXYEditorProvider)
respectively.
To ensure connectivity of the composite curve during editing operations,
an instance of TLcdDefaultCurveConnectorProvider
is used as ILcdCurveConnectorProvider
.
Custom implementations can be set through
setCurveConnectorProvider(com.luciad.shape.constraints.ILcdCurveConnectorProvider)
.
public TLcdGXYCompositeCurvePainter(ILcdGXYPainterProvider<ILcdGXYPathPainter> aCurveGXYPainterProvider, ILcdGXYEditorProvider aCurveGXYEditorProvider)
TLcdGXYCompositeCurvePainter
with the specified painter and editor,
and sets the display name to "CompositeCurve".
To ensure connectivity of the composite curve during editing operations,
an instance of TLcdDefaultCurveConnectorProvider
is used as ILcdCurveConnectorProvider
.
Custom implementations can be set through
setCurveConnectorProvider(com.luciad.shape.constraints.ILcdCurveConnectorProvider)
.
aCurveGXYPainterProvider
- the painter provider for the ILcdCurve
objects
inside the ILcdCompositeCurve
object.aCurveGXYEditorProvider
- the editor provider for the ILcdCurve
objects
inside the ILcdCompositeCurve
object.public TLcdGXYCompositeCurvePainter(ILcdGXYPainterProvider<ILcdGXYPathPainter> aCurveGXYPainterProvider, ILcdGXYEditorProvider aCurveGXYEditorProvider, ILcdCurveConnectorProvider aCurveConnectorProvider)
TLcdGXYCompositeCurvePainter
with the specified painter, editor and
connector provider, and sets the display name to "CompositeCurve".aCurveGXYPainterProvider
- the painter provider for the ILcdCurve
objects
inside the ILcdCompositeCurve
object.aCurveGXYEditorProvider
- the editor provider for the ILcdCurve
objects
inside the ILcdCompositeCurve
object.aCurveConnectorProvider
- the connector provider to ensure connectivity of the composite curve
during editing operations.public int getAnchorPointLocation()
public void setAnchorPointLocation(int aAnchorPointLocation)
aAnchorPointLocation
- one of MIDDLE_OF_BOUNDS
, FOCUS_POINT
,
ONE_CURVE_ANCHOR_POINT
, FIRST_POSSIBLE_CURVE_ANCHOR_POINT
,
START_OF_CURVE
, MIDDLE_OF_CURVE
, END_OF_CURVE
.public void paint(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
This implementation will retrieve a painter for all ILcdCurve
objects inside the
ILcdCompositeCurve
object using the set painter provider
and will use that painter to paint the corresponding shape.
paint
in interface ILcdGXYPainter
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.public ILcdGXYEditor getGXYEditor(Object aObject)
Object
. If this
Object
is not the same as the Object
set to this painter, the
setObject(Object)
method is called to update the object set to the painter.getGXYEditor
in interface ILcdGXYEditorProvider
aObject
- the object to be edited.Object
.public void setObject(Object aObject)
ILcdGXYPainter
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.
setObject
in interface ILcdGXYEditor
setObject
in interface ILcdGXYPainter
aObject
- the object for which the representation shall be handled by this painter.ILcdGXYPainter.getObject()
public void setLineStyle(ILcdGXYPainterStyle aLineStyle)
null
.aLineStyle
- the line style to use when painting the outline of the object.getLineStyle()
public ILcdGXYPainterStyle getLineStyle()
null
.setLineStyle(ILcdGXYPainterStyle)
protected void setupGraphicsForLine(ILcdCompositeCurve aCurve, Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
Called just before painting the composite curve on the specified Graphics
object.
It can be redefined in order to set specific Graphics
properties like Color
,
etc...
This implementation calls ILcdGXYPainterStyle.setupGraphics(java.awt.Graphics, java.lang.Object, int, com.luciad.view.gxy.ILcdGXYContext)
on the lineStyle property
if a line style has been set to this instance.
aCurve
- The curve to paint.aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.public Object getObject()
ILcdGXYPainter
getObject
in interface ILcdGXYEditor
getObject
in interface ILcdGXYPainter
ILcdGXYPainter.setObject(Object)
public void setCurveGXYPainterProvider(ILcdGXYPainterProvider<ILcdGXYPathPainter> aCurveGXYPainterProvider)
aCurveGXYPainterProvider
- the painter provider for the ILcdCurve
objects
inside the ILcdCompositeCurve
object.getCurveGXYPainterProvider()
public ILcdGXYPainterProvider<ILcdGXYPathPainter> getCurveGXYPainterProvider()
setCurveGXYPainterProvider(com.luciad.view.gxy.ILcdGXYPainterProvider)
public void setCurveGXYEditorProvider(ILcdGXYEditorProvider aCurveGXYEditorProvider)
aCurveGXYEditorProvider
- the editor provider for the ILcdCurve
objects
inside the ILcdCompositeCurve
object.getCurveGXYEditorProvider()
public ILcdGXYEditorProvider getCurveGXYEditorProvider()
setCurveGXYEditorProvider(com.luciad.view.gxy.ILcdGXYEditorProvider)
public void setCurveConnectorProvider(ILcdCurveConnectorProvider aCurveConnectorProvider)
aCurveConnectorProvider
- a connector provider that returns a connector for the curve types encountered
in every composite curve.getCurveConnectorProvider()
public ILcdCurveConnectorProvider getCurveConnectorProvider()
setCurveConnectorProvider(com.luciad.shape.constraints.ILcdCurveConnectorProvider)
public void anchorPointSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException
Moves the specified aPointSFCT
to the anchor point of the ILcdCompositeCurve
object. If the composite curve only contains one object, the anchor point of that object is used.
When more shapes are available in the composite curve, the center point of the bounds, calculated
by boundsSFCT
, is used
anchorPointSFCT
in interface ILcdGXYPainter
anchorPointSFCT
in class ALcdGXYPainter
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.aPointSFCT
- The point that needs to be updated.TLcdNoBoundsException
- if the ILcdCompositeCurve
object doesn't have
a valid anchor point, e.g. if it is always invisible in the current projection.paint
public boolean supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
Supports snapping when at least one of the painters of the shapes inside the ILcdCompositeCurve
object supports snapping.
supportSnap
in interface ILcdGXYPainter
supportSnap
in class ALcdGXYPainter
aGraphics
- the graphics on which is worked.aGXYContext
- the context of the snapping.true
if one of the painters for the shapes inside the ILcdCompositeCurve
object supports snapping, false
otherwise.public Object snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
Returns the first snap target that was found by the painters of the shapes inside the
ILcdCompositeCurve
object. If no point was touched, null
will be
returned.
snapTarget
in interface ILcdGXYPainter
snapTarget
in class ALcdGXYPainter
aGraphics
- the graphics on which is worked.aGXYContext
- the context of the snapping.ILcdCompositeCurve
object, null
otherwise.supportSnap
public void boundsSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
If this method returns without exception the bounds argument must encompass the representation of the object. A point outside the bounds will not be contained within the painted object.
The bounds returned in this method can be seen as the equivalent in the view space of the bounds in the model
space for ILcdBounded
objects.
boundsSFCT
in interface ILcdGXYPainter
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.aBoundsSFCT
- The bounds to update.TLcdNoBoundsException
- if no bounds can be determined for the representation of the object.
This can happen when the object does not have a representation in the given context, for example when it is located
in a part of the world which is not visible in the current view.isTouched
public Cursor getCursor(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
Cursor
that clarifies the render mode and context this painter is operating
in. When no specific Cursor
is required, null
is returned.getCursor
in interface ILcdGXYPainter
getCursor
in class ALcdGXYPainter
aGraphics
- The graphics on which the object is painted.aRenderMode
- The mode to render the object in.aGXYContext
- The context in which the object is rendered.null
if
no particular cursor is required.public boolean edit(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
This implementation translates either the touched handle or the entire composite curve for
ILcdGXYEditor.TRANSLATED
, and translates the touched sub curve if the user drags with
ILcdGXYEditor.RESHAPED
. Note that this behavior relies on the sub curve painter's
isTouched
method to distinguish between touching
the curve body
and the handles
.
Other edit operations are passed onto the first touched sub curve that is successfully edited.
For every shape that has to be edited, an
editor is retrieved via the set editor provider
. The retrieved editor
is then used to edit the corresponding ILcdCurve
object.
In the creation render modes, only the last ILcdCurve
object is edited.
edit
in interface ILcdGXYEditor
aGraphics
- The graphics to edit the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.ILcdGXYContext
,
acceptSnapTarget
public int getCreationClickCount()
ILcdCompositeCurve
object set to this editor. This method will return the number of user interactions
required by the editor corresponding to the last ILcdCurve
object.getCreationClickCount
in interface ILcdGXYEditor
ILcdCurve
object.public boolean acceptSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
Determines whether a snap target should be accepted or not. A snap target is accepted if at least one of the curve editors returned by the curve editor provider accepts the snap target.
acceptSnapTarget
in interface ILcdGXYEditor
aGraphics
- the graphics on which the snap target should be checked.aGXYContext
- the context in which the snap target should be checked.true
if at least one of the curve editors returned by the curve editor provider
accepts the snap target, false
otherwise.ILcdGXYContext.getSnapTarget()
public boolean isTouched(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
ILcdCurve
objects inside the ILcdCompositeCurve
object
is touched.isTouched
in interface ILcdGXYPainter
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context in which the object is rendered.ILcdCurve
objects inside the ILcdCompositeCurve
object
is touched.boundsSFCT
public boolean appendAWTPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdAWTPath aAWTPathSFCT)
ILcdGXYPathPainter
appendAWTPath
in interface ILcdGXYPathPainter
aGXYContext
- the graphics contextaRenderMode
- the rendering modeaAWTPathSFCT
- the path to append topublic boolean appendGeneralPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdGeneralPath aGeneralPathSFCT)
ILcdGXYPathPainter
appendGeneralPath
in interface ILcdGXYPathPainter
aGXYContext
- the graphics contextaRenderMode
- the rendering modeaGeneralPathSFCT
- the path to append topublic Object clone(Map aObjectDictionary)
ILcdDeepCloneable
java.util.Map
, using reference-equality instead of object-equality when
comparing keys (such as the java.util.IdentityHashMap
). It contains as keys the objects in the original
object graph that have already been cloned, and as values their corresponding clone.
The Object returned by this method should fulfill the following conditions, as specified in
the general Object.clone()
contract:
this.clone(aObjectDictionary) != this
this.clone(aObjectDictionary).getClass() == this.getClass()
this.clone(aObjectDictionary).equals(this)
clone
method is called,
this method shall return that clone:
aObjectDictionary.get(this) == null || aObjectDictionary.get(this) == this.clone(aObjectDictionary)
clone method has completed:
this.clone(aObjectDictionary) == aObjectDictionary.get(this)
clone
in interface ILcdDeepCloneable
aObjectDictionary
- the Object dictionary that keeps track of the objects for which a clone has already been made,
and their corresponding clone Object.public Object clone()
ILcdCloneable
Makes Object.clone()
public.
java.lang.Object
, it can be implemented like this:
public Object clone() {
try {
return super.clone();
} catch ( CloneNotSupportedException e ) {
// Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
throw new RuntimeException( e );
}
}
clone
in interface ILcdCloneable
clone
in interface ILcdGXYEditorProvider
clone
in interface ILcdGXYPainterProvider
clone
in class ALcdGXYPainter
Object.clone()