Package hec.gfx2d

Class PlotIcon

All Implemented Interfaces:
Serializable, Accessible, Icon

public class PlotIcon extends PlotIconBase
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:
  • Field Details

    • margins

      public Insets margins
    • lineThickness

      public int lineThickness
    • _curveColors

      public Vector _curveColors
    • _xData

      protected Vector _xData
    • _yData

      protected Vector _yData
    • _xCurve

      protected Vector _xCurve
    • _yCurve

      protected Vector _yCurve
    • _sizes

      protected Vector _sizes
  • Constructor Details

    • PlotIcon

      public PlotIcon()
    • PlotIcon

      public PlotIcon(Dimension dim)
      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

      public void addData(TimeSeriesContainer tsContainer)
      Overrides:
      addData in class PlotIconBase
    • setData

      public void setData(TimeSeriesContainer tsContainer)
      Description copied from class: PlotIconBase
      Sets this class to hold a TimeSeriesContainer. All other data references are lost.
      Overrides:
      setData in class PlotIconBase
    • addData

      public void addData(PairedDataContainer pdContainer)
      Overrides:
      addData in class PlotIconBase
    • setData

      public void setData(PairedDataContainer pdContainer)
      Description copied from class: PlotIconBase
      Sets this class to hold a PairedDataContainer. All other data references are lost.
      Overrides:
      setData in class PlotIconBase
    • 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

      public void setData(Vector x, Vector y)
      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

      public void setColors(Vector colors)
    • getColors

      public Vector getColors()
    • clearData

      public void clearData()
      Overrides:
      clearData in class PlotIconBase
    • getDataContainerList

      public List getDataContainerList()
      Overrides:
      getDataContainerList in class PlotIconBase
    • getXDataVector

      public Vector getXDataVector()
    • getYDataVector

      public Vector getYDataVector()
    • isDrawingPoints

      public boolean isDrawingPoints()
    • setDrawPoints

      public void setDrawPoints(boolean drawpoints)
    • getPointSize

      public int getPointSize()
    • setPointSize

      public void setPointSize(int pointSize)
    • paintIcon

      public void paintIcon(Component c, Graphics g, int x, int y)
      Specified by:
      paintIcon in interface Icon
      Overrides:
      paintIcon in class ImageIcon
    • paintPlotIcon

      protected void paintPlotIcon(Component c, Graphics2D g2, int x, int y)
    • computeCurve

      protected void computeCurve()