public abstract class Graph2DRenderer<T extends Graph2DRendererUpdate> extends Object
Constructor and Description |
---|
Graph2DRenderer(int graphWidth,
int graphHeight)
Creates a graph renderer.
|
Modifier and Type | Method and Description |
---|---|
protected void |
calculateGraphArea()
Calculates the graph area based on:
The image size
The plot ranges
The value scales
The font for the labels
The margins
To calculate area based on labels, ensure that calculateGraphArea() is called
prior to calling calculateGraphAreaNoLabels().
|
protected void |
calculateLabels()
Calculates:
The font for the labels
The margins based on labels
|
protected void |
calculateRanges(Range xDataRange,
Range xDisplayRange,
Range yDataRange,
Range yDisplayRange)
Given the new data ranges, calculates the new aggregated and plot
ranges.
|
protected void |
drawBackground()
Draws the background with the background color.
|
protected void |
drawGraphArea()
Draw the calculated graph area.
|
protected void |
drawHorizontalReferenceLines()
Draws the horizontal reference lines based on the calculated
graph area.
|
protected void |
drawValueExplicitLine(ListNumber xValues,
ListNumber yValues,
InterpolationScheme interpolation,
ReductionScheme reduction)
Draws an explicit line give the interpolation and reduction schemes,
the x values and the y values.
|
protected void |
drawValueLine(ListNumber xValues,
ListNumber yValues,
InterpolationScheme interpolation)
Draws an implicit line given the interpolation scheme and the x,y values.
|
protected void |
drawVerticalReferenceLines()
Draw reference lines that correspond to reference values.
|
protected void |
drawXLabels()
Draw the horizontal labels based on the calculated graph area.
|
protected void |
drawYLabels()
Draw the vertical labels based on the calculated graph area.
|
int |
getImageHeight()
The current height of the graph.
|
int |
getImageWidth()
The current width of the graph.
|
Range |
getXAggregatedRange()
The aggregated range of all the data that has been rendered.
|
AxisRange |
getXAxisRange()
The current strategy to calculate the x range for the graph.
|
Range |
getXPlotRange()
The range of the x axis in the last graph rendering.
|
Range |
getYAggregatedRange()
The aggregated range of all the data that has been rendered.
|
AxisRange |
getYAxisRange()
The current strategy to calculate the y range for the graph.
|
Range |
getYPlotRange()
The range of the y axis in the last graph rendering.
|
abstract T |
newUpdate()
Creates a new update for the given graph.
|
protected void |
processScaledValue(int index,
double valueX,
double valueY,
double scaledX,
double scaledY)
Empty function, designed to be implemented in sub-classes.
|
protected double |
scaledX(double value) |
protected double |
scaledY(double value)
Scale the y value to the graph area.
|
protected void |
setClip(Graphics2D g)
Sets the clip area to the actual graph area
|
protected void |
setupDataAsAreas()
Sets up a graph to start and end at the beginning border of a pixel.
|
protected void |
setupDataAsPoints()
Sets up a graph to start and end at the center of a pixel.
|
protected void |
setupXAsAreas()
Sets up the x-axis of a graph to start and end at the left border of a pixel.
|
protected void |
setupXAsPoints()
Sets up the x-axis of a graph to start and end at the center of a pixel.
|
protected void |
setupYAsAreas()
Sets up the y-axis of a graph to start and end at the top border of a pixel.
|
protected void |
setupYAsPoints()
Sets up the y-axis of a graph to start and end at the center of a pixel.
|
void |
update(T update)
Applies the update to the renderer.
|
protected double xPlotValueStart
protected double yPlotValueStart
protected double xPlotValueEnd
protected double yPlotValueEnd
protected int xAreaCoordStart
protected int yAreaCoordStart
protected int yAreaCoordEnd
protected int xAreaCoordEnd
protected double xPlotCoordStart
protected double yPlotCoordStart
protected double yPlotCoordEnd
protected double xPlotCoordEnd
protected double yPlotCoordHeight
protected double xPlotCoordWidth
protected Graphics2D g
protected ValueScale xValueScale
protected ValueScale yValueScale
protected Color backgroundColor
protected Color labelColor
protected Color referenceLineColor
protected Font labelFont
protected int bottomMargin
protected int topMargin
protected int leftMargin
protected int rightMargin
protected int bottomAreaMargin
protected int topAreaMargin
protected int leftAreaMargin
protected int rightAreaMargin
protected int xLabelMargin
protected int yLabelMargin
protected double xPointMargin
protected double yPointMargin
protected FontMetrics labelFontMetrics
protected ListDouble xReferenceCoords
protected ListDouble xReferenceValues
protected ListDouble yReferenceCoords
protected ListDouble yReferenceValues
public Graph2DRenderer(int graphWidth, int graphHeight)
graphWidth
- the graph widthgraphHeight
- the graph heightpublic int getImageHeight()
public int getImageWidth()
public AxisRange getXAxisRange()
public AxisRange getYAxisRange()
public Range getXAggregatedRange()
public Range getYAggregatedRange()
public Range getXPlotRange()
public Range getYPlotRange()
public void update(T update)
When sub-classing, one should re-implement this method by first calling it and then applying all the updates specific to the sub-class.
update
- the update to applypublic abstract T newUpdate()
protected void calculateRanges(Range xDataRange, Range xDisplayRange, Range yDataRange, Range yDisplayRange)
xDataRange
- the new data range for xxDisplayRange
- the new display range for xyDataRange
- the new data range for yyDisplayRange
- the new display range for yprotected void drawHorizontalReferenceLines()
protected void drawVerticalReferenceLines()
protected void calculateLabels()
protected void calculateGraphArea()
protected void drawBackground()
protected void drawGraphArea()
protected void processScaledValue(int index, double valueX, double valueY, double scaledX, double scaledY)
Used on every value in a dataset.
index
- the index of the valuevalueX
- the x valuevalueY
- the y valuescaledX
- the x pixelscaledY
- the y pixelprotected void drawValueLine(ListNumber xValues, ListNumber yValues, InterpolationScheme interpolation)
xValues
- the x valuesyValues
- the y valuesinterpolation
- the interpolation schemeprotected void drawValueExplicitLine(ListNumber xValues, ListNumber yValues, InterpolationScheme interpolation, ReductionScheme reduction)
xValues
- the x valuesyValues
- the y valuesinterpolation
- the interpolationreduction
- the reductionprotected final double scaledX(double value)
protected final double scaledY(double value)
value
- the y valueprotected void setClip(Graphics2D g)
g
- the graphics contextprotected void drawYLabels()
protected void drawXLabels()
protected void setupDataAsPoints()
protected void setupXAsPoints()
protected void setupYAsPoints()
protected void setupDataAsAreas()
protected void setupXAsAreas()
protected void setupYAsAreas()
Copyright © 2015. All rights reserved.