Class SurveyScale
java.lang.Object
org.jfree.report.modules.misc.survey.SurveyScale
- All Implemented Interfaces:
Serializable
Draws a survey scale. By implementing the Drawable interface, instances can be displayed within a report using the
DrawableElement class.
- Author:
- David Gilbert
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new default instance.SurveyScale
(int lowest, int highest, Number[] values) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic Shape
createDiamond
(float s) Creates a diamond shape.static Shape
createDownTriangle
(float s) Creates a triangle shape that points downwards.protected ArrayList
Creates the shape list used when drawing the scale.static Shape
createUpTriangle
(float s) Creates a triangle shape that points upwards.void
draw
(Graphics2D g2, Rectangle2D area) Draws the survey scale.protected void
drawBorder
(Graphics2D g2, Rectangle2D area) protected void
drawRangeArea
(Rectangle2D area, Graphics2D g2) protected void
drawScaleValues
(Graphics2D g2, Rectangle2D area) protected void
drawTickMarks
(Graphics2D g2, Rectangle2D area) protected void
drawValues
(Graphics2D g2, Rectangle2D area) Returns the default shape, which is used, if a shape for a certain value is not defined.int
protected double
double
int
protected int
getRange()
Returns the lower bound of the highlighted range.Returns the paint used to highlight the range.Returns the upper bound of the highlighted range.Returns the font used to display the scale values.Returns the color used to draw the scale values (if they are visible).getShape
(int index) Returns the shape used to indicate the value of a response.protected double
double
Number[]
boolean
boolean
Returns a flag that controls whether or not a border is drawn around the scale.boolean
Returns a flag that controls whether or not scale values are drawn.boolean
Returns the flag that controls whether the tick marks are drawn.boolean
isShapeFilled
(int index) Returns a flag that controls whether the shape for a particular value should be filled.protected void
This method is called whenever lowest or highest has changed.void
setAutoConfigure
(boolean autoConfigure) void
setBorderPaint
(Paint borderPaint) void
setDefaultShape
(Shape defaultShape) Redefines the default shape.void
setDrawBorder
(boolean flag) Sets a flag that controls whether or not a border is drawn around the scale.void
setDrawScaleValues
(boolean flag) Sets a flag that controls whether or not scale values are drawn.void
setDrawTickMarks
(boolean flag) Sets the flag that controls whether the tick marks are drawn.void
setFillPaint
(Paint fillPaint) void
setHighest
(int highest) protected void
setLowerBound
(double lowerBound) void
setLowerMargin
(double lowerMargin) void
setLowest
(int lowest) void
setOutlineStroke
(Stroke outlineStroke) protected void
setRange
(int range) void
setRangeLowerBound
(Number bound) Sets the lower bound for the range that is highlighted on the scale.void
setRangePaint
(Paint paint) Sets the paint used to highlight the range (if one is specified).void
setRangeUpperBound
(Number bound) Sets the upper bound for the range that is highlighted on the scale.void
setScaleValueFont
(Font font) Sets the font used to display the scale values.void
setScaleValuePaint
(Paint paint) Sets the color used to draw the scale values.void
Sets the shape used to mark a particular value in the dataset.void
setShapeFilled
(int index, boolean fill) Sets the flag that controls whether the shape for a particular value should be filled.void
setTickMarkPaint
(Paint tickMarkPaint) protected void
setUpperBound
(double upperBound) void
setUpperMargin
(double upperMargin)
-
Constructor Details
-
SurveyScale
public SurveyScale()Creates a new default instance. -
SurveyScale
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 Details
-
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
Creates the shape list used when drawing the scale. The list returned must contain exactly 6 elements.- Returns:
-
createDiamond
Creates a diamond shape.- Parameters:
s
- the size factor (equal to half the height of the diamond).- Returns:
- A diamond shape.
-
createUpTriangle
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
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
Returns the lower bound of the highlighted range. Anull
value indicates that no range is set for highlighting.- Returns:
- The lower bound (possibly
null
).
-
setRangeLowerBound
Sets the lower bound for the range that is highlighted on the scale.- Parameters:
bound
- the lower bound (null
permitted).
-
getRangeUpperBound
Returns the upper bound of the highlighted range. Anull
value indicates that no range is set for highlighting.- Returns:
- The upper bound (possibly
null
).
-
setRangeUpperBound
Sets the upper bound for the range that is highlighted on the scale.- Parameters:
bound
- the upper bound (null
permitted).
-
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
Returns the font used to display the scale values.- Returns:
- A font (never
null
).
-
setScaleValueFont
Sets the font used to display the scale values.- Parameters:
font
- the font (null
not permitted).
-
getScaleValuePaint
Returns the color used to draw the scale values (if they are visible).- Returns:
- A paint (never
null
).
-
setScaleValuePaint
Sets the color used to draw the scale values.- Parameters:
paint
- the paint (null
not permitted).
-
getShape
Returns the shape used to indicate the value of a response.- Parameters:
index
- the value index (zero-based).- Returns:
- The shape.
-
setShape
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).
-
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
Returns the paint used to highlight the range.- Returns:
- A
Paint
object (nevernull
).
-
setRangePaint
Sets the paint used to highlight the range (if one is specified).- Parameters:
paint
- the paint (null
not permitted).
-
getBorderPaint
-
setBorderPaint
-
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
Redefines the default shape.- Parameters:
defaultShape
- the default shape- Throws:
NullPointerException
- if the given shape is null.
-
getTickMarkPaint
-
setTickMarkPaint
-
getValues
-
getFillPaint
-
setFillPaint
-
getOutlineStroke
-
setOutlineStroke
-
getUpperMargin
public double getUpperMargin() -
setUpperMargin
public void setUpperMargin(double upperMargin) -
getLowerMargin
public double getLowerMargin() -
setLowerMargin
public void setLowerMargin(double lowerMargin) -
draw
Draws the survey scale.- Parameters:
g2
- the graphics device.area
- the area.
-
drawValues
-
drawScaleValues
-
drawTickMarks
-
drawRangeArea
-
drawBorder
-