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 boolean
set
-
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 void
clear()
Clear the current graph including graph settings.void
clear(int i1, int i2)
Clear the graph characterized by an index in X and Y.void
clearAll()
Clear all graphs from data and settings.void
close()
Close the canvas (and dispose all components) Note: a memory leak is found - no time to study it.void
doc()
Show online documentation.void
draw(F2D f1)
Draw F2D function as a surface.void
draw(F2D f1, F2D f2)
Draw two F2D functions on the same plot.void
draw(F2D h2, H2D h1)
Draw F2D and H2D on the same plot.void
draw(H2D f1)
Draw H2D histogram.void
draw(H2D[] d)
Draw array of histogramsvoid
draw(H2D h1, F2D h2)
Draw H2D histogram and F2D function on the same plot.void
draw(H2D h1, H2D h2)
Plot two H2D histograms on the same plot.void
draw(P2D h1)
Display P2D data holder with X,Y,Z values in 3D.void
draw(P2D[] d)
Draw array of P2D holdersvoid
draw(P3D h)
Display P3D data holder with X,Y,Z values in 3D as surface.void
draw(P3D[] d)
Draw array of P3D holdersvoid
drawBox()
Set drawiing an empty frame.java.awt.Color
getAxesFontColor()
Color for tic labelsjava.awt.Font
getAxisFont()
Get font for axesint
getColorMode()
Get current the color modedouble
getDistance()
Get the distancedouble
getElevationAngle()
Get the anglejava.awt.Color
getFrameColor()
Get color of the framejava.awt.Color
getLabelColor()
Get label colordouble
getLabelOffset(int axes)
Get offset for labels on Xfloat
getPenWidthAxes()
Gets the pen width to draw axes.double
getRotationAngle()
Get the rotation angledouble
getScaling()
Get the scalingjplot3d.SurfaceModelCanvas
getSurfaceModel()
Get current surfaceboolean
isSurface()
Is the plot will be shown as a surface?void
quit()
exit the frame and clear all componentsvoid
resizePad(double widthScale, double heightScale)
Resize the current pad.void
resizePad(int n1, int n2, double widthScale, double heightScale)
Resize the pad given by the inxX and indxY.void
setAutoRange()
Set autorange in X,Y,Z at the same time for the current plotvoid
setAutoRange(boolean b)
Set autorange in X,Y,Z.void
setAutoRangeAll(boolean b)
Set to autorange all padsvoid
setAutoRangeXY()
Set autorange in Y,Z at the same time for the current plotvoid
setAxesFontColor(java.awt.Color fontColorAxes)
Get color for tic labelsvoid
setAxisFont(java.awt.Font fontAxis)
Sets font for axesvoid
setBars()
Set bar type of plotvoid
setBars(boolean a)
Set bar type of plotvoid
setBoxColor(java.awt.Color a)
Set color of the boxvoid
setBoxed(boolean boxed)
Set boxed framevoid
setColorFill(java.awt.Color a)
Set color of to fill histogram barsvoid
setColorLines(java.awt.Color a)
Set color of the lines to draw histogram barsvoid
setColorMode(int a)
Sets the color modevoid
setContour()
Set contour stylevoid
setContour(boolean a)
Set contour stylevoid
setContourLines(int v)
Set number of divisions for contour plotsvoid
setDensity()
Set density type of plotvoid
setDensity(boolean a)
Set density plotvoid
setDisplayGrids(boolean a)
Display gridvoid
setDisplayXY(boolean a)
Display or not X and Yvoid
setDisplayZ(boolean a)
Display or not title for Zvoid
setDistance(double distance)
Set distance to the objectvoid
setDivisions(int v)
Set number of divisions for surface plotsvoid
setElevationAngle(double angle)
Set the elevation anglevoid
setFill(boolean fill)
Set fill color or not for histogram barsvoid
setFrameColor(java.awt.Color a)
Set color of the framevoid
setLabelColor(java.awt.Color a)
Set color of the labelvoid
setLabelFont(java.awt.Font a)
Set Font for the labelsvoid
setLabelFontColor(java.awt.Color fontColorLabel)
Set color for labelsvoid
setLabelOffsetX(double a)
Set label offset on Xvoid
setLabelOffsetY(double a)
Set label offset on Yvoid
setLabelOffsetZ(double a)
Set label offset on Zvoid
setNameX(java.lang.String a)
Set a name for X axisvoid
setNameY(java.lang.String a)
Set a name for Y axisvoid
setNameZ(java.lang.String a)
Set a name for Z axisvoid
setPenWidthAxes(double w)
Set line width to draw axes.void
setRange(double Xmin, double Xmax, double Ymin, double Ymax)
Set X and Y range for the 3D plot.void
setRange(double Xmin, double Xmax, double Ymin, double Ymax, double Zmin, double Zmax)
Set X, Y, Z ranges for the 3D plotvoid
setRangeZ(double Zmin, double Zmax)
Sets the z range of calculated surface vertices.void
setRotationAngle(double angle)
Set the rotation angle.void
setScaling(double scale)
Set the scalingvoid
setSurface()
Set surface type of plotvoid
setSurface(boolean a)
Set surface type of plotvoid
setTicFont(java.awt.Font a)
Set font for the ticksvoid
setTicOffset(double a)
Set tick offsetvoid
update()
Update the graphicsvoid
update(int n1, int n2)
Refresh only a particular plotvoid
updateAll()
Refresh all the plots on the same canvas HPLOTvoid
updateData()
Update data on the plotvoid
updateData(int n1, int n2)
Update data on the plotvoid
visible()
Show the canvasvoid
visible(boolean vs)
Set the canvas frame visible or notvoid
visible(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