Class ALcdRasterPainter

java.lang.Object
com.luciad.view.gxy.ALcdGXYPainter
com.luciad.format.raster.ALcdRasterPainter
All Implemented Interfaces:
ILcdRasterPainter, ILcdCloneable, ILcdPropertyChangeSource, ILcdGXYPainter, ILcdGXYPainterProvider, Serializable, Cloneable
Direct Known Subclasses:
TLcdAllInMemoryRasterPainter, TLcdMultilevelRasterPainter, TLcdNoWarpMultilevelRasterPainter, TLcdNoWarpRasterPainter, TLcdRasterPainter, TLcdWarpMultilevelRasterPainter, TLcdWarpRasterPainter

public abstract class ALcdRasterPainter extends ALcdGXYPainter implements ILcdRasterPainter
This abstract class provides a basis for implementing the ILcdRasterPainter interface.
See Also:
  • Field Details

    • DENSITY_TOO_HIGH

      protected static final int DENSITY_TOO_HIGH
      See Also:
    • DENSITY_OK

      protected static final int DENSITY_OK
      See Also:
    • DENSITY_TOO_LOW

      protected static final int DENSITY_TOO_LOW
      See Also:
    • fStartResolutionFactor

      protected double fStartResolutionFactor
    • fStopResolutionFactor

      protected double fStopResolutionFactor
    • fForcePainting

      protected boolean fForcePainting
    • fMaxNumberOfOutlineTiles

      protected int fMaxNumberOfOutlineTiles
    • fPaintOutline

      protected boolean fPaintOutline
    • fFillOutlineArea

      protected boolean fFillOutlineArea
    • fColorModel

      protected ColorModel fColorModel
    • fRGBImageFilter

      protected RGBImageFilter fRGBImageFilter
    • fTransparency

      protected float fTransparency
    • fBrightness

      protected float fBrightness
    • fContrast

      protected float fContrast
  • Constructor Details

    • ALcdRasterPainter

      public ALcdRasterPainter()
  • Method Details

    • setSnapIcon

      public void setSnapIcon(ILcdIcon aSnapIcon)
      Sets the icon that marks snap targets of the object currently set to this painter. This icon is painted when the paint method is called with the render mode ILcdGXYPainter.SNAPS.
      Parameters:
      aSnapIcon - The icon that should be used to paint snap target points.
      See Also:
    • getSnapIcon

      public ILcdIcon getSnapIcon()
      Returns the icon that is used to paint snap target points of the object set to this painter.
      Returns:
      the icon that is used to paint snap target points of the object set to this painter.
      See Also:
    • paint

      public void paint(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
      Description copied from interface: ILcdGXYPainter
      Displays 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 of ILcdGXYPainter and ILcdGXYEditor interfaces must be consistent for an object: the painter must display the result of the user interaction on the object, while the editor is responsible for modifying the object as a result of the user interaction. A good practice to ensure a consistent implementation is to implement both the ILcdGXYPainter and ILcdGXYEditor interfaces in a single class.

      When the mode passed includes SNAPS, the part of the representation which corresponds to the object returned as snap target by the method snapTarget must be painted in order to provide the user with a visual indication of the snap target.

      The Graphics passed in this method can be different from the Graphics returned by a view due to techniques such as double buffering (as applied in Swing). Basic drawing operations must always be performed on the Graphics passed as an argument in this method.

      Specified by:
      paint in interface ILcdGXYPainter
      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aRenderMode - the mode the object is represented in (see class documentation).
      aGXYContext - the ILcdGXYContext the drawing depends on.
    • isTouched

      public boolean isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Description copied from interface: ILcdGXYPainter
      Checks 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() and ILcdGXYContext.getY(). If the check is part of an ongoing operation of user interaction, for example, when the mouse is being dragged, the location of the start of the operation can also be taken into account using the methods ILcdGXYContext.getDeltaX() and ILcdGXYContext.getDeltaY(). The context contains the transformations required to convert this location into the equivalent location in model space. Implementations of this interface usually follow either of the following patterns:

      • 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 boundsSFCT is often used to speed up the performance of this method as a location outside these bounds can never touch the representation of the object.

      Note that this method does not give an indication of what part of the object is touched. It is up to the painter implementations to provide methods to make this distinction. The method does also not indicate what sensitivity must be applied when checking if an object is touched. It is up to the implementation to decide what should be the maximum distance between the location given in the context and the closest relevant point or area of the representation of the object.

      Specified by:
      isTouched in interface ILcdGXYPainter
      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - the mode the object is represented in
      aGXYContext - 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:
    • supportSnap

      public boolean supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
      Description copied from class: ALcdGXYPainter
      Override this method to support snapping. This implementation does not support snapping.
      Specified by:
      supportSnap in interface ILcdGXYPainter
      Overrides:
      supportSnap in class ALcdGXYPainter
      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aGXYContext - the context in which this object is represented and in which the editing of an object occurs.
      Returns:
      false.
    • snapTarget

      public Object snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)

      Returns one of the bounds points of the ILcdRaster object if it is touched. If no point was touched, null will be returned.

      Specified by:
      snapTarget in interface ILcdGXYPainter
      Overrides:
      snapTarget in class ALcdGXYPainter
      Parameters:
      aGraphics - the graphics on which is worked.
      aGXYContext - the context of the snapping.
      Returns:
      one of the bounds points of the ILcdRaster object if it is touched, null otherwise.
      See Also:
    • setStartResolutionFactor

      public void setStartResolutionFactor(double aFactor)
      Description copied from interface: ILcdRasterPainter
      Sets 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:
      setStartResolutionFactor in interface ILcdRasterPainter
    • getStartResolutionFactor

      public double getStartResolutionFactor()
      Specified by:
      getStartResolutionFactor in interface ILcdRasterPainter
      See Also:
    • setStopResolutionFactor

      public void setStopResolutionFactor(double aFactor)
      Description copied from interface: ILcdRasterPainter
      Sets 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:
      setStopResolutionFactor in interface ILcdRasterPainter
    • getStopResolutionFactor

      public double getStopResolutionFactor()
      Specified by:
      getStopResolutionFactor in interface ILcdRasterPainter
      See Also:
    • getStartScale

      public double getStartScale()
      Returns the start scale.
      Returns:
      the start scale currently used to determine whether or not rasters or outlines should be painted at a certain view scale.
      See Also:
    • setStartScale

      public void setStartScale(double aStartScale)
      As an alternative for the start resolution factor and stop resolution factor, this method and getStopScale() can be used for more intuitive control on when to paint a raster and when to paint the outline. When the internal scale of the view (ILcdGXYView.getScale() is smaller than the start scale, the outline will be painted in stead of the raster. The default value is 0. Warning: when the view scale is in between the start and stop scale, the start resolution factor and the stop resolution factor are still used as a second check. If you don't want interference from these two settings, set the start resolution factor to Double.POSITIVE_INFINITY and the stop resolution factor to 0.
      Parameters:
      aStartScale - The view scale at which one starts painting the raster rather that the outline (when zooming in).
      See Also:
    • getStopScale

      public double getStopScale()
      Returns the stop scale.
      Returns:
      the stop scale currently used to determine whether or not rasters should be painted at a certain view scale.
      See Also:
    • setStopScale

      public void setStopScale(double aStopScale)
      As an alternative for the start resolution factor and stop resolution factor, this method and getStartScale() can be used for more intuitive control on when to paint a raster. When the internal scale of the view (ILcdGXYView.getScale() is larger than the stop scale, the raster won't be painted. The default value is Double.POSITIVE_INFINITY.
      Parameters:
      aStopScale - The view scale at which one stops painting the raster (when zooming in).
      See Also:
    • setForcePainting

      public void setForcePainting(boolean aForcePainting)
      Description copied from interface: ILcdRasterPainter
      Specifies whether the visible portion of the raster should always be painted, irrespective of the startResolutionFactor and stopResolutionFactor.
      Specified by:
      setForcePainting in interface ILcdRasterPainter
      See Also:
    • isForcePainting

      public boolean isForcePainting()
      Specified by:
      isForcePainting in interface ILcdRasterPainter
      See Also:
    • setPaintOutline

      public void setPaintOutline(boolean aPaintOutline)
      Description copied from interface: ILcdRasterPainter
      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.
      Specified by:
      setPaintOutline in interface ILcdRasterPainter
      See Also:
    • isPaintOutline

      public boolean isPaintOutline()
      Specified by:
      isPaintOutline in interface ILcdRasterPainter
      See Also:
    • setOutlineStyle

      public void setOutlineStyle(ILcdGXYPainterStyle aOutlineStyle)
      Sets the style that is used when drawing the outline of the area of raster and/or tiles. If set to a non-null value the configure style will take precedence over the configured outline color if the style modifies the Graphics current color.
      Parameters:
      aOutlineStyle - the outline style to use
      See Also:
    • getOutlineStyle

      public ILcdGXYPainterStyle getOutlineStyle()
      Returns the style that is used to draw the outline of the area of raster and/or tiles.
      Returns:
      a painter style or null
    • setOutlineColor

      public void setOutlineColor(Color aColor)
      Description copied from interface: ILcdRasterPainter
      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.
      Specified by:
      setOutlineColor in interface ILcdRasterPainter
      See Also:
    • getOutlineColor

      public Color getOutlineColor()
      Specified by:
      getOutlineColor in interface ILcdRasterPainter
      See Also:
    • isFillOutlineArea

      public boolean isFillOutlineArea()
      See Also:
    • setFillOutlineArea

      public void setFillOutlineArea(boolean aFillOutlineArea)
      Specifies whether the raster outlines and tile outlines should be filled when the pixel density (number of raster pixels per screen pixel) of the raster to be painted is higher than the startResolutionFactor.
      See Also:
    • getOutlineAreaFillStyle

      public ILcdGXYPainterStyle getOutlineAreaFillStyle()
      See Also:
    • setOutlineAreaFillStyle

      public void setOutlineAreaFillStyle(ILcdGXYPainterStyle aFillStyle)
      Sets the style that is used when filling the outline area of raster and/or tiles. If the fill style is set to null and fill outline area is enabled the result visual result on screen is undefined.
      Parameters:
      aFillStyle - the fill style to use
      See Also:
    • setMaxNumberOfOutlineTiles

      public void setMaxNumberOfOutlineTiles(int aMaxNumberOfOutlineTiles)
      Description copied from interface: ILcdRasterPainter
      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. If the number of tiles is larger than this maximum, only the global outline of the raster is painted.
      Specified by:
      setMaxNumberOfOutlineTiles in interface ILcdRasterPainter
      See Also:
    • getMaxNumberOfOutlineTiles

      public int getMaxNumberOfOutlineTiles()
      Specified by:
      getMaxNumberOfOutlineTiles in interface ILcdRasterPainter
      See Also:
    • setMaxNoOfOutlineTiles

      public void setMaxNoOfOutlineTiles(int aMaxNumberOfOutlineTiles)
      Specified by:
      setMaxNoOfOutlineTiles in interface ILcdRasterPainter
    • getMaxNoOfOutlineTiles

      public int getMaxNoOfOutlineTiles()
      Specified by:
      getMaxNoOfOutlineTiles in interface ILcdRasterPainter
    • setColorModel

      public void setColorModel(ColorModel aColorModel)
      Description copied from interface: ILcdRasterPainter
      Sets the ColorModel that determines how a raster pixel is transformed into color components for a screen pixel. If it is not set, the raster itself determines the ColorModel. If that is not set either, the contained raster tiles determine the ColorModel.
      Specified by:
      setColorModel in interface ILcdRasterPainter
    • getColorModel

      public ColorModel getColorModel()
      Specified by:
      getColorModel in interface ILcdRasterPainter
      See Also:
    • setRGBImageFilter

      public void setRGBImageFilter(RGBImageFilter aRGBImageFilter)
      Sets the optional filter that is applied to painted rasters. The filter should be spatially invariant. Any brightness and transparency settings are applied on top of it.
    • getRGBImageFilter

      public RGBImageFilter getRGBImageFilter()
      Returns the optional filter that is applied to painted rasters.
    • setTransparency

      public void setTransparency(float aTransparency)
      Description copied from interface: ILcdRasterPainter
      Sets 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:
      setTransparency in interface ILcdRasterPainter
    • getTransparency

      public float getTransparency()
      Specified by:
      getTransparency in interface ILcdRasterPainter
      See Also:
    • setBrightness

      public void setBrightness(float aBrightness)
      Description copied from interface: ILcdRasterPainter
      Sets 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:
      setBrightness in interface ILcdRasterPainter
      See Also:
    • getBrightness

      public float getBrightness()
      Specified by:
      getBrightness in interface ILcdRasterPainter
      See Also:
    • setContrast

      public void setContrast(float aContrast)
      Sets the contrast that is applied to painted rasters. It is a value in [0, 2]. A value of 1 (the default) leaves the contrast unchanged. A value larger than 1 enhances the contrast of dark colors by making them brighter, while a value smaller than 1 enhances the contrast of bright colors by making them darker.
    • getContrast

      public float getContrast()
    • densityCheck

      public int densityCheck(ILcdRaster aRaster, ILcdGXYContext aGXYContext)
      Determines if the raster density of the given raster is suitable for processing or analysis in the given context, considering the start resolution factor and the stop resolution factor, and the forced painting flag.

      The raster density may be considered too high, meaning that too many raster pixels are mapped onto a single view pixel. This would typically make lazy loading the raster data disproportionally slow.

      Conversely, the raster density may be considered too low, meaning that a single raster pixel is mapped onto too many view pixels. This would typically make the raster data insufficiently accurate to work with.

      Parameters:
      aRaster - the raster to be processed or analyzed.
      aGXYContext - the context that contains the model of the raster, the model-to-world transformation, and the view-to-world transformation.
      Returns:
      DENSITY_TOO_HIGH, DENSITY_OK, or DENSITY_TOO_LOW.
      See Also:
    • densityCheck

      public int densityCheck(ILcdRaster aRaster, ILcdGXYContext aGXYContext, Graphics aGraphics)
      Determines if the pixel density of the given raster is suitable for display, in the given context, considering the start resolution factor and the stop resolution factor, and the forced painting flag.

      The raster's pixel density may be considered too high, meaning that too many raster pixels are mapped onto a single view pixel. This would typically make lazy loading the raster data disproportionally slow.

      Conversely, the raster's pixel density may be considered too low, meaning that a single raster pixel is mapped onto too many view pixels. This would typically make the raster data insufficiently accurate to display.

      Parameters:
      aRaster - the raster to be displayed.
      aGXYContext - the context that contains the model of the raster, the model-to-world transformation, and the view-to-world transformation.
      aGraphics - the Graphics instance on which the raster is to be painted.
      Returns:
      DENSITY_TOO_HIGH, DENSITY_OK, or DENSITY_TOO_LOW.
      See Also:
    • resolutionFactor

      public double resolutionFactor(ILcdRaster aRaster, ILcdGXYContext aGXYContext, Graphics aGraphics) throws TLcdNoBoundsException
      Computes the ratio between the given raster's pixel density and the ideal display density for the given context.
      Parameters:
      aRaster - the raster to be displayed.
      aGXYContext - the context that contains the model of the raster, the model-to-world transformation, and the view-to-world transformation.
      aGraphics - the Graphics instance on which the raster is to be painted.
      Returns:
      the resolution factor.
      Throws:
      TLcdNoBoundsException
      See Also:
    • idealPixelDensity

      public final double idealPixelDensity(ILcdBounds aModelBounds, ILcdGXYContext aGXYContext, Graphics aGraphics) throws TLcdNoBoundsException
      Computes the ideal pixel density that a raster should have for display in the given context. The ideal density is a number of pixels per unit of area, expressed in model coordinates, such that one model pixel maps onto one view pixel, on average. This ideal density can serve as a reference for an actual raster with a pixel density that may or may not be ideal.
      Parameters:
      aModelBounds - the area of the raster to be displayed, expressed in model coordinates.
      aGXYContext - the context that contains the model of the raster, the model-to-world transformation, and the view-to-world transformation.
      aGraphics - the Graphics instance on which the raster is to be painted.
      Returns:
      the ideal pixel density.
      Throws:
      TLcdNoBoundsException
    • idealPixelDensity

      public final double idealPixelDensity(ILcdRaster aRaster, ILcdGXYContext aGXYContext, Graphics aGraphics) throws TLcdNoBoundsException
      Computes the ideal pixel density that a raster should have for display in the given context. The ideal density is a number of pixels per unit of area, expressed in model coordinates, such that one model pixel maps onto one view pixel, on average. This ideal density can serve as a reference for an actual raster with a pixel density that may or may not be ideal.
      Parameters:
      aRaster - the raster to be displayed
      aGXYContext - the context that contains the model of the raster, the model-to-world transformation, and the view-to-world transformation.
      aGraphics - the Graphics instance on which the raster is to be painted.
      Returns:
      the ideal pixel density.
      Throws:
      TLcdNoBoundsException
    • idealPixelDensity

      public final double idealPixelDensity(ILcdMultilevelRaster aRaster, ILcdGXYContext aGXYContext, Graphics aGraphics) throws TLcdNoBoundsException
      Computes the ideal pixel density that a raster should have for display in the given context. The ideal density is a number of pixels per unit of area, expressed in model coordinates, such that one model pixel maps onto one view pixel, on average. This ideal density can serve as a reference for an actual raster with a pixel density that may or may not be ideal.
      Parameters:
      aRaster - the raster to be displayed
      aGXYContext - the context that contains the model of the raster, the model-to-world transformation, and the view-to-world transformation.
      aGraphics - the Graphics instance on which the raster is to be painted.
      Returns:
      the ideal pixel density.
      Throws:
      TLcdNoBoundsException
    • clone

      public Object clone()
      Description copied from interface: ILcdCloneable

      Makes Object.clone() public.

      When for example extending from 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:
      clone in interface ILcdCloneable
      Specified by:
      clone in interface ILcdGXYPainterProvider
      Overrides:
      clone in class ALcdGXYPainter
      Returns:
      a clone of this painter provider.
      See Also: