org.pentaho.reporting.engine.classic.core.modules.misc.survey
Class SurveyScale

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.modules.misc.survey.SurveyScale
All Implemented Interfaces:
Serializable, ReportDrawable

public class SurveyScale
extends Object
implements ReportDrawable, 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:
Serialized Form

Constructor Summary
SurveyScale()
          Creates a new default instance.
SurveyScale(int lowest, int highest, Number[] values)
          Creates a new instance.
 
Method Summary
static Shape createDiamond(float s)
          Creates a diamond shape.
static Shape createDownTriangle(float s)
          Creates a triangle shape that points downwards.
static Shape createUpTriangle(float s)
          Creates a triangle shape that points upwards.
 void draw(Graphics2D g2, Rectangle2D area)
          Draws the survey scale.
 Paint getBorderPaint()
           
 Shape getDefaultShape()
          Returns the default shape, which is used, if a shape for a certain value is not defined.
 Paint getFillPaint()
           
 int getHighest()
           
 ImageMap getImageMap(Rectangle2D bounds)
          Returns an optional image-map for the entry.
 double getLowerMargin()
           
 int getLowest()
           
 Stroke getOutlineStroke()
           
 Number getRangeLowerBound()
          Returns the lower bound of the highlighted range.
 Paint getRangePaint()
          Returns the paint used to highlight the range.
 Number getRangeUpperBound()
          Returns the upper bound of the highlighted range.
 Font getScaleValueFont()
          Returns the font used to display the scale values.
 Paint getScaleValuePaint()
          Returns the color used to draw the scale values (if they are visible).
 Shape getShape(int index)
          Returns the shape used to indicate the value of a response.
 StyleSheet getStyleSheet()
           
 Paint getTickMarkPaint()
           
 double getUpperMargin()
           
 Number[] getValues()
           
 boolean isAutoConfigure()
           
 boolean isDrawBorder()
          Returns a flag that controls whether or not a border is drawn around the scale.
 boolean isDrawScaleValues()
          Returns a flag that controls whether or not scale values are drawn.
 boolean isDrawTickMarks()
          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.
 void setAutoConfigure(boolean autoConfigure)
           
 void setBorderPaint(Paint borderPaint)
           
 void setConfiguration(org.pentaho.reporting.libraries.base.config.Configuration config)
          Provides the current report configuration of the current report process to the drawable.
 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)
           
 void setLayoutSupport(LayoutSupport layoutSupport)
          Provides the Layout-Support of the current report processor to the drawable.
 void setLowerMargin(double lowerMargin)
           
 void setLowest(int lowest)
           
 void setOutlineStroke(Stroke outlineStroke)
           
 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 setResourceBundleFactory(ResourceBundleFactory bundleFactory)
          Defines the resource-bundle factory that can be used to localize the drawing process.
 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 setShape(int index, Shape shape)
          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 setStyleSheet(StyleSheet style)
          Provides the computed stylesheet of the report element that contained this drawable.
 void setTickMarkPaint(Paint tickMarkPaint)
           
 void setUpperMargin(double upperMargin)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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)

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.

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.

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.

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).

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).

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).

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).

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 Font getScaleValueFont()
Returns the font used to display the scale values.

Returns:
A font (never null).

setScaleValueFont

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

Parameters:
font - the font (null not permitted).

getScaleValuePaint

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

Returns:
A paint (never null).

setScaleValuePaint

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

Parameters:
paint - the paint (null not permitted).

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.

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).

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 Paint getRangePaint()
Returns the paint used to highlight the range.

Returns:
A Paint object (never null).

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).

getBorderPaint

public Paint getBorderPaint()

setBorderPaint

public void setBorderPaint(Paint borderPaint)

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.

setDefaultShape

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

Parameters:
defaultShape - the default shape
Throws:
NullPointerException - if the given shape is null.

getTickMarkPaint

public Paint getTickMarkPaint()

setTickMarkPaint

public void setTickMarkPaint(Paint tickMarkPaint)

getValues

public Number[] getValues()

getFillPaint

public Paint getFillPaint()

setFillPaint

public void setFillPaint(Paint fillPaint)

getOutlineStroke

public Stroke getOutlineStroke()

setOutlineStroke

public void setOutlineStroke(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(Graphics2D g2,
                 Rectangle2D area)
Draws the survey scale.

Specified by:
draw in interface ReportDrawable
Parameters:
g2 - the graphics device.
area - the area.

setLayoutSupport

public void setLayoutSupport(LayoutSupport layoutSupport)
Provides the Layout-Support of the current report processor to the drawable. The layout-support can be used to compute text-layouts.

Parameters:
layoutSupport - the layout support.

setConfiguration

public void setConfiguration(org.pentaho.reporting.libraries.base.config.Configuration config)
Provides the current report configuration of the current report process to the drawable. The report configuration can be used to configure the drawing process through the report.

Specified by:
setConfiguration in interface ReportDrawable
Parameters:
config - the report configuration.

setStyleSheet

public void setStyleSheet(StyleSheet style)
Provides the computed stylesheet of the report element that contained this drawable. The stylesheet is immutable.

Specified by:
setStyleSheet in interface ReportDrawable
Parameters:
style - the stylesheet.

getStyleSheet

public StyleSheet getStyleSheet()

setResourceBundleFactory

public void setResourceBundleFactory(ResourceBundleFactory bundleFactory)
Defines the resource-bundle factory that can be used to localize the drawing process.

Specified by:
setResourceBundleFactory in interface ReportDrawable
Parameters:
bundleFactory - the resource-bundle factory.

getImageMap

public ImageMap getImageMap(Rectangle2D bounds)
Description copied from interface: ReportDrawable
Returns an optional image-map for the entry.

Specified by:
getImageMap in interface ReportDrawable
Parameters:
bounds - the bounds for which the image map is computed.
Returns:
the computed image-map or null if there is no image-map available.