Class SurveyScale
- java.lang.Object
-
- org.jfree.report.modules.misc.survey.SurveyScale
-
- All Implemented Interfaces:
java.io.Serializable
public class SurveyScale extends java.lang.Object implements java.io.SerializableDraws a survey scale. By implementing the Drawable interface, instances can be displayed within a report using the DrawableElement class.- Author:
- David Gilbert
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SurveyScale()Creates a new default instance.SurveyScale(int lowest, int highest, java.lang.Number[] values)Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.awt.ShapecreateDiamond(float s)Creates a diamond shape.static java.awt.ShapecreateDownTriangle(float s)Creates a triangle shape that points downwards.protected java.util.ArrayListcreateShapeList()Creates the shape list used when drawing the scale.static java.awt.ShapecreateUpTriangle(float s)Creates a triangle shape that points upwards.voiddraw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)Draws the survey scale.protected voiddrawBorder(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)protected voiddrawRangeArea(java.awt.geom.Rectangle2D area, java.awt.Graphics2D g2)protected voiddrawScaleValues(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)protected voiddrawTickMarks(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)protected voiddrawValues(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)java.awt.PaintgetBorderPaint()java.awt.ShapegetDefaultShape()Returns the default shape, which is used, if a shape for a certain value is not defined.java.awt.PaintgetFillPaint()intgetHighest()protected doublegetLowerBound()doublegetLowerMargin()intgetLowest()java.awt.StrokegetOutlineStroke()protected intgetRange()java.lang.NumbergetRangeLowerBound()Returns the lower bound of the highlighted range.java.awt.PaintgetRangePaint()Returns the paint used to highlight the range.java.lang.NumbergetRangeUpperBound()Returns the upper bound of the highlighted range.java.awt.FontgetScaleValueFont()Returns the font used to display the scale values.java.awt.PaintgetScaleValuePaint()Returns the color used to draw the scale values (if they are visible).java.awt.ShapegetShape(int index)Returns the shape used to indicate the value of a response.java.awt.PaintgetTickMarkPaint()protected doublegetUpperBound()doublegetUpperMargin()java.lang.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(java.awt.Paint borderPaint)voidsetDefaultShape(java.awt.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(java.awt.Paint fillPaint)voidsetHighest(int highest)protected voidsetLowerBound(double lowerBound)voidsetLowerMargin(double lowerMargin)voidsetLowest(int lowest)voidsetOutlineStroke(java.awt.Stroke outlineStroke)protected voidsetRange(int range)voidsetRangeLowerBound(java.lang.Number bound)Sets the lower bound for the range that is highlighted on the scale.voidsetRangePaint(java.awt.Paint paint)Sets the paint used to highlight the range (if one is specified).voidsetRangeUpperBound(java.lang.Number bound)Sets the upper bound for the range that is highlighted on the scale.voidsetScaleValueFont(java.awt.Font font)Sets the font used to display the scale values.voidsetScaleValuePaint(java.awt.Paint paint)Sets the color used to draw the scale values.voidsetShape(int index, java.awt.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(java.awt.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, java.lang.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
-
isAutoConfigure
public boolean isAutoConfigure()
-
setAutoConfigure
public void setAutoConfigure(boolean autoConfigure)
-
getLowest
public int getLowest()
-
setLowest
public void setLowest(int lowest)
-
getHighest
public int getHighest()
-
setHighest
public void setHighest(int highest)
-
recompute
protected void recompute()
This method is called whenever lowest or highest has changed. It will recompute the range and upper and lower bounds.
-
getRange
protected int getRange()
-
setRange
protected void setRange(int range)
-
getLowerBound
protected double getLowerBound()
-
setLowerBound
protected void setLowerBound(double lowerBound)
-
getUpperBound
protected double getUpperBound()
-
setUpperBound
protected void setUpperBound(double upperBound)
-
createShapeList
protected java.util.ArrayList createShapeList()
Creates the shape list used when drawing the scale. The list returned must contain exactly 6 elements.- Returns:
-
createDiamond
public static java.awt.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.
-
createUpTriangle
public static java.awt.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.
-
createDownTriangle
public static java.awt.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.
-
getRangeLowerBound
public java.lang.Number getRangeLowerBound()
Returns the lower bound of the highlighted range. Anullvalue indicates that no range is set for highlighting.- Returns:
- The lower bound (possibly
null).
-
setRangeLowerBound
public void setRangeLowerBound(java.lang.Number bound)
Sets the lower bound for the range that is highlighted on the scale.- Parameters:
bound- the lower bound (nullpermitted).
-
getRangeUpperBound
public java.lang.Number getRangeUpperBound()
Returns the upper bound of the highlighted range. Anullvalue indicates that no range is set for highlighting.- Returns:
- The upper bound (possibly
null).
-
setRangeUpperBound
public void setRangeUpperBound(java.lang.Number bound)
Sets the upper bound for the range that is highlighted on the scale.- Parameters:
bound- the upper bound (nullpermitted).
-
isDrawBorder
public boolean isDrawBorder()
Returns a flag that controls whether or not a border is drawn around the scale.- Returns:
- A boolean.
-
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.
-
isDrawTickMarks
public boolean isDrawTickMarks()
Returns the flag that controls whether the tick marks are drawn.- Returns:
- A boolean.
-
setDrawTickMarks
public void setDrawTickMarks(boolean flag)
Sets the flag that controls whether the tick marks are drawn.- Parameters:
flag- a boolean.
-
isDrawScaleValues
public boolean isDrawScaleValues()
Returns a flag that controls whether or not scale values are drawn.- Returns:
- a boolean.
-
setDrawScaleValues
public void setDrawScaleValues(boolean flag)
Sets a flag that controls whether or not scale values are drawn.- Parameters:
flag- the flag.
-
getScaleValueFont
public java.awt.Font getScaleValueFont()
Returns the font used to display the scale values.- Returns:
- A font (never
null).
-
setScaleValueFont
public void setScaleValueFont(java.awt.Font font)
Sets the font used to display the scale values.- Parameters:
font- the font (nullnot permitted).
-
getScaleValuePaint
public java.awt.Paint getScaleValuePaint()
Returns the color used to draw the scale values (if they are visible).- Returns:
- A paint (never
null).
-
setScaleValuePaint
public void setScaleValuePaint(java.awt.Paint paint)
Sets the color used to draw the scale values.- Parameters:
paint- the paint (nullnot permitted).
-
getShape
public java.awt.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.
-
setShape
public void setShape(int index, java.awt.Shape shape)Sets the shape used to mark a particular value in the dataset.- Parameters:
index- the value index (zero-based).shape- the shape (nullnot permitted).
-
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.
-
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.
-
getRangePaint
public java.awt.Paint getRangePaint()
Returns the paint used to highlight the range.- Returns:
- A
Paintobject (nevernull).
-
setRangePaint
public void setRangePaint(java.awt.Paint paint)
Sets the paint used to highlight the range (if one is specified).- Parameters:
paint- the paint (nullnot permitted).
-
getBorderPaint
public java.awt.Paint getBorderPaint()
-
setBorderPaint
public void setBorderPaint(java.awt.Paint borderPaint)
-
getDefaultShape
public java.awt.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.
-
setDefaultShape
public void setDefaultShape(java.awt.Shape defaultShape)
Redefines the default shape.- Parameters:
defaultShape- the default shape- Throws:
java.lang.NullPointerException- if the given shape is null.
-
getTickMarkPaint
public java.awt.Paint getTickMarkPaint()
-
setTickMarkPaint
public void setTickMarkPaint(java.awt.Paint tickMarkPaint)
-
getValues
public java.lang.Number[] getValues()
-
getFillPaint
public java.awt.Paint getFillPaint()
-
setFillPaint
public void setFillPaint(java.awt.Paint fillPaint)
-
getOutlineStroke
public java.awt.Stroke getOutlineStroke()
-
setOutlineStroke
public void setOutlineStroke(java.awt.Stroke outlineStroke)
-
getUpperMargin
public double getUpperMargin()
-
setUpperMargin
public void setUpperMargin(double upperMargin)
-
getLowerMargin
public double getLowerMargin()
-
setLowerMargin
public void setLowerMargin(double lowerMargin)
-
draw
public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)Draws the survey scale.- Parameters:
g2- the graphics device.area- the area.
-
drawValues
protected void drawValues(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
-
drawScaleValues
protected void drawScaleValues(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
-
drawTickMarks
protected void drawTickMarks(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
-
drawRangeArea
protected void drawRangeArea(java.awt.geom.Rectangle2D area, java.awt.Graphics2D g2)
-
drawBorder
protected void drawBorder(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
-
-