com.davisor.graphics.chart
Class LineFactory

java.lang.Object
  extended bycom.davisor.graphics.chart.ChartFactory
      extended bycom.davisor.graphics.chart.AxisFactory
          extended bycom.davisor.graphics.chart.ShapeFactory
              extended bycom.davisor.graphics.chart.LineFactory
All Implemented Interfaces:
com.davisor.core.Dupable, com.davisor.core.MIMETypes, com.davisor.core.Public
Direct Known Subclasses:
AreaFactory

public class LineFactory
extends ShapeFactory

LineFactory implements a line chart producer that can make polyline charts from one-dimensional multichannel data.

This factory inherits all of it's attribute and data operation logic from AxisFactory superclass, and most of it's rendering logic from ShapeFactory superclass. In fact, this class implements itself only some low-level rendering methods that lay out shape chart visual elements in a way suitable for line charts. Please see AxisFactory documentation for more information about what kind of data and attributes this factory accepts.

Line factory 3D lines are rendered using painter's algorithm and simple isometric projection. This imposes certain limitations of what kind of lines can be rendered in 3D:

Implementation information

Line charts use the following shape chart behaviour controls:

Since:
JDK1.2
See Also:
ChartAttributes, ChartData, ColumnBarFactory, PieFactory, RowBarFactory, ScatterFactory

Nested Class Summary
 
Nested classes inherited from class com.davisor.graphics.chart.ShapeFactory
ShapeFactory.ShapeContext
 
Nested classes inherited from class com.davisor.graphics.chart.AxisFactory
AxisFactory.AxisContext, AxisFactory.AxisMetrics
 
Nested classes inherited from class com.davisor.graphics.chart.ChartFactory
ChartFactory.ChartContext, ChartFactory.ChartMetrics
 
Field Summary
 
Fields inherited from class com.davisor.graphics.chart.ShapeFactory
BELOW, CENTER, LEFT, OVER, RIGHT
 
Fields inherited from class com.davisor.graphics.chart.AxisFactory
DEFAULTLABELTYPE, FLIPX, FLIPY, MAJORMARGIN, MINORMARGIN, MINSIZE
 
Fields inherited from class com.davisor.graphics.chart.ChartFactory
ALL, BRIGHT, CHANNEL, COS, DARK, DOTSEQUENCE, DOTSTROKE, DOTSTROKEWIDTH, DUMPFACTORYNAME, ENCODERINFO, FONT, FRC, HAS_3D, I, LABEL, LABELFIELDNAMES, LABELFIELDS, MIME_DEFAULT, NONE, NORMAL, NULLSTROKE, PERCENT, PI2, SHAPE, SIN, STROKE, STROKEWIDTH, TIC, VALUE, X, Y, Z
 
Fields inherited from interface com.davisor.core.MIMETypes
FILETYPE_BMP, FILETYPE_CSS, FILETYPE_DOC, FILETYPE_ECMA, FILETYPE_GIF, FILETYPE_HTML, FILETYPE_HTML_CSS, FILETYPE_INDEX, FILETYPE_INDEX_DOC, FILETYPE_INDEX_HTML, FILETYPE_INDEX_HTML_CSS, FILETYPE_INDEX_PDF, FILETYPE_INDEX_PPT, FILETYPE_INDEX_SVG, FILETYPE_INDEX_XHTML, FILETYPE_INDEX_XLS, FILETYPE_INDEX_XMSE, FILETYPE_INDEX_XMSP, FILETYPE_INDEX_XMSW, FILETYPE_INDEX_XSLFO, FILETYPE_JPEG, FILETYPE_PDF, FILETYPE_PNG, FILETYPE_PNG_WBMP, FILETYPE_PPM, FILETYPE_PPT, FILETYPE_SVG, FILETYPE_TEXT, FILETYPE_WBMP, FILETYPE_XHTML, FILETYPE_XLS, FILETYPE_XML, FILETYPE_XMSE, FILETYPE_XMSP, FILETYPE_XMSW, FILETYPE_XSLFO, FILETYPE_XSLFO_CSS, MIME_BMP, MIME_CSS, MIME_DOC, MIME_ECMA, MIME_GIF, MIME_HTML, MIME_HTML_CSS, MIME_INDEX, MIME_INDEX_DOC, MIME_INDEX_HTML, MIME_INDEX_HTML_CSS, MIME_INDEX_PDF, MIME_INDEX_PPT, MIME_INDEX_SVG, MIME_INDEX_XHTML, MIME_INDEX_XLS, MIME_INDEX_XMSE, MIME_INDEX_XMSP, MIME_INDEX_XMSW, MIME_INDEX_XSLFO, MIME_JPEG, MIME_OTHER, MIME_PDF, MIME_PNG, MIME_PNG_WBMP, MIME_PPM, MIME_PPT, MIME_SVG, MIME_TEXT, MIME_WBMP, MIME_XHTML, MIME_XLS, MIME_XML, MIME_XMSE, MIME_XMSP, MIME_XMSW, MIME_XSLFO, MIME_XSLFO_CSS
 
Constructor Summary
LineFactory()
          Default constructor.
LineFactory(LineFactory factory)
          Copy constructor.
 
Method Summary
protected  boolean absCumulativeValues(boolean isometric)
          Tests if the visualization strategy implemented by this shape factory instance requires that only absolute values should be used for cumulative data.
protected  void drawValues(java.awt.Graphics2D g, java.awt.Paint color, java.awt.Paint paint, java.awt.Font font, java.lang.String[] value, AxisFactory.AxisMetrics info, int alignment, java.awt.geom.Rectangle2D[] shapeBounds, boolean multiSeriesMode)
          Draws values at the top the data points.
 com.davisor.core.Dupable dup()
          Duplicates this factory.
protected  float[] getIdealSize(ChartAxes axes, int elements, int channels, float[] labelOffsets, float[][] titleSizes, float[][] labelSizes, float[][] markerSizes, float[] markerOffsets)
          Gets the ideal suggested size for this chart.
protected  DataValue getSubChannel(DataValue channelValue, int subChannel)
          Gets a sub-channel value.
protected  int getSubChannels(Type valueType)
          Gets the number of sub-channels.
protected  boolean isSilent(ChartAxis axis)
          Tests axis silency in chart factory spesific way.
protected  DataValue[] resolveDataLimits(ChartData data, ChartAttributes attr, PlotRenderAttributes plot, int[] channels, boolean isometric, boolean[] cumulative)
          Determines global minimum and maximum data values.
protected  boolean sumCumulativeValues()
          Tests if the visualization strategy implemented by this shape factory instance requires that cumulative data values should be summed together or not.
protected  boolean zeroCumulativeValues()
          Tests if the visualization strategy implemented by this shape factory instance requires that missing cumulative data values should be replaced by zero values.
 
Methods inherited from class com.davisor.graphics.chart.ShapeFactory
createContext, createContext, createContext, createMetrics, drawChart, drawGroup, drawLine, drawSegments, drawShapes, drawSmoothedLine, getAngle, getDefaultLineColor, getDefaultLinePaint, getLegendShape, isAbsolute, isCumulative, resolveLimits
 
Methods inherited from class com.davisor.graphics.chart.AxisFactory
computeMinorMargin, createChart, createChart, createContext, createMetrics, createMetrics, createMetrics, drawAxis, drawMarkers, drawTics, drawXYAxes, drawXYZAxes, fillGrid, fillMarkers, formatDouble, getIdealSize, hasGridLines, labelAxis, labelMarkers, resolveLabels, resolveLabels, resolveMarkerSizes, resolveOverlap, titleAxis, transpose
 
Methods inherited from class com.davisor.graphics.chart.ChartFactory
annotate, combineProperties, createChannelType, createChannelType, createChart, createChart, createChart, createChart, createChart, createFormat, createPaintChannelType, createPaintChannelType, createShapeChannelType, createShapeChannelType, createSummary, drawLabel, getContentType, getDefaultPaint, getFactory, getFactory, getGroup, getIsometricCoefficients, getName, has3D, hasSVG, isClassAvailable, isMultiSeriesMode, main, mayHaveLegend, registerFactory, resolveDataLimits, rotateSize, shade, unregisterFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineFactory

public LineFactory()
Default constructor.


LineFactory

public LineFactory(LineFactory factory)
Copy constructor.

Method Detail

resolveDataLimits

protected DataValue[] resolveDataLimits(ChartData data,
                                        ChartAttributes attr,
                                        PlotRenderAttributes plot,
                                        int[] channels,
                                        boolean isometric,
                                        boolean[] cumulative)
                                 throws InvalidDataException
Determines global minimum and maximum data values.

Due isometric rendering constrains, LineFactory must render isometric cumulative and area charts with absolute data values only. This method takes these restrictinos into account when data limits are resolved.

Warning! Do not modify the returned values since they may be references to the original data points.

Overrides:
resolveDataLimits in class ChartFactory
Parameters:
data - chart data to be inspected
attr - chart rendering attributes
plot - local plot area attributes
channels - indexes of the channels to be inspected
isometric - isometric rendering may affect how doata is understood
cumulative - precomputed channel cumulativenes values
Returns:
global minimum and maximum values, taken over all value channels
Throws:
InvalidDataException - if data limit resolvation fails
See Also:
ChartFactory.resolveDataLimits(DataValue[][],boolean[]), ChartData.getLimits(int[],Type,boolean[],boolean[])

getIdealSize

protected float[] getIdealSize(ChartAxes axes,
                               int elements,
                               int channels,
                               float[] labelOffsets,
                               float[][] titleSizes,
                               float[][] labelSizes,
                               float[][] markerSizes,
                               float[] markerOffsets)
Gets the ideal suggested size for this chart.

Overrides:
getIdealSize in class AxisFactory
Parameters:
axes - axis attributes
elements - the expected number of data element groups
channels - the expected number of data channels
labelOffsets - axis label offsets ([x,y,z])
titleSizes - axis title sizes ([x,y][w,h])
labelSizes - axis label sizes ([x,y][w,h])
Returns:
suggested ideal chart width and height ([w,h])
See Also:
AxisFactory.getIdealSize(ChartAxes,float[],float[], float[][],float[][],float[][],float[])

isSilent

protected boolean isSilent(ChartAxis axis)
Tests axis silency in chart factory spesific way.

Line factories make category axes that have no labels silent by default. Label precense is detected by checking if axis step data type has an instance of EnumType. If it is, the axis is assumed to have labels.

Overrides:
isSilent in class AxisFactory
Parameters:
axis - axis to check
Returns:
true if given axis is silent in this context
See Also:
ChartAxis.isSilent()

dup

public com.davisor.core.Dupable dup()
Duplicates this factory.


absCumulativeValues

protected boolean absCumulativeValues(boolean isometric)
Tests if the visualization strategy implemented by this shape factory instance requires that only absolute values should be used for cumulative data.

Specified by:
absCumulativeValues in class ShapeFactory
Parameters:
isometric - tells if visualization will be isometric 3D or not
Returns:
true for isometric rendering, false otherwise
See Also:
DataValue.abs(), sumCumulativeValues(), zeroCumulativeValues()

getSubChannel

protected DataValue getSubChannel(DataValue channelValue,
                                  int subChannel)
Gets a sub-channel value.

Specified by:
getSubChannel in class ShapeFactory
Parameters:
channelValue - channel value
subChannel - sub-channel index
Returns:
sub-channel value taken from given channel value, or the channel value itself if it has no sub-values (may be null)

getSubChannels

protected int getSubChannels(Type valueType)
Gets the number of sub-channels.

Specified by:
getSubChannels in class ShapeFactory
Parameters:
valueType - channel type
Returns:
number of sub-channels in data values of given type (may be zero, indicating that the type has no sub-channels)

sumCumulativeValues

protected boolean sumCumulativeValues()
Tests if the visualization strategy implemented by this shape factory instance requires that cumulative data values should be summed together or not.

Specified by:
sumCumulativeValues in class ShapeFactory
Returns:
true
See Also:
DataValue.add(DataValue), absCumulativeValues(boolean), zeroCumulativeValues()

zeroCumulativeValues

protected boolean zeroCumulativeValues()
Tests if the visualization strategy implemented by this shape factory instance requires that missing cumulative data values should be replaced by zero values.

Specified by:
zeroCumulativeValues in class ShapeFactory
Returns:
true
See Also:
Type.zero(), absCumulativeValues(boolean), sumCumulativeValues()

drawValues

protected void drawValues(java.awt.Graphics2D g,
                          java.awt.Paint color,
                          java.awt.Paint paint,
                          java.awt.Font font,
                          java.lang.String[] value,
                          AxisFactory.AxisMetrics info,
                          int alignment,
                          java.awt.geom.Rectangle2D[] shapeBounds,
                          boolean multiSeriesMode)
Draws values at the top the data points. Vertical alignment affects to label positioning. If there are shapes, up and down aligned values are drawn above or below the shapes respectively. Values are centered horizontally except the first and the last values which are left and right aligned.

Specified by:
drawValues in class ShapeFactory
Parameters:
g - the graphics' context to draw into
color - label colors
paint - label paints
font - label font
value - value texts
info - axis info
alignment - label alignment in relation to shape
shapeBounds - value will be aligned in relation to shape bounds
multiSeriesMode - if this is false, palette colors will be rotated


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