jhplot
Class HPlotXYZ
- java.lang.Object
-
- jhplot.gui.GHPanel
-
- jhplot.gui.GHFrame
-
- jhplot.HPlotXYZ
-
- All Implemented Interfaces:
- java.awt.event.ComponentListener, java.io.Serializable, java.util.EventListener
public class HPlotXYZ extends GHFrame
Create a interactive canvas to show objects in 3D. This canvas uses the GL native libraries. Use it for showing 2D histograms (H2D class), functions (F2D), data points (P2D class).- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description booleanset
-
Constructor Summary
Constructors Constructor and Description HPlotXYZ()Construct a HGraph canvas with a plot with the default parameters 600 by 400, and 10% space for the global title "Default"HPlotXYZ(java.lang.String title)Construct a HGraph canvas with a plot with the default parameters 600 by 400, and 10% space for the global titleHPlotXYZ(java.lang.String title, int xs, int ys)Construct a HView2D canvas with a single plot/graphHPlotXYZ(java.lang.String title, int xsize, int ysize, int n1, int n2)Create a canvas to display histograms in 3DHPlotXYZ(java.lang.String title, int xsize, int ysize, int n1, int n2, boolean set)Create a canvas to display histograms in 3D
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description AbstractDrawableadd(AbstractDrawable shape)Add a object to the listAbstractDrawableadd(F2D f)Add a F2D function (a function with 2 arguments, x and y).AbstractDrawableadd(F2D f, double xmin, double xmax, double ymin, double ymax)Add a F2D function (a function with 2 arguments, x and y).AbstractDrawableadd(F2D h1, int xsteps, int ysteps, double xmin, double xmax, double ymin, double ymax)Add a F2D function (a function with 2 arguments, x and y).voidadd(H2D h2d)Show H2D histogram as barsvoidadd(P2D h1)Add a container with X,Y.Z values to be shown.AbstractDrawableadd(P2D h1, java.awt.Color color)Add a container with X,Y.Z values to be shown.AbstractDrawableadd(P2D h1, double pointSize)Add a container with X,Y.Z values to be shown.AbstractDrawableadd(P2D h1, double penSize, java.awt.Color color)Draw X,Y.Z values in 3DvoidaddAsBars(H2D h2d)Add a H2D histogram as bars.AbstractDrawableaddAsSurface(H2D h2d)Add a H2D histogram.voidaddBar(double x, double y, double z, double height, double radius)Build a bar as a cylinder in 3D and add to the list of shapes on the current pad.voidaddDisk(double x, double y, double z, double radiusInner, double radiusOuter, int slices, int loops)Add a sphere to the current canvas.voidaddFlatLine(float[] x, float[] y, double depth)Add a flat line to the current pad.voidaddLight(double x, double y, double z, java.awt.Color AmbiantColor, java.awt.Color DiffuseColor, java.awt.Color SpecularColor)Add light to the scene.voidaddParallelepiped(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)Add parallelepiped to the current canvas.voidaddPoint(double x, double y, double z, double width)Add a point to the list of shapes on the current pad.voidaddPolygon(P2D p2d)Add a flat line to the current pad.voidaddSphere(double x, double y, double z, double radius, double height, int slices, int stacks)Add a sphere to the current canvas.AbstractDrawableaddText(java.lang.String text, double[] pos, java.awt.Color co)Add a text to the canvas.voidaddTube(double x, double y, double z, double radiusBottom, double radiusTop, double height, int slices, int stacks)Add a tube to the current canvas.CameraThreadControlleranimate()Start animation of the current canvas.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.voiddistroy()Remove the canvas framevoiddoc()Show online documentation.voiddraw(AbstractDrawable[] shapes)Draw a list of shapes on the current canvasAbstractDrawabledraw(H2D h2d)Draw a H2D histogram.AbstractDrawabledraw(P2D h1, double penSize, java.awt.Color color)Draw X,Y.Z values in 3D using variable colors.voidexport(java.lang.String file)Fast export of the canvas to an image file (depends on the extension, i.e.ChartgetChart()Get the current canvas chart.intgetContourLevels()Get number of levels for contour plots.booleangetContourMesh3D()Get to contour mesh style from 3D plots.intgetFontAxisLabels()Get fonts for axis labels in terms of GLUT.BITMAP fonts.intgetFontAxisTicks()Get fonts for axis ticks in terms of GLUT.BITMAP fonts.java.util.List<AbstractDrawable>getShapeList()Get list of shapes plotted on the current pad given by the cd() method.ViewgetView()Get current view of the plotted object.voidquit()exit the frame and clear all componentsvoidsetAxesBox(boolean isbox)The box can be turned on/off for the current pad.voidsetAxesLabel(int axis, boolean shown)Show or not label on axes.voidsetAxesLabelFont(java.awt.Font font, Color color)Set font and color for axis labels.voidsetAxisPenWidth(int pwidth)Set line width to draw boxes and axis.voidsetAxisTick(int axis, boolean shown)Show or not ticks on axes.voidsetBackground(java.awt.Color co)Set background for the current pad.voidsetColorFill(java.awt.Color color)Set fill color for the current objectvoidsetColorSolid(boolean solid)If you set true, color will be solid and no colorfull color map is used.voidsetColorWireframe(java.awt.Color color)Set fill color for the current objectvoidsetContourColor3D()Set to contour color style to 3D plots.voidsetContourColor3D(boolean contour)Add (or not) contour color to 3D plot.voidsetContourLevels(int nlevels)Set number of levels for contour plots.voidsetContourMesh3D()Set to contour mesh style to 3D plots.voidsetContourMesh3D(boolean contour)Set (or not) contour mesh style to 3D plots.voidsetFaceDisplayed(boolean face)Set face shown or notvoidsetFontAxisTicks(int font)Set fonts for tick labels in terms of GLUT.BITMAP fonts.voidsetGridColor(java.awt.Color co)Set Grid color to the current padvoidsetLegendBar()Set a legend to a given surface.voidsetNameX(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 axisvoidsetRange(double minX, double maxX, double minY, double maxY, double minZ, double maxZ)Sets the range for the current plotvoidsetRotationAngle(double angle)Get the rotation anglevoidsetScale(double scale)Set the scaling for the current image box.voidsetTickDecimal(int axis, int dig)Set decimal precision for a given axis.voidsetTickDecimalAll(int dig)Set decimal notation with a given number of digits for all ticks.voidsetTickScientific(int axis, int dig)Set scientific notation with a given number of digits.voidsetTickScientificAll(int dig)Set scientific notation with a given number of digits for all ticks.voidsetViewPoint(double x, double y, double z)Set view pointvoidsetWireframe(boolean wiredrame)Set wireframe mode for the current object.voidsetWireframeWidth(double width)Set width of the line for wireframevoidupdate()Update current pad.voidupdate(int n1, int n2)Refresh only a particular pad.voidupdateAll()Refresh all the plots on the same canvas.voidvisible()Show the canvasvoidvisible(boolean vs)Set the canvas frame visible or notvoidvisible(int posX, int posY)Set the canvas frame visible.voidzoom(double scale)Set the scaling for the axis of the current object.-
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, 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
-
HPlotXYZ
public HPlotXYZ(java.lang.String title, int xsize, int ysize, int n1, int n2, boolean set)Create a canvas to display histograms in 3D- Parameters:
title- Titlexsize- size in x directionysize- size in y directionn1- number of plots/graphs in xn2- number of plots in y
-
HPlotXYZ
public HPlotXYZ(java.lang.String title, int xsize, int ysize, int n1, int n2)Create a canvas to display histograms in 3D- 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
-
HPlotXYZ
public HPlotXYZ(java.lang.String title, int xs, int ys)Construct a HView2D canvas with a single plot/graph- Parameters:
title- Title for the canvasxs- size in xys- size in y
-
HPlotXYZ
public HPlotXYZ(java.lang.String title)
Construct a HGraph canvas with a plot with the default parameters 600 by 400, and 10% space for the global title- Parameters:
title- Title
-
HPlotXYZ
public HPlotXYZ()
Construct a HGraph canvas with a plot with the default parameters 600 by 400, and 10% space for the global title "Default"
-
-
Method Detail
-
setRange
public void setRange(double minX, double maxX, double minY, double maxY, double minZ, double maxZ)Sets the range for the current plot- Parameters:
minX- Min value in XmaxX- Max value in XminY- Min value in YmaxY- Max value in YminZ- Min value in ZmaxZ- Max value in Z
-
setFontAxisTicks
public void setFontAxisTicks(int font)
Set fonts for tick labels in terms of GLUT.BITMAP fonts.- Parameters:
font- font in terms GLUT.BITMAP
-
setAxisPenWidth
public void setAxisPenWidth(int pwidth)
Set line width to draw boxes and axis.- Parameters:
pwidth- with of the pen to draw boxes etc.
-
getFontAxisTicks
public int getFontAxisTicks()
Get fonts for axis ticks in terms of GLUT.BITMAP fonts.- Returns:
- font font in terms GLUT.BITMAP
-
getFontAxisLabels
public int getFontAxisLabels()
Get fonts for axis labels in terms of GLUT.BITMAP fonts.- Returns:
- font font in terms GLUT.BITMAP
-
animate
public CameraThreadController animate()
Start animation of the current canvas.- Returns:
- animation;
-
setColorFill
public void setColorFill(java.awt.Color color)
Set fill color for the current object- Parameters:
color- to fill object
-
setColorWireframe
public void setColorWireframe(java.awt.Color color)
Set fill color for the current object- Parameters:
color- for wireframe
-
setWireframe
public void setWireframe(boolean wiredrame)
Set wireframe mode for the current object.- Parameters:
wiredrame- true than no solid fill is used.
-
setWireframeWidth
public void setWireframeWidth(double width)
Set width of the line for wireframe- Parameters:
width- width
-
setColorSolid
public void setColorSolid(boolean solid)
If you set true, color will be solid and no colorfull color map is used.- Parameters:
solid- apply a solid color to the current object
-
getView
public View getView()
Get current view of the plotted object.- Returns:
- view
-
setScale
public void setScale(double scale)
Set the scaling for the current image box.- Parameters:
scale- scaling factor for the image.
-
zoom
public void zoom(double scale)
Set the scaling for the axis of the current object. Use setScale() to change image size.- Parameters:
scale- scaling factor for the object
-
setRotationAngle
public void setRotationAngle(double angle)
Get the rotation angle- Parameters:
angle- angle
-
setFaceDisplayed
public void setFaceDisplayed(boolean face)
Set face shown or not- Parameters:
face- true is displayed.
-
setGridColor
public void setGridColor(java.awt.Color co)
Set Grid color to the current pad- Parameters:
co- grid color
-
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
-
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
-
clearAll
public void clearAll()
Clear all graphs from data and settings.
-
distroy
public void distroy()
Remove the canvas frame
-
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()
Show the canvas
-
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
-
setAxesLabel
public void setAxesLabel(int axis, boolean shown)Show or not label on axes.- Parameters:
axis- axis: 0 for X, 1 for Y, 2 for Zshown- true then shown.
-
setViewPoint
public void setViewPoint(double x, double y, double z)Set view point- Parameters:
x- Xy- Yz- Z
-
setAxesLabelFont
public void setAxesLabelFont(java.awt.Font font, Color color)Set font and color for axis labels.- Parameters:
font-color-
-
setContourMesh3D
public void setContourMesh3D(boolean contour)
Set (or not) contour mesh style to 3D plots.- Parameters:
contour- set to true for a contour style
-
setContourColor3D
public void setContourColor3D(boolean contour)
Add (or not) contour color to 3D plot.- Parameters:
contour- set to true for a contour color style
-
setContourLevels
public void setContourLevels(int nlevels)
Set number of levels for contour plots.- Parameters:
nlevels- number of levels for contour plots.
-
getContourLevels
public int getContourLevels()
Get number of levels for contour plots.- Returns:
- number of levels for contour plots.
-
setContourMesh3D
public void setContourMesh3D()
Set to contour mesh style to 3D plots.
-
setContourColor3D
public void setContourColor3D()
Set to contour color style to 3D plots.
-
getContourMesh3D
public boolean getContourMesh3D()
Get to contour mesh style from 3D plots.
-
setAxisTick
public void setAxisTick(int axis, boolean shown)Show or not ticks on axes.- Parameters:
axis- axis: 0 for X, 1 for Y, 2 for Zshown- true then shown.
-
add
public void add(P2D h1)
Add a container with X,Y.Z values to be shown. Call update() method to draw all objects.- Parameters:
h1-
-
add
public AbstractDrawable add(P2D h1, java.awt.Color color)
Add a container with X,Y.Z values to be shown. Call update() method to draw all objects.- Parameters:
h1-color- Color of this data.
-
add
public AbstractDrawable add(P2D h1, double pointSize)
Add a container with X,Y.Z values to be shown. Call update() method to draw all objects.- Parameters:
h1- input datapointSize- size of the point
-
draw
public AbstractDrawable draw(P2D h1, double penSize, java.awt.Color color)
Draw X,Y.Z values in 3D using variable colors. Better use "add()" method to add the data to canvas.- Parameters:
h1-penSize- size of the pointscolor- to show points
-
add
public AbstractDrawable add(P2D h1, double penSize, java.awt.Color color)
Draw X,Y.Z values in 3D- Parameters:
h1- input datapenSize- size of the pointscolor- to show points- Returns:
- return added object for styling
-
add
public AbstractDrawable add(AbstractDrawable shape)
Add a object to the list- Parameters:
shape-
-
draw
public void draw(AbstractDrawable[] shapes)
Draw a list of shapes on the current canvas- Parameters:
shapes-
-
update
public void update()
Update current pad. All objects added with the method "add" will be shown.
-
update
public void update(int n1, int n2)Refresh only a particular pad.- Parameters:
n1- the location of the plot in xn2- the location of the plot in y
-
updateAll
public void updateAll()
Refresh all the plots on the same canvas. Inactive.
-
addText
public AbstractDrawable addText(java.lang.String text, double[] pos, java.awt.Color co)
Add a text to the canvas.- Parameters:
text- textpos- position (x,y,z)color- color- Returns:
- return what is added
-
add
public AbstractDrawable add(F2D f)
Add a F2D function (a function with 2 arguments, x and y). The function will be shows as a surface. This function is plotted with 50 steps in X and Y. Min and Max values for axes taken from the definition.- Parameters:
f- function to show- Returns:
- added object for styling
-
add
public AbstractDrawable add(F2D f, double xmin, double xmax, double ymin, double ymax)
Add a F2D function (a function with 2 arguments, x and y). The function will be shows as a surface. This function is plotted with 40 steps in X and Y.- Parameters:
f- function to showxmin-xmax-ymin-ymax-- Returns:
- object for styling
-
add
public AbstractDrawable add(F2D h1, int xsteps, int ysteps, double xmin, double xmax, double ymin, double ymax)
Add a F2D function (a function with 2 arguments, x and y). The function will be shows as a surface. Use "update()" method to draw it.- Parameters:
h1-xsteps- number of divisions in Xysteps- number of divisions in Yxmin- min Xxmax- max Xymin- min Yymax- max Y- Returns:
-
addAsSurface
public AbstractDrawable addAsSurface(H2D h2d)
Add a H2D histogram. The histogram will be shows as a surface. Use "update()" method to draw it.- Parameters:
h2d- Histogram for drawing.return- what was added
-
add
public void add(H2D h2d)
Show H2D histogram as bars- Parameters:
h2d- input histogramreturn- what was added
-
export
public void export(java.lang.String file)
Fast export of the canvas to an image file (depends on the extension, i.e. PNG, JPG). No questions will be asked, an existing file will be rewritten. Only one image allowed at the time.
-
addAsBars
public void addAsBars(H2D h2d)
Add a H2D histogram as bars. The histogram will be shows as a surface. Use "update()" method to draw it.- Parameters:
h2d- Histogram for drawing.
-
setLegendBar
public void setLegendBar()
Set a legend to a given surface.- Parameters:
surface- input object
-
draw
public AbstractDrawable draw(H2D h2d)
Draw a H2D histogram. Better use "add" to overlay histograms. Then use "update()" method to draw it.- Parameters:
h2d- Histogram for drawing.
-
getChart
public Chart getChart()
Get the current canvas chart.- Returns:
- current chart.
-
setBackground
public void setBackground(java.awt.Color co)
Set background for the current pad.- Parameters:
co- color to be set
-
setTickScientific
public void setTickScientific(int axis, int dig)Set scientific notation with a given number of digits.- Parameters:
axis- axis. 0=X, 1=Y, 2=Zdig- number of digits
-
setTickDecimal
public void setTickDecimal(int axis, int dig)Set decimal precision for a given axis.- Parameters:
axis- axis. 0=X, 1=Y, 2=Zdig- precision.
-
setTickScientificAll
public void setTickScientificAll(int dig)
Set scientific notation with a given number of digits for all ticks.- Parameters:
dig- number of digits
-
setTickDecimalAll
public void setTickDecimalAll(int dig)
Set decimal notation with a given number of digits for all ticks.- Parameters:
dig- number of digits
-
setAxesBox
public void setAxesBox(boolean isbox)
The box can be turned on/off for the current pad.- Parameters:
isbox- false is box with axes is off
-
close
public void close()
Close the canvas.
-
doc
public void doc()
Show online documentation.
-
addBar
public void addBar(double x, double y, double z, double height, double radius)Build a bar as a cylinder in 3D and add to the list of shapes on the current pad. Use "update" method to display it.- Parameters:
x- position in Xy- position in Yradius- radius
-
addPoint
public void addPoint(double x, double y, double z, double width)Add a point to the list of shapes on the current pad. Use "update" method to display it.- Parameters:
x- position in Xy- position in Yz- position in Zwidth- width or size
-
addPolygon
public void addPolygon(P2D p2d)
Add a flat line to the current pad. Use "update" method to display it.- Parameters:
p2d- array of X,Y,Z which define polygone points
-
addFlatLine
public void addFlatLine(float[] x, float[] y, double depth)Add a flat line to the current pad. Use "update" method to display it.- Parameters:
x- position in Xy- position in Ydepth- depthcolor- color color to fill
-
addDisk
public void addDisk(double x, double y, double z, double radiusInner, double radiusOuter, int slices, int loops)Add a sphere to the current canvas. Use "update" to show it.- Parameters:
x- position Xy- position Yz- position Zslices- number of vertical slices (i.e. wireframes)stacks- loops
-
addSphere
public void addSphere(double x, double y, double z, double radius, double height, int slices, int stacks)Add a sphere to the current canvas. Use "update" to show it.- Parameters:
x- position Xy- position Yz- position Zradius- radius of the sphereheight- heightslices- number of vertical slices (i.e. wireframes)stacks- number of horizontal stacks (i.e. wireframes)
-
addTube
public void addTube(double x, double y, double z, double radiusBottom, double radiusTop, double height, int slices, int stacks)Add a tube to the current canvas. Use "update" to show it.- Parameters:
x- position Xy- position Yz- position ZradiusBottom- radius of the bottom circleradiusTop- radius of the top circleheight- height of the cylinderslices- number of vertical slices (i.e. wireframes)stacks- number of horizontal stacks (i.e. wireframes)
-
addParallelepiped
public void addParallelepiped(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)Add parallelepiped to the current canvas.- Parameters:
xmin-xmax-ymin-ymax-zmin-zmax-
-
addLight
public void addLight(double x, double y, double z, java.awt.Color AmbiantColor, java.awt.Color DiffuseColor, java.awt.Color SpecularColor)Add light to the scene.- Parameters:
x- X positiony- Y positionz- Z positionAmbiantColor- Ambiant ColorDiffuseColor- Diffuse ColorSpecularColor- Specular Color
-
getShapeList
public java.util.List<AbstractDrawable> getShapeList()
Get list of shapes plotted on the current pad given by the cd() method.- Returns:
- list of plotted shapes.
-
-
DMelt 3.0 © DataMelt by jWork.ORG