|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.davisor.graphics.chart.ChartFactory.ChartMetrics
ChartMetrics provides common interface for all chart factories to store chart and chart component size information, and to resize charts. The minimum information metrics required from all chart types is the physical size of the chart rendering.
All charts must use a metrics object derived from this class, as
ChartMetrics is the principal interface through which different
combination charts like LayoutFactory and ComboFactory interact and organize their children. A failure to
implement a chart type specific metrics object and in particular
propert implementations for scale(int, float) and scaleToSize(java.lang.Number, java.lang.Number) methods will make those chart types incompatible
with combination charts.
Chart metrics stores chart size in two separate member variables
and provides corresponding separate accessor methods for both of
them. This is the typical arrangement in traditional API
design. Many chart factory operations are however identical to
both horizontal (X) and vertical (Y) dimensions. In these cases,
it is important to be able to parmetrise the dimension that is
being accessed. For this reason, chart metrics provides also
indexable accessor methods like getSize(int) for chart
size variables.
getWidth(),
getHeight(),
getSize(int),
ChartFactory.ChartContext| Field Summary | |
protected float |
M_height
Chart height, stricly within chart boundary line. |
protected float |
M_width
Chart width, stricly within chart boundary line. |
| Constructor Summary | |
ChartFactory.ChartMetrics(float width,
float height)
Creates new chart metrics. |
|
| Method Summary | |
void |
add(int dim,
float term)
Adds term to given size component. |
float |
getHeight()
Gets the chart height. |
float |
getSize(int dim)
Gets the chart size component. |
float |
getWidth()
Gets the chart width. |
void |
scale(float xFactor,
float yFactor)
Scales all metrics components. |
void |
scale(int dim,
float factor)
Scales given size component. |
void |
scaleToSize(java.lang.Number width,
java.lang.Number height)
Scales the metrics to make the chart meet given new size. |
void |
setHeight(float height)
Sets the chart height. |
void |
setSize(int dim,
float size)
Sets the chart size component. |
void |
setWidth(float width)
Sets the chart width. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected float M_width
protected float M_height
| Constructor Detail |
public ChartFactory.ChartMetrics(float width,
float height)
width - chart width, in millimetersheight - chart height, in millimeters| Method Detail |
public void add(int dim,
float term)
dim - dimension index (X or Y)term - sum termscale(int,float)public float getHeight()
setHeight(float)public float getSize(int dim)
dim - dimension index (X or Y)getWidth(),
getHeight(),
setSize(int,float)public float getWidth()
setWidth(float)
public void scale(int dim,
float factor)
dim - dimension index (X or Y)factor - scaling factoradd(int,float)
public void scale(float xFactor,
float yFactor)
This default implementation scales current chart size with the given scalar factors. Sub-classes are expected to override this method with implementations that scale all sub-class specific metrics components, too.
xFactor - horizontal scaling factoryFactor - vertical scaling factor
public void scaleToSize(java.lang.Number width,
java.lang.Number height)
This method is used is particular when charts are laid out with
LayoutFactory and other similar tools. For this reason,
the implementations of this method are expected to rescale the
chart in some intelligent, optimal way, better that the
following equivivalent but propably non-optimal linear scaling:
Optimal chart scaling does not need to be linear with respect of chart internal components. Instead, areas that hold text should not become overly large or small. If neccessary, charts should recompute their entire metrics information if they can't otherwise produce optimal results.
This default implementation replaces current size components
with not null given components. Sub-classes are
expected to override this method with implementations that
scale all sub-class specific metrics components, too.
width - new chart width (may be null = keep the old width)height - new chart height (may be null = keep the old height)getSize(int)public void setHeight(float height)
height - new chart heightgetHeight()
public void setSize(int dim,
float size)
dim - dimension index (X or Y)getSize(int)public void setWidth(float width)
width - new chart widthgetWidth()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||