|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.davisor.graphics.chart.ChartFactory
com.davisor.graphics.chart.AxisFactory
com.davisor.graphics.chart.BarFactory
BarFactory is a base class for chart producers that can make bar charts out of one- or multidimensional data. Bar charts support the 3D look and a wealth of chart attributes.
Bar charts visualize data as bar groups. A bar group is made out of one or more bars, where each bar represents a single value from one or more channels. A single bar is made out of one or more bar segments, where the segments represent the values from one base channel and optionally some additional cumulative channels. Bars in a bar group reside next to each other, while the bar groups are separated by symmetric gaps.
_ _
| |_ | |_
|b| | |b| | <- segment
_|a|_| _|a|_|
| |r| | | |r| | <- segment
___|_|_|_|___ ___|_|_|_|___
0 1 2 1 2 3 <- sequence number
gap gap gap gap
group group
Bar charts utilize the services of the AxisFactory base class, in order to prepare the chart data and attributes for rendering. This class then converts the chart data values, expressed originally in arbitrary user value data types, to the chart device coordinates, expressed in scalar pixel values. The values are then rendered using the various draw methods that this class provides.
The BarFactory subclasses implement the details of how exactly the chart bars are rendered. The subclasses do this by implementing the abstract interface that this class and it's superclass define. Please see the appropriate subclass documentation for more information.
AxisFactory.createChart(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartFactory.ChartMetrics, com.davisor.graphics.chart.ChartAttributes, com.davisor.graphics.chart.Chart),
drawBar(java.awt.Graphics2D, java.awt.Paint, java.awt.Paint[], int, int, float, float, float, float, float, float, float, float, float),
drawValue(java.awt.Graphics2D, java.awt.Paint, java.awt.Paint, java.awt.Font, java.lang.String, com.davisor.graphics.chart.AxisFactory.AxisMetrics, int, int, float, float, float, float, float, int, float),
AxisFactory.createChart(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartFactory.ChartMetrics, com.davisor.graphics.chart.ChartAttributes, com.davisor.graphics.chart.Chart),
ChartAttributes,
ColumnBarFactory,
PaintParameters,
RowBarFactory,
ShapeFactory| Nested Class Summary | |
protected class |
BarFactory.BarEntry
BarEntry stores the data of one bar block needed in rendering. |
protected class |
BarFactory.BarLabel
BarLabel stores value label rendering information for later use. |
class |
BarFactory.BarMetrics
BarMetrics implements bar chart spesific axis metrics. |
| 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 | |
protected static int |
NEG
|
protected static int |
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 | |
BarFactory()
Default constructor. |
|
BarFactory(BarFactory factory)
Copy constructor. |
|
| Method Summary | |
protected float |
computeMinorMargin(int dim,
float[][] labelSizes)
Computes label minor margin size in bar factory spesific way. |
protected AxisFactory.AxisContext |
createContext(ChartData data,
ChartAttributes attr,
ChartAxes axes,
short index)
Creates and initializes a bar chart context. |
protected AxisFactory.AxisMetrics |
createMetrics(ChartAxes axes,
float chartWidth,
float chartHeight,
float[] titleSize,
float[] labelSize,
float[] markerSize,
float[] axisOffset,
float[] labelOffset,
float[] markerOffset,
float[] symbolOffset,
float[] majorEdge,
float[] minorEdge)
Defines metrics for two-dimensional bar chart. |
protected float |
drawBar(java.awt.Graphics2D g,
boolean tupleMode,
java.awt.Paint color,
java.awt.Paint[] paints,
java.awt.Stroke stroke,
int group,
int bar,
float zero,
float groupWidth,
float barSize,
float gapSize,
float borderWidth,
float beginValue,
float size,
float rotWidth,
float rotHeight,
DataValue dataValue,
DataValue minValue,
DataValue maxValue,
boolean hidden)
Passes drawing to subclasses. |
protected void |
drawBar(java.awt.Graphics2D g,
java.awt.Paint[] paint,
float x1,
float y1,
float x2,
float y2,
float dx,
float dy)
Draws a filled rectangular bar shape, optionally with 3D shearing. |
protected abstract void |
drawBar(java.awt.Graphics2D g,
java.awt.Paint color,
java.awt.Paint[] paint,
int group,
int bar,
float zero,
float groupWidth,
float barSize,
float gapSize,
float borderWidth,
float beginValue,
float endValue,
float rotWidth,
float rotHeight)
Draws a bar segment in a bar group. |
protected Chart |
drawChart(AxisFactory.AxisContext context,
AxisFactory.AxisMetrics metrics,
ChartAxes axes,
boolean fillGrid,
boolean drawAxes,
boolean drawLabel,
boolean drawGrid,
Chart chart)
Renders a bar sub-chart out of the given chart data. |
protected abstract void |
drawValue(java.awt.Graphics2D g,
java.awt.Paint color,
java.awt.Paint paint,
java.awt.Font font,
java.lang.String label,
AxisFactory.AxisMetrics info,
int group,
int bar,
float groupWidth,
float barSize,
float gapSize,
float beginValue,
float endValue,
int alignment,
float padding)
Draws a bar value at the top of a bar. |
protected abstract int |
getCategoryAxis()
Gets the index of the axis along which the indexes grow. |
protected static float |
getGap(ChartAxis axis)
Gets the relative width of the gap between two bars. |
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 abstract int |
getValueAxis()
Gets the index of the axis along which the values grow. |
protected boolean |
hasGridLines(ChartAxis axis)
Tests if axis has grid lines in chart factory spesific way. |
protected boolean |
isSilent(ChartAxis axis)
Tests axis silency in chart factory spesific way. |
protected void |
renderChart(AxisFactory.AxisContext context,
AxisFactory.AxisMetrics metrics,
ChartAxes axes,
Chart chart)
Default code for bar chart rendering. |
protected DataValue[] |
resolveDataLimits(ChartData data,
ChartAttributes attr,
PlotRenderAttributes plot,
int[] channels,
boolean isometric,
boolean[] cumulative)
Determines global minimum and maximum data values. |
protected DataValue[][] |
resolveLimits(ChartDataSummary summary)
Computes chart factory specific limit values for axes. |
| 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 |
| Methods inherited from interface com.davisor.core.Dupable |
dup |
| Field Detail |
protected static final int NEG
protected static final int POS
| Constructor Detail |
public BarFactory()
public BarFactory(BarFactory factory)
| Method Detail |
protected abstract int getCategoryAxis()
protected abstract int getValueAxis()
protected abstract void drawBar(java.awt.Graphics2D g,
java.awt.Paint color,
java.awt.Paint[] paint,
int group,
int bar,
float zero,
float groupWidth,
float barSize,
float gapSize,
float borderWidth,
float beginValue,
float endValue,
float rotWidth,
float rotHeight)
g - the graphic's context to draw intocolor - bar segment border colorpaint - bar segment fill paint shadesgroup - the number of this bar groupbar - bar sequence number within this groupgroupWidth - bar group widthbarSize - bar group widthgapSize - bar group gap widthborderWidth - bar border widthbeginValue - bar begin valueendValue - bar end valuerotWidth - shearing X-offsetrotHeight - shearing Y-offsetdrawBar(java.awt.Graphics2D, java.awt.Paint, java.awt.Paint[], int, int, float, float, float, float, float, float, float, float, float),
ChartFactory.shade(java.awt.Paint),
ColumnBarFactory.drawBar(java.awt.Graphics2D, java.awt.Paint, java.awt.Paint[], int, int, float, float, float, float, float, float, float, float, float),
RowBarFactory.drawBar(java.awt.Graphics2D, java.awt.Paint, java.awt.Paint[], int, int, float, float, float, float, float, float, float, float, float)
protected abstract void drawValue(java.awt.Graphics2D g,
java.awt.Paint color,
java.awt.Paint paint,
java.awt.Font font,
java.lang.String label,
AxisFactory.AxisMetrics info,
int group,
int bar,
float groupWidth,
float barSize,
float gapSize,
float beginValue,
float endValue,
int alignment,
float padding)
g - the graphics' context to draw intocolor - label colorfont - label fontlabel - value textinfo - chart axis intogroup - the number of this bar groupbar - bar sequence number within this groupgroupWidth - bar group widthbarSize - bar group widthgapSize - bar group widthbeginValue - bar begin valueendValue - bar end valuealignment - label alignmentpadding - padding around the label
protected DataValue[] resolveDataLimits(ChartData data,
ChartAttributes attr,
PlotRenderAttributes plot,
int[] channels,
boolean isometric,
boolean[] cumulative)
throws InvalidDataException
Bar factories group positive and negative value bars above and below the zero line, respectively. In particular, cumulative positive and negative values are summed separately.
Warning! Do not modify the returned values since they may be references to the original data points.
resolveDataLimits in class ChartFactorydata - chart data to be inspectedattr - chart rendering attributesplot - local plot area attributeschannels - indexes of the channels to be inspectedisometric - isometric rendering may affect how data is understoodcumulative - precomputed channel cumulativenes values
InvalidDataException - if data limit resolvation failsChartFactory.resolveDataLimits(DataValue[][],boolean[])
protected float computeMinorMargin(int dim,
float[][] labelSizes)
| X | XX = edgemost label text
| X |
| X |
+------ X +------
XX XX
computeMinorMargin in class AxisFactorydim - dimension indexlabelSizes - label width and height ([x,y][w,h])
AxisFactory.resolveLabels(com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.AxisFactory.AxisContext),
AxisFactory.computeMinorMargin(int, float[][])
protected AxisFactory.AxisContext createContext(ChartData data,
ChartAttributes attr,
ChartAxes axes,
short index)
throws ChartException
AxisAttributes.BEFORE_VALUE, because otherwise the default default
value would place the crossing value axis at the middle of the
first bar.
createContext in class AxisFactorydata - chart dataattr - chart attributesaxes - chart axesindex - context index among other contexts
ChartException - if chart generation failscreateMetrics(com.davisor.graphics.chart.ChartAxes, float, float, float[], float[], float[], float[], float[], float[], float[], float[], float[]),
getCategoryAxis(),
ChartAxes.getAxis(int),
ChartAxis.setDefaultPosition(float)
protected AxisFactory.AxisMetrics createMetrics(ChartAxes axes,
float chartWidth,
float chartHeight,
float[] titleSize,
float[] labelSize,
float[] markerSize,
float[] axisOffset,
float[] labelOffset,
float[] markerOffset,
float[] symbolOffset,
float[] majorEdge,
float[] minorEdge)
throws ChartException
createMetrics in class AxisFactoryaxes - chart axeschartWidth - chart width, stricly within chart borderschartHeight - chart height, stricly within chart borderstitleSize - title sizelabelSize - label sizeaxisOffset - axis line offsetslabelOffset - label offsetssymbolOffset - symbol line offsetsmajorEdge - major edge sizesminorEdge - minor edge sizesmarkerSize - marker sizemarkerOffset - marker offset
ChartException - if chart generation failsAxisFactory.drawXYAxes(java.awt.Graphics2D, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.AxisFactory.AxisMetrics, boolean, boolean, boolean, boolean),
AxisFactory.AxisMetrics
protected Chart drawChart(AxisFactory.AxisContext context,
AxisFactory.AxisMetrics metrics,
ChartAxes axes,
boolean fillGrid,
boolean drawAxes,
boolean drawLabel,
boolean drawGrid,
Chart chart)
throws InvalidDataException
drawChart in class AxisFactorycontext - chart contextmetrics - chart metricsaxes - chart axesfillGrid - enables or disables axis background fillingdrawAxes - determine which axes may be drawndrawLabel - determine if default labeling is to be applieddrawGrid - determine if axis grid is to be drawnchart - chart to draw into
InvalidDataException - if data is invalid for chart drawingcreateContext(com.davisor.graphics.chart.ChartData, com.davisor.graphics.chart.ChartAttributes, com.davisor.graphics.chart.ChartAxes, short),
drawBar(java.awt.Graphics2D, java.awt.Paint, java.awt.Paint[], int, int, float, float, float, float, float, float, float, float, float),
drawValue(java.awt.Graphics2D, java.awt.Paint, java.awt.Paint, java.awt.Font, java.lang.String, com.davisor.graphics.chart.AxisFactory.AxisMetrics, int, int, float, float, float, float, float, int, float),
createMetrics(com.davisor.graphics.chart.ChartAxes, float, float, float[], float[], float[], float[], float[], float[], float[], float[], float[]),
ChartFactory.createSummary(com.davisor.graphics.chart.ChartData, com.davisor.graphics.chart.ChartAttributes, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.PlotRenderAttributes, com.davisor.data.EnumType, int[], boolean, int[]),
ColumnBarFactory,
RowBarFactory
protected void renderChart(AxisFactory.AxisContext context,
AxisFactory.AxisMetrics metrics,
ChartAxes axes,
Chart chart)
throws InvalidDataException
InvalidDataException - if data is invalid for chart drawingdrawChart(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
protected float[] getIdealSize(ChartAxes axes,
int elements,
int channels,
float[] labelOffsets,
float[][] titleSizes,
float[][] labelSizes,
float[][] markerSizes,
float[] markerOffsets)
The column bar chart's ideal size is wide and high enough for vertical value labels running along the value-axis, and horizontal text labels running along the category-axis.
getIdealSize in class AxisFactoryaxes - axis attributeselements - the expected number of data element groupschannels - the expected number of data channelslabelOffsets - axis label offsets ([x,y,z])titleSizes - axis title sizes ([x,y][w,h])labelSizes - axis label sizes ([x,y][w,h])
AxisFactory.getIdealSize(ChartAxes,float[],float[],
float[][],float[][],float[][],float[])protected boolean hasGridLines(ChartAxis axis)
Bar chart value axes have grid lines by default, while category
axes do not. An axis is a value axis if it's dimension equals to
value.
hasGridLines in class AxisFactoryaxis - axis to check
true if given axis has grid lines in this contextChartAxis.getDim(),
ChartAxis.hasGridLines()protected boolean isSilent(ChartAxis axis)
Bar 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.
isSilent in class AxisFactoryaxis - axis to check
true if given axis is silent in this contextChartAxis.isSilent()protected DataValue[][] resolveLimits(ChartDataSummary summary)
This implementation places data value limit values on the value axis, and label limit values on the category axis. If the given extreme values are incomplete or have errors, then the value axis limits are left unset. This may happen in particular if no label information is available.
resolveLimits in class AxisFactorysummary - data summary
getValueAxis(),
ChartFactory.createSummary(com.davisor.graphics.chart.ChartData, com.davisor.graphics.chart.ChartAttributes, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.PlotRenderAttributes, com.davisor.data.EnumType, int[], boolean, int[])
protected float drawBar(java.awt.Graphics2D g,
boolean tupleMode,
java.awt.Paint color,
java.awt.Paint[] paints,
java.awt.Stroke stroke,
int group,
int bar,
float zero,
float groupWidth,
float barSize,
float gapSize,
float borderWidth,
float beginValue,
float size,
float rotWidth,
float rotHeight,
DataValue dataValue,
DataValue minValue,
DataValue maxValue,
boolean hidden)
protected void drawBar(java.awt.Graphics2D g,
java.awt.Paint[] paint,
float x1,
float y1,
float x2,
float y2,
float dx,
float dy)
g - graphics context to draw intopaint - face paintsx1 - bar lower left corner X -coordinatey1 - bar lower left corner Y -coordinatex2 - bar upper right corner X -coordinatey2 - bar upper right corner Y -coordinatedx - X -coordinate shearing offsetdy - Y -coordinate shearing offsetprotected static float getGap(ChartAxis axis)
<---b---> : ___ : : | | : ___ : | | : | | ___|_*_|___|_*_|__ gap = a/b : : : : >a< >a<
axis - axis to read gap value
ChartAxis.getGap()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||