Class TLcdLonLatBorderGridPainter
- All Implemented Interfaces:
ILcdCloneable,ILcdPropertyChangeSource,ILcdGXYPainter,ILcdGXYPainterProvider,Serializable,Cloneable
ILcdGXYPainter paints TLcdLonLatGrid objects
as a maritime-style border around the view.
The border contains two rectangular frames. The inner frame shows colored blocks between the major ticks. The outer frame shows tick marks at the minor ticks. The number of major ticks and minor ticks per longitude and latitude delta can be specified.
Text labels around the frames indicate major labels in a major label format, and minor labels in a minor label format. Major labels are placed at each longitude and latitude delta, while minor labels are placed at each major tick, space permitting.
- Since:
- 6.0
- See Also:
-
Field Summary
Fields inherited from class com.luciad.view.gxy.ALcdGXYPainter
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBoundsFields inherited from interface com.luciad.view.gxy.ILcdGXYPainter
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidboundsSFCT(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.Returns theColorof the border background (default = Color.white).intReturns the total width of the bottom border, in pixels (default = 20).getColor()Returns theColorof the ticks and blocks (default = Color.black).intReturns the total width of the left border, in pixels.Returns theColorfor the major labels (default = Color.black).Returns theFontfor the major labels.Returns the formatter to be used for the labels of the major ticks.intReturns the number of major ticks per latitude interval (default = 10).intReturns the number of major ticks per longitude interval (default = 10).Returns theColorfor the minor labels (default = Color.gray).Returns theFontfor the minor labels.Returns the formatter to be used for the labels of the minor ticks.intReturns the number of minor ticks per latitude interval (default = 20).intReturns the number of minor ticks per longitude interval (default = 20).Returns the Object for which the representation is currently being handled by this painter.intReturns the total width of the right border, in pixels (default = 20).intReturns the total width of the top border, in pixels (default = 20).booleanReturns whether the grid labels are painted (default = true).booleanReturns whether the grid labels are painted at an angle (default = true).booleanisTouched(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.voidpaint(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.voidsetBackgroundColor(Color aBackgroundColor) Sets theColorof the border background (default = Color.white).voidsetBottomBorder(int aBottomBorder) Sets the total width of the bottom border, in pixels (default = 20).voidSets theColorof the ticks and blocks (default = Color.black).voidsetLabeled(boolean aBoolean) Specifies whether the grid labels should be painted (default = true).voidsetLeftBorder(int aLeftBorder) Sets the total width of the left border, in pixels (default = 20).voidsetMajorLabelColor(Color aColor) Sets theColorfor the major labels (default = Color.black).voidsetMajorLabelFont(Font aFont) Sets theFontfor the major labels.voidsetMajorLabelLonLatFormatter(ILcdLonLatFormatter aMajorLabelLonLatFormatter) Sets the formatter to be used for the labels of the major ticks.voidsetMajorTicksPerDeltaLat(int aMajorTicksDeltaLat) Sets the number of major ticks per latitude interval (default = 10).voidsetMajorTicksPerDeltaLon(int aMajorTicksDeltaLon) Sets the number of major ticks per longitude interval (default = 10).voidsetMinorLabelColor(Color aColor) Sets theColorfor the minor labels (default = Color.gray).voidsetMinorLabelFont(Font aFont) Sets theFontfor the minor labels.voidsetMinorLabelLonLatFormatter(ILcdLonLatFormatter aMinorLabelLonLatFormatter) Sets the formatter to be used for labels of the minor ticks.voidsetMinorTicksPerDeltaLat(int aMinorTicksDeltaLat) Sets the number of minor ticks per latitude interval (default = 20).voidsetMinorTicksPerDeltaLon(int aMinorTicksDeltaLon) Sets the number of minor ticks per longitude interval (default = 20).voidSets the Object for which the representation shall be handled by this painter.voidsetRightBorder(int aRightBorder) Sets the total width of the right border, in pixels (default = 20).voidsetSlantedLabels(boolean aBoolean) Specifies whether the grid labels should be painted at an angle (default = true).voidsetTopBorder(int aTopBorder) Sets the total width of the top border, in pixels (default = 20).Methods inherited from class com.luciad.view.gxy.ALcdGXYPainter
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn, snapTarget, supportSnapMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.view.gxy.ILcdGXYPainter
anchorPointSFCT, getCursor, getDisplayName, snapTarget, supportSnapMethods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
-
Constructor Details
-
TLcdLonLatBorderGridPainter
public TLcdLonLatBorderGridPainter()
-
-
Method Details
-
setLeftBorder
public void setLeftBorder(int aLeftBorder) Sets the total width of the left border, in pixels (default = 20). If set to 0, this part of the border is not painted. -
getLeftBorder
public int getLeftBorder()Returns the total width of the left border, in pixels. -
setRightBorder
public void setRightBorder(int aRightBorder) Sets the total width of the right border, in pixels (default = 20). If set to 0, this part of the border is not painted. -
getRightBorder
public int getRightBorder()Returns the total width of the right border, in pixels (default = 20). -
setTopBorder
public void setTopBorder(int aTopBorder) Sets the total width of the top border, in pixels (default = 20). If set to 0, this part of the border is not painted. -
getTopBorder
public int getTopBorder()Returns the total width of the top border, in pixels (default = 20). -
setBottomBorder
public void setBottomBorder(int aBottomBorder) Sets the total width of the bottom border, in pixels (default = 20). If set to 0, this part of the border is not painted. -
getBottomBorder
public int getBottomBorder()Returns the total width of the bottom border, in pixels (default = 20). -
getMinorTicksPerDeltaLon
public int getMinorTicksPerDeltaLon()Returns the number of minor ticks per longitude interval (default = 20). -
setMinorTicksPerDeltaLon
public void setMinorTicksPerDeltaLon(int aMinorTicksDeltaLon) Sets the number of minor ticks per longitude interval (default = 20). -
getMinorTicksPerDeltaLat
public int getMinorTicksPerDeltaLat()Returns the number of minor ticks per latitude interval (default = 20). -
setMinorTicksPerDeltaLat
public void setMinorTicksPerDeltaLat(int aMinorTicksDeltaLat) Sets the number of minor ticks per latitude interval (default = 20). -
getMajorTicksPerDeltaLon
public int getMajorTicksPerDeltaLon()Returns the number of major ticks per longitude interval (default = 10). -
setMajorTicksPerDeltaLon
public void setMajorTicksPerDeltaLon(int aMajorTicksDeltaLon) Sets the number of major ticks per longitude interval (default = 10). -
getMajorTicksPerDeltaLat
public int getMajorTicksPerDeltaLat()Returns the number of major ticks per latitude interval (default = 10). -
setMajorTicksPerDeltaLat
public void setMajorTicksPerDeltaLat(int aMajorTicksDeltaLat) Sets the number of major ticks per latitude interval (default = 10). -
getColor
Returns theColorof the ticks and blocks (default = Color.black). -
setColor
Sets theColorof the ticks and blocks (default = Color.black). -
getBackgroundColor
Returns theColorof the border background (default = Color.white). -
setBackgroundColor
Sets theColorof the border background (default = Color.white). -
isLabeled
public boolean isLabeled()Returns whether the grid labels are painted (default = true). -
setLabeled
public void setLabeled(boolean aBoolean) Specifies whether the grid labels should be painted (default = true). -
getMajorLabelLonLatFormatter
Returns the formatter to be used for the labels of the major ticks. -
setMajorLabelLonLatFormatter
Sets the formatter to be used for the labels of the major ticks. -
getMinorLabelLonLatFormatter
Returns the formatter to be used for the labels of the minor ticks. -
setMinorLabelLonLatFormatter
Sets the formatter to be used for labels of the minor ticks. -
isSlantedLabels
public boolean isSlantedLabels()Returns whether the grid labels are painted at an angle (default = true). -
setSlantedLabels
public void setSlantedLabels(boolean aBoolean) Specifies whether the grid labels should be painted at an angle (default = true). -
getMajorLabelColor
Returns theColorfor the major labels (default = Color.black). -
setMajorLabelColor
Sets theColorfor the major labels (default = Color.black). -
getMinorLabelColor
Returns theColorfor the minor labels (default = Color.gray). -
setMinorLabelColor
Sets theColorfor the minor labels (default = Color.gray). -
getMajorLabelFont
Returns theFontfor the major labels. -
setMajorLabelFont
Sets theFontfor the major labels. -
getMinorLabelFont
Returns theFontfor the minor labels. -
setMinorLabelFont
Sets theFontfor the minor labels. -
setObject
Description copied from interface:ILcdGXYPainterSets 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:
setObjectin interfaceILcdGXYPainter- Parameters:
aObject- the object for which the representation shall be handled by this painter.- See Also:
-
getObject
Description copied from interface:ILcdGXYPainterReturns the Object for which the representation is currently being handled by this painter.- Specified by:
getObjectin interfaceILcdGXYPainter- Returns:
- the Object for which the representation is currently being handled by this painter.
- See Also:
-
paint
Description copied from interface:ILcdGXYPainterDisplays 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 ofILcdGXYPainterandILcdGXYEditorinterfaces 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 theILcdGXYPainterandILcdGXYEditorinterfaces 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
snapTargetmust 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:
paintin 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- theILcdGXYContextthe drawing depends on.
-
isTouched
Description copied from interface:ILcdGXYPainterChecks 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
boundsSFCTis 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:
isTouchedin 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:
-
boundsSFCT
public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) Description copied from interface:ILcdGXYPainterSets 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
ILcdBoundedobjects.- Specified by:
boundsSFCTin 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.- See Also:
-
clone
Description copied from interface:ILcdCloneableMakes
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:
clonein interfaceILcdCloneable- Specified by:
clonein interfaceILcdGXYPainterProvider- Overrides:
clonein classALcdGXYPainter- Returns:
- a clone of this painter provider.
- See Also:
-