lt.monarch.chart.chart2D.series
Class PieStrategy<ChartProjector extends Projector>

java.lang.Object
  extended by lt.monarch.chart.chart2D.series.PieStrategy<ChartProjector>
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Pie3DStrategy

public class PieStrategy<ChartProjector extends Projector>
extends java.lang.Object
implements java.io.Serializable

Pie series drawing strategy.

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
protected  boolean dirty
          True, if dirty, otherwise -false
protected  LegendEntry[] entries
           
protected  boolean explodeAndShrink
           
protected  double innerRadius
           
protected  int labelAreaMultiplier
          Specifies label area multiplier (used for pie resize and leave label area, pie size is resized by multiplier * series label font size)
protected  PieLabelFormat labelFormat
           
protected  java.lang.String labelFormatPattern
           
protected  double labelMargin
           
protected  PieLegendFormat legendFormat
           
protected  java.lang.String legendFormatPattern
           
protected  java.util.Locale locale
           
protected  PlaneMapper mapper
          Plane mapper
protected  double maxExplodeRadius
           
protected  MetaDataModel metaModel
          Meta data model
protected  double minExplodeRadius
           
protected  java.util.Map<DataColumnType,MinMaxValues> minMaxValues
          Minimum and Maximum values
protected  ArrayDataModel model
          Series data model
protected  Point2D np
           
protected  int numbersLabelPrecision
          Specifies number precision for series labels
protected  int numbersLegendPrecision
          Specifies number precision for series labels
protected  double overallAngle
           
protected  double overallRadius
           
protected  Point2D p1
           
protected  Point2D p2
           
protected  PaintMode paintMode
          Paint mode of the series
protected  java.lang.Double[] percentages
           
protected  Point2D planePoint
          Template point for mapping plane
protected  Projector projector
          Point projector
protected  double shrinkRadius
           
protected  java.util.ArrayList<ChartElementEntity> sliceElements
           
protected  double startAngle
           
protected  Style style
          Style of series
protected  GeneralPoint tempPoint
          Template point for projecting points
protected  java.lang.Double[] values
           
 
Constructor Summary
Constructor and Description
PieStrategy()
          Pie strategy constructor
 
Method Summary
Modifier and Type Method and Description
protected  double calculateShrink()
           
 void calculateValuesAndPercentages(ArrayDataModel model)
          Calculating values and percentages values of pie
protected  java.lang.String convertToString(java.lang.Double value, int precision, java.util.Locale local)
           
 LegendEntry[] createLegendEntries(ArrayDataModel model, MetaDataModel metaModel, Style style)
          Create legend entries list
 void dispose()
           
 void draw(AbstractGraphics g, ChartProjector projector, PlaneMapper mapper, HotSpotMap hotMap, Style style, PieSeries series)
           
protected  void drawLabels(AbstractGraphics g, ChartProjector projector, HotSpotMap hotMap, Style style, PieSeries series)
           
protected  void drawPie(AbstractGraphics g, ChartProjector projector, PlaneMapper mapper, HotSpotMap hotMap, Style style, PieSeries series)
           
protected  void finalize()
           
protected  void fixStyles()
           
 Point2D getCenterPoint()
          Returns the center of pie
 double getInnerRadius()
          Returns the Doughnut inner radius.
 int getLabelAreaMultiplier()
          Returns label area multiplier (used for pie resize and leave label area, pie size is resized by multiplier * series label font size)
 PieLabelFormat getLabelFormat()
          Return label format
 java.lang.String getLabelFormatPattern()
          Return label format
protected  java.lang.String getLabelText(double value, double percent, java.lang.String sliceTitle)
          Return slices label text
 PieLegendFormat getLegendFormat()
          Return legend format
 java.lang.String getLegendFormatPattern()
          Returns legend format pattern
protected  java.lang.String getLegendText(double value, double percent, java.lang.String sliceTitle)
          Return slices legend text
 java.util.Locale getLocale()
          Return locale of charts
 java.util.Map<DataColumnType,MinMaxValues> getMinMaxValues()
          Gets the minMaxValues value
 int getNumbersLabelPrecision()
          Gets precision of labels values floating point numbers.
 int getNumbersLegendPrecision()
          Gets precision of legend values floating point numbers.
 double getOverallAngle()
          Returns the pie angle, how much angle the pie should occupy
 double getRadius()
          Returns pie series radius.
 Point2D getSliceHalfPoint(int index, double radius)
          Calculate point half angle of slice
 double getStartAngle()
          Returns slice start angle of pie chart segment
protected  void initMinMaxValues()
          Initializes minimum and maximum values
protected  Point2D projectPoint(Projector projector, GeneralPoint ptt, Point2D planePoint, double x, double y)
          Projects the point
 void setCenterPoint(GeneralPoint centerPoint)
          Set center of pie chart
 void setExplodeAndShrink(boolean flag)
          Set explode and shrink
 void setInnerRadius(double radius)
          Sets the Doughnut inner radius.
 void setLabelAreaMultiplier(int labelAreaMultiplier)
          Specifies label area multiplier (used for pie resize and leave label area, pie size is resized by multiplier * series label font size)
 void setLabelFormat(PieLabelFormat labelFormat)
          Set label format
 void setLabelFormatPattern(java.lang.String labelFormatPattern)
          Set pattern of label format Examples: "%1$.2f, %2$.0f%%, %3$s" 1 - value, 2 - percent, 3 - slice name
 void setLegendFormat(PieLegendFormat legendFormat)
          Set legend format
 void setLegendFormatPattern(java.lang.String legendFormatPattern)
          Set pattern of legend format Examples: "%1$.2f, %2$.0f%%, %3$s" 1 - value, 2 - percent, 3 - slice name
 void setLocale(java.util.Locale locale)
          Set locale of chart
 void setNumbersLabelPrecision(int numbersLabelPrecision)
          Sets floating point numbers precision in the label values.
 void setNumbersLegendPrecision(int numbersLegendPrecision)
          Sets floating point numbers precision in the legend values.
 void setOverallAngle(double angle)
          Specifies the pie angle, how much angle the pie should occupy.
 void setRadius(double radius)
          Sets pie series radius.
 void setStartAngle(double angle)
          Sets start angle of pie chart segment.
protected  double sumAllValues()
           
protected  void updateLegendStyle()
          Update legend style of legend symbol
protected  void validateExplodeData()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

protected ArrayDataModel model
Series data model


metaModel

protected MetaDataModel metaModel
Meta data model


mapper

protected PlaneMapper mapper
Plane mapper


style

protected Style style
Style of series


tempPoint

protected GeneralPoint tempPoint
Template point for projecting points


planePoint

protected Point2D planePoint
Template point for mapping plane


projector

protected Projector projector
Point projector


paintMode

protected PaintMode paintMode
Paint mode of the series


dirty

protected boolean dirty
True, if dirty, otherwise -false


minMaxValues

protected java.util.Map<DataColumnType,MinMaxValues> minMaxValues
Minimum and Maximum values


innerRadius

protected double innerRadius

overallRadius

protected double overallRadius

shrinkRadius

protected double shrinkRadius

explodeAndShrink

protected boolean explodeAndShrink

minExplodeRadius

protected double minExplodeRadius

maxExplodeRadius

protected double maxExplodeRadius

labelMargin

protected double labelMargin

labelFormat

protected PieLabelFormat labelFormat

legendFormat

protected PieLegendFormat legendFormat

locale

protected java.util.Locale locale

values

protected java.lang.Double[] values

percentages

protected java.lang.Double[] percentages

overallAngle

protected double overallAngle

startAngle

protected double startAngle

entries

protected LegendEntry[] entries

p1

protected Point2D p1

p2

protected Point2D p2

np

protected Point2D np

labelFormatPattern

protected java.lang.String labelFormatPattern

legendFormatPattern

protected java.lang.String legendFormatPattern

numbersLabelPrecision

protected int numbersLabelPrecision
Specifies number precision for series labels


numbersLegendPrecision

protected int numbersLegendPrecision
Specifies number precision for series labels


sliceElements

protected java.util.ArrayList<ChartElementEntity> sliceElements

labelAreaMultiplier

protected int labelAreaMultiplier
Specifies label area multiplier (used for pie resize and leave label area, pie size is resized by multiplier * series label font size)

Constructor Detail

PieStrategy

public PieStrategy()
Pie strategy constructor

Method Detail

initMinMaxValues

protected void initMinMaxValues()
Initializes minimum and maximum values


dispose

public void dispose()

drawPie

protected void drawPie(AbstractGraphics g,
                       ChartProjector projector,
                       PlaneMapper mapper,
                       HotSpotMap hotMap,
                       Style style,
                       PieSeries series)

drawLabels

protected void drawLabels(AbstractGraphics g,
                          ChartProjector projector,
                          HotSpotMap hotMap,
                          Style style,
                          PieSeries series)

draw

public void draw(AbstractGraphics g,
                 ChartProjector projector,
                 PlaneMapper mapper,
                 HotSpotMap hotMap,
                 Style style,
                 PieSeries series)

sumAllValues

protected double sumAllValues()

validateExplodeData

protected void validateExplodeData()

calculateShrink

protected double calculateShrink()

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

projectPoint

protected Point2D projectPoint(Projector projector,
                               GeneralPoint ptt,
                               Point2D planePoint,
                               double x,
                               double y)
Projects the point

Parameters:
projector - projector
ptt - template point
planePoint - template point to map plane coordinates
x - x coordinate to map
y - y coordinate to map

getMinMaxValues

public java.util.Map<DataColumnType,MinMaxValues> getMinMaxValues()
Gets the minMaxValues value

Returns:
the minMaxValues value

setInnerRadius

public void setInnerRadius(double radius)
Sets the Doughnut inner radius.

Parameters:
radius - doughnut inner radius (in range [0, 0.5]).

getInnerRadius

public double getInnerRadius()
Returns the Doughnut inner radius.

Returns:
Doughnut inner radius.

setRadius

public void setRadius(double radius)
Sets pie series radius.

Parameters:
radius - radius of pie series in range [0,0.5]

getRadius

public double getRadius()
Returns pie series radius.

Returns:
pie radius.

setStartAngle

public void setStartAngle(double angle)
Sets start angle of pie chart segment.

Parameters:
angle - angle [0; 360]

getStartAngle

public double getStartAngle()
Returns slice start angle of pie chart segment

Returns:
startAngle

setOverallAngle

public void setOverallAngle(double angle)
Specifies the pie angle, how much angle the pie should occupy. Default value is 360 degrees.

Parameters:
angle - angle [0; 360]

getOverallAngle

public double getOverallAngle()
Returns the pie angle, how much angle the pie should occupy

Returns:
startAngle

setCenterPoint

public void setCenterPoint(GeneralPoint centerPoint)
Set center of pie chart

Parameters:
centerPoint - point of the center the pie

getCenterPoint

public Point2D getCenterPoint()
Returns the center of pie

Returns:
Point2D center of pie

getSliceHalfPoint

public Point2D getSliceHalfPoint(int index,
                                 double radius)
Calculate point half angle of slice

Parameters:
index -
radius - radius of pie
Returns:
point of half angle

setExplodeAndShrink

public void setExplodeAndShrink(boolean flag)
Set explode and shrink

Parameters:
flag - true, if explode and shrink, otherwise explode, but not shrink

createLegendEntries

public LegendEntry[] createLegendEntries(ArrayDataModel model,
                                         MetaDataModel metaModel,
                                         Style style)
Create legend entries list

Parameters:
model - data model
metaModel - meta data model
style - style of pie charts
Returns:
list of legend entries

updateLegendStyle

protected void updateLegendStyle()
Update legend style of legend symbol


setLabelFormat

public void setLabelFormat(PieLabelFormat labelFormat)
Set label format

Parameters:
labelFormat - the labelFormat to set

getLabelFormat

public PieLabelFormat getLabelFormat()
Return label format

Returns:
the label format

getLabelFormatPattern

public java.lang.String getLabelFormatPattern()
Return label format

Returns:
the label format

setLabelFormatPattern

public void setLabelFormatPattern(java.lang.String labelFormatPattern)
Set pattern of label format Examples: "%1$.2f, %2$.0f%%, %3$s" 1 - value, 2 - percent, 3 - slice name

Parameters:
labelFormatPattern - the labelFormatPattern to set

getLegendFormatPattern

public java.lang.String getLegendFormatPattern()
Returns legend format pattern

Returns:
the legendFormatPattern

setLegendFormatPattern

public void setLegendFormatPattern(java.lang.String legendFormatPattern)
Set pattern of legend format Examples: "%1$.2f, %2$.0f%%, %3$s" 1 - value, 2 - percent, 3 - slice name

Parameters:
legendFormatPattern - the legendFormatPattern to set

getLegendFormat

public PieLegendFormat getLegendFormat()
Return legend format

Returns:
the legendFormat

setLegendFormat

public void setLegendFormat(PieLegendFormat legendFormat)
Set legend format

Parameters:
legendFormat - the legendFormat to set

getLocale

public java.util.Locale getLocale()
Return locale of charts

Returns:
the locale

setLocale

public void setLocale(java.util.Locale locale)
Set locale of chart

Parameters:
locale - the locale to set

getLabelText

protected java.lang.String getLabelText(double value,
                                        double percent,
                                        java.lang.String sliceTitle)
Return slices label text

Parameters:
value - value of slice
percent - percentage value of slices
sliceTitle - slice name
Returns:
label text

getLegendText

protected java.lang.String getLegendText(double value,
                                         double percent,
                                         java.lang.String sliceTitle)
Return slices legend text

Parameters:
value - value of slice
percent - percentage value of slices
sliceTitle - slice name
Returns:
legend text

convertToString

protected java.lang.String convertToString(java.lang.Double value,
                                           int precision,
                                           java.util.Locale local)
Parameters:
value -
precision - precision of value
local - locale of chart
Returns:
converted value

calculateValuesAndPercentages

public void calculateValuesAndPercentages(ArrayDataModel model)
Calculating values and percentages values of pie

Parameters:
model - data model

getNumbersLabelPrecision

public int getNumbersLabelPrecision()
Gets precision of labels values floating point numbers.

Returns:
precision of chart's floating point numbers

setNumbersLabelPrecision

public void setNumbersLabelPrecision(int numbersLabelPrecision)
Sets floating point numbers precision in the label values. If precision is negative then precision will be set to 0.

Parameters:
numbersLabelPrecision - precision of floating point numbers.

getNumbersLegendPrecision

public int getNumbersLegendPrecision()
Gets precision of legend values floating point numbers.

Returns:
precision of chart's floating point numbers

setNumbersLegendPrecision

public void setNumbersLegendPrecision(int numbersLegendPrecision)
Sets floating point numbers precision in the legend values. If precision is negative then precision will be set to 0.

Parameters:
numbersLegendPrecision - precision of floating point numbers.

fixStyles

protected void fixStyles()

setLabelAreaMultiplier

public void setLabelAreaMultiplier(int labelAreaMultiplier)
Specifies label area multiplier (used for pie resize and leave label area, pie size is resized by multiplier * series label font size)

Parameters:
labelAreaMultiplier - label area multiplier

getLabelAreaMultiplier

public int getLabelAreaMultiplier()
Returns label area multiplier (used for pie resize and leave label area, pie size is resized by multiplier * series label font size)

Returns:
label area multiplier