org.jfree.report.modules.misc.survey

Class SurveyScale

public class SurveyScale extends Object implements Serializable

Draws a survey scale. By implementing the Drawable interface, instances can be displayed within a report using the DrawableElement class.

Author: David Gilbert

Constructor Summary
SurveyScale()
Creates a new default instance.
SurveyScale(int lowest, int highest, Number[] values)
Creates a new instance.
Method Summary
static ShapecreateDiamond(float s)
Creates a diamond shape.
static ShapecreateDownTriangle(float s)
Creates a triangle shape that points downwards.
protected ArrayListcreateShapeList()
Creates the shape list used when drawing the scale.
static ShapecreateUpTriangle(float s)
Creates a triangle shape that points upwards.
voiddraw(Graphics2D g2, Rectangle2D area)
Draws the survey scale.
protected voiddrawBorder(Graphics2D g2, Rectangle2D area)
protected voiddrawRangeArea(Rectangle2D area, Graphics2D g2)
protected voiddrawScaleValues(Graphics2D g2, Rectangle2D area)
protected voiddrawTickMarks(Graphics2D g2, Rectangle2D area)
protected voiddrawValues(Graphics2D g2, Rectangle2D area)
PaintgetBorderPaint()
ShapegetDefaultShape()
Returns the default shape, which is used, if a shape for a certain value is not defined.
PaintgetFillPaint()
intgetHighest()
protected doublegetLowerBound()
doublegetLowerMargin()
intgetLowest()
StrokegetOutlineStroke()
protected intgetRange()
NumbergetRangeLowerBound()
Returns the lower bound of the highlighted range.
PaintgetRangePaint()
Returns the paint used to highlight the range.
NumbergetRangeUpperBound()
Returns the upper bound of the highlighted range.
FontgetScaleValueFont()
Returns the font used to display the scale values.
PaintgetScaleValuePaint()
Returns the color used to draw the scale values (if they are visible).
ShapegetShape(int index)
Returns the shape used to indicate the value of a response.
PaintgetTickMarkPaint()
protected doublegetUpperBound()
doublegetUpperMargin()
Number[]getValues()
booleanisAutoConfigure()
booleanisDrawBorder()
Returns a flag that controls whether or not a border is drawn around the scale.
booleanisDrawScaleValues()
Returns a flag that controls whether or not scale values are drawn.
booleanisDrawTickMarks()
Returns the flag that controls whether the tick marks are drawn.
booleanisShapeFilled(int index)
Returns a flag that controls whether the shape for a particular value should be filled.
protected voidrecompute()
This method is called whenever lowest or highest has changed.
voidsetAutoConfigure(boolean autoConfigure)
voidsetBorderPaint(Paint borderPaint)
voidsetDefaultShape(Shape defaultShape)
Redefines the default shape.
voidsetDrawBorder(boolean flag)
Sets a flag that controls whether or not a border is drawn around the scale.
voidsetDrawScaleValues(boolean flag)
Sets a flag that controls whether or not scale values are drawn.
voidsetDrawTickMarks(boolean flag)
Sets the flag that controls whether the tick marks are drawn.
voidsetFillPaint(Paint fillPaint)
voidsetHighest(int highest)
protected voidsetLowerBound(double lowerBound)
voidsetLowerMargin(double lowerMargin)
voidsetLowest(int lowest)
voidsetOutlineStroke(Stroke outlineStroke)
protected voidsetRange(int range)
voidsetRangeLowerBound(Number bound)
Sets the lower bound for the range that is highlighted on the scale.
voidsetRangePaint(Paint paint)
Sets the paint used to highlight the range (if one is specified).
voidsetRangeUpperBound(Number bound)
Sets the upper bound for the range that is highlighted on the scale.
voidsetScaleValueFont(Font font)
Sets the font used to display the scale values.
voidsetScaleValuePaint(Paint paint)
Sets the color used to draw the scale values.
voidsetShape(int index, Shape shape)
Sets the shape used to mark a particular value in the dataset.
voidsetShapeFilled(int index, boolean fill)
Sets the flag that controls whether the shape for a particular value should be filled.
voidsetTickMarkPaint(Paint tickMarkPaint)
protected voidsetUpperBound(double upperBound)
voidsetUpperMargin(double upperMargin)

Constructor Detail

SurveyScale

public SurveyScale()
Creates a new default instance.

SurveyScale

public SurveyScale(int lowest, int highest, Number[] values)
Creates a new instance.

Parameters: lowest the lowest response value on the scale. highest the highest response value on the scale. values the values to display.

Method Detail

createDiamond

public static Shape createDiamond(float s)
Creates a diamond shape.

Parameters: s the size factor (equal to half the height of the diamond).

Returns: A diamond shape.

createDownTriangle

public static Shape createDownTriangle(float s)
Creates a triangle shape that points downwards.

Parameters: s the size factor (equal to half the height of the triangle).

Returns: A triangle shape.

createShapeList

protected ArrayList createShapeList()
Creates the shape list used when drawing the scale. The list returned must contain exactly 6 elements.

Returns:

createUpTriangle

public static Shape createUpTriangle(float s)
Creates a triangle shape that points upwards.

Parameters: s the size factor (equal to half the height of the triangle).

Returns: A triangle shape.

draw

public void draw(Graphics2D g2, Rectangle2D area)
Draws the survey scale.

Parameters: g2 the graphics device. area the area.

drawBorder

protected void drawBorder(Graphics2D g2, Rectangle2D area)

drawRangeArea

protected void drawRangeArea(Rectangle2D area, Graphics2D g2)

drawScaleValues

protected void drawScaleValues(Graphics2D g2, Rectangle2D area)

drawTickMarks

protected void drawTickMarks(Graphics2D g2, Rectangle2D area)

drawValues

protected void drawValues(Graphics2D g2, Rectangle2D area)

getBorderPaint

public Paint getBorderPaint()

getDefaultShape

public Shape getDefaultShape()
Returns the default shape, which is used, if a shape for a certain value is not defined.

Returns: the default shape, never null.

getFillPaint

public Paint getFillPaint()

getHighest

public int getHighest()

getLowerBound

protected double getLowerBound()

getLowerMargin

public double getLowerMargin()

getLowest

public int getLowest()

getOutlineStroke

public Stroke getOutlineStroke()

getRange

protected int getRange()

getRangeLowerBound

public Number getRangeLowerBound()
Returns the lower bound of the highlighted range. A null value indicates that no range is set for highlighting.

Returns: The lower bound (possibly null).

getRangePaint

public Paint getRangePaint()
Returns the paint used to highlight the range.

Returns: A Paint object (never null).

getRangeUpperBound

public Number getRangeUpperBound()
Returns the upper bound of the highlighted range. A null value indicates that no range is set for highlighting.

Returns: The upper bound (possibly null).

getScaleValueFont

public Font getScaleValueFont()
Returns the font used to display the scale values.

Returns: A font (never null).

getScaleValuePaint

public Paint getScaleValuePaint()
Returns the color used to draw the scale values (if they are visible).

Returns: A paint (never null).

getShape

public Shape getShape(int index)
Returns the shape used to indicate the value of a response.

Parameters: index the value index (zero-based).

Returns: The shape.

getTickMarkPaint

public Paint getTickMarkPaint()

getUpperBound

protected double getUpperBound()

getUpperMargin

public double getUpperMargin()

getValues

public Number[] getValues()

isAutoConfigure

public boolean isAutoConfigure()

isDrawBorder

public boolean isDrawBorder()
Returns a flag that controls whether or not a border is drawn around the scale.

Returns: A boolean.

isDrawScaleValues

public boolean isDrawScaleValues()
Returns a flag that controls whether or not scale values are drawn.

Returns: a boolean.

isDrawTickMarks

public boolean isDrawTickMarks()
Returns the flag that controls whether the tick marks are drawn.

Returns: A boolean.

isShapeFilled

public boolean isShapeFilled(int index)
Returns a flag that controls whether the shape for a particular value should be filled.

Parameters: index the value index (zero-based).

Returns: A boolean.

recompute

protected void recompute()
This method is called whenever lowest or highest has changed. It will recompute the range and upper and lower bounds.

setAutoConfigure

public void setAutoConfigure(boolean autoConfigure)

setBorderPaint

public void setBorderPaint(Paint borderPaint)

setDefaultShape

public void setDefaultShape(Shape defaultShape)
Redefines the default shape.

Parameters: defaultShape the default shape

Throws: NullPointerException if the given shape is null.

setDrawBorder

public void setDrawBorder(boolean flag)
Sets a flag that controls whether or not a border is drawn around the scale.

Parameters: flag the flag.

setDrawScaleValues

public void setDrawScaleValues(boolean flag)
Sets a flag that controls whether or not scale values are drawn.

Parameters: flag the flag.

setDrawTickMarks

public void setDrawTickMarks(boolean flag)
Sets the flag that controls whether the tick marks are drawn.

Parameters: flag a boolean.

setFillPaint

public void setFillPaint(Paint fillPaint)

setHighest

public void setHighest(int highest)

setLowerBound

protected void setLowerBound(double lowerBound)

setLowerMargin

public void setLowerMargin(double lowerMargin)

setLowest

public void setLowest(int lowest)

setOutlineStroke

public void setOutlineStroke(Stroke outlineStroke)

setRange

protected void setRange(int range)

setRangeLowerBound

public void setRangeLowerBound(Number bound)
Sets the lower bound for the range that is highlighted on the scale.

Parameters: bound the lower bound (null permitted).

setRangePaint

public void setRangePaint(Paint paint)
Sets the paint used to highlight the range (if one is specified).

Parameters: paint the paint (null not permitted).

setRangeUpperBound

public void setRangeUpperBound(Number bound)
Sets the upper bound for the range that is highlighted on the scale.

Parameters: bound the upper bound (null permitted).

setScaleValueFont

public void setScaleValueFont(Font font)
Sets the font used to display the scale values.

Parameters: font the font (null not permitted).

setScaleValuePaint

public void setScaleValuePaint(Paint paint)
Sets the color used to draw the scale values.

Parameters: paint the paint (null not permitted).

setShape

public void setShape(int index, Shape shape)
Sets the shape used to mark a particular value in the dataset.

Parameters: index the value index (zero-based). shape the shape (null not permitted).

setShapeFilled

public void setShapeFilled(int index, boolean fill)
Sets the flag that controls whether the shape for a particular value should be filled.

Parameters: index the value index (zero-based). fill the flag.

setTickMarkPaint

public void setTickMarkPaint(Paint tickMarkPaint)

setUpperBound

protected void setUpperBound(double upperBound)

setUpperMargin

public void setUpperMargin(double upperMargin)