jhplot
Class HPlot3D
- java.lang.Object
-
- jhplot.gui.GHPanel
-
- jhplot.gui.GHFrame
-
- jhplot.HPlot3D
-
- All Implemented Interfaces:
- java.awt.event.ComponentListener, java.io.Serializable, java.util.EventListener
- Direct Known Subclasses:
- SHPlot3D
public class HPlot3D extends GHFrame
Create a interactive canvas to show objects in 3D. Use it for showing 2D histograms (H2D class), functions (F2D), data points (P2D class) or more complicated surfaces (P3D class).- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description booleanset
-
Constructor Summary
Constructors Constructor and Description HPlot3D()Construct a 3D canvas with a plot with the default parameters 600 by 400, and 10% space for the global title "Default"HPlot3D(java.lang.String title)Construct a 3D canvas with a plot with the default parameters 600 by 400, and 10% space for the global titleHPlot3D(java.lang.String title, int xs, int ys)Construct a 3D canvas with a single plot/graphHPlot3D(java.lang.String title, int xsize, int ysize, int n1, int n2)Create a 3D canvas to display data.HPlot3D(java.lang.String title, int xsize, int ysize, int n1, int n2, boolean set)Create interactive 3D canvas to display data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclear()Clear the current graph including graph settings.voidclear(int i1, int i2)Clear the graph characterized by an index in X and Y.voidclearAll()Clear all graphs from data and settings.voidclose()Close the canvas (and dispose all components) Note: a memory leak is found - no time to study it.voiddoc()Show online documentation.voiddraw(F2D f1)Draw F2D function as a surface.voiddraw(F2D f1, F2D f2)Draw two F2D functions on the same plot.voiddraw(F2D h2, H2D h1)Draw F2D and H2D on the same plot.voiddraw(H2D f1)Draw H2D histogram.voiddraw(H2D[] d)Draw array of histogramsvoiddraw(H2D h1, F2D h2)Draw H2D histogram and F2D function on the same plot.voiddraw(H2D h1, H2D h2)Plot two H2D histograms on the same plot.voiddraw(P2D h1)Display P2D data holder with X,Y,Z values in 3D.voiddraw(P2D[] d)Draw array of P2D holdersvoiddraw(P3D h)Display P3D data holder with X,Y,Z values in 3D as surface.voiddraw(P3D[] d)Draw array of P3D holdersvoiddrawBox()Set drawiing an empty frame.java.awt.ColorgetAxesFontColor()Color for tic labelsjava.awt.FontgetAxisFont()Get font for axesintgetColorMode()Get current the color modedoublegetDistance()Get the distancedoublegetElevationAngle()Get the anglejava.awt.ColorgetFrameColor()Get color of the framejava.awt.ColorgetLabelColor()Get label colordoublegetLabelOffset(int axes)Get offset for labels on XfloatgetPenWidthAxes()Gets the pen width to draw axes.doublegetRotationAngle()Get the rotation angledoublegetScaling()Get the scalingjplot3d.SurfaceModelCanvasgetSurfaceModel()Get current surfacebooleanisSurface()Is the plot will be shown as a surface?voidquit()exit the frame and clear all componentsvoidresizePad(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 in X,Y,Z at the same time for the current plotvoidsetAutoRange(boolean b)Set autorange in X,Y,Z.voidsetAutoRangeAll(boolean b)Set to autorange all padsvoidsetAutoRangeXY()Set autorange in Y,Z at the same time for the current plotvoidsetAxesFontColor(java.awt.Color fontColorAxes)Get color for tic labelsvoidsetAxisFont(java.awt.Font fontAxis)Sets font for axesvoidsetBars()Set bar type of plotvoidsetBars(boolean a)Set bar type of plotvoidsetBoxColor(java.awt.Color a)Set color of the boxvoidsetBoxed(boolean boxed)Set boxed framevoidsetColorFill(java.awt.Color a)Set color of to fill histogram barsvoidsetColorLines(java.awt.Color a)Set color of the lines to draw histogram barsvoidsetColorMode(int a)Sets the color modevoidsetContour()Set contour stylevoidsetContour(boolean a)Set contour stylevoidsetContourLines(int v)Set number of divisions for contour plotsvoidsetDensity()Set density type of plotvoidsetDensity(boolean a)Set density plotvoidsetDisplayGrids(boolean a)Display gridvoidsetDisplayXY(boolean a)Display or not X and YvoidsetDisplayZ(boolean a)Display or not title for ZvoidsetDistance(double distance)Set distance to the objectvoidsetDivisions(int v)Set number of divisions for surface plotsvoidsetElevationAngle(double angle)Set the elevation anglevoidsetFill(boolean fill)Set fill color or not for histogram barsvoidsetFrameColor(java.awt.Color a)Set color of the framevoidsetLabelColor(java.awt.Color a)Set color of the labelvoidsetLabelFont(java.awt.Font a)Set Font for the labelsvoidsetLabelFontColor(java.awt.Color fontColorLabel)Set color for labelsvoidsetLabelOffsetX(double a)Set label offset on XvoidsetLabelOffsetY(double a)Set label offset on YvoidsetLabelOffsetZ(double a)Set label offset on ZvoidsetNameX(java.lang.String a)Set a name for X axisvoidsetNameY(java.lang.String a)Set a name for Y axisvoidsetNameZ(java.lang.String a)Set a name for Z axisvoidsetPenWidthAxes(double w)Set line width to draw axes.voidsetRange(double Xmin, double Xmax, double Ymin, double Ymax)Set X and Y range for the 3D plot.voidsetRange(double Xmin, double Xmax, double Ymin, double Ymax, double Zmin, double Zmax)Set X, Y, Z ranges for the 3D plotvoidsetRangeZ(double Zmin, double Zmax)Sets the z range of calculated surface vertices.voidsetRotationAngle(double angle)Set the rotation angle.voidsetScaling(double scale)Set the scalingvoidsetSurface()Set surface type of plotvoidsetSurface(boolean a)Set surface type of plotvoidsetTicFont(java.awt.Font a)Set font for the ticksvoidsetTicOffset(double a)Set tick offsetvoidupdate()Update the graphicsvoidupdate(int n1, int n2)Refresh only a particular plotvoidupdateAll()Refresh all the plots on the same canvas HPLOTvoidupdateData()Update data on the plotvoidupdateData(int n1, int n2)Update data on the plotvoidvisible()Show the canvasvoidvisible(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, 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
-
HPlot3D
public HPlot3D(java.lang.String title, int xsize, int ysize, int n1, int n2, boolean set)Create interactive 3D canvas to display data.- Parameters:
title- Titlexsize- size in x directionysize- size in y directionn1- number of plots/graphs in xn2- number of plots in y
-
HPlot3D
public HPlot3D(java.lang.String title, int xsize, int ysize, int n1, int n2)Create a 3D canvas to display data. Set is done by the default.- 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
-
HPlot3D
public HPlot3D(java.lang.String title, int xs, int ys)Construct a 3D canvas with a single plot/graph- Parameters:
title- Title for the canvasxs- size in xys- size in y
-
HPlot3D
public HPlot3D(java.lang.String title)
Construct a 3D canvas with a plot with the default parameters 600 by 400, and 10% space for the global title- Parameters:
title- Title
-
HPlot3D
public HPlot3D()
Construct a 3D 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.
-
setDistance
public void setDistance(double distance)
Set distance to the object- Parameters:
distance- distance
-
getDistance
public double getDistance()
Get the distance- Returns:
- distance
-
setScaling
public void setScaling(double scale)
Set the scaling- Parameters:
scale-
-
getScaling
public double getScaling()
Get the scaling- Returns:
-
setRotationAngle
public void setRotationAngle(double angle)
Set the rotation angle.- Parameters:
angle- angle
-
getRotationAngle
public double getRotationAngle()
Get the rotation angle- Returns:
- angle
-
setElevationAngle
public void setElevationAngle(double angle)
Set the elevation angle- Parameters:
angle- elevation angle
-
getElevationAngle
public double getElevationAngle()
Get the angle- Returns:
-
setLabelFontColor
public void setLabelFontColor(java.awt.Color fontColorLabel)
Set color for labels- Parameters:
fontColorLabel-
-
update
public void update(int n1, int n2)Refresh only a particular plot- Parameters:
n1- the location of the plot in xn2- the location of the plot in y
-
updateData
public void updateData(int n1, int n2)Update data on the plot- Parameters:
n1- the location of the plot in xn2- the location of the plot in y
-
updateData
public void updateData()
Update data on the plot
-
getLabelOffset
public double getLabelOffset(int axes)
Get offset for labels on X- Returns:
- axes 0 for X, 1 for Y, 2 for Z
-
updateAll
public void updateAll()
Refresh all the plots on the same canvas HPLOT
-
clear
public void clear()
Clear the current graph including graph settings. Note: the current graph is set by the cd() method
-
clear
public void clear(int i1, int i2)Clear the graph characterized by an index in X and Y. This method cleans the data and all graph settings.- Parameters:
i1- location of the graph in Xi2- location of the graph in Y
-
setPenWidthAxes
public void setPenWidthAxes(double w)
Set line width to draw axes.- Parameters:
w- width of the lines
-
getPenWidthAxes
public float getPenWidthAxes()
Gets the pen width to draw axes.- Returns:
- width of the lines
-
drawBox
public void drawBox()
Set drawiing an empty frame.
-
clearAll
public void clearAll()
Clear all graphs from data and settings.
-
quit
public void quit()
exit the frame and clear all components
-
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(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
-
visible
public void visible()
Show the canvas
-
isSurface
public boolean isSurface()
Is the plot will be shown as a surface?- Returns:
- true, if this is a surface plot
-
setNameX
public void setNameX(java.lang.String a)
Set a name for X axis- Parameters:
a- Name of the label for X axis
-
setNameY
public void setNameY(java.lang.String a)
Set a name for Y axis- Parameters:
a- Name of the label for Y axis
-
setNameZ
public void setNameZ(java.lang.String a)
Set a name for Z axis- Parameters:
a- Name of the label for Z axis
-
setLabelFont
public void setLabelFont(java.awt.Font a)
Set Font for the labels- Parameters:
a- Font
-
setAxisFont
public void setAxisFont(java.awt.Font fontAxis)
Sets font for axes- Parameters:
fontAxis- font
-
getAxisFont
public java.awt.Font getAxisFont()
Get font for axes- Returns:
-
setLabelColor
public void setLabelColor(java.awt.Color a)
Set color of the label- Parameters:
a- Color
-
setColorLines
public void setColorLines(java.awt.Color a)
Set color of the lines to draw histogram bars- Parameters:
a- Color
-
setColorFill
public void setColorFill(java.awt.Color a)
Set color of to fill histogram bars- Parameters:
a- Color
-
setFill
public void setFill(boolean fill)
Set fill color or not for histogram bars- Parameters:
fill- if true, color will be set for the histogram bars
-
setTicFont
public void setTicFont(java.awt.Font a)
Set font for the ticks- Parameters:
a- Font
-
setDisplayXY
public void setDisplayXY(boolean a)
Display or not X and Y- Parameters:
a- true if it should be shown
-
setDivisions
public void setDivisions(int v)
Set number of divisions for surface plots- Parameters:
v- number of divisions in X and Y
-
setContourLines
public void setContourLines(int v)
Set number of divisions for contour plots- Parameters:
v- number of divisions in X and Y
-
setDisplayGrids
public void setDisplayGrids(boolean a)
Display grid- Parameters:
a- true if grid is displayed
-
setDisplayZ
public void setDisplayZ(boolean a)
Display or not title for Z- Parameters:
a- true, if it is shown
-
setContour
public void setContour()
Set contour style
-
setContour
public void setContour(boolean a)
Set contour style- Parameters:
a-
-
setDensity
public void setDensity()
Set density type of plot
-
setDensity
public void setDensity(boolean a)
Set density plot- Parameters:
a-
-
setSurface
public void setSurface()
Set surface type of plot
-
setSurface
public void setSurface(boolean a)
Set surface type of plot
-
setBars
public void setBars()
Set bar type of plot
-
setBars
public void setBars(boolean a)
Set bar type of plot
-
setBoxColor
public void setBoxColor(java.awt.Color a)
Set color of the box- Parameters:
a- Color
-
setFrameColor
public void setFrameColor(java.awt.Color a)
Set color of the frame- Parameters:
a- Color
-
setBoxed
public void setBoxed(boolean boxed)
Set boxed frame- Parameters:
boxed- true if it is boxed
-
getAxesFontColor
public java.awt.Color getAxesFontColor()
Color for tic labels- Returns:
-
setAxesFontColor
public void setAxesFontColor(java.awt.Color fontColorAxes)
Get color for tic labels- Parameters:
fontColorAxes- color
-
getFrameColor
public java.awt.Color getFrameColor()
Get color of the frame- Returns:
- a Color
-
setColorMode
public void setColorMode(int a)
Sets the color mode- Parameters:
a- color modes:0: WIREFRAME
1: HIDDEN
2: SPECTRUM IN COLOR
3: GRAYSCALE
4: DUALSHADES
5: FOG
6: MESH
-
getSurfaceModel
public jplot3d.SurfaceModelCanvas getSurfaceModel()
Get current surface- Returns:
-
getColorMode
public int getColorMode()
Get current the color mode- Parameters:
a- color modes:0: WIREFRAME
1: HIDDEN
2: SPECTRUM IN COLOR
3: GRAYSCALE
4: DUALSHADES
5: FOG
6: MESH
-
getLabelColor
public java.awt.Color getLabelColor()
Get label color- Returns:
-
update
public void update()
Update the graphics
-
setTicOffset
public void setTicOffset(double a)
Set tick offset- Parameters:
a- tick offset
-
setLabelOffsetX
public void setLabelOffsetX(double a)
Set label offset on X- Parameters:
a- label offset
-
setLabelOffsetY
public void setLabelOffsetY(double a)
Set label offset on Y- Parameters:
a- label offset
-
setLabelOffsetZ
public void setLabelOffsetZ(double a)
Set label offset on Z- Parameters:
a- label offset
-
setRange
public void setRange(double Xmin, double Xmax, double Ymin, double Ymax)Set X and Y range for the 3D plot. Z is set to autorange.- Parameters:
Xmin- Min in XXmax- Max in XYmin- Min in YYmax- Max in Y
-
setRange
public void setRange(double Xmin, double Xmax, double Ymin, double Ymax, double Zmin, double Zmax)Set X, Y, Z ranges for the 3D plot- Parameters:
Xmin- Min in XXmax- Max in XYmin- Min in YYmax- Max in YZmin- Min in ZZmax- Max in Z
-
setRangeZ
public void setRangeZ(double Zmin, double Zmax)Sets the z range of calculated surface vertices. The ranges will not affect surface appearance. They affect axes scale appearance.- Parameters:
Zmin- the minimum zZmax- the maximum z
-
draw
public void draw(H2D f1)
Draw H2D histogram. By default, we shows it as bars. Call setSurface() to show it as a surface.- Parameters:
f1- H2D histogram
-
draw
public void draw(H2D[] d)
Draw array of histograms- Parameters:
d- array of histograms
-
draw
public void draw(P2D h1)
Display P2D data holder with X,Y,Z values in 3D. If setSurface applied, it will draw the surface.- Parameters:
h1- P2D data holder
-
draw
public void draw(P2D[] d)
Draw array of P2D holders- Parameters:
d- array of P2D data holders
-
setAutoRange
public void setAutoRange(boolean b)
Set autorange in X,Y,Z.- Parameters:
b- if true, sets autorange
-
setAutoRangeAll
public void setAutoRangeAll(boolean b)
Set to autorange all pads- Parameters:
b-
-
setAutoRange
public void setAutoRange()
Set autorange in X,Y,Z at the same time for the current plot
-
setAutoRangeXY
public void setAutoRangeXY()
Set autorange in Y,Z at the same time for the current plot
-
draw
public void draw(P3D h)
Display P3D data holder with X,Y,Z values in 3D as surface. If setSurface applied, it will draw the surface- Parameters:
h- P3D data holder.
-
draw
public void draw(P3D[] d)
Draw array of P3D holders- Parameters:
d- array of P3D data holders
-
draw
public void draw(H2D h1, H2D h2)
Plot two H2D histograms on the same plot. When only one histogram is plotted, i.e. h2=null, then the bar option is used. If two histograms are plotted, the surface option is used (in this case the numbers of bins in X and Y should be the same.- Parameters:
h1- first H2D histogramh2- second H2D histogram
-
draw
public void draw(F2D f1)
Draw F2D function as a surface.- Parameters:
f1- F2D function
-
draw
public void draw(F2D f1, F2D f2)
Draw two F2D functions on the same plot. The bar option is not supported, i.e. the functions will be shown by surface.- Parameters:
f1- first F2D functionf2- second F2D function
-
draw
public void draw(H2D h1, F2D h2)
Draw H2D histogram and F2D function on the same plot. Note: the bar option for histogram is not supported. In addition, the number of bins in X and Y should be the same.- Parameters:
h1- H2D histogramh2- F2D function
-
draw
public void draw(F2D h2, H2D h1)
Draw F2D and H2D on the same plot.- Parameters:
h2- F2D functionh1- H2D histogram
-
close
public void close()
Close the canvas (and dispose all components) Note: a memory leak is found - no time to study it. set to null all the stuff
-
doc
public void doc()
Show online documentation.
-
-
DMelt 3.0 © DataMelt by jWork.ORG