java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.marginallyclever.convenience.swing.graph.SingleLineGraph
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class SingleLineGraph extends JPanel
A simple line graph. Assumes at most one y value per x value. Interpolates between given values.
See Also:
  • Constructor Details

    • SingleLineGraph

      public SingleLineGraph()
  • Method Details

    • updateToolTip

      public void updateToolTip(MouseEvent event)
    • addValue

      public void addValue(double x, double y)
    • removeValue

      public void removeValue(double x)
    • clear

      public void clear()
    • setBounds

      public void setBounds(double xMin, double xMax, double yMin, double yMax)
      Set the bounds of the graph. This limits the range of values that can be displayed. Data outside this range will not be drawn, but will still be stored.
      Parameters:
      xMin - the minimum x value
      xMax - the maximum x value
      yMin - the minimum y value
      yMax - the maximum y value
    • setYMin

      public void setYMin(double yMin)
    • setYMax

      public void setYMax(double yMax)
    • setXMin

      public void setXMin(double xMin)
    • setXMax

      public void setXMax(double xMax)
    • setBoundsToData

      public void setBoundsToData()
    • getDataBounds

      public double[] getDataBounds()
      Returns:
      minx,maxx,miny,maxy
    • getMajorLineColor

      public Color getMajorLineColor()
    • setMajorLineColor

      public void setMajorLineColor(Color majorLineColor)
    • getMinorLineColor

      public Color getMinorLineColor()
    • setMinorLineColor

      public void setMinorLineColor(Color minorLineColor)
    • getGridSpacingX

      public int getGridSpacingX()
    • setGridSpacingX

      public void setGridSpacingX(int gridSpacingX)
    • getGridSpacingY

      public int getGridSpacingY()
    • setGridSpacingY

      public void setGridSpacingY(int gridSpacingY)