public class GraphBuffer extends Object
This class takes care of putting the pixels where it is told. It specifically does not concerns itself with the calculation of what/where to draw. It provides the drawing of aggregated data structures, so that the plotting can be efficient and clean.
It also serves as a wrapper around Java2D (Graphics2D
) so that
the drawing can be re-implemented efficiently on other engines in the future,
such as JavaFX.
Constructor and Description |
---|
GraphBuffer(Graph2DRenderer<?> renderer)
Creates a GraphBuffer suitable for the given renderer.
|
GraphBuffer(int width,
int height)
Creates a GraphBuffer with the given width and height.
|
Modifier and Type | Method and Description |
---|---|
void |
drawDataImage(int xStartPoint,
int yStartPoint,
int[] xPointToDataMap,
int[] yPointToDataMap,
Cell2DDataset data,
NumberColorMapInstance colorMap)
Plots a two dimensional array of values encoded by color.
|
void |
drawValueExplicitLine(Point2DDataset data,
InterpolationScheme interpolation,
ReductionScheme reduction,
ProcessValue pv) |
void |
drawValueLine(ListNumber xValues,
ListNumber yValues,
InterpolationScheme interpolation,
ProcessValue pv) |
Graphics2D |
getGraphicsContext()
Temporary method to retrieve the graphics context.
|
BufferedImage |
getImage()
Temporary method to retrieve the image buffer.
|
void |
setPixel(int x,
int y,
int color)
Changes the pixel at the given coordinates to the given color.
|
void |
setXScaleAsCell(Range range,
int xMinPixel,
int xMaxPixel,
ValueScale xValueScale)
Sets the scaling data for the x axis assuming values are going
to represent cells.
|
void |
setXScaleAsPoint(Range range,
int xMinPixel,
int xMaxPixel,
ValueScale xValueScale)
Sets the scaling data for the x axis assuming values are going
to represent points.
|
void |
setYScaleAsCell(Range range,
int yMinPixel,
int yMaxPixel,
ValueScale yValueScale)
Sets the scaling data for the y axis assuming values are going
to represent cells.
|
void |
setYScaleAsPoint(Range range,
int yMinPixel,
int yMaxPixel,
ValueScale yValueScale)
Sets the scaling data for the y axis assuming values are going
to represent points.
|
double |
xPixelCenterToValue(int pixelValue)
Converts the center of given pixel position to the actual value.
|
double |
xPixelLeftToValue(int pixelValue)
Converts the left side of given pixel position to the actual value.
|
double |
xPixelRightToValue(int pixelValue)
Converts the right side of given pixel position to the actual value.
|
int |
xValueToPixel(double value)
Converts the given value to the pixel position.
|
double |
yPixelBottomToValue(int pixelValue)
Converts the bottom side of given pixel position to the actual value.
|
double |
yPixelCenterToValue(int pixelValue)
Converts the center of given pixel position to the actual value.
|
double |
yPixelTopToValue(int pixelValue)
Converts the top side of given pixel position to the actual value.
|
int |
yValueToPixel(double value)
Converts the given value to the pixel position.
|
public GraphBuffer(int width, int height)
width
- width of the graphheight
- height of the graphpublic GraphBuffer(Graph2DRenderer<?> renderer)
renderer
- the graph rendererpublic void setPixel(int x, int y, int color)
x
- x-coordinate of a pixely
- y-coordinate of a pixelcolor
- color-value of the pixelpublic BufferedImage getImage()
public Graphics2D getGraphicsContext()
public void drawDataImage(int xStartPoint, int yStartPoint, int[] xPointToDataMap, int[] yPointToDataMap, Cell2DDataset data, NumberColorMapInstance colorMap)
xStartPoint
- the horizontal coordinate for the first pixel of the imageyStartPoint
- the vertical coordinate for the first pixel of the imagexPointToDataMap
- a map from pixel horizontal offset to data indexyPointToDataMap
- a map from pixel vertical offset to data indexdata
- the dataset to be plottedcolorMap
- the color mappublic void setXScaleAsCell(Range range, int xMinPixel, int xMaxPixel, ValueScale xValueScale)
range
- the range to be displayedxMinPixel
- the pixel corresponding to the minimumxMaxPixel
- the pixel corresponding to the maximumxValueScale
- the scale used to transform values to pixelpublic void setXScaleAsPoint(Range range, int xMinPixel, int xMaxPixel, ValueScale xValueScale)
range
- the range to be displayedxMinPixel
- the pixel corresponding to the minimumxMaxPixel
- the pixel corresponding to the maximumxValueScale
- the scale used to transform values to pixelpublic int xValueToPixel(double value)
value
- the valuepublic double xPixelLeftToValue(int pixelValue)
pixelValue
- the pixelpublic double xPixelRightToValue(int pixelValue)
pixelValue
- the pixelpublic double xPixelCenterToValue(int pixelValue)
pixelValue
- the pixelpublic void setYScaleAsCell(Range range, int yMinPixel, int yMaxPixel, ValueScale yValueScale)
range
- the range to be displayedyMinPixel
- the pixel corresponding to the minimumyMaxPixel
- the pixel corresponding to the maximumyValueScale
- the scale used to transform values to pixelpublic void setYScaleAsPoint(Range range, int yMinPixel, int yMaxPixel, ValueScale yValueScale)
range
- the range to be displayedyMinPixel
- the pixel corresponding to the minimumyMaxPixel
- the pixel corresponding to the maximumyValueScale
- the scale used to transform values to pixelpublic int yValueToPixel(double value)
value
- the valuepublic double yPixelTopToValue(int pixelValue)
pixelValue
- the pixelpublic double yPixelCenterToValue(int pixelValue)
pixelValue
- the pixelpublic double yPixelBottomToValue(int pixelValue)
pixelValue
- the pixelpublic void drawValueLine(ListNumber xValues, ListNumber yValues, InterpolationScheme interpolation, ProcessValue pv)
public void drawValueExplicitLine(Point2DDataset data, InterpolationScheme interpolation, ReductionScheme reduction, ProcessValue pv)
Copyright © 2015. All rights reserved.