jhplot
Class HPlot2D

java.lang.Object
  extended by jhplot.GHPanel
      extended by jhplot.GHFrame
          extended by jhplot.HPlot2D
All Implemented Interfaces:
ComponentListener, Serializable, 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 Summary
HPlot2D()
          Construct a HChart canvas with a plot with the default parameters 600 by 400, and 10% space for the global title "Default"
HPlot2D(String title)
          Construct a HChart canvas with a plot with the default parameters 600 by 400, and 10% space for the global title
HPlot2D(String title, int xs, int ys)
          Construct a HChart canvas with a single plot/graph
HPlot2D(String title, int xs, int ys, boolean set)
          Construct a HChart canvas with a single plot/graph
HPlot2D(String title, int xs, int ys, int n1, int n2)
          Construct a HChart canvas with plots/graphs
HPlot2D(String title, int xsize, int ysize, int n1, int n2, boolean set)
          Create canvas with a several plots
 
Method Summary
 void add(HLabel label, double textHeight)
          Add a label to the Canvas in NDC coordinates
 void clear()
          Clear the current pad
 void clearAll()
          Clear all pads
 void close()
          Close the canvas (and dispose all components).
 void distroy()
          Remove the canvas frame
 void doc()
          Show online documentation.
 void draw(Cloud2D c2d)
          Plot cloud 2D.
 void draw(F2D h)
          Plot F2D function (x-y) as density plot
 void draw(H2D h)
          Draw 2D histogram using a style (see setStyle())
 void draw(Histogram2D h1d)
          Draw 2D histogram
 void draw(P1D h)
          Plot P1D data (x-y) as density plot
 sgtplot.Axis getAxis(int axis)
          Return axis objects
 sgtplot.SGLabel getAxisTitle(int axis)
          Get label title
 sgtplot.ColorKey getColorBar()
          Get color bar (key) for the current plot
 sgtplot.swing.JPlotLayout getPlotCanvas()
          Get the original canvas
 int getStyle()
          Get current style
 void quit()
          Quit the canvas (and dispose all components) Note: a memory leak is found - no time to study it.
 void setAutoRange()
          Set autorange for the current plot
 void setAutoRange(boolean autorange)
          Set autorange or not for the current plot
 void setAutoRange(int axis, boolean autorange)
          Set autorange for the current plot
 void setAutoRangeAll()
          Set autorange in X and Y at the same time for all plots
 void setAxis(int axis, sgtplot.Axis axisObject)
          Set axis objects
 void setAxis(int axis, boolean b)
          Sets whether an axis line will be drawn or not.
 void setAxisLabelColor(Color color)
          Sets the pen color for ticks
 void setAxisLabelFont(Font fnt)
          Set fonts for axis Label
 void setAxisLabelPosition(int axis, int labp)
          Position of label for axis
 void setAxisNumberSubtics(int nstic)
          Sets the number of small sub-ticks
 void setAxisPenTicWidth(int penWidth)
          Sets the pen width to draw tick axes
 void setAxisTicHeight(int lthgt)
          Sets the tick heights in NDC units
 void setAxisTitle(int axis, sgtplot.SGLabel lab)
          Set label for axis
 void setBackground(Color c)
          Set background for the plot.
 void setColorBar(sgtplot.ColorKey k)
          Set color bar (key) for the current plot
 void setData()
           
 void setGTitle(String title)
          Set global title for this plot.
 void setName(String title)
          Set global title to the current chart
 void setNameX(String s)
          Sets the name for X axis.
 void setNameY(String s)
          Sets the name for Y axis.
 void setRange(int axis, double min, double max, int bins)
          Sets the range for the current plot and axis.
 void setStyle(int style)
          Set style to the current plot.
 void setSubTicLength(int axis, double length)
          Sets the length of the sub-ticks.
 void showTest()
           
 void update()
          Update current canvas
 void visible()
          Set the canvas frame visible
 void visible(boolean vs)
          Set the canvas frame visible or not
 
Methods inherited from class jhplot.GHFrame
addGraph, cd, componentHidden, componentMoved, componentShown, getCdX, getCdY, getFrame, getHTMLUrl, getNtotX, getNtotY, setPlotsNum, updateFrame
 
Methods inherited from class jhplot.GHPanel
addComp, componentResized, disableDoubleBuffering, enableDoubleBuffering, export, exportDialog, exportImage, getCanvasPanel, getMarginBackground, getMarginPanelBottom, getMarginPanelCenter, getMarginPanelLeft, getMarginPanelRight, getMarginPanelTop, getMarginSizeBottom, getMarginSizeLeft, getMarginSizeRight, getMarginSizeTop, getSizeX, getSizeY, getTextBottom, getTextBottomColor, getTextBottomColorBack, getTextBottomFont, getTextLeft, getTextLeftColor, getTextLeftColorBack, getTextLeftFont, getTextPosBottomX, getTextPosBottomY, getTextPosLeftX, getTextPosLeftY, getTextPosRightX, getTextPosRightY, getTextPosTopX, getTextPosTopY, getTextRight, getTextRightColor, getTextRightColorBack, getTextRightFont, getTextRotationBottom, getTextRotationLeft, getTextRotationRight, getTextRotationTop, getTextTop, getTextTopColor, getTextTopColorBack, getTextTopFont, isBorderShown, printGraph, resetMargins, setGTitle, setGTitle, setGTitle, setGTitle, setMarginBackground, setMarginSizeBottom, setMarginSizeLeft, setMarginSizeRight, setMarginSizeTop, setSizePanel, setTextBottom, setTextBottom, setTextBottom, setTextBottom, setTextBottomColorBack, setTextLeft, setTextLeft, setTextLeft, setTextLeft, setTextLeftColorBack, setTextPosBottomX, setTextPosBottomY, setTextPosLeftX, setTextPosLeftY, setTextPosRightX, setTextPosRightY, setTextPosTopX, setTextPosTopY, setTextRight, setTextRight, setTextRight, setTextRight, setTextRightColorBack, setTextRotationBottom, setTextRotationLeft, setTextRotationRight, setTextRotationTop, setTextTop, setTextTop, setTextTop, setTextTopColorBack, showBorders
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HPlot2D

public HPlot2D(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(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(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(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(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

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 sgtplot.ColorKey getColorBar()
Get color bar (key) for the current plot

Returns:
color bar

setColorBar

public void setColorBar(sgtplot.ColorKey k)
Set color bar (key) for the current plot

Parameters:
k - key

update

public void update()
Update current canvas


getPlotCanvas

public sgtplot.swing.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(String title)
Set global title to the current chart

Parameters:
title - title

setNameX

public void setNameX(String s)
Sets the name for X axis.

Parameters:
s - Title for X axis.

setNameY

public void setNameY(String s)
Sets the name for Y axis.

Parameters:
s - Title for Y axis.

setBackground

public void setBackground(Color c)
Set background for the plot.

Parameters:
c - background color.

setGTitle

public void setGTitle(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


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 sgtplot.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,
                    sgtplot.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(Font fnt)
Set fonts for axis Label

Parameters:
fnt - font

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(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(int 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 sgtplot.SGLabel getAxisTitle(int axis)
Get label title

Returns:
axis

setAxisTitle

public void setAxisTitle(int axis,
                         sgtplot.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



jHepWork 3.0 ©