uk.ac.starlink.ttools.plot
Class BarStyle

java.lang.Object
  extended by uk.ac.starlink.ttools.plot.DefaultStyle
      extended by uk.ac.starlink.ttools.plot.BarStyle
All Implemented Interfaces:
Icon, Style

public class BarStyle
extends DefaultStyle
implements Icon

Defines a style for plotting a bar in a histogram.

Since:
16 Nov 2005
Author:
Mark Taylor

Nested Class Summary
static class BarStyle.Form
          Describes the form of a bar style, that is what each bar looks like.
static class BarStyle.Placement
          Describes bar placement, that is how multiple bars covering the same data range are to be arranged.
 
Field Summary
static BarStyle.Form FORM_FILLED
          Bar form using filled rectangles.
static BarStyle.Form FORM_FILLED3D
          Bar form using filled 3d rectangles.
static BarStyle.Form FORM_OPEN
          Bar form using open rectangles.
static BarStyle.Form FORM_SEMIFILLED
          Bar form with an outline and a transparent inside.
static BarStyle.Form FORM_SEMITOP
          Bar form with steps and a transparent inside.
static BarStyle.Form FORM_SPIKE
          Bar form using 1-d spikes.
static BarStyle.Form FORM_TOP
          Bar form drawing only the tops of the bars.
static BarStyle.Placement PLACE_ADJACENT
          Placement which puts bars next to each other.
static BarStyle.Placement PLACE_OVER
          Placement which puts bars in the same X region.
 
Constructor Summary
BarStyle(Color color, BarStyle.Form form, BarStyle.Placement placement)
          Constructor.
 
Method Summary
 void drawBar(Graphics g, int xlo, int xhi, int ylo, int yhi, int iseq, int nseq)
          Draws a bar for inclusion in a histogram.
 void drawEdge(Graphics g, int x, int y1, int y2, int iseq, int nseq)
          Draws the edge of a bar.
 BarStyle.Form getForm()
          Returns the form of this style.
 int getIconHeight()
           
 int getIconWidth()
           
 Icon getLegendIcon()
          Returns an icon suitable for displaying in a legend for this style.
 BarStyle.Placement getPlacement()
          Returns the placement of this style.
 void paintIcon(Component c, Graphics g, int x, int y)
           
 
Methods inherited from class uk.ac.starlink.ttools.plot.DefaultStyle
equals, getColor, getDash, getLineWidth, getOtherAtts, getStroke, getStroke, hashCode, setColor, setDash, setLineWidth, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FORM_OPEN

public static final BarStyle.Form FORM_OPEN
Bar form using open rectangles.


FORM_FILLED

public static final BarStyle.Form FORM_FILLED
Bar form using filled rectangles.


FORM_FILLED3D

public static final BarStyle.Form FORM_FILLED3D
Bar form using filled 3d rectangles.


FORM_TOP

public static final BarStyle.Form FORM_TOP
Bar form drawing only the tops of the bars.


FORM_SPIKE

public static final BarStyle.Form FORM_SPIKE
Bar form using 1-d spikes.


FORM_SEMIFILLED

public static final BarStyle.Form FORM_SEMIFILLED
Bar form with an outline and a transparent inside.


FORM_SEMITOP

public static final BarStyle.Form FORM_SEMITOP
Bar form with steps and a transparent inside.


PLACE_ADJACENT

public static final BarStyle.Placement PLACE_ADJACENT
Placement which puts bars next to each other.


PLACE_OVER

public static final BarStyle.Placement PLACE_OVER
Placement which puts bars in the same X region.

Constructor Detail

BarStyle

public BarStyle(Color color,
                BarStyle.Form form,
                BarStyle.Placement placement)
Constructor.

Parameters:
color - initial colour
form - bar form
placement - bar placement
Method Detail

drawBar

public void drawBar(Graphics g,
                    int xlo,
                    int xhi,
                    int ylo,
                    int yhi,
                    int iseq,
                    int nseq)
Draws a bar for inclusion in a histogram.

Parameters:
g - graphics context
xlo - lower bound in X direction
xhi - upper bound in X direction
ylo - lower bound in Y direction
yhi - upper bound in Y direction
iseq - index of the set being plotted
nseq - number of sets being plotted for this bar

drawEdge

public void drawEdge(Graphics g,
                     int x,
                     int y1,
                     int y2,
                     int iseq,
                     int nseq)
Draws the edge of a bar. This can be invoked to draw the boundary between one bar and its immediate neighbour; the edge described by the call's parameters is not the edge of the block representing the bar's data, but the edge between the current bar and its neighbour on one side or the other, so it may go up or down from the Y value. For many bar styles this will be a no-op.

Parameters:
g - graphics context
x - x position of the edge
y1 - one y value for the edge
y2 - other y value for the edge
iseq - index of the set being plotted
nseq - number of sets being plotted for this bar

getForm

public BarStyle.Form getForm()
Returns the form of this style.

Returns:
bar form

getPlacement

public BarStyle.Placement getPlacement()
Returns the placement of this style.

Returns:
bar placement

getLegendIcon

public Icon getLegendIcon()
Description copied from interface: Style
Returns an icon suitable for displaying in a legend for this style.

Specified by:
getLegendIcon in interface Style

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface Icon

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface Icon

paintIcon

public void paintIcon(Component c,
                      Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface Icon


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