com.davisor.graphics.chart
Class PieFactory.PieMetrics

java.lang.Object
  extended bycom.davisor.graphics.chart.ChartFactory.ChartMetrics
      extended bycom.davisor.graphics.chart.PieFactory.PieMetrics
Enclosing class:
PieFactory

public class PieFactory.PieMetrics
extends ChartFactory.ChartMetrics

PieMetrics contains calculated values for size variables needed when drawing the pie.

Unlike typical metrics, pie metrics need to remember the context they we created with so that they can reread values from there if the metrics ever needs to be recalculated.

See Also:
PieFactory.PieMetrics

Field Summary
 float centerX
          Pie center.
 float centerY
          Pie center.
protected  PieFactory.PieContext context
          Reference to the context this metrics was created with.
 java.awt.Font font
          Value label font
 float offset
          Horizontal offset between slice and label
 float r
          radius
 java.util.List slices
          Pie slices with exact coordinates and render information.
 
Fields inherited from class com.davisor.graphics.chart.ChartFactory.ChartMetrics
M_height, M_width
 
Constructor Summary
PieFactory.PieMetrics(PieFactory.PieContext context)
          Creates new pie metrics.
 
Method Summary
 void scale(float xFactor, float yFactor)
          Apply linear scaling to the image.
 void scaleToSize(java.lang.Number width, java.lang.Number height)
          Scales the metrics to make the chart meet given new size.
 
Methods inherited from class com.davisor.graphics.chart.ChartFactory.ChartMetrics
add, getHeight, getSize, getWidth, scale, setHeight, setSize, setWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected PieFactory.PieContext context
Reference to the context this metrics was created with.


font

public java.awt.Font font
Value label font


centerX

public float centerX
Pie center.


centerY

public float centerY
Pie center.


r

public float r
radius


offset

public float offset
Horizontal offset between slice and label


slices

public java.util.List slices
Pie slices with exact coordinates and render information.

Constructor Detail

PieFactory.PieMetrics

public PieFactory.PieMetrics(PieFactory.PieContext context)
Creates new pie metrics.

Parameters:
context - the context this metrics was created with
Method Detail

scale

public void scale(float xFactor,
                  float yFactor)
Apply linear scaling to the image. Affects to all measurements.

Overrides:
scale in class ChartFactory.ChartMetrics
Parameters:
xFactor - horizontal scaling factor
yFactor - vertical scaling factor

scaleToSize

public void scaleToSize(java.lang.Number width,
                        java.lang.Number height)
Scales the metrics to make the chart meet given new size. The old width or height is kept if if a coresponding new value is not given.

Rescaling a pie is a troublesome operation, in particular because pie labels do not scale linearly. Instead, we have to recompute the entire metrics again agains the given new chart size constrains.

Overrides:
scaleToSize in class ChartFactory.ChartMetrics
Parameters:
width - new chart width (may be null = keep the old width)
height - new chart height (may be null = keep the old height)
See Also:
ChartFactory.ChartMetrics.getSize(int), PieFactory.createMetrics(PieFactory.PieContext,Number,Number)


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.