public class TLcdGXYProcedureTrajectoryPainter extends ALcdGXYPainter implements ILcdGXYEditor
TLcdProcedureTrajectory
objects. The painter
supports separate paint styles for the different procedure geometry types
(normal, connector, error and decoration). The normal paint style can also
be overridden for missed approaches. Painting of the decorations is optional.Modifier and Type | Field and Description |
---|---|
static int |
DECORATION_ONLY
Use this mode to paint the decorations, but not the procedure.
|
static int |
PROCEDURE_AFTER_DECORATION
Use this mode to paint all the decorations first, then the procedure.
|
static int |
PROCEDURE_AND_DECORATION
Use this mode to paint both the procedure and the decorations, in whatever
order they are received from the procedure geometry calculator.
|
static int |
PROCEDURE_ONLY
Use this mode to paint the procedure without decorations.
|
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
Constructor and Description |
---|
TLcdGXYProcedureTrajectoryPainter() |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptSnapTarget(Graphics aGraphics,
ILcdGXYContext aContext)
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 i,
ILcdGXYContext aContext,
Point aPoint)
Implements
ILcdGXYPainter.anchorPointSFCT . |
void |
boundsSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext,
ILcd2DEditableBounds a2DEditableBounds)
Sets the supplied bounds (in view coordinates, pixels) so that it encompasses the representation of the object
in the given mode taking into account the given context.
|
Object |
clone()
Makes
Object.clone() public. |
boolean |
edit(Graphics aGraphics,
int i,
ILcdGXYContext aContext)
Defines how an object shall be edited by this editor, taking into account the mode and the
context passed.
|
ILcdGXYPainterStyle |
getConnectorPainterStyle()
Returns the
ILcdGXYPainterStyle to be used for connector
procedure geometry. |
int |
getCreationClickCount()
Returns the number user interactions required to complete the initialization of an object set to this editor.
|
ILcdGXYPainterStyle |
getDecorationPainterStyle()
Returns the
ILcdGXYPainterStyle to be used for decoration
procedure geometry. |
ILcdGXYPainterStyle |
getErrorPainterStyle()
Returns the
ILcdGXYPainterStyle to be used for erroneous
procedure geometry. |
ILcdGXYPainterStyle |
getMissedApproachPainterStyle()
Returns the
ILcdGXYPainterStyle to be used for normal procedure
geometry that comes after the missed approach point. |
ILcdGXYPainterStyle |
getNormalPainterStyle()
Returns the
ILcdGXYPainterStyle to be used for normal procedure
geometry. |
Object |
getObject()
Returns the object this editor is currently set to edit.
|
int |
getPaintMode()
Returns the current paint mode.
|
ILcdGXYPainterProvider |
getPointPainterProvider()
Returns the painter provider to be used for drawing points that are output
with the procedure geometry.
|
boolean |
isTouched(Graphics aGraphics,
int aMode,
ILcdGXYContext aILcdGXYContext)
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.
|
void |
setConnectorPainterStyle(ILcdGXYPainterStyle aConnectorPainterStyle)
Sets the
ILcdGXYPainterStyle to be used for connector
procedure geometry. |
void |
setDecorationPainterStyle(ILcdGXYPainterStyle aDecorationPainterStyle)
Sets the
ILcdGXYPainterStyle to be used for decoration
procedure geometry. |
void |
setErrorPainterStyle(ILcdGXYPainterStyle aErrorPainterStyle)
Sets the
ILcdGXYPainterStyle to be used for erroneous
procedure geometry. |
void |
setMissedApproachPainterStyle(ILcdGXYPainterStyle aMissedApproachPainterStyle)
Sets the
ILcdGXYPainterStyle to be used for normal procedure
geometry that comes after the missed approach point. |
void |
setNormalPainterStyle(ILcdGXYPainterStyle aNormalPainterStyle)
Sets the
ILcdGXYPainterStyle to be used for normal procedure
geometry. |
void |
setObject(Object o)
Sets the object which may be edited by this editor.
|
void |
setPaintMode(int aPaintMode)
Sets the paint mode, which determines if the procedure and its decorations
are displayed or not.
|
void |
setPointPainterProvider(ILcdGXYPainterProvider aPointPainterProvider)
Sets the painter provider to be used for drawing points that are output
with the procedure geometry.
|
addPropertyChangeListener, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn, snapTarget, supportSnap
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDisplayName
addPropertyChangeListener, removePropertyChangeListener
public static final int PROCEDURE_ONLY
public static final int DECORATION_ONLY
public static final int PROCEDURE_AND_DECORATION
public static final int PROCEDURE_AFTER_DECORATION
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 ILcdGXYPainterProvider
clone
in class ALcdGXYPainter
Object.clone()
public void setPaintMode(int aPaintMode)
aPaintMode
- One of PROCEDURE_ONLY, DECORATION_ONLY, PROCEDURE_AND_DECORATION or PROCEDURE_AFTER_DECORATION.public int getPaintMode()
public void setNormalPainterStyle(ILcdGXYPainterStyle aNormalPainterStyle)
ILcdGXYPainterStyle
to be used for normal procedure
geometry.public ILcdGXYPainterStyle getNormalPainterStyle()
ILcdGXYPainterStyle
to be used for normal procedure
geometry.public void setMissedApproachPainterStyle(ILcdGXYPainterStyle aMissedApproachPainterStyle)
ILcdGXYPainterStyle
to be used for normal procedure
geometry that comes after the missed approach point. Only applicable to
IAP procedures.public ILcdGXYPainterStyle getMissedApproachPainterStyle()
ILcdGXYPainterStyle
to be used for normal procedure
geometry that comes after the missed approach point. Only applicable to
IAP procedures.public void setErrorPainterStyle(ILcdGXYPainterStyle aErrorPainterStyle)
ILcdGXYPainterStyle
to be used for erroneous
procedure geometry.public ILcdGXYPainterStyle getErrorPainterStyle()
ILcdGXYPainterStyle
to be used for erroneous
procedure geometry.public void setDecorationPainterStyle(ILcdGXYPainterStyle aDecorationPainterStyle)
ILcdGXYPainterStyle
to be used for decoration
procedure geometry.public ILcdGXYPainterStyle getDecorationPainterStyle()
ILcdGXYPainterStyle
to be used for decoration
procedure geometry.public void setConnectorPainterStyle(ILcdGXYPainterStyle aConnectorPainterStyle)
ILcdGXYPainterStyle
to be used for connector
procedure geometry.public ILcdGXYPainterStyle getConnectorPainterStyle()
ILcdGXYPainterStyle
to be used for connector
procedure geometry.public void setPointPainterProvider(ILcdGXYPainterProvider aPointPainterProvider)
public ILcdGXYPainterProvider getPointPainterProvider()
public boolean isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aILcdGXYContext)
ILcdGXYPainter
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()
and ILcdGXYContext.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 methods
ILcdGXYContext.getDeltaX()
and ILcdGXYContext.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:
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.
isTouched
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented inaILcdGXYContext
- contains the location of the interaction and the transformations to convert this location into
model coordinatesboundsSFCT
public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds a2DEditableBounds) throws TLcdNoBoundsException
ILcdGXYPainter
If this method returns without exception the bounds argument must encompass the representation of the object. A point outside the bounds will not be contained within the painted object.
The bounds returned in this method can be seen as the equivalent in the view space of the bounds in the model
space for ILcdBounded
objects.
boundsSFCT
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented in (see class documentation). For example, an object may be
represented differently in SELECTED mode compared to DEFAULT mode. The returned bounds of the representation
must take this different representation into account.aGXYContext
- the context for which the representation of the object is painted. It contains amongst others
the transformations from model to world and world to view.a2DEditableBounds
- the bounds that must be adapted to encompass the representation of the object in the given
mode and context. These bounds must not be taken into account when the method has thrown an exception.TLcdNoBoundsException
- if no bounds can be determined for the representation of the object.
This can happen when the object does not have a representation in the given context, for example when it is located
in a part of the world which is not visible in the current view.isTouched
public void paint(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ILcdGXYPainter
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:
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 of ILcdGXYPainter
and ILcdGXYEditor
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 the ILcdGXYPainter
and ILcdGXYEditor
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.
paint
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented in (see class documentation).aGXYContext
- the ILcdGXYContext
the drawing depends on.public Object getObject()
ILcdGXYEditor
getObject
in interface ILcdGXYEditor
getObject
in interface ILcdGXYPainter
ILcdGXYPainter.setObject(Object)
public void setObject(Object o)
ILcdGXYEditor
When the object is set to an editor, the context parameter in subsequent calls to methods in this class should contain a layer that contains this object and for which the editor for this object is this editor.
setObject
in interface ILcdGXYEditor
setObject
in interface ILcdGXYPainter
o
- the object for which the editing shall be handled by this editor.ILcdGXYEditor.getObject()
public boolean edit(Graphics aGraphics, int i, ILcdGXYContext aContext)
ILcdGXYEditor
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
and
getY
contain the location(s) of the user interaction. The methods
getDeltaX
and
getDeltaY
contain the distance(s) over which the user interaction is taking place. For example, getX
and
getY
may contain the current mouse location while getDeltaX
and getDeltaY
contain the distance over which the mouse has been dragged. The 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.
edit
in interface ILcdGXYEditor
aGraphics
- the Graphics on which the representation of the object is paintedi
- indicates how the user interaction should be interpreted. Is one of the following:
TRANSLATED
,
RESHAPED
,
START_CREATION
,
CREATING
,
END_CREATION
.
aContext
- contains information on the user interaction and
the transformations to transform from view space to the object model space.ILcdGXYContext
,
acceptSnapTarget
public int getCreationClickCount()
ILcdGXYEditor
getCreationClickCount
in interface ILcdGXYEditor
public boolean acceptSnapTarget(Graphics aGraphics, ILcdGXYContext aContext)
ILcdGXYEditor
edit
method with this
context passed should edit the object so that (part of) the object snaps to the object passed
as snap target in the context.
The context contains information on the user interaction at hand: the current location of the
user interaction, given by its
X
and
Y
coordinates, and
the
distance in X direction
and
distance in Y direction
over which the user interaction is taking place.
For example, getX
and
getY
may contain the current mouse location while getDeltaX
and getDeltaY
contain the distance over which the mouse has been dragged.
The context also contains the candidate
snap target
and the
layer the snap target is contained in
.
acceptSnapTarget
in interface ILcdGXYEditor
aGraphics
- the Graphics on which the representation of the object is paintedaContext
- the context containing the information on the user interaction and the snap target.ILcdGXYContext.getSnapTarget()
public void anchorPointSFCT(Graphics aGraphics, int i, ILcdGXYContext aContext, Point aPoint) throws TLcdNoBoundsException
ALcdGXYPainter
ILcdGXYPainter.anchorPointSFCT
.
aPointSFCT
will be set to the center of the
bounds calculated by boundsSFCT.anchorPointSFCT
in interface ILcdGXYPainter
anchorPointSFCT
in class ALcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedi
- the mode the object is painted in (see class documentation)aContext
- 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.aPoint
- 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.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.paint