com.davisor.graphics.chart
Class ScaleLegendFactory

java.lang.Object
  extended bycom.davisor.graphics.chart.ChartFactory
      extended bycom.davisor.graphics.chart.LegendFactory
          extended bycom.davisor.graphics.chart.ScaleLegendFactory
All Implemented Interfaces:
com.davisor.core.Dupable, com.davisor.core.MIMETypes, com.davisor.core.Public
Direct Known Subclasses:
PaintLegendFactory, ShapeLegendFactory

public abstract class ScaleLegendFactory
extends LegendFactory

ScaleLegendFactory provides common functionality to legend factories that show scales in a legend. The common functionality provides the calculation of the size of the legend, scaling of the legend and drawing of legend entries.

Each subclass is expected to create the context, which is provided in this class, for the chart and provide the method for creating the chart.


Nested Class Summary
 class ScaleLegendFactory.ScaleLegendContext
          Context information for legend size calculation and drawing.
 class ScaleLegendFactory.ScaleLegendEntry
          Contains shape, label, and size information.
 class ScaleLegendFactory.ScaleLegendMetrics
          Legend metrics contain the legend sizing information.
 
Nested classes inherited from class com.davisor.graphics.chart.ChartFactory
ChartFactory.ChartContext, ChartFactory.ChartMetrics
 
Field Summary
static int DEFAULT_BORDER_PADDING
          Default border padding (3).
static int DEFAULT_HORIZONTAL_LABEL_GAP
          Default horizontal gap between shape and label (20).
 
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
ScaleLegendFactory()
          Default constructor.
ScaleLegendFactory(ChartFactory factory)
          Copy contructor.
 
Method Summary
 ChartFactory.ChartMetrics createMetrics(ChartFactory.ChartContext chartContext, ChartAttributes attr)
          Defines metrics for a scale legend factory.
protected  void drawHorizontalEntry(java.awt.Graphics2D g, int horizontalLabelGap, int horizontalShapeGap, boolean ignoreShape, java.lang.String label, boolean labelAtLeft, java.awt.Paint labelColor, java.awt.Font labelFont, float labelHeight, java.awt.Paint labelPaint, float labelWidth, float maximumEntryHeight, float maximumShapeHeight, float maximumShapeWidth, java.awt.Paint pointColor, java.awt.Paint pointPaint, java.awt.Shape pointShape, java.awt.Stroke pointStroke, float shapeHeight, float shapeWidth, int verticalShapeGap, float x, float y)
          Draws a horizontal legend entry.
protected  void drawVerticalEntry(java.awt.Graphics2D g, int horizontalLabelGap, int horizontalShapeGap, boolean ignoreShape, java.lang.String label, java.awt.Paint labelColor, java.awt.Font labelFont, float labelHeight, java.awt.Paint labelPaint, float labelWidth, float maximumEntryHeight, float maximumShapeHeight, float maximumShapeWidth, java.awt.Paint pointColor, java.awt.Paint pointPaint, java.awt.Shape pointShape, java.awt.Stroke pointStroke, float shapeHeight, float shapeWidth, int verticalShapeGap, float x, float y)
          Draw a vertical legend entry.
 
Methods inherited from class com.davisor.graphics.chart.LegendFactory
getLabelBackgroundPaint, mayHaveLegend
 
Methods inherited from class com.davisor.graphics.chart.ChartFactory
annotate, combineProperties, createChannelType, createChannelType, createChart, createChart, createChart, createChart, createChart, createChart, createContext, createFormat, createPaintChannelType, createPaintChannelType, createShapeChannelType, createShapeChannelType, createSummary, drawLabel, getContentType, getDefaultPaint, getFactory, getFactory, getGroup, getIsometricCoefficients, getLegendShape, getName, has3D, hasSVG, isClassAvailable, isMultiSeriesMode, main, registerFactory, resolveDataLimits, resolveDataLimits, rotateSize, shade, unregisterFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.davisor.core.Dupable
dup
 

Field Detail

DEFAULT_HORIZONTAL_LABEL_GAP

public static final int DEFAULT_HORIZONTAL_LABEL_GAP
Default horizontal gap between shape and label (20).

See Also:
Constant Field Values

DEFAULT_BORDER_PADDING

public static final int DEFAULT_BORDER_PADDING
Default border padding (3).

See Also:
Constant Field Values
Constructor Detail

ScaleLegendFactory

public ScaleLegendFactory()
Default constructor.


ScaleLegendFactory

public ScaleLegendFactory(ChartFactory factory)
Copy contructor.

Method Detail

createMetrics

public ChartFactory.ChartMetrics createMetrics(ChartFactory.ChartContext chartContext,
                                               ChartAttributes attr)
                                        throws ChartException
Defines metrics for a scale legend factory. In addition to determining the required width and height for the legend, the widths and heights of labels and shapes are resolved.

Specified by:
createMetrics in class ChartFactory
Parameters:
chartContext - chart context
attr - chart attributes
Throws:
ChartException - if chart generation fails

drawHorizontalEntry

protected void drawHorizontalEntry(java.awt.Graphics2D g,
                                   int horizontalLabelGap,
                                   int horizontalShapeGap,
                                   boolean ignoreShape,
                                   java.lang.String label,
                                   boolean labelAtLeft,
                                   java.awt.Paint labelColor,
                                   java.awt.Font labelFont,
                                   float labelHeight,
                                   java.awt.Paint labelPaint,
                                   float labelWidth,
                                   float maximumEntryHeight,
                                   float maximumShapeHeight,
                                   float maximumShapeWidth,
                                   java.awt.Paint pointColor,
                                   java.awt.Paint pointPaint,
                                   java.awt.Shape pointShape,
                                   java.awt.Stroke pointStroke,
                                   float shapeHeight,
                                   float shapeWidth,
                                   int verticalShapeGap,
                                   float x,
                                   float y)
Draws a horizontal legend entry. In horizontal legend entry, the shape and label are positioned as follows:

The center (0,0) of the shape is positioned with:

The top left corner of the label is positioned with:

If the shape is ignored, the x-coordinate of the label is simply x.

Parameters:
g - graphics container
horizontalLabelGap - gap between shape and label
horizontalShapeGap - gap divided to the left and right side of shape
ignoreShape - should shape be ignored in label positioning
label - text of the label
labelAtLeft - should label be before shape
labelColor - color of the label
labelFont - font of the label
labelHeight - height of the label
labelPaint - paint of the label
labelWidth - width of the label
maximumEntryHeight - maximum height of the entry
maximumShapeHeight - maximum shape height
maximumShapeWidth - maximum shape width
pointColor - color of the shape (may be null)
pointPaint - paint of the shape (may be null)
pointShape - shape of the entry (may be null)
pointStroke - stroke of the shape (may be null)
shapeHeight - height of the shape (ignored)
shapeWidth - width of the shape
verticalShapeGap - gap to the top and bottom side of shape (ignored)
x - x-coordinate
y - y-coordinate

drawVerticalEntry

protected void drawVerticalEntry(java.awt.Graphics2D g,
                                 int horizontalLabelGap,
                                 int horizontalShapeGap,
                                 boolean ignoreShape,
                                 java.lang.String label,
                                 java.awt.Paint labelColor,
                                 java.awt.Font labelFont,
                                 float labelHeight,
                                 java.awt.Paint labelPaint,
                                 float labelWidth,
                                 float maximumEntryHeight,
                                 float maximumShapeHeight,
                                 float maximumShapeWidth,
                                 java.awt.Paint pointColor,
                                 java.awt.Paint pointPaint,
                                 java.awt.Shape pointShape,
                                 java.awt.Stroke pointStroke,
                                 float shapeHeight,
                                 float shapeWidth,
                                 int verticalShapeGap,
                                 float x,
                                 float y)
Draw a vertical legend entry. In vertical legend entry, the shape and label are positioned as follows:

 ---------------
 - shape label -
 ---------------
 

The center (0,0) of the shape is positioned with:

 (x + maximumShapeWidth * 
  (1 + (horizontalShapeGap + horizontalLabelGap) / 100) / 2,
  y + max(labelHeight, 
          shapeHeight + maximumShapeHeight * verticalShapeGap / 100) / 2)
 

The top left corner of the label is positioned with:

 (x + maximumShapeWidth * (1 + (horizontalShapeGap + 
                                horizontalLabelGap) / 100),
  y + (max(labelHeight, 
          shapeHeight + maximumShapeHeight * verticalShapeGap / 100) -
      labelHeight) / 2
 

Parameters:
g - graphics container
horizontalLabelGap - gap between shape and label
horizontalShapeGap - gap divided to the left and right side of shape
ignoreShape - should shape be ignored in label positioning (ignored)
label - text of the label
labelColor - color of the label
labelFont - font of the label
labelHeight - height of the label
labelPaint - paint of the label
labelWidth - width of the label
maximumEntryHeight - maximum height of an entry (ignored)
maximumShapeHeight - maximum height of a shape
maximumShapeWidth - maximum width of a shape
pointColor - color of the shape (may be null)
pointPaint - paint of the shape (may be null)
pointShape - shape (may be null)
pointStroke - stroke of the shape (may be null)
shapeHeight - height of the shape
shapeWidth - width of the shape (ignored)
verticalShapeGap - gap divided to the top and bottom side of shape
x - x-coordinate
y - y-coordinate


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