public abstract class ALcdRasterPainter extends ALcdGXYPainter implements ILcdRasterPainter
ILcdRasterPainter
interface.Modifier and Type | Field and Description |
---|---|
protected static int |
DENSITY_OK |
protected static int |
DENSITY_TOO_HIGH |
protected static int |
DENSITY_TOO_LOW |
protected float |
fBrightness |
protected ColorModel |
fColorModel |
protected float |
fContrast |
protected boolean |
fFillOutlineArea |
protected boolean |
fForcePainting |
protected int |
fMaxNumberOfOutlineTiles |
protected boolean |
fPaintOutline |
protected RGBImageFilter |
fRGBImageFilter |
protected double |
fStartResolutionFactor |
protected double |
fStopResolutionFactor |
protected float |
fTransparency |
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
Constructor and Description |
---|
ALcdRasterPainter() |
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Makes
Object.clone() 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.
|
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.
|
float |
getBrightness() |
ColorModel |
getColorModel() |
float |
getContrast() |
int |
getMaxNoOfOutlineTiles() |
int |
getMaxNumberOfOutlineTiles() |
ILcdGXYPainterStyle |
getOutlineAreaFillStyle() |
Color |
getOutlineColor() |
ILcdGXYPainterStyle |
getOutlineStyle()
Returns the style that is used to draw the outline of the area of raster and/or tiles.
|
RGBImageFilter |
getRGBImageFilter()
Returns the optional filter that is applied to painted rasters.
|
ILcdIcon |
getSnapIcon()
Returns the icon that is used to paint snap target points of the object set to this painter.
|
double |
getStartResolutionFactor() |
double |
getStartScale()
Returns the start scale.
|
double |
getStopResolutionFactor() |
double |
getStopScale()
Returns the stop scale.
|
float |
getTransparency() |
double |
idealPixelDensity(ILcdBounds aModelBounds,
ILcdGXYContext aGXYContext,
Graphics aGraphics)
Computes the ideal pixel density that a raster should have for display in
the given context.
|
double |
idealPixelDensity(ILcdMultilevelRaster aRaster,
ILcdGXYContext aGXYContext,
Graphics aGraphics)
Computes the ideal pixel density that a raster should have for display in
the given context.
|
double |
idealPixelDensity(ILcdRaster aRaster,
ILcdGXYContext aGXYContext,
Graphics aGraphics)
Computes the ideal pixel density that a raster should have for display in
the given context.
|
boolean |
isFillOutlineArea() |
boolean |
isForcePainting() |
boolean |
isPaintOutline() |
boolean |
isTouched(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.
|
void |
paint(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Displays the representation of the object in the given mode on the Graphics passed, taking into account the
supplied context.
|
double |
resolutionFactor(ILcdRaster aRaster,
ILcdGXYContext aGXYContext,
Graphics aGraphics)
Computes the ratio between the given raster's pixel density and the ideal
display density for the given context.
|
void |
setBrightness(float aBrightness)
Sets the brightness factor that is applied to painted rasters.
|
void |
setColorModel(ColorModel aColorModel)
Sets the ColorModel that determines how a raster pixel is transformed
into color components for a screen pixel.
|
void |
setContrast(float aContrast)
Sets the gamma correction that is applied to painted rasters.
|
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.
|
void |
setForcePainting(boolean aForcePainting)
Specifies whether the visible portion of the raster should always be
painted, irrespective of the startResolutionFactor and
stopResolutionFactor.
|
void |
setMaxNoOfOutlineTiles(int aMaxNumberOfOutlineTiles) |
void |
setMaxNumberOfOutlineTiles(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.
|
void |
setOutlineAreaFillStyle(ILcdGXYPainterStyle aFillStyle)
Sets the style that is used when filling the outline area of raster and/or tiles.
|
void |
setOutlineColor(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.
|
void |
setOutlineStyle(ILcdGXYPainterStyle aOutlineStyle)
Sets the style that is used when drawing the outline of the area of raster and/or tiles.
|
void |
setPaintOutline(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.
|
void |
setRGBImageFilter(RGBImageFilter aRGBImageFilter)
Sets the optional filter that is applied to painted rasters.
|
void |
setSnapIcon(ILcdIcon aSnapIcon)
Sets the icon that marks snap targets of the object currently set to this painter.
|
void |
setStartResolutionFactor(double aFactor)
Sets the highest pixel density (number of raster pixels per screen pixel)
at which a raster is painted.
|
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. |
void |
setStopResolutionFactor(double aFactor)
Sets the lowest pixel density (number of raster pixels per screen pixel)
at which a raster is painted.
|
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. |
void |
setTransparency(float aTransparency)
Sets the transparency factor that is applied to painted rasters.
|
Object |
snapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns one of the bounds points of the
ILcdRaster object if it is
touched. |
boolean |
supportSnap(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Override this method to support snapping.
|
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
anchorPointSFCT, boundsSFCT, getCursor, getDisplayName, getObject, setObject
addPropertyChangeListener, removePropertyChangeListener
protected static final int DENSITY_TOO_HIGH
protected static final int DENSITY_OK
protected static final int DENSITY_TOO_LOW
protected double fStartResolutionFactor
protected double fStopResolutionFactor
protected boolean fForcePainting
protected int fMaxNumberOfOutlineTiles
protected boolean fPaintOutline
protected boolean fFillOutlineArea
protected ColorModel fColorModel
protected RGBImageFilter fRGBImageFilter
protected float fTransparency
protected float fBrightness
protected float fContrast
public void setSnapIcon(ILcdIcon aSnapIcon)
paint
method is called with the render mode ILcdGXYPainter.SNAPS
.aSnapIcon
- The icon that should be used to paint snap target points.getSnapIcon()
public ILcdIcon getSnapIcon()
setSnapIcon(ILcdIcon)
public void paint(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
ILcdGXYPainter
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:
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.
paint
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaRenderMode
- the mode the object is represented in (see class documentation).aGXYContext
- the ILcdGXYContext
the drawing depends on.public boolean isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ILcdGXYPainter
The location that must be taken into account to check whether the representation is touched can be retrieved from
the context passed with the methods
ILcdGXYContext.getX()
and ILcdGXYContext.getY()
.
If the check is part of an ongoing operation of
user interaction, for example, when the mouse is being dragged, the location of the start of the operation can also
be taken into account using the methods
ILcdGXYContext.getDeltaX()
and ILcdGXYContext.getDeltaY()
.
The context contains the transformations required to convert this location into the equivalent location in
model space. Implementations of this interface usually follow either of the following patterns:
As the mode influences the way an object is represented, it must also be taken into account when checking whether that representation is being touched. When the mode contains CREATING, RESHAPING or TRANSLATING which indicate that the object must be represented in a state for an ongoing operation, the location of the start of the operation may be taken into account as mentioned above. The painting result can take into account multiple locations, to respond to, for example, multi-touch input. When the mode contains SELECTED, the painter should also check if the non-selected representation is touched, since these are always painted on top of each other.
The boundsSFCT
is often used to speed up the performance of this method as a location outside these bounds can never
touch the representation of the object.
Note that this method does not give an indication of what part of the object is touched. It is up to the painter implementations to provide methods to make this distinction. The method does also not indicate what sensitivity must be applied when checking if an object is touched. It is up to the implementation to decide what should be the maximum distance between the location given in the context and the closest relevant point or area of the representation of the object.
isTouched
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented inaGXYContext
- contains the location of the interaction and the transformations to convert this location into
model coordinatesboundsSFCT
public boolean supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
ALcdGXYPainter
supportSnap
in interface ILcdGXYPainter
supportSnap
in class ALcdGXYPainter
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.false
.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.
snapTarget
in interface ILcdGXYPainter
snapTarget
in class ALcdGXYPainter
aGraphics
- the graphics on which is worked.aGXYContext
- the context of the snapping.ILcdRaster
object if it is
touched, null
otherwise.supportSnap
public void setStartResolutionFactor(double aFactor)
ILcdRasterPainter
setStartResolutionFactor
in interface ILcdRasterPainter
public double getStartResolutionFactor()
getStartResolutionFactor
in interface ILcdRasterPainter
ILcdRasterPainter.setStartResolutionFactor(double)
public void setStopResolutionFactor(double aFactor)
ILcdRasterPainter
setStopResolutionFactor
in interface ILcdRasterPainter
public double getStopResolutionFactor()
getStopResolutionFactor
in interface ILcdRasterPainter
ILcdRasterPainter.setStopResolutionFactor(double)
public double getStartScale()
setStartScale(double)
public void setStartScale(double aStartScale)
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.aStartScale
- The view scale at which one starts painting the raster rather that the outline (when zooming in).getStartScale()
public double getStopScale()
setStopScale(double)
public void setStopScale(double aStopScale)
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.aStopScale
- The view scale at which one stops painting the raster (when zooming in).getStopScale()
public void setForcePainting(boolean aForcePainting)
ILcdRasterPainter
setForcePainting
in interface ILcdRasterPainter
ILcdRasterPainter.setStartResolutionFactor(double)
,
ILcdRasterPainter.setStopResolutionFactor(double)
public boolean isForcePainting()
isForcePainting
in interface ILcdRasterPainter
ILcdRasterPainter.setForcePainting(boolean)
public void setPaintOutline(boolean aPaintOutline)
ILcdRasterPainter
setPaintOutline
in interface ILcdRasterPainter
ILcdRasterPainter.setStartResolutionFactor(double)
public boolean isPaintOutline()
isPaintOutline
in interface ILcdRasterPainter
ILcdRasterPainter.setPaintOutline(boolean)
public void setOutlineStyle(ILcdGXYPainterStyle aOutlineStyle)
non-null
value the configure style will take precedence over the
configured outline color if the style modifies the Graphics current color.aOutlineStyle
- the outline style to usesetPaintOutline(boolean)
,
setOutlineColor(java.awt.Color)
public ILcdGXYPainterStyle getOutlineStyle()
null
public void setOutlineColor(Color aColor)
ILcdRasterPainter
setOutlineColor
in interface ILcdRasterPainter
ILcdRasterPainter.setPaintOutline(boolean)
,
ILcdRasterPainter.setStartResolutionFactor(double)
public Color getOutlineColor()
getOutlineColor
in interface ILcdRasterPainter
ILcdRasterPainter.setOutlineColor(java.awt.Color)
public boolean isFillOutlineArea()
setFillOutlineArea(boolean)
public void setFillOutlineArea(boolean aFillOutlineArea)
public ILcdGXYPainterStyle getOutlineAreaFillStyle()
public void setOutlineAreaFillStyle(ILcdGXYPainterStyle aFillStyle)
null
and fill outline area
is enabled the result visual result on screen is undefined.aFillStyle
- the fill style to usesetFillOutlineArea(boolean)
public void setMaxNumberOfOutlineTiles(int aMaxNumberOfOutlineTiles)
ILcdRasterPainter
setMaxNumberOfOutlineTiles
in interface ILcdRasterPainter
ILcdRasterPainter.setStartResolutionFactor(double)
public int getMaxNumberOfOutlineTiles()
getMaxNumberOfOutlineTiles
in interface ILcdRasterPainter
ILcdRasterPainter.setMaxNumberOfOutlineTiles(int)
public void setMaxNoOfOutlineTiles(int aMaxNumberOfOutlineTiles)
setMaxNoOfOutlineTiles
in interface ILcdRasterPainter
public int getMaxNoOfOutlineTiles()
getMaxNoOfOutlineTiles
in interface ILcdRasterPainter
public void setColorModel(ColorModel aColorModel)
ILcdRasterPainter
setColorModel
in interface ILcdRasterPainter
public ColorModel getColorModel()
getColorModel
in interface ILcdRasterPainter
ILcdRasterPainter.setColorModel(java.awt.image.ColorModel)
public void setRGBImageFilter(RGBImageFilter aRGBImageFilter)
public RGBImageFilter getRGBImageFilter()
public void setTransparency(float aTransparency)
ILcdRasterPainter
setTransparency
in interface ILcdRasterPainter
public float getTransparency()
getTransparency
in interface ILcdRasterPainter
ILcdRasterPainter.setTransparency(float)
public void setBrightness(float aBrightness)
ILcdRasterPainter
setBrightness
in interface ILcdRasterPainter
setContrast(float)
public float getBrightness()
getBrightness
in interface ILcdRasterPainter
ILcdRasterPainter.setBrightness(float)
public void setContrast(float aContrast)
public float getContrast()
public int densityCheck(ILcdRaster aRaster, ILcdGXYContext aGXYContext)
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.
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.DENSITY_TOO_HIGH
, DENSITY_OK
, or
DENSITY_TOO_LOW
.setForcePainting(boolean)
,
setStartResolutionFactor(double)
,
setStopResolutionFactor(double)
public int densityCheck(ILcdRaster aRaster, ILcdGXYContext aGXYContext, Graphics aGraphics)
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.
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.DENSITY_TOO_HIGH
, DENSITY_OK
, or
DENSITY_TOO_LOW
.resolutionFactor(ILcdRaster, ILcdGXYContext, Graphics)
,
setForcePainting(boolean)
,
setStartResolutionFactor(double)
,
setStopResolutionFactor(double)
public double resolutionFactor(ILcdRaster aRaster, ILcdGXYContext aGXYContext, Graphics aGraphics) throws TLcdNoBoundsException
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.TLcdNoBoundsException
idealPixelDensity(ILcdBounds, ILcdGXYContext, Graphics)
public final double idealPixelDensity(ILcdBounds aModelBounds, ILcdGXYContext aGXYContext, Graphics aGraphics) throws TLcdNoBoundsException
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.TLcdNoBoundsException
public final double idealPixelDensity(ILcdRaster aRaster, ILcdGXYContext aGXYContext, Graphics aGraphics) throws TLcdNoBoundsException
aRaster
- the raster to be displayedaGXYContext
- 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.TLcdNoBoundsException
public final double idealPixelDensity(ILcdMultilevelRaster aRaster, ILcdGXYContext aGXYContext, Graphics aGraphics) throws TLcdNoBoundsException
aRaster
- the raster to be displayedaGXYContext
- 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.TLcdNoBoundsException
public Object clone()
ILcdCloneable
Makes Object.clone()
public.
java.lang.Object
, it can be implemented like this:
public Object clone() {
try {
return super.clone();
} catch ( CloneNotSupportedException e ) {
// Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
throw new RuntimeException( e );
}
}
clone
in interface ILcdCloneable
clone
in interface ILcdGXYPainterProvider
clone
in class ALcdGXYPainter
Object.clone()