Package hec.gfx2d
Class PlotIcon
java.lang.Object
javax.swing.ImageIcon
hec.gfx2d.PlotIconBase
hec.gfx2d.PlotIcon
- All Implemented Interfaces:
Serializable
,Accessible
,Icon
A "postage stamp plot", or a mini-plot that only has the curve (one)
plotted. There are no labels, axises, etc.
This class implements Icon. An example is using this icon in conjunction with a Button (i.e., as the argument for the constructor of the button). The x-axis can either be int[] (as in a time series plot) or double[]. The y-axis is always double. The plot size can be fixed with setSize(), or by using a container that does not change size. For a Button, it is best to set the margins to 0 (zero). The plot margin, line color, line thickness, and background color may all be set by changing the public parameters:
public Insets margins = new Insets(5, 5, 5, 5); public int lineThickness = 1; public Color linecolor = Color.blue; public Color _backgroundColor = Color.white;Example:
PlotIcon plotIcon = new PlotIcon(); plotIcon.setData(myX[], myY[]); plotIcon.setSize(new Dimension(40, 60)) // optional - fixes size to 40 x 60 JButton plotButton = new JButton(icon); plotButton.setMargin(new Insets(0,0,0,0)); plotButton.setBounds( ... // plus other JButton stuff! // All done! (to update with a new data set, just call setData again, then repaint
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.ImageIcon
ImageIcon.AccessibleImageIcon
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Vector
protected Vector
protected Vector
protected Vector
protected Vector
int
Fields inherited from class hec.gfx2d.PlotIconBase
_accumulationType, _backgroundColor, _borderColor, _cumulativeInterval, _dataContainerList, _dataSetNames, _dimension, _fixedDimension, _maxXSet, _maxYSet, _minXSet, _minYSet, _noDataColor, _selected, _size, _xLoc, _yLoc, UNDEFINED, UNDEFINED_MAX, UNDEFINED_MIN
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addData
(double[] x, double[] y) Add data to be represented.void
addData
(int[] x, double[] y) Add data to be represented.void
addData
(PairedDataContainer pdContainer) void
addData
(TimeSeriesContainer tsContainer) void
protected void
int
boolean
void
protected void
paintPlotIcon
(Component c, Graphics2D g2, int x, int y) void
void
setData
(double[] x, double[] y) Set the data to be represented.void
setData
(int[] x, double[] y) Set the data to be represented.void
setData
(PairedDataContainer pdContainer) Sets this class to hold a PairedDataContainer.void
setData
(TimeSeriesContainer tsContainer) Sets this class to hold a TimeSeriesContainer.void
Set the data to be represented.void
setDrawPoints
(boolean drawpoints) void
setPointSize
(int pointSize) Methods inherited from class hec.gfx2d.PlotIconBase
accumulate, getColorSettings, getCumulativeInterval, getDataContainer, getDataSetName, getDataSetNames, getIconHeight, getIconWidth, getLastValue, getRectangle, hasData, setColorSettings, setCumulative, setDataContainerList, setDataSetName, setDataSetNames, setSelected, setSize, setTsDataSetNames, setXLimits, setXLimits, setYLimits
Methods inherited from class javax.swing.ImageIcon
getAccessibleContext, getDescription, getImage, getImageLoadStatus, getImageObserver, loadImage, setDescription, setImage, setImageObserver, toString
-
Field Details
-
margins
-
lineThickness
public int lineThickness -
_curveColors
-
_xData
-
_yData
-
_xCurve
-
_yCurve
-
_sizes
-
-
Constructor Details
-
PlotIcon
public PlotIcon() -
PlotIcon
Fix the icon size (or call setSize) -
PlotIcon
public PlotIcon(double[] x, double[] y) Pass in double data values in the constructor (or call setData) -
PlotIcon
public PlotIcon(int[] x, double[] y) Pass in int x, and double y data values in the constructor (or call setData)
-
-
Method Details
-
addData
- Overrides:
addData
in classPlotIconBase
-
setData
Description copied from class:PlotIconBase
Sets this class to hold a TimeSeriesContainer. All other data references are lost.- Overrides:
setData
in classPlotIconBase
-
addData
- Overrides:
addData
in classPlotIconBase
-
setData
Description copied from class:PlotIconBase
Sets this class to hold a PairedDataContainer. All other data references are lost.- Overrides:
setData
in classPlotIconBase
-
setData
public void setData(double[] x, double[] y) Set the data to be represented. This will also update the data. The data is not duplicated, but a pointer is kept. -
setData
public void setData(int[] x, double[] y) Set the data to be represented. This will also update the data. The data is not duplicated, but a pointer is kept. -
addData
public void addData(double[] x, double[] y) Add data to be represented. This will also update the data. The data is not duplicated, but a pointer is kept. -
addData
public void addData(int[] x, double[] y) Add data to be represented. This will also update the data. The data is not duplicated, but a pointer is kept. -
setData
Set the data to be represented. This will also update the data. The data is not duplicated, but a pointer is kept. y is a Vector of doubleArrayContainers x may be a Vector of intArrayContainers or doubleArrayContainers -
setColors
-
getColors
-
clearData
public void clearData()- Overrides:
clearData
in classPlotIconBase
-
getDataContainerList
- Overrides:
getDataContainerList
in classPlotIconBase
-
getXDataVector
-
getYDataVector
-
isDrawingPoints
public boolean isDrawingPoints() -
setDrawPoints
public void setDrawPoints(boolean drawpoints) -
getPointSize
public int getPointSize() -
setPointSize
public void setPointSize(int pointSize) -
paintIcon
-
paintPlotIcon
-
computeCurve
protected void computeCurve()
-