jhplot
Class HPlot2D
- java.lang.Object
-
- jhplot.gui.GHPanel
-
- jhplot.gui.GHFrame
-
- jhplot.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 Summary
Constructors Constructor and Description HPlot2D()Construct a HChart canvas with a plot with the default parameters 600 by 400, and 10% space for the global title "Default"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 titleHPlot2D(java.lang.String title, int xs, int ys)Construct a HChart canvas with a single plot/graphHPlot2D(java.lang.String title, int xs, int ys, boolean set)Construct a HChart canvas with a single plot/graphHPlot2D(java.lang.String title, int xs, int ys, int n1, int n2)Construct a HChart canvas with plots/graphsHPlot2D(java.lang.String title, int xsize, int ysize, int n1, int n2, boolean set)Create canvas with a several plots
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(HLabel label, double textHeight)Add a label to the Canvas in NDC coordinates.voidclear()Clear the current padvoidclearAll()Clear all padsvoidclose()Close the canvas (and dispose all components).voiddistroy()Remove the canvas framevoiddoc()Show online documentation.voiddraw(Cloud2D c2d)Plot cloud 2D.voiddraw(F2D h)Plot F2D function (x-y) as density plotvoiddraw(H2D h)Draw 2D histogram using a style (see setStyle())voiddraw(Histogram2D h1d)Draw 2D histogramvoiddraw(P1D h)Plot P1D data (x-y) as density plotAxisgetAxis(int axis)Return axis objectsSGLabelgetAxisTitle(int axis)Get label titleColorKeygetColorBar()Get color bar (key) for the current plotJPlotLayoutgetPlotCanvas()Get the original canvasintgetStyle()Get current stylevoidquit()Quit the canvas (and dispose all components) Note: a memory leak is found - no time to study it.voidresizePad(double widthScale, double heightScale)Resize the current pad.voidresizePad(int n1, int n2, double widthScale, double heightScale)Resize the pad given by the inxX and indxY.voidsetAutoRange()Set autorange for the current plotvoidsetAutoRange(boolean autorange)Set autorange or not for the current plotvoidsetAutoRange(int axis, boolean autorange)Set autorange for the current plotvoidsetAutoRangeAll()Set autorange in X and Y at the same time for all plotsvoidsetAxis(int axis, Axis axisObject)Set axis objectsvoidsetAxis(int axis, boolean b)Sets whether an axis line will be drawn or not.voidsetAxisLabelColor(java.awt.Color color)Sets the pen color for ticksvoidsetAxisLabelFont(java.awt.Font fnt)Set fonts for axis LabelvoidsetAxisLabelHeight(double lhgt)Set the label height in physical units.voidsetAxisLabelPosition(int axis, int labp)Position of label for axisvoidsetAxisNumberSubtics(int nstic)Sets the number of small sub-ticksvoidsetAxisPenTicWidth(int penWidth)Sets the pen width to draw tick axesvoidsetAxisTicHeight(double lthgt)Sets the tick heights in NDC unitsvoidsetAxisTitle(int axis, SGLabel lab)Set label for axisvoidsetBackground(java.awt.Color c)Set background for the plot.voidsetColorBar(ColorKey k)Set color bar (key) for the current plotvoidsetData()voidsetGTitle(java.lang.String title)Set global title for this plot.voidsetName(java.lang.String title)Set global title to the current chartvoidsetNameX(java.lang.String s)Sets the name for X axis.voidsetNameY(java.lang.String s)Sets the name for Y axis.voidsetRange(int axis, double min, double max, int bins)Sets the range for the current plot and axis.voidsetStyle(int style)Set style to the current plot.voidsetSubTicLength(int axis, double length)Sets the length of the sub-ticks.voidshowTest()voidupdate()Update current canvasvoidvisible()Set the canvas frame visiblevoidvisible(boolean vs)Set the canvas frame visible or notvoidvisible(int posX, int posY)Set the canvas frame visible.-
Methods inherited from class jhplot.gui.GHFrame
addGraph, cd, componentHidden, componentMoved, componentShown, getCdX, getCdY, getFrame, getHTMLUrl, getNtotX, getNtotY, setPlotsNum, updateFrame
-
Methods inherited from class jhplot.gui.GHPanel
addComp, componentResized, convertSVG, convertSVG, disableDoubleBuffering, enableDoubleBuffering, export, 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
-
-
-
-
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- Titlexsize- size in x directionysize- size in y directionn1- number of plots/graphs in xn2- number of plots/graphs in yset- 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 canvasxs- size in xys- 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 canvasxs- size in xys- size in yset- 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 canvasxs- size in xys- size in yn1- number of plots/graphs in xn2- 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 padheightScale- 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 xn2- the location of the plot in ywidthScale- scale factor applied to the width of the current padheightScale- 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 contoursmin- Min valuemax- Max valuebins- 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.
-
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 axisaxis- 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.
-
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).
-
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