public class TLcdICAORunwayPainter extends Object implements ILcdGXYPainter, ILcdGXYPainterProvider
ILcdRunway
objects according to the ICAO
guidelines for aeronautical charts. Each runway with two or more points will
be painted as a rectangle. This rectangle is constructed by using the first
and the last point of the runway. Runways with less than two points will not
be painted; nonetheless, a valid ILcdGXYPainter
will be returned
for them when invoking getGXYPainter()
.
If a surface type property is available for the runway objects, the surface
type is used to determine a paint style for the rectangle, following the ICAO
guidelines:
setSurfaceTypeExpression
.
This painter evaluates its expressions using an instance of
TLcdDataObjectExpressionLanguage
.Modifier and Type | Field and Description |
---|---|
static String |
ALWAYS
Use this fill mode to always paint a fill by default.
|
static String |
BY_SURFACE_TYPE
Use this fill mode to paint a fill if a surface type is available.
|
static String |
NO_FILL
Use this fill mode to disable the fill entirely.
|
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
Constructor and Description |
---|
TLcdICAORunwayPainter()
Creates a new
TLcdICAORunwayPainter object. |
TLcdICAORunwayPainter(TLcdICAORunwayPainter aICAORunwayPainter)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
Registers the given
PropertyChangeListener to be notified when this object's
properties change. |
void |
anchorPointSFCT(Graphics aGraphics,
int aSequenceNumber,
ILcdGXYContext aContext,
Point aPoint)
Moves the Point passed to the location (in view coordinates, pixels) of the anchor point of the representation of
the object in the given mode taking into account the given context.
|
void |
boundsSFCT(Graphics aGraphics,
int aSequenceNumber,
ILcdGXYContext aContext,
ILcd2DEditableBounds aILcd2DEditableBounds)
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. |
Cursor |
getCursor(Graphics aGraphics,
int aSequenceNumber,
ILcdGXYContext aContext)
Returns a cursor that clarifies the mode and context the painter is operating in.
|
Color |
getDefaultColor()
Returns the default color.
|
String |
getDisplayName()
Returns a textual representation of this painter.
|
ILcdGXYPainter |
getGXYPainter(Object aObject)
Returns a painter for
ILcdRunway objects. |
Object |
getObject()
Returns the Object for which the representation is currently being handled by this painter.
|
Color |
getSelectionColor()
Returns the selection color.
|
ILcdIcon |
getSnapIcon() |
boolean |
isTouched(Graphics aGraphics,
int aSequenceNumber,
ILcdGXYContext aContext)
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)
Overrides the paint method of the
TLcdGXYPointListPainter class. |
void |
removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
De-registers the given
PropertyChangeListener from receiving property change events
for this object. |
void |
setDefaultColor(Color aDefaultColor)
Specifies the default color.
|
void |
setFillMode(String aFillMode)
Sets the fill mode of this painter that determines when a runway should be painted with a fill.
|
void |
setLineStyle(TLcdG2DLineStyle aLineStyle)
Specifies a
TLcdG2DLineStyle object that
will be used to draw the runway bounds. |
void |
setObject(Object aObject)
Sets the Object for which the representation shall be handled by this painter.
|
void |
setPaintCache(boolean aPaintCache)
Sets whether the paint cache must be enabled.
|
void |
setSelectionColor(Color aSelectionColor)
Specifies the selection color.
|
void |
setSnapIcon(ILcdIcon aSnapIcon) |
void |
setSurfaceTypeExpression(String aSurfaceTypeExpression)
Sets the expression that evaluates to to surface type of the runway object.
|
void |
setSurfaceTypeIndex(int aSurfaceTypeIndex)
Deprecated.
|
Object |
snapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns an object that can be used as snapping target when graphically editing an object.
|
boolean |
supportSnap(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns whether the painter can provide a snap target based on the representation of the object in the given
context.
|
public static final String NO_FILL
setFillMode(String)
,
Constant Field Valuespublic static final String BY_SURFACE_TYPE
setFillMode(String)
,
Constant Field Valuespublic static final String ALWAYS
setFillMode(String)
,
Constant Field Valuespublic TLcdICAORunwayPainter()
TLcdICAORunwayPainter
object.public TLcdICAORunwayPainter(TLcdICAORunwayPainter aICAORunwayPainter)
aICAORunwayPainter
- the TLcdICAORunwayPainter
to be copied.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 ILcdGXYPainter
aObject
- the object for which the representation shall be handled by this painter.ILcdGXYPainter.getObject()
public Object getObject()
ILcdGXYPainter
getObject
in interface ILcdGXYPainter
ILcdGXYPainter.setObject(Object)
public void setSnapIcon(ILcdIcon aSnapIcon)
public ILcdIcon getSnapIcon()
public void boundsSFCT(Graphics aGraphics, int aSequenceNumber, ILcdGXYContext aContext, ILcd2DEditableBounds aILcd2DEditableBounds) 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 paintedaSequenceNumber
- 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.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.aILcd2DEditableBounds
- 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 boolean isTouched(Graphics aGraphics, int aSequenceNumber, ILcdGXYContext aContext)
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 paintedaSequenceNumber
- the mode the object is represented inaContext
- contains the location of the interaction and the transformations to convert this location into
model coordinatesboundsSFCT
public void addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
ILcdPropertyChangeSource
Registers the given PropertyChangeListener
to be notified when this object's
properties change.
In case you need to register a listener which keeps a reference to an object with a shorter life-time than this change source,
you can use a ALcdWeakPropertyChangeListener
instance as property change listener.
addPropertyChangeListener
in interface ILcdPropertyChangeSource
aPropertyChangeListener
- The listener to be notifiedALcdWeakPropertyChangeListener
,
ILcdPropertyChangeSource.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void anchorPointSFCT(Graphics aGraphics, int aSequenceNumber, ILcdGXYContext aContext, Point aPoint) throws TLcdNoBoundsException
ILcdGXYPainter
The anchor point is an important point of the representation, typically the point which would be used
when the object would be represented as a single point. The anchor point is mostly used to attach extra information
to the representation of an object, for example, using labels. A typical implementation of this method for painters
which can handle ILcdShape
objects is the location of the focus point of the shape.
anchorPointSFCT
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaSequenceNumber
- 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
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 Object
Object.clone()
public Cursor getCursor(Graphics aGraphics, int aSequenceNumber, ILcdGXYContext aContext)
ILcdGXYPainter
TRANSLATING
, the cursor could be the MOVE cursor.
When no specific cursor is required implementations must return null.getCursor
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaSequenceNumber
- the rendering mode to return the cursor for.aContext
- the context in which the rendering occurs.Cursor
to indicate the type of operating
aMode
and aGXYContext
. Returns
null
if no particular Cursor
is required.public String getDisplayName()
ILcdGXYPainter
getDisplayName
in interface ILcdGXYPainter
public void removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
ILcdPropertyChangeSource
De-registers the given PropertyChangeListener
from receiving property change events
for this object.
If the listener was added more than once, it will be notified one less time after being
removed.
If the listener is null
, or was never added, no exception is thrown and no action is taken.
removePropertyChangeListener
in interface ILcdPropertyChangeSource
aPropertyChangeListener
- the listener that should no longer be notified of changes of
this object's propertiesILcdPropertyChangeSource.addPropertyChangeListener(java.beans.PropertyChangeListener)
public Object snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
ILcdGXYPainter
This method must only be called when supportSnap
returns true for the given context.
snapTarget
in interface ILcdGXYPainter
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.supportSnap
public boolean supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
ILcdGXYPainter
supportSnap
in interface ILcdGXYPainter
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.public ILcdGXYPainter getGXYPainter(Object aObject)
ILcdRunway
objects.
In all other cases, null
is returned.getGXYPainter
in interface ILcdGXYPainterProvider
aObject
- An object to return a painter for.ILcdRunway
objects, null
otherwise.public void paint(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
TLcdGXYPointListPainter
class.
We distinguish between three different situations:
paint
in interface ILcdGXYPainter
aGraphics
- The Graphics to paint on.aMode
- The paint mode.aGXYContext
- The paint context.@Deprecated public void setSurfaceTypeIndex(int aSurfaceTypeIndex)
setSurfaceTypeExpression(String)
ILcdRunwayFeature.SURFACE_TYPE
.
If set, it is used to determine a paint style for each runway, following the ICAO guidelines:
aSurfaceTypeIndex
- The index of the surface type feature.public void setSurfaceTypeExpression(String aSurfaceTypeExpression)
TLcdDataObjectExpressionLanguage
.aSurfaceTypeExpression
- the surface type property.public Color getDefaultColor()
public void setDefaultColor(Color aDefaultColor)
aDefaultColor
- the default color.public void setFillMode(String aFillMode)
FillMode.BY_SURFACE_TYPE
.aFillMode
- A valid FillMode
, must not be nullpublic Color getSelectionColor()
public void setSelectionColor(Color aSelectionColor)
aSelectionColor
- the selection color.public void setLineStyle(TLcdG2DLineStyle aLineStyle)
TLcdG2DLineStyle
object that
will be used to draw the runway bounds.aLineStyle
- a TLcdG2DLineStyle
object.public void setPaintCache(boolean aPaintCache)
aPaintCache
- whether the paint cache must be enabled.