Package uk.ac.starlink.ttools.plot
Class BarStyle
- java.lang.Object
-
- uk.ac.starlink.ttools.plot.DefaultStyle
-
- uk.ac.starlink.ttools.plot.BarStyle
-
- All Implemented Interfaces:
javax.swing.Icon
,Style
public class BarStyle extends DefaultStyle implements javax.swing.Icon
Defines a style for plotting a bar in a histogram.- Since:
- 16 Nov 2005
- Author:
- Mark Taylor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description 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
Fields Modifier and Type Field Description 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
Constructors Constructor Description BarStyle(java.awt.Color color, BarStyle.Form form, BarStyle.Placement placement)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
drawBar(java.awt.Graphics g, int xlo, int xhi, int ylo, int yhi, int iseq, int nseq)
Draws a bar for inclusion in a histogram.void
drawEdge(java.awt.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()
javax.swing.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(java.awt.Component c, java.awt.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
-
-
-
-
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(java.awt.Color color, BarStyle.Form form, BarStyle.Placement placement)
Constructor.- Parameters:
color
- initial colourform
- bar formplacement
- bar placement
-
-
Method Detail
-
drawBar
public void drawBar(java.awt.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 contextxlo
- lower bound in X directionxhi
- upper bound in X directionylo
- lower bound in Y directionyhi
- upper bound in Y directioniseq
- index of the set being plottednseq
- number of sets being plotted for this bar
-
drawEdge
public void drawEdge(java.awt.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 contextx
- x position of the edgey1
- one y value for the edgey2
- other y value for the edgeiseq
- index of the set being plottednseq
- 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 javax.swing.Icon getLegendIcon()
Description copied from interface:Style
Returns an icon suitable for displaying in a legend for this style.- Specified by:
getLegendIcon
in interfaceStyle
-
getIconHeight
public int getIconHeight()
- Specified by:
getIconHeight
in interfacejavax.swing.Icon
-
getIconWidth
public int getIconWidth()
- Specified by:
getIconWidth
in interfacejavax.swing.Icon
-
paintIcon
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
- Specified by:
paintIcon
in interfacejavax.swing.Icon
-
-