Class XYPlot.Curve

  • Enclosing class:
    XYPlot

    public class XYPlot.Curve
    extends java.lang.Object
    Curve on this plot.
    Author:
    Erich Schubert
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  XYPlot.Curve.Itr
      Iterator for the curve. 2D, does not follow Java collections style.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int color
      Suggested color (number).
      protected double[] data
      X and Y positions
      protected int len
      Size.
    • Constructor Summary

      Constructors 
      Constructor Description
      Curve​(int color)
      Constructor.
      Curve​(int color, int size)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(double x, double y)
      Add a coordinate pair, but don't simplify
      int getColor()
      Suggested color number.
      double getX​(int off)
      Curve X value at given position
      double getY​(int off)
      Curve Y value at given position
      XYPlot.Curve.Itr iterator()
      Get an iterator for the curve.
      int size()
      Size of curve.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • data

        protected double[] data
        X and Y positions
      • len

        protected int len
        Size.
      • color

        protected int color
        Suggested color (number).
    • Constructor Detail

      • Curve

        public Curve​(int color)
        Constructor.
        Parameters:
        color - Color number (curve number)
      • Curve

        public Curve​(int color,
                     int size)
        Constructor.
        Parameters:
        color - Color number (curve number)
        size - Expected size
    • Method Detail

      • getColor

        public int getColor()
        Suggested color number.
        Returns:
        Color number
      • add

        public void add​(double x,
                        double y)
        Add a coordinate pair, but don't simplify
        Parameters:
        x - X coordinate
        y - Y coordinate
      • getX

        public double getX​(int off)
        Curve X value at given position
        Parameters:
        off - Offset
        Returns:
        X value
      • getY

        public double getY​(int off)
        Curve Y value at given position
        Parameters:
        off - Offset
        Returns:
        Y value
      • size

        public int size()
        Size of curve.
        Returns:
        curve length
      • iterator

        public XYPlot.Curve.Itr iterator()
        Get an iterator for the curve. Note: this is not a Java style iterator, since the only way to get positions is using "next" in Java style. Here, we can have two getters for current values! Instead, use this style of iteration:
         
         for (XYCurve.Itr it = curve.iterator(); it.valid(); it.advance()) {
           doSomethingWith(it.getX(), it.getY());
         }
         
         
        Returns:
        Iterator