Documentation of 'jhplot.HPlot2D' Java class.
HPlot2D
jhplot

Class HPlot2D

  • All Implemented Interfaces:
    java.awt.event.ComponentListener, java.io.Serializable, java.util.EventListener


    public class HPlot2D
    extends GHFrame
    A class to build a contour (density) plots in 2D. Use it to show H2D histograms, F2D functions, density plots for P1D arrays.
    See Also:
    Serialized Form
    • Constructor Detail

      • HPlot2D

        public HPlot2D(java.lang.String title,
                       int xsize,
                       int ysize,
                       int n1,
                       int n2,
                       boolean set)
        Create canvas with a several plots
        Parameters:
        title - Title
        xsize - size in x direction
        ysize - size in y direction
        n1 - number of plots/graphs in x
        n2 - number of plots/graphs in y
        set - set or not the graph
      • HPlot2D

        public HPlot2D(java.lang.String title,
                       int xs,
                       int ys)
        Construct a HChart canvas with a single plot/graph
        Parameters:
        title - Title for the canvas
        xs - size in x
        ys - size in y
      • HPlot2D

        public HPlot2D(java.lang.String title,
                       int xs,
                       int ys,
                       boolean set)
        Construct a HChart canvas with a single plot/graph
        Parameters:
        title - Title for the canvas
        xs - size in x
        ys - size in y
        set - set or not the graph (boolean)
      • HPlot2D

        public HPlot2D(java.lang.String title,
                       int xs,
                       int ys,
                       int n1,
                       int n2)
        Construct a HChart canvas with plots/graphs
        Parameters:
        title - Title for the canvas
        xs - size in x
        ys - size in y
        n1 - number of plots/graphs in x
        n2 - number of plots/graphs in y
      • HPlot2D

        public HPlot2D(java.lang.String title)
        Construct a HChart canvas with a plot with the default parameters 600 by 400, and 10% space for the global title
        Parameters:
        title - Title
      • HPlot2D

        public HPlot2D()
        Construct a HChart canvas with a plot with the default parameters 600 by 400, and 10% space for the global title "Default"
    • Method Detail

      • resizePad

        public void resizePad(double widthScale,
                              double heightScale)
        Resize the current pad. It calculates the original pad sizes, and then scale it by a given factor. In this case, the pad sizes can be different.
        Parameters:
        widthScale - scale factor applied to the width of the current pad
        heightScale - scale factor applied the height of the current pad.
      • resizePad

        public void resizePad(int n1,
                              int n2,
                              double widthScale,
                              double heightScale)
        Resize the pad given by the inxX and indxY. It calculates the original pad sizes, and then scale it by a given factor. In this case, the pad sizes can be different.
        Parameters:
        n1 - the location of the plot in x
        n2 - the location of the plot in y
        widthScale - scale factor applied to the width of the current pad
        heightScale - scale factor applied the height of the current pad.
      • draw

        public void draw(Cloud2D c2d)
        Plot cloud 2D. Assume 100 bins in X and Y
        Parameters:
        c2D - Input 2D cloud
      • draw

        public void draw(Histogram2D h1d)
        Draw 2D histogram
        Parameters:
        h1d - input istogram1D
      • draw

        public void draw(H2D h)
        Draw 2D histogram using a style (see setStyle())
        Parameters:
        h - input historam
      • add

        public void add(HLabel label,
                        double textHeight)
        Add a label to the Canvas in NDC coordinates.
        Parameters:
        label - Label to be added
      • getColorBar

        public ColorKey getColorBar()
        Get color bar (key) for the current plot
        Returns:
        color bar
      • setColorBar

        public void setColorBar(ColorKey k)
        Set color bar (key) for the current plot
        Parameters:
        k - key
      • update

        public void update()
        Update current canvas
      • getPlotCanvas

        public JPlotLayout getPlotCanvas()
        Get the original canvas
        Returns:
      • draw

        public void draw(P1D h)
        Plot P1D data (x-y) as density plot
        Parameters:
        h - input P1D
      • draw

        public void draw(F2D h)
        Plot F2D function (x-y) as density plot
        Parameters:
        h - input 2d function
      • setAutoRange

        public void setAutoRange()
        Set autorange for the current plot
      • setAutoRange

        public void setAutoRange(boolean autorange)
        Set autorange or not for the current plot
        Parameters:
        autorange - true if autorange
      • setAutoRange

        public void setAutoRange(int axis,
                                 boolean autorange)
        Set autorange for the current plot
        Parameters:
        axis - axis (0=x, 1=y, 2=z)
        autorange - true if autorange
      • setRange

        public void setRange(int axis,
                             double min,
                             double max,
                             int bins)
        Sets the range for the current plot and axis. In case of Z-axis (axis=2), we changing the contour levels.
        Parameters:
        axis - apply for axis X (=0) or axis Y (=1) and axis Z (=2) for contours
        min - Min value
        max - Max value
        bins - number of bins between min and max
      • setAutoRangeAll

        public void setAutoRangeAll()
        Set autorange in X and Y at the same time for all plots
      • setName

        public void setName(java.lang.String title)
        Set global title to the current chart
        Parameters:
        title - title
      • setNameX

        public void setNameX(java.lang.String s)
        Sets the name for X axis.
        Parameters:
        s - Title for X axis.
      • setNameY

        public void setNameY(java.lang.String s)
        Sets the name for Y axis.
        Parameters:
        s - Title for Y axis.
      • setBackground

        public void setBackground(java.awt.Color c)
        Set background for the plot.
        Parameters:
        c - background color.
      • setGTitle

        public void setGTitle(java.lang.String title)
        Set global title for this plot.
        Overrides:
        setGTitle in class GHPanel
        Parameters:
        title - plot title
      • visible

        public void visible(boolean vs)
        Set the canvas frame visible or not
        Parameters:
        vs - (boolean) true: visible, false: not visible
      • visible

        public void visible()
        Set the canvas frame visible
      • visible

        public void visible(int posX,
                            int posY)
        Set the canvas frame visible. Also set its location.
        Parameters:
        posX - - the x-coordinate of the new location's top-left corner in the parent's coordinate space;
        posY - - he y-coordinate of the new location's top-left corner in the parent's coordinate space
      • showTest

        public void showTest()
      • setData

        public void setData()
      • setStyle

        public void setStyle(int style)
        Set style to the current plot.
        Parameters:
        style - 0 means RASTER style;
        1 means CONTOUR style;
        2 means RASTER_CONTOUR
        3 means AREA_FILL
        4 means AREA_FILL_CONTOUR
        5 means ARROWS
      • getAxis

        public Axis getAxis(int axis)
        Return axis objects
        Parameters:
        axis - axis =0 for X axis, and =1 for Y axis
        Returns:
        axis object
      • setAxis

        public void setAxis(int axis,
                            Axis axisObject)
        Set axis objects
        Parameters:
        axis - axis =0 for X axis, and =1 for Y axis
        axis - object
      • setAxis

        public void setAxis(int axis,
                            boolean b)
        Sets whether an axis line will be drawn or not. This does not affect tics and labels.
        Parameters:
        axis - defines to which axis this function applies, generally something like X_AXIS or Y_AXIS.
        b - toggle, true if the axis should be drawn.
      • setAxisLabelFont

        public void setAxisLabelFont(java.awt.Font fnt)
        Set fonts for axis Label
        Parameters:
        fnt - font
      • setAxisLabelHeight

        public void setAxisLabelHeight(double lhgt)
        Set the label height in physical units.
        Parameters:
        lhgt - label height.
      • setSubTicLength

        public void setSubTicLength(int axis,
                                    double length)
        Sets the length of the sub-ticks. In fact, the actual sub tick length is the value you set here multiplied by the axis length. By default, the tick-length is exactly 0.007 times the axis length. Using a value proportional to the axes system leads to reasonable proportions even if the graph is blown up to full screen (which users often do, trust me).
        Parameters:
        axis - defines to which axis this function applies, generally something like X_AXIS or Y_AXIS.
        length - subtick length relative to the axis length
      • setAxisPenTicWidth

        public void setAxisPenTicWidth(int penWidth)
        Sets the pen width to draw tick axes
        Parameters:
        penWidth - pen width to draw the tick axes lines
      • setAxisLabelColor

        public void setAxisLabelColor(java.awt.Color color)
        Sets the pen color for ticks
        Parameters:
        color - pen color.
      • setAxisNumberSubtics

        public void setAxisNumberSubtics(int nstic)
        Sets the number of small sub-ticks
        Parameters:
        nstic - number of small ticks
      • setAxisTicHeight

        public void setAxisTicHeight(double lthgt)
        Sets the tick heights in NDC units
        Parameters:
        lthgt - height of ticks in NDC units
      • setAxisLabelPosition

        public void setAxisLabelPosition(int axis,
                                         int labp)
        Position of label for axis
        Parameters:
        axis - axis (0 for x, 1 for y)
        labp - position
      • getAxisTitle

        public SGLabel getAxisTitle(int axis)
        Get label title
        Returns:
        axis
      • setAxisTitle

        public void setAxisTitle(int axis,
                                 SGLabel lab)
        Set label for axis
        Parameters:
        lab - label
      • getStyle

        public int getStyle()
        Get current style
      • doc

        public void doc()
        Show online documentation.
      • clearAll

        public void clearAll()
        Clear all pads
      • clear

        public void clear()
        Clear the current pad
      • distroy

        public void distroy()
        Remove the canvas frame
      • close

        public void close()
        Close the canvas (and dispose all components).
      • quit

        public void quit()
        Quit the canvas (and dispose all components) Note: a memory leak is found - no time to study it. set to null all the stuff

DMelt 3.0 © DataMelt by jWork.ORG