Package uk.ac.starlink.ttools.plot
Class ErrorRenderer
- java.lang.Object
-
- uk.ac.starlink.ttools.plot.ErrorRenderer
-
public abstract class ErrorRenderer extends java.lang.Object
Renders error bars.- Since:
- 20 Feb 2007
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description static ErrorRenderer
DEFAULT
General purpose error renderer.static ErrorRenderer
EXAMPLE
Error renderer suitable for use in user controls.static ErrorRenderer
NONE
Error renderer which draws nothing.static ErrorRenderer
TANGENT
Error renderer suitable for displaying 2D tangential errors.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ErrorRenderer(java.lang.String name)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
drawErrors(java.awt.Graphics g, int x, int y, int[] xoffs, int[] yoffs)
Renders error bars in one or more dimensions around a given point.abstract java.awt.Rectangle
getBounds(int x, int y, int[] xoffs, int[] yoffs)
Returns a rectangle which will contain the rendered error bar graphics for a given point.abstract javax.swing.Icon
getLegendIcon()
Returns an icon giving a general example of what this form looks like.abstract javax.swing.Icon
getLegendIcon(ErrorMode[] modes, int width, int height, int xpad, int ypad)
Returns an icon giving an example of what this form looks like in a detailed context.java.lang.String
getName()
Returns a user-readable name for this style of error rendering.static ErrorRenderer[]
getOptions1d()
Returns an array of ErrorRenderers which can render 1-dimensional (vertical) errors.static ErrorRenderer[]
getOptions2d()
Returns an array of ErrorRenderers which can render 2-dimensional errors.static ErrorRenderer[]
getOptions3d()
Returns an array of ErrorRenderers which can render 3-dimensional errors.static ErrorRenderer[]
getOptionsEllipse()
Returns an array of ErrorRenderers which is suitable for 2d ellipse-like applications.static ErrorRenderer[]
getOptionsGeneral()
Returns an array of ErrorRenderers which can render errors of arbitrary dimensionality.static ErrorRenderer[]
getOptionsSizeXY()
Returns an array of ErrorRenderers which is suitable for applications that plot a shape with independently variable horizontal and vertical extents.static ErrorRenderer[]
getOptionsSpherical()
Returns an array of ErrorRenderers which can render errors suitable for spherical or spherical polar coordinates.static ErrorRenderer[]
getOptionsVector()
Returns an array of ErrorRenderers which is suitable for vector-like applications.Pixellator
getPixels(java.awt.Rectangle clip, int x, int y, int[] xoffs, int[] yoffs)
Returns an array of pixel positions which can be used to draw this marker onto a raster.abstract boolean
isBlank(ErrorMode[] modes)
Indicates whether this renderer is known to produce no output for a particular set of ErrorModes.abstract boolean
supportsDimensionality(int ndim)
Reports whether this form can be used on a given error dimensionality.java.lang.String
toString()
-
-
-
Field Detail
-
NONE
public static final ErrorRenderer NONE
Error renderer which draws nothing.
-
DEFAULT
public static final ErrorRenderer DEFAULT
General purpose error renderer.
-
EXAMPLE
public static final ErrorRenderer EXAMPLE
Error renderer suitable for use in user controls.
-
TANGENT
public static final ErrorRenderer TANGENT
Error renderer suitable for displaying 2D tangential errors.
-
-
Method Detail
-
getLegendIcon
public abstract javax.swing.Icon getLegendIcon()
Returns an icon giving a general example of what this form looks like.- Returns:
- example icon
-
getLegendIcon
public abstract javax.swing.Icon getLegendIcon(ErrorMode[] modes, int width, int height, int xpad, int ypad)
Returns an icon giving an example of what this form looks like in a detailed context.- Parameters:
modes
- array of ErrorModes, one per error dimension (x, y, ...)width
- total width of iconheight
- total height of iconxpad
- internal horizontal padding of iconypad
- internal vertical padding of icon
-
getName
public java.lang.String getName()
Returns a user-readable name for this style of error rendering.- Returns:
- renderer name
-
isBlank
public abstract boolean isBlank(ErrorMode[] modes)
Indicates whether this renderer is known to produce no output for a particular set of ErrorModes. Ifmodes
is null, the question is about whether this renderer will produce no output regardless of the error mode context.- Parameters:
modes
- error mode context, or null- Returns:
- true if this renderer can be guaranteed to paint nothing
-
supportsDimensionality
public abstract boolean supportsDimensionality(int ndim)
Reports whether this form can be used on a given error dimensionality.- Parameters:
ndim
- number of error dimensions to be used- Returns:
- true iff this object can do rendering
-
drawErrors
public abstract void drawErrors(java.awt.Graphics g, int x, int y, int[] xoffs, int[] yoffs)
Renders error bars in one or more dimensions around a given point. The positions of the ends of error bars relative to the the point are given. There may in general be (2*N) of these, though certainErrorRenderer
implementations may impose restrictions on this count. They must come in consecutive pairs which describe error bars along the same axis in different directions. Missing error bars are represented as (0,0). The values must come in axis order where that makes sense, but note in some contexts (e.g. 3D) these may be data axes rather than graphics plane axes.This method is quite likely to get called from time to time with ridiculously large offset arrays. Implementations should try to ensure that they don't attempt graphics operations which may cause the graphics system undue grief, such as filling an ellipse the size of a village.
- Parameters:
g
- graphics contextx
- data point X coordinatey
- data point Y coordinatexoffs
- X coordinates of error bar limit offsets from (x,y)yoffs
- Y coordinates of error bar limit offsets from (x,y)
-
getBounds
public abstract java.awt.Rectangle getBounds(int x, int y, int[] xoffs, int[] yoffs)
Returns a rectangle which will contain the rendered error bar graphics for a given point.- Parameters:
x
- data point X coordinatey
- data point Y coordinatexoffs
- X coordinates of error bar limit offsets from (x,y)yoffs
- Y coordinates of error bar limit offsets from (x,y)- Returns:
- bounding box
-
getPixels
public Pixellator getPixels(java.awt.Rectangle clip, int x, int y, int[] xoffs, int[] yoffs)
Returns an array of pixel positions which can be used to draw this marker onto a raster. This can be used as an alternative to rendering the marker using thedrawErrors(java.awt.Graphics, int, int, int[], int[])
method, for instance in situations where it might be more efficient. The assumption is that all the pixels are the same colour.The ErrorRenderer implementation calculates this by painting onto a temporary BufferedImage and then examining the raster to see which pixels have been painted. This is probably not very efficient. Subclasses are encouraged to override this method if they can calculate the pixels which will be painted directly.
- Parameters:
clip
- clipping regionx
- data point X coordinatey
- data point Y coordinatexoffs
- X coordinates of error bar limit offsets from (x,y)yoffs
- Y coordinates of error bar limit offsets from (x,y)- Returns:
- array of pixel coordinates representing the error bar as a bitmap
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getOptions1d
public static ErrorRenderer[] getOptions1d()
Returns an array of ErrorRenderers which can render 1-dimensional (vertical) errors.- Returns:
- selection of renderers
-
getOptions2d
public static ErrorRenderer[] getOptions2d()
Returns an array of ErrorRenderers which can render 2-dimensional errors.- Returns:
- selection of renderers
-
getOptions3d
public static ErrorRenderer[] getOptions3d()
Returns an array of ErrorRenderers which can render 3-dimensional errors.- Returns:
- selection of renderers
-
getOptionsSpherical
public static ErrorRenderer[] getOptionsSpherical()
Returns an array of ErrorRenderers which can render errors suitable for spherical or spherical polar coordinates. The first two dimensions of offset values submitted to such renderers are the tangential ones, and the third, if present, is the radial one.- Returns:
- selection of renderers
-
getOptionsGeneral
public static ErrorRenderer[] getOptionsGeneral()
Returns an array of ErrorRenderers which can render errors of arbitrary dimensionality.- Returns:
- selection of renderers
-
getOptionsEllipse
public static ErrorRenderer[] getOptionsEllipse()
Returns an array of ErrorRenderers which is suitable for 2d ellipse-like applications.- Returns:
- selection of renderers
-
getOptionsSizeXY
public static ErrorRenderer[] getOptionsSizeXY()
Returns an array of ErrorRenderers which is suitable for applications that plot a shape with independently variable horizontal and vertical extents.- Returns:
- selection of renderers
-
getOptionsVector
public static ErrorRenderer[] getOptionsVector()
Returns an array of ErrorRenderers which is suitable for vector-like applications.- Returns:
- selection of renderers
-
-