public class Graph extends Object
| Modifier and Type | Field and Description |
|---|---|
boolean |
AUTOX |
boolean |
AUTOY |
int |
CHEIGHT
canvas height and width
|
int |
CWIDTH |
ArrayList<DataSet> |
DATASETS |
double |
MAXX |
double |
MAXY |
double |
MINX |
double |
MINY |
GraphPanel |
panel |
| Modifier and Type | Method and Description |
|---|---|
DataSet |
addData(double[] x,
double[] y)
Creates a new DataSite, with color, line and point information that
will be drawn.
|
void |
appendPoint(int set,
double x,
double y)
Append a data point to an existing data set.
|
void |
autoScale()
Goes through all of the current data and find the min/max for scaling the image.
|
void |
autoScaleX()
Sets the autoscale in the x directions.
|
void |
autoScaleY()
Sets the autoscale for the y-axis
|
void |
clearData() |
void |
createTics()
Creates the strings for the width, and calculates their dimensions so that the graph
can be appropriately scaled.
|
int |
dataSetCount() |
void |
drawBorder(GraphPainter p,
AffineTransform transform) |
void |
drawSet(DataSet set,
GraphPainter painter,
AffineTransform transform) |
void |
drawXTics(GraphPainter p,
AffineTransform t)
Takes the full x range and breaks it into 7 tics, uses the transform to place points.
|
void |
drawYTics(GraphPainter p,
AffineTransform t)
Takes the full y range and breaks it into 5 tics, uses the transform to place points.
|
Color |
getBackground() |
double[] |
getDataCoordinates(double panel_x,
double panel_y)
Based on the coordinates of the panel, gets the coordinates in data space.
|
DataSet |
getDataSet(int i)
Gets the data set at the corresponding index i.
|
GraphPanel |
getGraphPanel() |
double[] |
getImageCoordinates(double real_x,
double real_y)
Takes a coordinate in the data/real space and returns a coodinate in image space.
|
double |
getKeyX() |
double |
getKeyY() |
String |
getTitle() |
String |
getXLabel() |
int |
getXTicCount() |
String |
getYLabel() |
int |
getYTicCount() |
void |
refresh(boolean rescale)
This does all of the reset/repaint functions.
|
void |
repaint() |
DataSet |
replaceData(int set,
double[] x,
double[] y)
replaces the data set with a new data set consisting of the xy pairs.
|
void |
resetGraph()
Resets the graph and paints it onto a buffered image
|
void |
resetGraph(GraphPainter p) |
void |
resizeGraph(int x,
int y) |
void |
savePng(File f) |
void |
saveSvg(File f) |
void |
setAxisColor(Color c) |
void |
setBackground(Color c) |
void |
setContentSize(int width,
int height) |
void |
setKeyX(double x)
Sets the distance from the right edge of the graph for the top left
cornder of the key.
|
void |
setKeyY(double y)
Sets the distance from the top of the graph to the top of the key.
|
void |
setLabelFont(LGFont labelFont) |
void |
setTicFont(LGFont ticFont) |
void |
setTitle(String label) |
void |
setTitleFont(LGFont font) |
void |
setXLabel(String label) |
void |
setXRange(double min,
double max)
Set the xrange values the minimum must be less than the maximum.
|
void |
setXTicCount(int c) |
void |
setYLabel(String label) |
void |
setYRange(double min,
double max)
Set the xrange values the minimum must be less than the maximum.
|
void |
setYTicCount(int c) |
void |
show()
Shows the graph in its own JFrame
|
void |
show(boolean exit_on_close) |
void |
show(boolean exit_on_close,
String window_title) |
public boolean AUTOX
public boolean AUTOY
public double MINX
public double MINY
public double MAXX
public double MAXY
public int CHEIGHT
public int CWIDTH
public GraphPanel panel
public DataSet addData(double[] x, double[] y)
x - array of x valuesy - array of y valuespublic DataSet replaceData(int set, double[] x, double[] y)
set - x - y - public void resizeGraph(int x,
int y)
public void resetGraph()
public void resetGraph(GraphPainter p)
public void drawYTics(GraphPainter p, AffineTransform t)
p - t - public void drawXTics(GraphPainter p, AffineTransform t)
p - t - public void clearData()
public void drawSet(DataSet set, GraphPainter painter, AffineTransform transform)
public void setXLabel(String label)
public void setYLabel(String label)
public void setTitle(String label)
public void drawBorder(GraphPainter p, AffineTransform transform)
public void savePng(File f) throws IOException
IOExceptionpublic void saveSvg(File f)
public void createTics()
public void autoScaleX()
public void autoScaleY()
public void autoScale()
public void setXRange(double min,
double max)
throws IllegalArgumentException
min - min x valuemax - max y valueIllegalArgumentExceptionpublic void setYRange(double min,
double max)
throws IllegalArgumentException
min - min x valuemax - max y valueIllegalArgumentExceptionpublic DataSet getDataSet(int i)
i - index of selected datasetpublic int dataSetCount()
public void appendPoint(int set,
double x,
double y)
set - x - y - public void setContentSize(int width,
int height)
public void show()
public void show(boolean exit_on_close,
String window_title)
public void show(boolean exit_on_close)
public void repaint()
public void refresh(boolean rescale)
rescale - if the auto scale is performed.public void setYTicCount(int c)
public void setXTicCount(int c)
public int getXTicCount()
public int getYTicCount()
public void setBackground(Color c)
public void setAxisColor(Color c)
public Color getBackground()
public String getXLabel()
public String getYLabel()
public String getTitle()
public void setKeyX(double x)
x - distance from right edge of graph.public void setKeyY(double y)
y - public double getKeyX()
public double getKeyY()
public GraphPanel getGraphPanel()
public double[] getDataCoordinates(double panel_x,
double panel_y)
panel_x - x position on the panel.panel_y - y position on the panel.public double[] getImageCoordinates(double real_x,
double real_y)
real_x - value of x in data space.real_y - value of y in data space.public void setTitleFont(LGFont font)
public void setLabelFont(LGFont labelFont)
public void setTicFont(LGFont ticFont)
Copyright © 2017. All rights reserved.