Class TLcdShadedMultilevelRasterPainter
- All Implemented Interfaces:
ILcdRasterPainter,ILcdCloneable,ILcdPropertyChangeSource,ILcdGXYPainter,ILcdGXYPainterProvider,Serializable,Cloneable
- Since:
- 10.1.33
- See Also:
-
Field Summary
Fields inherited from interface com.luciad.view.gxy.ILcdGXYPainter
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING -
Constructor Summary
ConstructorsConstructorDescriptionTLcdShadedMultilevelRasterPainter(ILcdRasterPainter aRasterPainter, ILcdBuffer aBuffer) Creates a shaded multi-level raster painter with a buffer for caching the shaded rasters and a painter for painting them.Creates a shaded multi-level raster painter with a buffer for caching the shaded rasters. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPropertyChangeListener(PropertyChangeListener aPropertyChangeListener) Registers the givenPropertyChangeListenerto be notified when this object's properties change.voidanchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) 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.voidboundsSFCT(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.floatgetCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Returns a cursor that clarifies the mode and context the painter is operating in.Returns a textual representation of this painter.doubleReturns the elevation exaggeration.getGXYPainter(Object aObject) Finds anILcdGXYPainterthat can be used to paint or locate the object passed.intintReturns the Object for which the representation is currently being handled by this painter.doubledoubleReturns the direction of the sun.floatbooleanbooleanbooleanisTouched(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.voidremovePropertyChangeListener(PropertyChangeListener aPropertyChangeListener) De-registers the givenPropertyChangeListenerfrom receiving property change events for this object.voidsetBrightness(float aBrightness) Sets the brightness that is applied to painted rasters.voidsetColorModel(ColorModel aColorModel) Sets the color model for the shaded raster.voidsetElevationExaggeration(double aElevationExaggeration) Sets the elevation exaggeration.voidsetForcePainting(boolean aForcePainting) Specifies whether the visible portion of the raster should always be painted, irrespective of the startResolutionFactor and stopResolutionFactor.voidsetMaxNoOfOutlineTiles(int aMaxNumberOfOutlineTiles) voidsetMaxNumberOfOutlineTiles(int aMaxNumberOfOutlineTiles) Sets the maximum number of outlines of individual tiles to paint when the pixel density (number of raster pixels per screen pixel) of the raster to be painted is higher than the startResolutionFactor.voidSets the Object for which the representation shall be handled by this painter.voidsetOutlineColor(Color aColor) Sets the line color used to paint the raster outlines and tile outlines when the pixel density (number of raster pixels per screen pixel) of the raster to be painted is higher than the startResolutionFactor.voidsetPaintOutline(boolean aPaintOutline) Specifies whether the raster outlines and tile outlines should be painted when the pixel density (number of raster pixels per screen pixel) of the raster to be painted is higher than the startResolutionFactor.voidsetStartResolutionFactor(double aFactor) Sets the highest pixel density (number of raster pixels per screen pixel) at which a raster is painted.voidsetStopResolutionFactor(double aFactor) Sets the lowest pixel density (number of raster pixels per screen pixel) at which a raster is painted.voidsetSunPosition(ILcdPoint aPoint) Sets the direction of the sun.voidsetTransparency(float aTransparency) Sets the transparency factor that is applied to painted rasters.snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns an object that can be used as snapping target when graphically editing an object.booleansupportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns whether the painter can provide a snap target based on the representation of the object in the given context.
-
Constructor Details
-
TLcdShadedMultilevelRasterPainter
Creates a shaded multi-level raster painter with a buffer for caching the shaded rasters. -
TLcdShadedMultilevelRasterPainter
Creates a shaded multi-level raster painter with a buffer for caching the shaded rasters and a painter for painting them.
-
-
Method Details
-
setElevationExaggeration
public void setElevationExaggeration(double aElevationExaggeration) Sets the elevation exaggeration. The default is 10. -
getElevationExaggeration
public double getElevationExaggeration()Returns the elevation exaggeration. -
setSunPosition
Sets the direction of the sun. The x and y coordinates are in the raster tile coordinate system. The z coordinate is up. The default is (-1, -1, 3). -
getSunPosition
Returns the direction of the sun. -
setStartResolutionFactor
public void setStartResolutionFactor(double aFactor) Description copied from interface:ILcdRasterPainterSets the highest pixel density (number of raster pixels per screen pixel) at which a raster is painted. If the pixel density is too high, only the raster outlines and tile outlines are painted (or a lower resolution level is chosen). This can avoid having to load a large raster to fill a relatively small view.- Specified by:
setStartResolutionFactorin interfaceILcdRasterPainter
-
getStartResolutionFactor
public double getStartResolutionFactor()- Specified by:
getStartResolutionFactorin interfaceILcdRasterPainter- See Also:
-
setStopResolutionFactor
public void setStopResolutionFactor(double aFactor) Description copied from interface:ILcdRasterPainterSets the lowest pixel density (number of raster pixels per screen pixel) at which a raster is painted. If the pixel density is too low, nothing is painted. This can avoid painting overly pixelated rasters.- Specified by:
setStopResolutionFactorin interfaceILcdRasterPainter
-
getStopResolutionFactor
public double getStopResolutionFactor()- Specified by:
getStopResolutionFactorin interfaceILcdRasterPainter- See Also:
-
setForcePainting
public void setForcePainting(boolean aForcePainting) Description copied from interface:ILcdRasterPainterSpecifies whether the visible portion of the raster should always be painted, irrespective of the startResolutionFactor and stopResolutionFactor.- Specified by:
setForcePaintingin interfaceILcdRasterPainter- See Also:
-
isForcePainting
public boolean isForcePainting()- Specified by:
isForcePaintingin interfaceILcdRasterPainter- See Also:
-
setPaintOutline
public void setPaintOutline(boolean aPaintOutline) Description copied from interface:ILcdRasterPainterSpecifies whether the raster outlines and tile outlines should be painted when the pixel density (number of raster pixels per screen pixel) of the raster to be painted is higher than the startResolutionFactor.- Specified by:
setPaintOutlinein interfaceILcdRasterPainter- See Also:
-
isPaintOutline
public boolean isPaintOutline()- Specified by:
isPaintOutlinein interfaceILcdRasterPainter- See Also:
-
setOutlineColor
Description copied from interface:ILcdRasterPainterSets the line color used to paint the raster outlines and tile outlines when the pixel density (number of raster pixels per screen pixel) of the raster to be painted is higher than the startResolutionFactor.- Specified by:
setOutlineColorin interfaceILcdRasterPainter- See Also:
-
getOutlineColor
- Specified by:
getOutlineColorin interfaceILcdRasterPainter- See Also:
-
setMaxNumberOfOutlineTiles
public void setMaxNumberOfOutlineTiles(int aMaxNumberOfOutlineTiles) Description copied from interface:ILcdRasterPainterSets the maximum number of outlines of individual tiles to paint when the pixel density (number of raster pixels per screen pixel) of the raster to be painted is higher than the startResolutionFactor. If the number of tiles is larger than this maximum, only the global outline of the raster is painted.- Specified by:
setMaxNumberOfOutlineTilesin interfaceILcdRasterPainter- See Also:
-
getMaxNumberOfOutlineTiles
public int getMaxNumberOfOutlineTiles()- Specified by:
getMaxNumberOfOutlineTilesin interfaceILcdRasterPainter- See Also:
-
setMaxNoOfOutlineTiles
public void setMaxNoOfOutlineTiles(int aMaxNumberOfOutlineTiles) - Specified by:
setMaxNoOfOutlineTilesin interfaceILcdRasterPainter
-
getMaxNoOfOutlineTiles
public int getMaxNoOfOutlineTiles()- Specified by:
getMaxNoOfOutlineTilesin interfaceILcdRasterPainter
-
setColorModel
Sets the color model for the shaded raster. This should be an IndexColorModel with 256 indexed colors ranging from 0 for completely shaded to 254 for fully lit. Color 255 is used for unknown elevation values.- Specified by:
setColorModelin interfaceILcdRasterPainter
-
getColorModel
- Specified by:
getColorModelin interfaceILcdRasterPainter- See Also:
-
setBrightness
public void setBrightness(float aBrightness) Description copied from interface:ILcdRasterPainterSets the brightness that is applied to painted rasters. It is a value in[0, 2]. A value of 1 (the default) leaves the brightness unchanged. Values larger than 1 makes the colors brighter, while a value smaller than 1 makes the colors less bright.- Specified by:
setBrightnessin interfaceILcdRasterPainter- See Also:
-
getBrightness
public float getBrightness()- Specified by:
getBrightnessin interfaceILcdRasterPainter- See Also:
-
setTransparency
public void setTransparency(float aTransparency) Description copied from interface:ILcdRasterPainterSets the transparency factor that is applied to painted rasters. It is an alpha value between 0 and 1, with 0 being perfectly transparent, and 1 (the default) being perfectly opaque.- Specified by:
setTransparencyin interfaceILcdRasterPainter
-
getTransparency
public float getTransparency()- Specified by:
getTransparencyin interfaceILcdRasterPainter- See Also:
-
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.
-
boundsSFCT
public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException 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.- Throws:
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.- See Also:
-
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:
-
anchorPointSFCT
public void anchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException Description copied from interface:ILcdGXYPainterMoves 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.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
ILcdShapeobjects is the location of the focus point of the shape.- Specified by:
anchorPointSFCTin interfaceILcdGXYPainter- Parameters:
aGraphics- the Graphics on which the representation of the object is paintedaMode- the mode the object is painted in (see class documentation)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.aPointSFCT- 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.- Throws:
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.- See Also:
-
supportSnap
Description copied from interface:ILcdGXYPainterReturns whether the painter can provide a snap target based on the representation of the object in the given context.- Specified by:
supportSnapin interfaceILcdGXYPainter- Parameters:
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.- Returns:
- true if an object can be returned that can be used to snap to in the given context, false otherwise.
-
snapTarget
Description copied from interface:ILcdGXYPainterReturns an object that can be used as snapping target when graphically editing an object. For example, an object which is beneath the current mouse position (as given in the context).This method must only be called when
supportSnapreturns true for the given context.- Specified by:
snapTargetin interfaceILcdGXYPainter- Parameters:
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.- Returns:
- an object that can be used as snapping target when graphically editing an object. It must be defined in the same model reference as the object set to this painter.
- See Also:
-
getCursor
Description copied from interface:ILcdGXYPainterReturns a cursor that clarifies the mode and context the painter is operating in. For example, when the mode isTRANSLATING, the cursor could be the MOVE cursor. When no specific cursor is required implementations must return null.- Specified by:
getCursorin interfaceILcdGXYPainter- Parameters:
aGraphics- the Graphics on which the representation of the object is paintedaMode- the rendering mode to return the cursor for.aGXYContext- the context in which the rendering occurs.- Returns:
- a
Cursorto indicate the type of operatingaModeandaGXYContext. Returnsnullif no particularCursoris required.
-
getDisplayName
Description copied from interface:ILcdGXYPainterReturns a textual representation of this painter. This can be useful when different representations of an object are handled by different painter implementations. Having a textual representation can facilitate choosing between different painter implementations.- Specified by:
getDisplayNamein interfaceILcdGXYPainter- Returns:
- a textual representation of this painter.
-
addPropertyChangeListener
Description copied from interface:ILcdPropertyChangeSourceRegisters the given
PropertyChangeListenerto 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
ALcdWeakPropertyChangeListenerinstance as property change listener.- Specified by:
addPropertyChangeListenerin interfaceILcdPropertyChangeSource- Parameters:
aPropertyChangeListener- The listener to be notified- See Also:
-
removePropertyChangeListener
Description copied from interface:ILcdPropertyChangeSourceDe-registers the given
PropertyChangeListenerfrom 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.- Specified by:
removePropertyChangeListenerin interfaceILcdPropertyChangeSource- Parameters:
aPropertyChangeListener- the listener that should no longer be notified of changes of this object's properties- See Also:
-
getGXYPainter
Description copied from interface:ILcdGXYPainterProviderFinds anILcdGXYPainterthat can be used to paint or locate the object passed.The painter provider is responsible for setting the object to the painter before returning the painter. An implementation should therefore have the following structure:
public ILcdGXYPainter getGXYPainter(Object aObject) { ILcdGXYPainter painter = ... // find the painter for the object if (painter != null) { painter.setObject(aObject); } return painter; }- Specified by:
getGXYPainterin interfaceILcdGXYPainterProvider- Parameters:
aObject- the object to find a painter for- Returns:
- a painter that can be used to paint or locate the object; or null if no painter could be found for the given object, or the object could not be set on the retrieved painter.
-
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 classObject- Returns:
- a clone of this painter provider.
- See Also:
-