Class Plot2DPanelOJ

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.math.plot.PlotPanel
org.openjump.core.ui.plot.Plot2DPanelOJ
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class Plot2DPanelOJ extends org.math.plot.PlotPanel
Class suitable for plotting 2D data on a panel, to be added to a swing container. Class for ascending compatibility
Author:
Yann Richet
See Also:
  • Constructor Details

    • Plot2DPanelOJ

      public Plot2DPanelOJ()
      Constructor for Plot2DPanel. Create a new blank instance of Plot2DPanel, to be added to a swing component.
    • Plot2DPanelOJ

      public Plot2DPanelOJ(double[] min, double[] max, String[] axesScales, String[] axesLabels)
    • Plot2DPanelOJ

      public Plot2DPanelOJ(org.math.plot.canvas.PlotCanvas _canvas, String legendOrientation)
    • Plot2DPanelOJ

      public Plot2DPanelOJ(org.math.plot.canvas.PlotCanvas _canvas)
    • Plot2DPanelOJ

      public Plot2DPanelOJ(String legendOrientation)
  • Method Details

    • addScatterPlot

      public int addScatterPlot(String name, Color color, double[][] XY)
      Adds a scatter plot (each data point is plotted as a single dot marker) to the current plot panel.
      Parameters:
      name - Name for the plot, which will be used in the legend. (String)
      color - Plot color. (Color)
      XY - Pairs of array of double. First one contains the X position of the data points, second contains Y position.
      Each array of the pair must be of the same length; if not a ArrayIndexOutOfBoundsException exception will be thrown.
      Each data set must come in pair of array of double; if not a ArrayIndexOutOfBoundsException exception will be thrown.
      Returns:
      the index of the plot in the panel (int).
      See Also:
    • addScatterPlot

      public int addScatterPlot(String name, Color color, double[] Y)
    • addScatterPlot

      public int addScatterPlot(String name, Color color, double[] X, double[] Y)
    • addScatterPlot

      public int addScatterPlot(String name, double[][] XY)
    • addScatterPlotOJ

      public int addScatterPlotOJ(String name, double[][] XY, int[] fID, PlugInContext context, Layer layer)
      [sstein] method for OpenJUMP
      Parameters:
      name - name of the plot
      XY - data as a 2-dimensional array of double
      fID - feature identifiers as an array of integers
      context - the PlugInContext
      layer - layer
    • addScatterPlot

      public int addScatterPlot(String name, double[] Y)
    • addScatterPlot

      public int addScatterPlot(String name, double[] X, double[] Y)
    • addLinePlot

      public int addLinePlot(String name, Color color, double[][] XY)
      Adds a line plot (each data point is connected to the next one by a solid line) to the current plot panel.
      Parameters:
      name - Name for the plot, which will be used in the legend. (String)
      color - Plot color. (Color)
      XY - Pairs of array of double. First one contains the X position of the data points, second contains Y position.
      Each array of the pair must be of the same length; if not a ArrayIndexOutOfBoundsException exception will be thrown.
      Each data set must come in pair of array of double; if not a ArrayIndexOutOfBoundsException exception will be thrown.
      Returns:
      the index of the plot in the panel (int).
      See Also:
    • addLinePlot

      public int addLinePlot(String name, Color color, double[] Y)
    • addLinePlot

      public int addLinePlot(String name, Color color, double[] X, double[] Y)
    • addLinePlot

      public int addLinePlot(String name, double[][] XY)
    • addLinePlot

      public int addLinePlot(String name, double[] Y)
    • addLinePlot

      public int addLinePlot(String name, double[] X, double[] Y)
    • addBarPlot

      public int addBarPlot(String name, Color color, double[][] XY)
      Adds a bar plot (each data point is shown as a dot marker connected to the horizontal axis by a vertical line) to the current plot panel.
      Parameters:
      name - Name for the plot, which will be used in the legend. (String)
      color - Plot color. (Color)
      XY - Pairs of array of double. First one contains the X position of the data points, second contains Y position.
      Each array of the pair must be of the same length; if not a ArrayIndexOutOfBoundsException exception will be thrown.
      Each data set must come in pair of array of double; if not a ArrayIndexOutOfBoundsException exception will be thrown.
      Returns:
      the index of the plot in the panel (int).
      See Also:
    • addBarPlot

      public int addBarPlot(String name, Color color, double[] Y)
    • addBarPlot

      public int addBarPlot(String name, Color color, double[] X, double[] Y)
    • addBarPlot

      public int addBarPlot(String name, double[][] XY)
    • addBarPlot

      public int addBarPlot(String name, double[] Y)
    • addBarPlotOJ

      public int addBarPlotOJ(String name, double[] Y, int[] fID, PlugInContext context, Layer layer)
    • addBarPlot

      public int addBarPlot(String name, double[] X, double[] Y)
    • addStaircasePlot

      public int addStaircasePlot(String name, Color color, double[][] XY)
      Adds a staircase plot (each data point is connected to the following one by a horizontal line then a vertical line) to the current plot panel.
      Parameters:
      name - Name for the plot, which will be used in the legend. (String)
      color - Plot color. (Color)
      XY - Pairs of array of double. First one contains the X position of the data points, second contains Y position.
      Each array of the pair must be of the same length; if not a ArrayIndexOutOfBoundsException exception will be thrown.
      Each data set must come in pair of array of double; if not a ArrayIndexOutOfBoundsException exception will be thrown.
      Returns:
      the index of the plot in the panel (int).
      See Also:
    • addStaircasePlot

      public int addStaircasePlot(String name, Color color, double[] Y)
    • addStaircasePlot

      public int addStaircasePlot(String name, Color color, double[] X, double[] Y)
    • addStaircasePlot

      public int addStaircasePlot(String name, double[][] XY)
    • addStaircasePlot

      public int addStaircasePlot(String name, double[] Y)
    • addStaircasePlot

      public int addStaircasePlot(String name, double[] X, double[] Y)
    • addBoxPlot

      public int addBoxPlot(String name, Color color, double[][] XY, double[][] dXdY)
      Adds a box plot to the current plot panel. Each data point is plotted as a dot marker at the center of a rectangle.
      Parameters:
      name - Name for the plot, which will be used in the legend. (String)
      color - Plot color. (Color)
      XY - m*2 array of array of double. Contains the x,y coordinates of the m boxes' center (m lines, 2 rows).
      dXdY - m*2 array of array of double. Contains the width and heigth of the m boxes (m lines, 2 rows).
      Returns:
      the index of the plot in the panel (int).
      See Also:
    • addBoxPlot

      public int addBoxPlot(String name, double[][] XY, double[][] dXdY)
    • addBoxPlot

      public int addBoxPlot(String name, Color color, double[][] XYdXdY)
      Adds a box plot to the current plot panel. Each data point is plotted as a dot marker at the center of a rectangle.
      Parameters:
      name - Name for the plot, which will be used in the legend. (String)
      color - Plot color. (Color)
      XYdXdY - m*4 array of array of double. Contains the x,y coordinates of the m boxes' center and the boxes width and heigth (m lines, 4 rows).
      Returns:
      the index of the plot in the panel (int).
      See Also:
    • addBoxPlot

      public int addBoxPlot(String name, double[][] XYdXdY)
    • addHistogramPlot

      public int addHistogramPlot(String name, Color color, double[][] XY, double[] dX)
      Adds a histogram plot to the current plot panel. Each data point is as vertical bar which width can be set.
      Parameters:
      name - Name for the plot, which will be used in the legend. (String)
      color - Plot color. (Color)
      XY - m*2 array of array of double. Contains the x coordinate and the heigth of each bar (m lines, 2 rows).
      dX - Array of double. Contains the width each bar (m lines).
      Returns:
      the index of the plot in the panel (int).
      See Also:
    • addHistogramPlot

      public int addHistogramPlot(String name, double[][] XY, double[] dX)
    • addHistogramPlot

      public int addHistogramPlot(String name, Color color, double[][] XYdX)
    • addHistogramPlot

      public int addHistogramPlot(String name, double[][] XYdX)
      Adds a histogram plot to the current plot panel. Each data point is as vertical bar which width can be set.
      Parameters:
      name - Name for the plot, which will be used in the legend. (String)
      XYdX - m*3 array of array of double. Contains the x coordinate, the heigth of each bar and the width of each bar (m lines, 3 rows).
      Returns:
      the index of the plot in the panel (int).
      See Also:
    • addHistogramPlot

      public int addHistogramPlot(String name, Color color, double[] sample, int n)
      Adds a plot of the statistical repartition of a sample, as a histogram.
      Parameters:
      name - Name for the plot, which will be used in the legend. (String)
      color - Plot color. (Color)
      sample - Array of double containing the data which statistics will be plotted.
      n - Bin number for the statistics (int).
      Returns:
      the index of the plot in the panel (int).
    • addHistogramPlot

      public int addHistogramPlot(String name, double[] X, int n)
    • addHistogramPlotOJ

      public int addHistogramPlotOJ(String name, double[] X, int n, PlugInContext context, Layer layer, String attrName)
      [sstein] method for OJUMP
      Parameters:
      name - name of the plot
      X - data as a double array
      n - number of classes
      context - the PlugInContext
      layer - the Layer
      attrName - name of the attribute to plot
    • addHistogramPlot

      public int addHistogramPlot(String name, Color color, double[] sample, double... bounds)
      Adds a plot of the statistical repartition of a sample, as a histogram. The bins' limits can be set.
      Parameters:
      name - Name for the plot, which will be used in the legend. (String)
      color - Plot color. (Color)
      sample - Array of double containing the data which statistics will be plotted.
      bounds - Specify the limits for the bins' boundaries.
      Returns:
      the index of the plot in the panel (int).
    • addHistogramPlot

      public int addHistogramPlot(String name, double[] X, double... bounds)
    • addHistogramPlot

      public int addHistogramPlot(String name, Color color, double[] X, double min, double max, int n)
    • addHistogramPlot

      public int addHistogramPlot(String name, double[] X, double min, double max, int n)
    • addCloudPlot

      public int addCloudPlot(String name, Color color, double[][] sampleXY, int nX, int nY)
    • addCloudPlot

      public int addCloudPlot(String name, double[][] sampleXY, int nX, int nY)
    • addPlot

      public int addPlot(String type, String name, Color color, double[]... XY)
      Specified by:
      addPlot in class org.math.plot.PlotPanel
    • getYData

      public Object[] getYData()
      Gets an array with data from Y. In the case of Histogram getYData method it returns the absolute frequency per classes
      Returns:
      array Object[]
    • getYData_RelativeFrequency

      public Object[] getYData_RelativeFrequency()
      returns the relative frequancy of Y data
      Returns:
      array Object[]
    • getYData_CumulativeFrequency

      public Object[] getYData_CumulativeFrequency()
      returns the cumulative frequancy of Y data
      Returns:
      array Object[]
    • getXData

      public Object[] getXData()
      Gets an array with data from X. In the case of Histogram getYData method returns the media value of the range fro each interval (for instance: 50 (interval between 0-100), 150 (interval between 100-200) etc)
      Returns:
      array Object[]
    • getXData_limits

      public Object[] getXData_limits(boolean maxvalue)
      gets the limit values of each interval of X data. maxvalue true= the upper value, maxvalue false= the lower value
      Parameters:
      maxvalue - whether the method return max values (true) or min values (false)
      Returns:
      max or min values of each class