com.davisor.graphics.chart
Class StockChartFactory

java.lang.Object
  extended bycom.davisor.graphics.chart.ChartFactory
      extended bycom.davisor.graphics.chart.AxisFactory
          extended bycom.davisor.graphics.chart.BarFactory
              extended bycom.davisor.graphics.chart.ColumnBarFactory
                  extended bycom.davisor.graphics.chart.StockChartFactory
All Implemented Interfaces:
com.davisor.core.Dupable, com.davisor.core.MIMETypes, com.davisor.core.Public
Direct Known Subclasses:
CandlestickFactory, OHLCFactory

public abstract class StockChartFactory
extends ColumnBarFactory

StockChartFactory is an abstract class for stock charts based on bar chart producer.

Data

StockChartFactory consumes Open-High-Low-Close data. That data must be given inside a group in that order. "Open" and "Close" values may be optional depending on the chart type. See sub class documentation for details.
 Example: 

 <data>
  <group type="value">
   <column values="25 27 60 51" />
   <column values="30 70 70 80" />
   <column values="20 20 40 40" />
   <column values="26 55 55 75" /> 
  </group>
  <column type="label" values="Mon Tue Wed Thu" />
 </data>
 

There can be more than one group, but then the number of columns inside groups must be the same. I.e. if "open"-data exists in one group, it must be available in all groups.

Rendering Attributes

This factory inherits lots of it's attribute and data operation logic from AxisFactory and BarFactory superclasses. However, there are some differences. The following attributes can be used: (*) Color and paint can alter depending on the values of "Open" and "Close". If pointColor or pointPaint is a palette, then the first palette color is used in cases when "Close"-value is greater or equal than "Open"-value. The second palette color is used when "Close"-value is smaller than "Open"-value. Default color is black and default paint is "white,black".

Warning!

All the common rendering possibilities of Davisor Chart make no sense with these very specialized chart types. Because the usage of nonsense attributes is not actively blocked, it is possible to get odd results with some attribute combinations. Try to avoid using non-supported features. Those include especially:

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

Nested Class Summary
 
Nested classes inherited from class com.davisor.graphics.chart.BarFactory
BarFactory.BarEntry, BarFactory.BarLabel, BarFactory.BarMetrics
 
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.BarFactory
NEG, POS
 
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
StockChartFactory()
          Default constructor.
StockChartFactory(BarFactory factory)
          Copy constructor.
 
Method Summary
protected  void drawOHLCBar(java.awt.Graphics2D g, java.awt.Paint color, java.awt.Paint paint, int group, int bar, float zero, float groupSize, float barSize, float gapSize, float borderWidth, float size, DataValue open, DataValue high, DataValue low, DataValue close, DataValue minValue, DataValue maxValue)
          Convert data values to device units and call sub-class implementation.
protected abstract  void drawOHLCBar(java.awt.Graphics2D g, java.awt.Paint color, java.awt.Paint paint, int group, int bar, float zero, float groupSize, float barSize, float gapSize, float borderWidth, float open, float high, float low, float close)
          Draw Open-High-Low-Close data onto chart.
protected  void renderChart(AxisFactory.AxisContext context, AxisFactory.AxisMetrics metrics, ChartAxes axes, Chart chart)
          Renders a stock chart based on Open-High-Low-Close data.
protected  DataValue[] resolveDataLimits(ChartData data, ChartAttributes attr, PlotRenderAttributes plot, int[] channels, boolean isometric, boolean[] cumulative)
          Resolves data limits without taking care of cumulativity since stock prices are not cumulative in their nature.
 
Methods inherited from class com.davisor.graphics.chart.ColumnBarFactory
drawBar, drawValue, dup, getCategoryAxis, getValueAxis
 
Methods inherited from class com.davisor.graphics.chart.BarFactory
computeMinorMargin, createContext, createMetrics, drawBar, drawBar, drawChart, getGap, getIdealSize, hasGridLines, isSilent, resolveLimits
 
Methods inherited from class com.davisor.graphics.chart.AxisFactory
createChart, createChart, createContext, createContext, createContext, createMetrics, createMetrics, createMetrics, drawAxis, drawMarkers, drawTics, drawXYAxes, drawXYZAxes, fillGrid, fillMarkers, formatDouble, getIdealSize, 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, getLegendShape, 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

StockChartFactory

public StockChartFactory()
Default constructor.


StockChartFactory

public StockChartFactory(BarFactory factory)
Copy constructor.

Method Detail

drawOHLCBar

protected abstract void drawOHLCBar(java.awt.Graphics2D g,
                                    java.awt.Paint color,
                                    java.awt.Paint paint,
                                    int group,
                                    int bar,
                                    float zero,
                                    float groupSize,
                                    float barSize,
                                    float gapSize,
                                    float borderWidth,
                                    float open,
                                    float high,
                                    float low,
                                    float close)
                             throws InvalidDataException
Draw Open-High-Low-Close data onto chart.

Parameters:
g - the graphic's context to draw into
color - bar segment border color
paint - bar segment fill paint
group - the number of this bar group
bar - bar sequence number within this group
zero - zero position
groupSize - bar group width
barSize - bar width
gapSize - bar group gap width
borderWidth - bar border (stroke) width
open - "Open"-value (may be Float.NaN)
high - "High"-value
low - "Low"-value
close - "Close"-value (may be Float.NaN)
Throws:
InvalidDataException - if chart generation fails

resolveDataLimits

protected DataValue[] resolveDataLimits(ChartData data,
                                        ChartAttributes attr,
                                        PlotRenderAttributes plot,
                                        int[] channels,
                                        boolean isometric,
                                        boolean[] cumulative)
                                 throws InvalidDataException
Resolves data limits without taking care of cumulativity since stock prices are not cumulative in their nature.

Assumes also that tuple memebers are mutually comparable. Returns the minimum and maximum over all signle values.

Overrides BarFactory.resolveDataLimits(ChartData,ChartAttributes, PlotRenderAttributes,int[],boolean,boolean[]).

Overrides:
resolveDataLimits in class BarFactory
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 data 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[])

renderChart

protected void renderChart(AxisFactory.AxisContext context,
                           AxisFactory.AxisMetrics metrics,
                           ChartAxes axes,
                           Chart chart)
                    throws InvalidDataException
Renders a stock chart based on Open-High-Low-Close data. Data must be available in that order in data channels.

Overrides:
renderChart in class BarFactory
Parameters:
context - chart context
metrics - chart metrics
axes - chart axes
chart - chart to draw into
Throws:
InvalidDataException - if data is invalid for chart rendering
See Also:
BarFactory.drawChart(com.davisor.graphics.chart.AxisFactory.AxisContext, com.davisor.graphics.chart.AxisFactory.AxisMetrics, com.davisor.graphics.chart.ChartAxes, boolean, boolean, boolean, boolean, com.davisor.graphics.chart.Chart), StockChartFactory

drawOHLCBar

protected void drawOHLCBar(java.awt.Graphics2D g,
                           java.awt.Paint color,
                           java.awt.Paint paint,
                           int group,
                           int bar,
                           float zero,
                           float groupSize,
                           float barSize,
                           float gapSize,
                           float borderWidth,
                           float size,
                           DataValue open,
                           DataValue high,
                           DataValue low,
                           DataValue close,
                           DataValue minValue,
                           DataValue maxValue)
                    throws InvalidDataException
Convert data values to device units and call sub-class implementation.

Parameters:
g - the graphic's context to draw into
color - bar segment border color
paint - bar segment fill paint
group - the number of this bar group
bar - bar sequence number within this group
zero - zero point
groupSize - bar group width
barSize - bar width
gapSize - bar group gap width
borderWidth - bar border (stroke) width
size - drawing area width
open - "Open"-value (may be null)
high - "High"-value
low - "Low"-value
close - "Close"-value (may be null)
minValue - axis minimum value
maxValue - axis maximum value
Throws:
InvalidDataException - if data is invalid for a stock chart
See Also:
drawOHLCBar(Graphics2D,Paint,Paint,int,int,float,float,float,float, float,float,float,float,float)


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