Interface ILcdGXYView
- All Superinterfaces:
ILcdGXYViewXYWorldTransformationProvider
,ILcdLayered
,ILcdPropertyChangeSource
,ILcdStatusSource
,ILcdTreeLayered
,ILcdView
,Serializable
- All Known Subinterfaces:
ILcdRotationCapableGXYView
- All Known Implementing Classes:
TLcdGXYViewBufferedImage
,TLcdGXYViewCanvas
,TLcdGXYViewJPanel
,TLcdGXYViewJPanelLightWeight
,TLcdGXYViewPanel
,TLcdGXYViewPlanarImage
,TLcdMapBufferedImage
,TLcdMapCanvas
,TLcdMapJPanel
,TLcdMapJPanelLightWeight
,TLcdMapPanel
ILcdView
to visualize two-dimensional object geometry, based on AWT Graphics
and organized in ILcdGXYLayer
objects.
View contents
AnILcdGXYView
aggregates
and displays a number of ILcdGXYLayer
objects.
For example, a view might display a map's geometry using three layers: states, roads and rivers.
The view is painted bottom-to-top, depending on the object representation, in the following order:
- a
background color
; - the bodies of each contained layer's models. Each layer is asked to paint itself, from bottom to top;
- the labels of each contained layer's models.
Typically labels are painted on top of any bodies.
The labels are painted by the layer itself, or by a
view label painter
, if it is set; - the selected bodies of each contained layer's models. Typically selections are painted on top of bodies and labels.
- the selected labels of each contained layer's models. The labels are painted by the layer itself, or by a view label painter, if it is set;
- corner icons, if any;
- the controller handling user interaction.
ILcdGXYLayer
for more information about paint representations.
User interaction
The view offers user interaction with its contained layers' objects through acontroller
. In the view example of the previous section,
the user might pan and zoom on the map, and retrieve more information on the displayed roads.
Only one controller can be active at a time. When you instantiate a view implementing
ILcdGXYView
, it activates a default controller that combines common types of user interaction:
view navigation, selection and editing.
Geographical aspects
The AWT coordinate system maps to a 2D world coordinate system, described by anILcdXYWorldReference
.
The following properties determine the view-world transformation:
- a scale, expressed in a
unitless map scale ratio
orthe number of pixels per world unit
; - a
world origin
, a point in the world coordinate system that corresponds with the view origin. Hence, the view and world origin represent the same physical point in different coordinate systems; - a
view origin
, a point in the view coordinate system that corresponds with the world origin.
ILcdRotationCapableGXYView
adds rotation as an extra view-world transformation parameter.
All view coordinates follow the Java AWT convention, meaning that the origin is in the upper-left corner.
Toolkit integration
This interface does not define how a view can be displayed on the screen.To achieve displaying 2D information,
ILcdGXYView
extends ILcdView
with some
AWT Component
properties:
it has a width, a height, a background color, and a current java.awt.Cursor
.
TLcdGXYViewJPanel
defines a view that lives in a Swing component.
TLcdGXYViewBufferedImage
defines a view that can be rendered to an image.
In addition, the ILcdGXYView
can be painted on a Graphics
or returned as
a java.awt.Image
.
Invalidating content
AnILcdGXYView
can be updated both automatically and manually.The view's representation is automatically invalidated for the following changes:
- changes in the containing layer's models;
- property changes of the containing layers;
- selection changes of the containing layers;
ILcdLayered
changes;- property changes affecting the view's representation, such as the world reference.
auto-update
property controls whether the view's representation is automatically updated
when any of the above changes occur.
Manual invalidations and updates are also possible using the invalidate(boolean, java.lang.Object, java.lang.String)
method.
Possible uses are updating the view
after changing a painter property, or combining several view changes in a single update.
Depending on the view's implementation, one can avoid invalidating the
entire view using the following methods:
invalidateGXYLayer(com.luciad.view.gxy.ILcdGXYLayer, boolean, java.lang.Object, java.lang.String)
to invalidate a single layer, for example, after changing its painter's properties;invalidateRegion(java.awt.Rectangle, boolean, java.lang.Object, java.lang.String)
to invalidate a region of the view representation, for example, after causing a change affecting the objects present in that region;invalidateSelection(boolean, java.lang.Object, java.lang.String)
andinvalidateRegionSelection(java.awt.Rectangle, boolean, java.lang.Object, java.lang.String)
to invalidate the layer's selected objects, after causing a change affecting the objects present in the selection.
ILcdGXYView
may cache a number of layers near the bottom. This behavior is controlled by
the setNumberOfCachedBackgroundLayers(int)
method.
Screen DPI and display scaling
To accurately work with map scales, the view needs the screen's DPI. Refer toTLcdMapScale
for more information.
GXY views support high DPI rendering, meaning that map features such as icons, line widths or font sizes will be
scaled up in response to the DPI scale settings of the host operating system.
This is largely transparent to the user, but some caveats apply when using the custom GXY painters to take into
account the scaled view.
If you set the DPI scale factor to 1.5 (150%), for instance, then Swing components will report their size as
being 1.5 times smaller than their actual pixel size. This means that the width and height reported by, for instance,
a JPanel
will be smaller than the panel's size in actual screen pixels.
GXY views will adapt themselves by generating larger views proportional to the DPI scale factor. In case of writing
your own custom GXY painters, if you are painting by using image buffers, you should take into account HiDPI support.
You have to use properly enlarged images according to the DPI scale factor, which can be retrieved
using TLcdGXYContext#getDPIScale()
.
High DPI rendering can be overridden using the -Dsun.java2d.uiScale=1.0
system property (1.0 corresponds to
100%). This sets the DPI scale to 100% (i.e. it switches DPI scaling off). The same property can also be used to
enforce a scale factor other than the one configured in the host operating system.
Further information
Exception handling can be controlled using anILcdPaintExceptionHandler
(see getPaintExceptionHandler()
. When the view, a layer or a painter catches an
exception during painting, it can retrieve the ILcdPaintExceptionHandler
from
the view and pass the exception to it.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Denotes the center position of the view when positioning corner icons.static final int
Denotes the lower left position of the view when positioning corner icons.static final int
Denotes the lower right position of the view when positioning corner icons.static final int
Denotes the upper left position of the view when positioning corner icons.static final int
Denotes the upper right position of the view when positioning corner icons. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addGXYLayer
(ILcdGXYLayer aLayer) Adds the givenILcdGXYLayer
to thisILcdGXYView
.boolean
addGXYLayer
(ILcdGXYLayer aLayer, boolean aRepaint) Adds the givenILcdGXYLayer
to thisILcdGXYView
, forcing a repaint if desired.void
addLayerSelectionListener
(ILcdSelectionListener aSelectionListener) Registers the givenILcdSelectionListener
to be informed of selection change events from any layer in this view.void
addModelListener
(ILcdModelListener aModelListener) Registers the givenILcdModelListener
to be informed ofILcdModel
change events from any layer's model in this view.default void
addStatusListener
(ILcdStatusListener aStatusListener) Registers the givenILcdStatusListener
to be notified of view status events.default void
addViewInvalidationListener
(ILcdViewInvalidationListener aInvalidationListener) Registers anILcdViewInvalidationListener
to be informed when the view's contents are invalid.Returns the background color of the view.Deprecated.Use the relevant layer's pen instead.Deprecated.This property is not used.Returns a graphics context for this view.Returns theILcdGXYController
handling the user interaction of the view.Deprecated.ILcdGXYViewLabelPlacer offers more powerful and flexible decluttering functionalitydefault ILcdGXYViewLabelPlacer
Returns the label placer for this view.int
Returns the view's current height in AWT pixels.getImage()
Returns anImage
of this view.default List
<ILcdGXYLayer> Returns aList
of the layers.default TLcdMapScale
getMapScale
(TLcdMapScale.ScaleLocation aScaleLocation) Returns the unitless map scale ratio for which to paint the view contents.default TLcdDimensionInterval
<TLcdMapScale> Returns the limits on the minimum and maximum scale of the view.double
Returns the maximum zoomed in scale of the view.double
Returns the maximum zoomed out scale of the view.int
Returns the number of layers whose combined representation is cached across repaints.Returns a handler to report paint exceptions.int
Deprecated.This mode is not taken into account.Returns the preferred size of the view.double
getScale()
Returns the scale for which to paint the view contents expressed in toolkit pixels per world unit.Returns the point in AWT pixel coordinates that maps onto the world origin.int
getWidth()
Returns the view's current width in AWT pixels.Returns the point in world coordinates that maps onto the view origin.Returns the view's 2D world coordinate system.boolean
Deprecated.getImage() always returns a valid image.void
invalidate
(boolean aRepaint, Object aSource, String aMessage) Asks the view to invalidate its content, optionally repainting the content asynchronously.void
invalidateAndWait
(boolean aRepaint, Object aSource, String aMessage) Asks the view to invalidate its content, optionally repainting the content synchronously.void
invalidateGXYLayer
(ILcdGXYLayer aGXYLayer, boolean aRepaint, Object aSource, String aMessage) Asks the view to invalidate the content of the givenILcdGXYLayer
, optionally repainting the content asynchronously.void
invalidateGXYLayerAndWait
(ILcdGXYLayer aGXYLayer, boolean aRepaint, Object aSource, String aMessage) Asks the view to invalidate the content of the givenILcdGXYLayer
, optionally repainting the content synchronously.void
invalidateRegion
(Rectangle aClip, boolean aRepaint, Object aSource, String aMessage) Asks the view to invalidate the content in the given AWT clip, optionally repainting the content asynchronously.void
invalidateRegionAndWait
(Rectangle aClip, boolean aRepaint, Object aSource, String aMessage) Asks the view to invalidate the content in the given AWT clip, optionally repainting the content synchronously.void
invalidateRegionSelection
(Rectangle aClip, boolean aRepaint, Object aSource, String aMessage) Asks the ILcdGXYView to invalidate its selection in the given AWT clip, optionally repainting the content asynchronously.void
invalidateRegionSelectionAndWait
(Rectangle aClip, boolean aRepaint, Object aSource, String aMessage) Asks the ILcdGXYView to invalidate its selection in the given AWT clip, optionally repainting the content synchronously.void
invalidateSelection
(boolean aRepaint, Object aSource, String aMessage) Asks the ILcdGXYView to invalidate its selection, optionally repainting the content asynchronously.void
invalidateSelectionAndWait
(boolean aRepaint, Object aSource, String aMessage) Asks the ILcdGXYView to invalidate its selection, optionally repainting the content synchronously.boolean
Specifies if anti-aliasing is enabled or not.boolean
Returns whether this view allows asynchronous operations.boolean
Returns whether the entire view's content is displayed, or only the controller's representation.boolean
Deprecated.This method has been deprecated in favor of the approach provided by theILcdGXYAsynchronousLayerWrapper
interface and its implementations, which is more versatile and which generally offers better thread safety.void
paintGXYView
(Graphics aGraphics) Paints the view on the givenGraphics
.void
pan
(int aDeltaX, int aDeltaY, boolean aRepaint) Changes the view and/or world origin of the view so that the view contents are panned by the specified AWT delta.void
putCornerIcon
(ILcdIcon aCornerIcon, int aPosition) Sets anILcdIcon
to be painted at the given corner of this view.void
removeLayerSelectionListener
(ILcdSelectionListener aSelectionListener) Unregisters the givenILcdSelectionListener
from receiving selection change events from any layer in this view.void
removeModelListener
(ILcdModelListener aModelListener) Unregisters the givenILcdModelListener
from receivingILcdModel
change events from any layer's model in this view.default void
removeStatusListener
(ILcdStatusListener aStatusListener) Unregisters the givenILcdStatusListener
from being notified of view status events.default void
removeViewInvalidationListener
(ILcdViewInvalidationListener aInvalidationListener) Unregisters anILcdViewInvalidationListener
so that it is no longer informed of invalidation events for this view.void
repaint()
Repaints the view.void
repaint
(int aX, int aY, int aWidth, int aHeight) Repaints the view within the given AWT rectangle.void
setBackground
(Color aColor) Sets the background color of the view.void
Sets the view cursor to the given cursor.void
setDrawOffScreenImageOnPaint
(boolean aDrawOffScreenImageOnPaint) Sets whether the entire view's content is displayed, or only the current controller's representation.void
setForeground
(Color aColor) Deprecated.This property is not used.void
setGXYController
(ILcdGXYController aGXYController) Makes the givenILcdGXYController
handle the user interaction of the view.default void
setGXYViewLabelPlacer
(ILcdGXYViewLabelPlacer aLabelPlacer) This method sets anILcdGXYViewLabelPlacer
to use for global labeling.default void
setMapScale
(TLcdMapScale aMapScale, TLcdMapScale.ScaleLocation aScaleLocation) Sets the unitless map scale ratio of this view, repainting the view according toisAutoUpdate
.default void
setMapScaleRange
(TLcdDimensionInterval<TLcdMapScale> aMapScaleRange) Enforces the given limits on the minimum and maximum scale of the view.void
setMaxScale
(double aMaxScale) Limits the maximum zoomed in scale of the view.void
setMinScale
(double aMinScale) Limits the maximum zoomed out scale of the view.void
setNumberOfCachedBackgroundLayers
(int aNumberOfCachedBackgroundLayers) Sets the number of layers whose combined representation is cached across repaints.default void
setPaintExceptionHandler
(ILcdPaintExceptionHandler aPaintExceptionHandler) Sets a handler to report paint exceptions.void
setPaintInBackground
(boolean aPaintInBackground) Deprecated.This method has been deprecated in favor of the approach provided by theILcdGXYAsynchronousLayerWrapper
interface and its implementations, which is more versatile and which generally offers better thread safety.void
setPaintingMode
(int aPaintingMode) Deprecated.This mode is not taken into account.void
setScale
(double aScale) Sets the scale of this view, repainting the view according toisAutoUpdate
.void
setScale
(double aScale, boolean aRepaint) Sets the scale of this view, optionally repainting the view.void
setScale
(double aScale, boolean aRepaint, boolean aAdjusting) Sets the scale of this view, optionally indicating subsequent property changes.default void
setScale
(double aScaleX, double aScaleY, boolean aRepaint, boolean aAdjusting) Sets the scale along the x-axis and y-axis of this view, repainting the view according toisAutoUpdate
.void
setViewOrigin
(Point aViewOrigin) Sets the view origin of the view, repainting the view according toisAutoUpdate
.void
setViewOrigin
(Point aViewOrigin, boolean aRepaint) Sets the view origin of the view, optionally repainting the view.void
setViewOrigin
(Point aViewOrigin, boolean aRepaint, boolean aAdjusting) Sets the view origin of the view, optionally indicating subsequent property changes.void
setWorldOrigin
(ILcdPoint aWorldOrigin) Sets the world origin of the view, repainting the view according toisAutoUpdate
.void
setWorldOrigin
(ILcdPoint aWorldOrigin, boolean aRepaint) Sets the world origin of the view, optionally repainting the view.void
setWorldOrigin
(ILcdPoint aWorldOrigin, boolean aRepaint, boolean aAdjusting) Sets the world origin of the view, optionally indicating subsequent property changes.void
setXYWorldReference
(ILcdXYWorldReference aXYWorldReference) Sets the view's 2D world coordinate system, repainting the view according toisAutoUpdate
.void
setXYWorldReference
(ILcdXYWorldReference aXYWorldReference, boolean aRepaint) Sets the view's 2D world coordinate system, optionally repainting the view.void
setXYWorldReference
(ILcdXYWorldReference aXYWorldReference, boolean aRepaint, boolean aAdjusting) Sets the view's 2D world coordinate system, optionally indicating subsequent property changes.Methods inherited from interface com.luciad.view.gxy.ILcdGXYViewXYWorldTransformationProvider
getGXYViewXYWorldTransformation
Methods inherited from interface com.luciad.view.ILcdLayered
addLayeredListener, moveLayerAt, removeLayeredListener
Methods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
Methods inherited from interface com.luciad.view.ILcdTreeLayered
addLayeredListener, containsLayer, getLayer, getRootNode, indexOf, layerCount, layerOf, layers, layersBackwards, removeAllLayers, removeLayer, removeLayeredListener
Methods inherited from interface com.luciad.view.ILcdView
addModel, isAutoUpdate, removeModel, setAutoUpdate
-
Field Details
-
UPPERLEFT
static final int UPPERLEFTDenotes the upper left position of the view when positioning corner icons.- See Also:
-
UPPERRIGHT
static final int UPPERRIGHTDenotes the upper right position of the view when positioning corner icons.- See Also:
-
LOWERRIGHT
static final int LOWERRIGHTDenotes the lower right position of the view when positioning corner icons.- See Also:
-
LOWERLEFT
static final int LOWERLEFTDenotes the lower left position of the view when positioning corner icons.- See Also:
-
CENTER
static final int CENTERDenotes the center position of the view when positioning corner icons.- See Also:
-
-
Method Details
-
getLayers
Description copied from interface:ILcdLayered
Returns aList
of the layers.- Specified by:
getLayers
in interfaceILcdLayered
- Returns:
- an unmodifiable
List
of the layers in thisILcdLayered
-
putCornerIcon
Sets anILcdIcon
to be painted at the given corner of this view. Only the last set icon for the given position is painted.- Parameters:
aCornerIcon
- theILcdIcon
to be painted at the given corner ornull
to unregister the iconaPosition
- one ofILcdGXYView.UPPERLEFT
,ILcdGXYView.UPPERRIGHT
,ILcdGXYView.LOWERRIGHT
,ILcdGXYView.LOWERLEFT
-
addGXYLayer
Adds the givenILcdGXYLayer
to thisILcdGXYView
. The layer is normally added to the top of the view's layers, but that is implementation specific. The view will be repainted depending on the result ofisAutoUpdate
. No action is performed if the given layer is already contained in the list.- Parameters:
aLayer
- the layer to add to this view- Returns:
true
if the layer was added successfully,false
if the view already contained the layer- See Also:
-
addGXYLayer
Adds the givenILcdGXYLayer
to thisILcdGXYView
, forcing a repaint if desired. The layer is normally added to the top of the view's layers, but that is implementation specific. No action is performed if the given layer is already contained in the list.- Parameters:
aLayer
- the layer to add to this viewaRepaint
- if true, the view is repainted. If false, the view is not repainted.- Returns:
true
if the layer was added successfully,false
if the view already contained the layer- See Also:
-
addModelListener
Registers the givenILcdModelListener
to be informed ofILcdModel
change events from any layer's model in this view.- Parameters:
aModelListener
- a listener that will be notified ofILcdModel
change events from any layer's model in this view- See Also:
-
removeModelListener
Unregisters the givenILcdModelListener
from receivingILcdModel
change events from any layer's model in this view.- Parameters:
aModelListener
- a listener that the view will no longer notify ofILcdModel
change events- See Also:
-
addLayerSelectionListener
Registers the givenILcdSelectionListener
to be informed of selection change events from any layer in this view.- Parameters:
aSelectionListener
- a listener that will be notified of selection change events from any layer in this view. The events will have the relevant layer as source.- See Also:
-
removeLayerSelectionListener
Unregisters the givenILcdSelectionListener
from receiving selection change events from any layer in this view.- Parameters:
aSelectionListener
- a listener that the view will no longer inform of selection change events- See Also:
-
getNumberOfCachedBackgroundLayers
int getNumberOfCachedBackgroundLayers()Returns the number of layers whose combined representation is cached across repaints. The layers are always the bottommost layer objects; they are regarded as background layers.- Returns:
- the number of bottommost layers to cache
- See Also:
-
setNumberOfCachedBackgroundLayers
void setNumberOfCachedBackgroundLayers(int aNumberOfCachedBackgroundLayers) Sets the number of layers whose combined representation is cached across repaints. The layers are the bottommost layer objects; they are regarded as background layers.Caching background layers is useful when one upper real-time layer needs to be refreshed often, whereas the contents of the background layers seldom change. When a real-time layer changes and needs to be repainted, the cached representation of the background layers is reused, speeding up the paint process. When a background layer changes, all layers need to be repainted to update the view.
- Parameters:
aNumberOfCachedBackgroundLayers
- the number of bottommost layers to cache. This number applies to theflat list
of layers.- See Also:
-
hasValidImage
boolean hasValidImage()Deprecated.getImage() always returns a valid image. Implementations of this method should hence always returntrue
.Returnstrue
if the view has a valid image.- Returns:
true
- See Also:
-
getImage
Image getImage()Returns anImage
of this view. The image has not been painted on by the controller. This method is guaranteed to return an up-to-date image: if the view has been invalidated in some way (e.g. when a layer has been removed) then this method first updates the view before returning an image. To improve performance and conserve memory, the view is allowed to cache, reuse and overwrite the image in subsequent repaints. NOTE: While using High DPI mode, this method will return an image which is bigger than the view dimensions reported bygetWidth()
andgetHeight()
methods.- Returns:
- an image containing the representation of this view
-
getGraphics
Graphics getGraphics()Returns a graphics context for this view. Most view implementations offer this context only to retrieve information from. Typically it cannot be used to draw on the view, especially if the view is automatically repainted.- Returns:
- a graphics context for this view
-
getWidth
int getWidth()Returns the view's current width in AWT pixels.- Returns:
- the view's current width in AWT pixels
-
getHeight
int getHeight()Returns the view's current height in AWT pixels.- Returns:
- the view's current height in AWT pixels
-
getPreferredSize
Dimension getPreferredSize()Returns the preferred size of the view. This interface does not specify a functionality for this property.- Returns:
- the preferred size of the view in AWT pixels
-
setCursor
Sets the view cursor to the given cursor. Its image is displayed when the mouse is within the view boundaries.- Parameters:
aCursor
- Cursor instance to use, or null to inherit the cursor of a containing entity, if any- See Also:
-
setBackground
Sets the background color of the view. This is the color that appears when no objects are painted on top of it.- Parameters:
aColor
- the color which appears at a location where no data is painted.- Throws:
IllegalArgumentException
- when the given color is null- See Also:
-
getBackground
Color getBackground()Returns the background color of the view. This is the color that appears when no objects are painted on top of it.- Returns:
- the background color of the view
- See Also:
-
setForeground
Deprecated.This property is not used. Implementations should remember the field so it can be queried withgetForeground()
Sets the foreground color of the view.- Parameters:
aColor
- the desired foregroundColor
- See Also:
-
getForeground
Color getForeground()Deprecated.This property is not used.Returns the foreground color of the view.- Returns:
- the view's foreground color
- See Also:
-
setScale
void setScale(double aScale) Sets the scale of this view, repainting the view according toisAutoUpdate
. The scale corresponds to the number of pixels per world unit, as determined by theILcdXYWorldReference
. Hence, increasing the scale zooms in, and decreasing the scale zooms out. A view displaying geographical data usually employs a scale in pixels per meter. As an example, to fit the world on a view that is 1000 pixels wide, a scale of about 1000 pixels/40.000km, or 1.0/40.000 is needed. For most use cases, we recommended setting theunitless map scale
instead.- Parameters:
aScale
- the new scale of the view. The view is scaled using the world origin as center. The scale is limited so that it does not exceed the interval defined by the minimum and maximum scales.- See Also:
-
setScale
void setScale(double aScale, boolean aRepaint) Sets the scale of this view, optionally repainting the view. The scale corresponds to the number of pixels per world unit, as determined by theILcdXYWorldReference
. Hence, increasing the scale zooms in, and decreasing the scale zooms out. A view displaying geographical data usually employs a scale in pixels per meter. As an example, to fit the world on a view that is 1000 pixels wide, a scale of about 1000 pixels/40.000km, or 1.0/40.000 is needed. For most use cases, we recommended setting theunitless map scale
instead.- Parameters:
aScale
- the new scale of the view. The view is scaled using the world origin as center. The scale is limited so that it does not exceed the interval defined by the minimum and maximum scales.aRepaint
- iftrue
, the view is repainted. If false, the view is not repainted.- See Also:
-
setScale
void setScale(double aScale, boolean aRepaint, boolean aAdjusting) Sets the scale of this view, optionally indicating subsequent property changes. The scale corresponds to the number of pixels per world unit, as determined by theILcdXYWorldReference
. Hence, increasing the scale zooms in, and decreasing the scale zooms out. A view displaying geographical data usually employs a scale in pixels per meter. As an example, to fit the world on a view that is 1000 pixels wide, a scale of about 1000 pixels/40.000km, or 1.0/40.000 is needed. For most use cases, we recommended setting theunitless map scale
instead.- Parameters:
aScale
- the new scale of the view. The view is scaled using the world origin as center. The scale is limited so that it does not exceed the interval defined by the minimum and maximum scales.aRepaint
- iftrue
, the view is repainted. If false, the view is not repainted.aAdjusting
- iftrue
, the caller indicates that he will trigger another property change right after this call. This is reflected in the associated property change event.- See Also:
-
setScale
default void setScale(double aScaleX, double aScaleY, boolean aRepaint, boolean aAdjusting) Sets the scale along the x-axis and y-axis of this view, repainting the view according toisAutoUpdate
.The scale corresponds to the number of pixels per world unit, as determined by the
ILcdXYWorldReference
. For example, a view displaying geographical data could use a scale in pixels per meter.The default implementation in this interface sets both scales to the geometric mean of the requested scales. The concrete view implementations do respect the individual scales.
- Parameters:
aScaleX
- the new scale along the x-axis of the view.aScaleY
- the new scale along the y-axis of the view.aRepaint
- iftrue
, the view is repainted. If false, the view is not repainted.aAdjusting
- iftrue
, the caller indicates that he will trigger another property change right after this call. This is reflected in the associated property change event.- Since:
- 2020.0
- See Also:
-
getScale
double getScale()Returns the scale for which to paint the view contents expressed in toolkit pixels per world unit. The world unit is determined by the view's world reference. Increasing the scale zooms in, and decreasing the scale zooms out. For most use cases, we recommended using theunitless map scale
instead.- Returns:
- the scale of this view
- See Also:
-
getMapScale
Returns the unitless map scale ratio for which to paint the view contents.- Returns:
- the scale of this view
- Since:
- 2021.0
- See Also:
-
setMapScale
Sets the unitless map scale ratio of this view, repainting the view according toisAutoUpdate
.- Parameters:
aMapScale
- the new scale of the view. The view is scaled using the world origin as center. The scale is limited so that it does not exceed the interval defined by the minimum and maximum scales. Nevernull
.- Since:
- 2021.0
- See Also:
-
setMapScaleRange
Enforces the given limits on the minimum and maximum scale of the view. Subsequent calls ofsetScale(double)
orsetMapScale(com.luciad.view.TLcdMapScale, com.luciad.view.TLcdMapScale.ScaleLocation)
will ensure that the scale falls within the given internal.- Parameters:
aMapScaleRange
- a range expressing the minimum and maximum allowed scale of the view, ornull
to disable the scale range- Since:
- 2021.0
- See Also:
-
getMapScaleRange
Returns the limits on the minimum and maximum scale of the view. Subsequent calls ofsetScale(double)
orsetMapScale(com.luciad.view.TLcdMapScale, com.luciad.view.TLcdMapScale.ScaleLocation)
will ensure that the scale falls within the given internal.- Returns:
- a range expressing the minimum and maximum allowed scale of the view
- Since:
- 2021.0
- See Also:
-
setMinScale
void setMinScale(double aMinScale) Limits the maximum zoomed out scale of the view. Subsequent calls ofsetScale(double)
orsetMapScale(com.luciad.view.TLcdMapScale, com.luciad.view.TLcdMapScale.ScaleLocation)
will ensure that the scale does not fall below the minimum scale. For most use cases, we recommended using theunitless map scale
variant instead.- Parameters:
aMinScale
- the new minimum scale of this view- See Also:
-
getMinScale
double getMinScale()Returns the maximum zoomed out scale of the view. Subsequent calls ofsetScale(double)
orsetMapScale(com.luciad.view.TLcdMapScale, com.luciad.view.TLcdMapScale.ScaleLocation)
will ensure that the scale does not fall below the minimum scale. For most use cases, we recommended using theunitless map scale
variant instead.- Returns:
- the minimum scale of the view
- See Also:
-
setMaxScale
void setMaxScale(double aMaxScale) Limits the maximum zoomed in scale of the view. Subsequent calls ofsetScale(double)
orsetMapScale(com.luciad.view.TLcdMapScale, com.luciad.view.TLcdMapScale.ScaleLocation)
will ensure that the scale does not rise above the maximum scale. For most use cases, we recommended using theunitless map scale
variant instead.- Parameters:
aMaxScale
- the new maximum scale of this view- See Also:
-
getMaxScale
double getMaxScale()Returns the maximum zoomed in scale of the view. Subsequent calls ofsetScale(double)
orsetMapScale(com.luciad.view.TLcdMapScale, com.luciad.view.TLcdMapScale.ScaleLocation)
will ensure that the scale does not rise above the maximum scale. For most use cases, we recommended using theunitless map scale
variant instead.- Returns:
- the maximum scale of the view
- See Also:
-
setWorldOrigin
Sets the world origin of the view, repainting the view according toisAutoUpdate
. The world origin is a point in world coordinates that maps onto the view origin.- Parameters:
aWorldOrigin
- the new world origin of this view, expressed in world coordinates. Only the XY coordinates are considered.- See Also:
-
setWorldOrigin
Sets the world origin of the view, optionally repainting the view. The world origin is a point in world coordinates that maps onto the view origin.- Parameters:
aWorldOrigin
- the new world origin of this view, expressed in world coordinates. Only the XY coordinates are considered.aRepaint
- iftrue
, the view is repainted. If false, the view is not repainted.- See Also:
-
setWorldOrigin
Sets the world origin of the view, optionally indicating subsequent property changes. The world origin is a point in world coordinates that maps onto the view origin.- Parameters:
aWorldOrigin
- the new world origin of this view, expressed in world coordinates. Only the XY coordinates are considered.aRepaint
- iftrue
, the view is repainted. If false, the view is not repainted.aAdjusting
- iftrue
, the caller indicates that he will trigger another property change right after this call. This is reflected in the associated property change event.- See Also:
-
getWorldOrigin
ILcdPoint getWorldOrigin()Returns the point in world coordinates that maps onto the view origin. Hence, the combination of world origin and view origin determines which part of the world is visible in the view. The points are considered to be 'on top of each other'- Returns:
- the world origin of the view, expressed in world coordinates. Only the XY coordinates of the point are relevant.
- See Also:
-
setViewOrigin
Sets the view origin of the view, repainting the view according toisAutoUpdate
. The view origin is a point in AWT pixel coordinates that maps onto the world origin.- Parameters:
aViewOrigin
- the new view origin of this view, expressed in AWT pixel coordinates- See Also:
-
setViewOrigin
Sets the view origin of the view, optionally repainting the view. The view origin is a point in AWT pixel coordinates that maps onto the world origin.- Parameters:
aViewOrigin
- the new view origin of this view, expressed in AWT pixel coordinatesaRepaint
- iftrue
, the view is repainted. If false, the view is not repainted.- See Also:
-
setViewOrigin
Sets the view origin of the view, optionally indicating subsequent property changes. The view origin is a point in AWT pixel coordinates that maps onto the world origin.- Parameters:
aViewOrigin
- the new view origin of this view, expressed in AWT pixel coordinatesaRepaint
- iftrue
, the view is repainted. If false, the view is not repainted.aAdjusting
- iftrue
, the caller indicates that he will trigger another property change right after this call. This is reflected in the associated property change event.- See Also:
-
getViewOrigin
Point getViewOrigin()Returns the point in AWT pixel coordinates that maps onto the world origin. Hence, the combination of world origin and view origin determines which part of the world is visible in the view. The points are considered to be 'on top of each other'.- Returns:
- the view origin expressed in AWT pixel coordinates
- See Also:
-
setXYWorldReference
Sets the view's 2D world coordinate system, repainting the view according toisAutoUpdate
.- Parameters:
aXYWorldReference
- the newILcdXYWorldReference
associated to this view- See Also:
-
setXYWorldReference
Sets the view's 2D world coordinate system, optionally repainting the view.- Parameters:
aXYWorldReference
- the newILcdXYWorldReference
associated to this viewaRepaint
- iftrue
, the view is repainted. If false, the view is not repainted.- See Also:
-
setXYWorldReference
void setXYWorldReference(ILcdXYWorldReference aXYWorldReference, boolean aRepaint, boolean aAdjusting) Sets the view's 2D world coordinate system, optionally indicating subsequent property changes.- Parameters:
aXYWorldReference
- the newILcdXYWorldReference
associated to this viewaRepaint
- iftrue
, the view is repainted. If false, the view is not repainted.aAdjusting
- iftrue
, the caller indicates that he will trigger another property change right after this call. This is reflected in the associated property change event.- See Also:
-
getXYWorldReference
ILcdXYWorldReference getXYWorldReference()Returns the view's 2D world coordinate system.- Returns:
- the view's 2D world coordinate system
- See Also:
-
setGXYController
Makes the given
ILcdGXYController
handle the user interaction of the view. The view calls the controller'sstartInteraction
method to make the controller aware of this fact, and calls the previous controller'sterminateInteraction
method, if any.Implementations of this method can direct input events to the controller by checking, for example, if the controller implements AWT input interfaces such as
KeyListener
andMouseListener
.- Parameters:
aGXYController
- the new controller of this view, ornull
if no controller is to be used- See Also:
-
getGXYController
ILcdGXYController getGXYController()Returns theILcdGXYController
handling the user interaction of the view.- Returns:
- the current controller handling the user interaction, or null if no controller is present
- See Also:
-
getDefaultPen
ILcdGXYPen getDefaultPen()Deprecated.Use the relevant layer's pen instead. Implementations of this method should return a pen supporting editing and painting on the view.Returns anILcdGXYPen
supporting editing and painting on the view.- Returns:
- the default
ILcdGXYPen
of this view - See Also:
-
setPaintingMode
void setPaintingMode(int aPaintingMode) Deprecated.This mode is not taken into account. Implementations should remember the value so that it can be queried usinggetPaintingMode()
.Sets the type or types of layer content to display in the ILcdGXYView.- Parameters:
aPaintingMode
- a binary OR of ILcdGXYLayer.BODIES, ILcdGXYLayer.LABELS, ILcdGXYLayer.SELECTION- See Also:
-
getPaintingMode
int getPaintingMode()Deprecated.This mode is not taken into account.Gets the painting mode for this ILcdGXYView.- Returns:
- a binary OR of ILcdGXYLayer.BODIES, ILcdGXYLayer.LABELS, ILcdGXYLayer.SELECTION
- See Also:
-
pan
void pan(int aDeltaX, int aDeltaY, boolean aRepaint) Changes the view and/or world origin of the view so that the view contents are panned by the specified AWT delta. Implementations of this method are allowed to only repaint newly exposed areas, hence this method is preferred over simply changing the world origin.- Parameters:
aDeltaX
- the shift in the X direction in screen coordinatesaDeltaY
- the shift in the Y direction in screen coordinatesaRepaint
- iftrue
, will trigger a repaint of the view's contents. Depending on the implementation, only the newly exposed areas may be painted. If false, the view is not repainted.
-
paintGXYView
Paints the view on the givenGraphics
. The painted image contains the following:- a background color;
- the bodies of each contained layer's models. Each layer is asked to paint itself, from bottom to top;
- the labels of each contained layer's models.
Typically labels are painted on top of any bodies.
The labels are painted by the layer itself, or by a
view label painter
, if it is set; - the selected bodies of each contained layer's models. Typically selections are painted on top of bodies and labels.
- the selected labels of each contained layer's models. The labels are painted by the layer itself, or by a view label painter, if it is set;
- corner icons, if any;
- the controller handling user interaction.
invalidate
methods.- Parameters:
aGraphics
- theGraphics
to paint the contents of this view on- See Also:
-
repaint
void repaint()Repaints the view. The view is allowed to reuse earlier painted results as long as they are valid. Invalidation of the contents may occur indirectly (e.g. by changing view or layer properties) or directly by calling one of theinvalidate
methods. This method may return before the repaint is complete.- See Also:
-
repaint
void repaint(int aX, int aY, int aWidth, int aHeight) Repaints the view within the given AWT rectangle. The view is allowed to reuse earlier painted results as long as they are valid. Invalidation of the contents may occur indirectly (e.g. by changing view or layer properties) or directly by calling one of theinvalidate
methods. This method may return before the repaint is complete.- Parameters:
aX
- the x-coordinate of the rectangle's top-left pointaY
- the y-coordinate of the rectangle's top-left pointaWidth
- the width of the rectangleaHeight
- the height of the rectangle- Since:
- 3.1
- See Also:
-
invalidate
Asks the view to invalidate its content, optionally repainting the content asynchronously. A subsequent repaint will ask (at the least) all layers to draw their bodies, labels and selection. This method is typically called when the entire view needs to be redrawn, for example, after a zoom operation or projection change.- Specified by:
invalidate
in interfaceILcdView
- Parameters:
aRepaint
- iftrue
, the view is updated immediately, but the method will not wait for the update to finish. If false, the view is updated on the next paint or repaint method call.aSource
- class instance calling the method. For tracing purposes.aMessage
- a message associated to this method call. For tracing purposes.- See Also:
-
invalidateAndWait
Asks the view to invalidate its content, optionally repainting the content synchronously. A subsequent repaint will ask (at the least) all layers to draw their bodies, labels and selection. This method is typically called when the entire view needs to be redrawn, for example, after a zoom operation or projection change.- Parameters:
aRepaint
- iftrue
the ILcdGXYView will be updated immediately, and the method will block until the update is complete. If false, the view is updated on the next paint or repaint method call.aSource
- class instance calling the method. For tracing purposes.aMessage
- a message associated to this method call. For tracing purposes.- See Also:
-
invalidateGXYLayer
Asks the view to invalidate the content of the givenILcdGXYLayer
, optionally repainting the content asynchronously. A subsequent repaint will (at the least) ask the given layer to draw its bodies, labels and selection, and may reuse earlier generated imagery for the other layers. This method is typically called when a single layer needs to be redrawn, for example, when its painter settings change.- Parameters:
aGXYLayer
- the layer to invalidateaRepaint
- iftrue
, the view is updated immediately, but the method will not wait for the update to finish. If false, the view is updated on the next paint or repaint method call.aSource
- class instance calling the method. For tracing purposes.aMessage
- a message associated to this method call. For tracing purposes.
-
invalidateGXYLayerAndWait
void invalidateGXYLayerAndWait(ILcdGXYLayer aGXYLayer, boolean aRepaint, Object aSource, String aMessage) Asks the view to invalidate the content of the givenILcdGXYLayer
, optionally repainting the content synchronously. A subsequent repaint will (at the least) ask the given layer to draw its bodies, labels and selection, and may reuse earlier generated imagery for the other layers. This method is typically called when a single layer needs to be redrawn, for example, when its painter settings change.- Parameters:
aGXYLayer
- the layer to invalidateaRepaint
- iftrue
the ILcdGXYView will be updated immediately, and the method will block until the update is complete. If false, the view is updated on the next paint or repaint method call.aSource
- class instance calling the method. For tracing purposes.aMessage
- a message associated to this method call. For tracing purposes.- See Also:
-
invalidateRegion
Asks the view to invalidate the content in the given AWT clip, optionally repainting the content asynchronously. A subsequent repaint will ask (at the least) all layers to draw their bodies, labels and selection in the given clip, and may reuse earlier generated imagery for the rest of the view. This method is typically called when a small portion of the view needs to be redrawn, for example, when the objects in that area have changed.- Parameters:
aClip
- the clip to invalidateaRepaint
- iftrue
, the view is updated immediately, but the method will not wait for the update to finish. If false, the view is updated on the next paint or repaint method call.aSource
- class instance calling the method. For tracing purposes.aMessage
- a message associated to this method call. For tracing purposes.- See Also:
-
invalidateRegionAndWait
Asks the view to invalidate the content in the given AWT clip, optionally repainting the content synchronously. A subsequent repaint will ask (at the least) all layers to draw their bodies, labels and selection in the given clip, and may reuse earlier generated imagery for the rest of the view. This method is typically called when a small portion of the view needs to be redrawn, for example, when the objects in that area have changed.- Parameters:
aClip
- the clip to invalidateaRepaint
- iftrue
the ILcdGXYView will be updated immediately, and the method will block until the update is complete. If false, the view is updated on the next paint or repaint method call.aSource
- class instance calling the method. For tracing purposes.aMessage
- a message associated to this method call. For tracing purposes.- See Also:
-
invalidateRegionSelection
Asks the ILcdGXYView to invalidate its selection in the given AWT clip, optionally repainting the content asynchronously. A subsequent repaint will ask (at the least) all layers to draw their selection in the given clip, and may reuse earlier generated imagery for the bodies, labels, and rest of the view. This method is typically called when the selection of a small portion of the view needs to be redrawn, for example, when changing the selection in that area.- Parameters:
aClip
- the clip to invalidateaRepaint
- iftrue
, the view is updated immediately, but the method will not wait for the update to finish. If false, the view is updated on the next paint or repaint method call.aSource
- class instance calling the method. For tracing purposes.aMessage
- a message associated to this method call. For tracing purposes.- See Also:
-
invalidateRegionSelectionAndWait
void invalidateRegionSelectionAndWait(Rectangle aClip, boolean aRepaint, Object aSource, String aMessage) Asks the ILcdGXYView to invalidate its selection in the given AWT clip, optionally repainting the content synchronously. A subsequent repaint will ask (at the least) all layers to draw their selection in the given clip, and may reuse earlier generated imagery for the bodies, labels, and rest of the view. This method is typically called when the selection of a small portion of the view needs to be redrawn, for example, when changing the selection in that area.- Parameters:
aClip
- the clip to invalidateaRepaint
- iftrue
the ILcdGXYView will be updated immediately, and the method will block until the update is complete. If false, the view is updated on the next paint or repaint method call.aSource
- class instance calling the method. For tracing purposes.aMessage
- a message associated to this method call. For tracing purposes.- See Also:
-
invalidateSelection
Asks the ILcdGXYView to invalidate its selection, optionally repainting the content asynchronously. A subsequent repaint will ask (at the least) all layers to draw their selection, and may reuse earlier generated imagery for the bodies and labels. This method is typically called when the selection needs to be redrawn, for example, when changing the selection.- Parameters:
aRepaint
- iftrue
, the view is updated immediately, but the method will not wait for the update to finish. If false, the view is updated on the next paint or repaint method call.aSource
- class instance calling the method. For tracing purposes.aMessage
- a message associated to this method call. For tracing purposes.- See Also:
-
invalidateSelectionAndWait
Asks the ILcdGXYView to invalidate its selection, optionally repainting the content synchronously. A subsequent repaint will ask (at the least) all layers to draw their selection, and may reuse earlier generated imagery for the bodies and labels. This method is typically called when the selection needs to be redrawn, for example, when changing the selection.- Parameters:
aRepaint
- iftrue
the ILcdGXYView will be updated immediately, and the method will block until the update is complete. If false, the view is updated on the next paint or repaint method call.aSource
- class instance calling the method. For tracing purposes.aMessage
- a message associated to this method call. For tracing purposes.- See Also:
-
setDrawOffScreenImageOnPaint
void setDrawOffScreenImageOnPaint(boolean aDrawOffScreenImageOnPaint) Sets whether the entire view's content is displayed, or only the current controller's representation. The controller can use this method to temporarily override the view's contents. The effect is visible upon the next repaint.- Parameters:
aDrawOffScreenImageOnPaint
-true
to make the view paint itself when one of the paint methods is called. False if only the current controller is painted.- See Also:
-
isDrawOffScreenImageOnPaint
boolean isDrawOffScreenImageOnPaint()Returns whether the entire view's content is displayed, or only the controller's representation.- Returns:
true
if the view paints itself when one of the paint methods is called. False if only the current controller is painted.- See Also:
-
getGXYViewLabelPainter
ILcdGXYViewLabelPainter getGXYViewLabelPainter()Deprecated.ILcdGXYViewLabelPlacer offers more powerful and flexible decluttering functionalityReturns the label painting algorithm for this view. A view label painter handles the labels of all the view's layers. Hence, the layers are not asked to paint their labels if the view label painter is not null. The view label painter can be used for decluttering labels across all layers. To do this, it can select the objects that need a label and delegate the actual painting to the relevant layer'sILcdGXYLabelPainter
.- Returns:
- the painter handling this view's labels, or null
- See Also:
-
getGXYViewLabelPlacer
Returns the label placer for this view. A view label placer handles the labels of all the view's layers. The layers are only responsible for painting their labels while the label placer declutters the labels.- Returns:
- the label placer handling this view's labels, or
null
. - Since:
- 2020.0
- See Also:
-
setGXYViewLabelPlacer
This method sets anILcdGXYViewLabelPlacer
to use for global labeling.This will override any configured view label painter.
- Parameters:
aLabelPlacer
- a view label placer.- Since:
- 2020.0
- See Also:
-
isPaintInBackground
boolean isPaintInBackground()Deprecated.This method has been deprecated in favor of the approach provided by theILcdGXYAsynchronousLayerWrapper
interface and its implementations, which is more versatile and which generally offers better thread safety.Returns whether the view is painted in a thread other than the event dispatch thread.- Returns:
true
if background painting is enabled;false
otherwise
-
setPaintInBackground
void setPaintInBackground(boolean aPaintInBackground) Deprecated.This method has been deprecated in favor of the approach provided by theILcdGXYAsynchronousLayerWrapper
interface and its implementations, which is more versatile and which generally offers better thread safety.Enables or disables painting in a thread other than the event dispatch thread. If background painting is not supported by an implementation, this method throws a runtime exception.- Parameters:
aPaintInBackground
-true
to enable painting in the background;false
to disable it
-
getPaintExceptionHandler
ILcdPaintExceptionHandler getPaintExceptionHandler()Returns a handler to report paint exceptions. The view, as well as layers and painters can use this handler if they encounter an exception during painting. Because painting may happen asynchronously, the handler may be called from different threads.- Returns:
- a handler to report paint exceptions.
-
setPaintExceptionHandler
Sets a handler to report paint exceptions. Layers and/or painters can use this handler if they encounter a problem during painting. Because painting may happen asynchronously, the handler may be called from different threads.- Parameters:
aPaintExceptionHandler
- a handler to report paint exceptions. This handler should never be null.- Since:
- 2020.0
-
isAsynchronousAllowed
boolean isAsynchronousAllowed()Returns whether this view allows asynchronous operations. Painters, layers or other parts of a view should not perform asynchronous operations when this method returns
false
. If this method returnstrue
, they can decide either way.When asynchronous operations are allowed, intermediate results of time-consuming asynchronous operations are displayed in order to provide an interactive user experience. For non-interactive applications, it is useful to disable asynchronous operations, since they can lead to more unpredictable results. Examples are tests, or server side functionality like the OGC WMS protocol which paints the view and returns it as an image. In these cases, you want the view to be painted completely without having to deal with intermediate results.
- Returns:
- whether this view allows asynchronous operations.
- Since:
- 2017.0
-
isAntiAliased
boolean isAntiAliased()Specifies if anti-aliasing is enabled or not. Anti-aliasing makes lines and text appear smoother, but slows down rendering a little bit. If this property isfalse
, it does not mean anti-aliasing is fully disabled. It only means anti-aliasing is not enabled on the view level, various layers and painters may still decide to enable anti-aliasing for what they render.- Returns:
true
if anti-aliasing is enabled,false
otherwise.- Since:
- 2017.0
-
addStatusListener
Registers the givenILcdStatusListener
to be notified of view status events. The amount, type and order of the status events is subject to change.- Specified by:
addStatusListener
in interfaceILcdStatusSource
- Parameters:
aStatusListener
- the listener that will be informed of status events- See Also:
-
removeStatusListener
Unregisters the givenILcdStatusListener
from being notified of view status events.- Specified by:
removeStatusListener
in interfaceILcdStatusSource
- Parameters:
aStatusListener
- the listener that will no longer be informed of status events- See Also:
-
addViewInvalidationListener
Registers anILcdViewInvalidationListener
to be informed when the view's contents are invalid. This can happen directly (e.g. by callinginvalidateGXYLayer(com.luciad.view.gxy.ILcdGXYLayer, boolean, java.lang.Object, java.lang.String)
) or indirectly (e.g. by callingpan(int, int, boolean)
)- Parameters:
aInvalidationListener
- the listener to notify when the view has been invalidated- Since:
- 2020.0
- See Also:
-
removeViewInvalidationListener
Unregisters anILcdViewInvalidationListener
so that it is no longer informed of invalidation events for this view.- Parameters:
aInvalidationListener
- the listener to no longer notify when the view has been invalidated- Since:
- 2020.0
- See Also:
-