uk.ac.starlink.ttools.plot
Class ErrorRenderer

java.lang.Object
  extended by uk.ac.starlink.ttools.plot.ErrorRenderer

public abstract class ErrorRenderer
extends Object

Renders error bars.

Since:
20 Feb 2007
Author:
Mark Taylor

Field Summary
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
protected ErrorRenderer(String name)
          Constructor.
 
Method Summary
abstract  void drawErrors(Graphics g, int x, int y, int[] xoffs, int[] yoffs)
          Renders error bars in one or more dimensions around a given point.
abstract  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  Icon getLegendIcon()
          Returns an icon giving a general example of what this form looks like.
abstract  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.
 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(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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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.

Constructor Detail

ErrorRenderer

protected ErrorRenderer(String name)
Constructor.

Parameters:
name - renderer name
Method Detail

getLegendIcon

public abstract Icon getLegendIcon()
Returns an icon giving a general example of what this form looks like.

Returns:
example icon

getLegendIcon

public abstract 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 icon
height - total height of icon
xpad - internal horizontal padding of icon
ypad - internal vertical padding of icon

getName

public 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. If modes 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(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 certain ErrorRenderer 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 context
x - data point X coordinate
y - data point Y coordinate
xoffs - X coordinates of error bar limit offsets from (x,y)
yoffs - Y coordinates of error bar limit offsets from (x,y)

getBounds

public abstract 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 coordinate
y - data point Y coordinate
xoffs - 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(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 the drawErrors(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 region
x - data point X coordinate
y - data point Y coordinate
xoffs - 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 String toString()
Overrides:
toString in class 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


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.