jhplot
Class HChart
- java.lang.Object
-
- jhplot.gui.GHPanel
-
- jhplot.gui.GHFrame
-
- jhplot.HChart
-
- All Implemented Interfaces:
- java.awt.event.ComponentListener, java.io.Serializable, java.util.EventListener
public class HChart extends GHFrame
Create various charts, such as pie, histograms, bar charts including 3D emulation, lines. This canvas uses JFreeChart project.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description HChart()
Construct a HChart canvas with a plot with the default parameters 600 by 400, and 10% space for the global title "Default"HChart(java.lang.String title)
Construct a HChart canvas with a plot with the default parameters 600 by 400, and 10% space for the global titleHChart(java.lang.String title, int xs, int ys)
Construct a HChart canvas with a single plot/graphHChart(java.lang.String title, int xs, int ys, boolean set)
Construct a HChart canvas with a single plot/graphHChart(java.lang.String title, int xs, int ys, int n1, int n2)
Construct a HChart canvas with plots/graphsHChart(java.lang.String title, int xsize, int ysize, int n1, int n2, boolean set)
Create HChart canvas with a several chart plots
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
add(F1D f1)
Add a F1D function to the canvas.void
add(H1D h1)
Add a H1D histogram to the chart.void
add(P1D d)
Draw data from a P1D.void
clear()
Clear the current graph including graph settings.void
clear(int i1, int i2)
Clear the chart characterized by an index in X and Y.void
clearAll()
Clear all graphs from data and settings.void
clearData()
Clear plot from the datavoid
clearFrame()
Clear the frame.void
clearPlot()
Clear plot.void
close()
Close the canvas (and dispose all components) Note: a memory leak is found - no time to investigate it.void
destroy()
Remove the canvas framevoid
doc()
Show online documentation.void
draw(java.util.ArrayList<java.lang.Double> x, java.util.ArrayList<java.lang.Double> y)
Draw X-Y data from arraysvoid
draw(double[] x, double[] y)
Draw X-Y data from arraysvoid
draw(F1D f1)
Draw a F1D function on the canvas.void
draw(H1D f1)
Draw a H1D histogram on the canvas.void
drawToGraphics2D(java.awt.Graphics2D g, int width, int height)
void
export(java.lang.String filename)
Export graph into an image file.void
export(java.lang.String filename, int width, int height)
Export graph into an image file.boolean
getAntiAlias()
Get antialiasing for the graphics of the current plotValueAxis
getAxis(int axis)
Get the axisAxis
getAxisX()
Get X-axisAxis
getAxisY()
Get Y-axisJFreeChart
getChart()
Returns current ChartChartPanel
getChartPanel()
Returns current Chart paneljava.awt.Color
getLabelColor()
Get label color.XYPlot
getPlot()
Get XY plotPlotOrientation
getPlotOrientation()
Get current plot orientation.java.awt.Color
getTickColor()
Get color of ticks.java.awt.Font
getTickFont()
Get font of ticks.void
quit()
Quit the framevoid
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
setAntiAlias(boolean setit)
Set antialiasing for the graphics of the current plotvoid
setAutoRange()
Set autorange in X and Y at the same timevoid
setAutoRange(boolean b)
Set auto-range in X and Y at the same timevoid
setAxis(int axis, ValueAxis a)
Sets axisvoid
setBackgColor(java.awt.Color color)
Sets the actual background color of the entire graph panel.void
setChartArea()
Make an Area chart.void
setChartBar()
Make a Bar chart.void
setChartBar3D()
Make a Bar chart in 3D.void
setChartLine()
Make a line chart.void
setChartLine(double stroke)
Make a line chart.void
setChartPie()
Make a Pie chart.void
setChartPie3D()
Make a Pie 3D chart.void
setChartPolar()
Make a chart using polar coordinates.void
setFontAxisX(java.awt.Font f, java.awt.Color c)
Set font and color for X-axis (for X-Y plots)void
setFontAxisY(java.awt.Font f, java.awt.Color c)
Set font and color for Y-axis (for X-Y plots)void
setFontLegent(java.awt.Font f)
Set font for legend titlevoid
setFontTitle(java.awt.Font f)
Set font for legend title.void
setGrid(boolean b)
Sets whether or not using grid lines.void
setGrid(int axis, boolean b)
Sets whether or not using grid lines.void
setGridColor(java.awt.Color c)
Sets color of the grid lines for all plots on the same canvasvoid
setGridPenWidth(double width)
Sets width of the line for the gridvoid
setGridPenWidth(int axis, double width)
Sets the width of the line for gridvoid
setLabelColor(java.awt.Color labelColor)
Set color of the labels.void
setLabelFont(java.awt.Font font)
Set fonts of the labels.void
setLegend(boolean b)
Sets whether or not this line style should draw the name in the legend of the graph.void
setLegendPosition(org.jfree.ui.RectangleEdge e)
Legend positionvoid
setLogScale(int axis, boolean b)
Sets true or false to plot on a log scale.void
setName(java.lang.String title)
Set global title to the current chart.void
setNameX(java.lang.String s)
Sets the name for X axis.void
setNameY(java.lang.String s)
Sets the name for Y axis.void
setPlotHorizontal()
Set plot hirizontal orientation.void
setPlotVertical()
Set plot vertical orientation (default).void
setRange(int axis, double min, double max)
Sets the range (min-max) displayed on the axis.void
setTheme(java.lang.String s)
Set a custom theme for chart.void
setTickColor(int axis, java.awt.Color tickColor)
Set tick color.void
setTickFont(java.awt.Font tickFont)
Set font of ticks.void
update()
Update all plotsvoid
update(int N1, int N2)
Update the chartvoid
valueArea(double value, java.lang.String series, java.lang.String category)
Set a value to a area chart.void
valueBar(double value, java.lang.String series, java.lang.String category)
Set a value to a Bar chart.void
valueBar3D(double value, java.lang.String series, java.lang.String category)
Set a value to a 3D Bar chart.void
valueLine(double value, java.lang.String series, java.lang.String category)
Set a value to a Line chart.void
valuePie(java.lang.String name, double value)
Set a value to pie data setvoid
valuePie3D(java.lang.String name, double value)
Set a value to 3D pie data set.void
visible()
Set the canvas frame visiblevoid
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, 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
-
HChart
public HChart(java.lang.String title, int xsize, int ysize, int n1, int n2, boolean set)
Create HChart canvas with a several chart 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
-
HChart
public HChart(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
-
HChart
public HChart(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)
-
HChart
public HChart(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
-
HChart
public HChart(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
-
HChart
public HChart()
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.
-
setPlotVertical
public void setPlotVertical()
Set plot vertical orientation (default).
-
setPlotHorizontal
public void setPlotHorizontal()
Set plot hirizontal orientation.
-
getPlotOrientation
public PlotOrientation getPlotOrientation()
Get current plot orientation.- Returns:
- Plot orientation.
-
setLabelColor
public void setLabelColor(java.awt.Color labelColor)
Set color of the labels.- Parameters:
labelColor
-
-
setLabelFont
public void setLabelFont(java.awt.Font font)
Set fonts of the labels.- Parameters:
font
-
-
getLabelColor
public java.awt.Color getLabelColor()
Get label color.- Returns:
- color
-
setTickColor
public void setTickColor(int axis, java.awt.Color tickColor)
Set tick color.- Parameters:
tickColor
-
-
getTickColor
public java.awt.Color getTickColor()
Get color of ticks.- Returns:
- color
-
setTickFont
public void setTickFont(java.awt.Font tickFont)
Set font of ticks.- Parameters:
tickFont
-
-
getTickFont
public java.awt.Font getTickFont()
Get font of ticks.- Returns:
-
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
-
setTheme
public void setTheme(java.lang.String s)
Set a custom theme for chart. It can be: LEGACY_THEME, JFREE_THEME, DARKNESS_THEME- Parameters:
s
- a theme, can be either LEGACY_THEME, JFREE_THEME, DARKNESS_THEME
-
destroy
public void destroy()
Remove the canvas frame
-
setFontAxisX
public void setFontAxisX(java.awt.Font f, java.awt.Color c)
Set font and color for X-axis (for X-Y plots)- Parameters:
f
- fontc
- color
-
setFontAxisY
public void setFontAxisY(java.awt.Font f, java.awt.Color c)
Set font and color for Y-axis (for X-Y plots)- Parameters:
f
- fontc
- color
-
setChartArea
public void setChartArea()
Make an Area chart.
-
setChartBar
public void setChartBar()
Make a Bar chart.
-
setChartBar3D
public void setChartBar3D()
Make a Bar chart in 3D.
-
setChartLine
public void setChartLine()
Make a line chart.
-
setChartLine
public void setChartLine(double stroke)
Make a line chart.- Parameters:
stroke
- stroke width to draw the line
-
setChartPie
public void setChartPie()
Make a Pie chart.
-
setChartPie3D
public void setChartPie3D()
Make a Pie 3D chart.
-
setChartPolar
public void setChartPolar()
Make a chart using polar coordinates. Then use add() method to add X-Y values.
-
clearPlot
public void clearPlot()
Clear plot.
-
clearData
public void clearData()
Clear plot from the data
-
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 chart 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.
-
update
public void update()
Update all plots
-
setName
public void setName(java.lang.String title)
Set global title to the current chart. Should be called before setChart* methods.- Parameters:
title
- title
-
setNameX
public void setNameX(java.lang.String s)
Sets the name for X axis. Should be called before setChart* methods.- Parameters:
s
- Title for X axis.
-
setNameY
public void setNameY(java.lang.String s)
Sets the name for Y axis. Should be called before setChart* methods.- Parameters:
s
- Title for Y axis.
-
setLogScale
public void setLogScale(int axis, boolean b)
Sets true or false to plot on a log scale.
-
setAxis
public void setAxis(int axis, ValueAxis a)
Sets axis- Parameters:
axis
- defines to which axis this function applies. 0 means X aaxis, 1 means Y axis.a
- axis object
-
getAxis
public ValueAxis getAxis(int axis)
Get the axis- Parameters:
axis
- defines to which axis this function applies. 0 means X aaxis, 1 means Y axis.
-
setFontLegent
public void setFontLegent(java.awt.Font f)
Set font for legend title- Parameters:
f
-
-
setFontTitle
public void setFontTitle(java.awt.Font f)
Set font for legend title.- Parameters:
f
- font of title
-
draw
public void draw(double[] x, double[] y)
Draw X-Y data from arrays- Parameters:
x
- X valuesy
- Y values
-
draw
public void draw(F1D f1)
Draw a F1D function on the canvas. For several functions, consider the add() method.- Parameters:
f1d
- F1D function
-
draw
public void draw(H1D f1)
Draw a H1D histogram on the canvas. For several histograms, consider the add() method.- Parameters:
f1d
- H1D histograms
-
add
public void add(F1D f1)
Add a F1D function to the canvas. Call update() to draw all functions. Use the methods setColor() etc. of F1D function to change the style If You set range during F1D initialization, it will be used. If not, canvas range is used.- Parameters:
f1d
- F1D function
-
add
public void add(H1D h1)
Add a H1D histogram to the chart. Call update() method to view it.- Parameters:
h1
- H1D histogram
-
draw
public void draw(java.util.ArrayList<java.lang.Double> x, java.util.ArrayList<java.lang.Double> y)
Draw X-Y data from arrays- Parameters:
x
- X valuesy
- Y values
-
setLegendPosition
public void setLegendPosition(org.jfree.ui.RectangleEdge e)
Legend position- Parameters:
e
-
-
setLegend
public void setLegend(boolean b)
Sets whether or not this line style should draw the name in the legend of the graph.- Parameters:
b
- true if the name should be shown
-
add
public void add(P1D d)
Draw data from a P1D. Drawing updated automatically. 1st level errors are shown if the dimension is above 5. Otherwise show X and Y. If you set setChartPolar() before,m you can also show polar coordinates.- Parameters:
d
- input P1D container
-
valuePie
public void valuePie(java.lang.String name, double value)
Set a value to pie data set- Parameters:
name
- Name for this numbervalue
- Number
-
clearFrame
public void clearFrame()
Clear the frame.
-
valuePie3D
public void valuePie3D(java.lang.String name, double value)
Set a value to 3D pie data set. You should call update() method to display it- Parameters:
name
- Name for this numbervalue
- Number
-
valueBar
public void valueBar(double value, java.lang.String series, java.lang.String category)
Set a value to a Bar chart. You should call update() method to display it- Parameters:
value
- Valueseries
- Seriescategory
- category
-
valueArea
public void valueArea(double value, java.lang.String series, java.lang.String category)
Set a value to a area chart. You should call update() method to display it- Parameters:
value
- Valueseries
- Seriescategory
- category
-
setRange
public void setRange(int axis, double min, double max)
Sets the range (min-max) displayed on the axis.
-
setAutoRange
public void setAutoRange(boolean b)
Set auto-range in X and Y at the same time- Parameters:
b
- if true, sets auto-range
-
setAutoRange
public void setAutoRange()
Set autorange in X and Y at the same time
-
setAntiAlias
public void setAntiAlias(boolean setit)
Set antialiasing for the graphics of the current plot- Parameters:
setit
- true if antialiasing is set
-
getAntiAlias
public boolean getAntiAlias()
Get antialiasing for the graphics of the current plot- Returns:
- true if antialiasing is set
-
setGrid
public void setGrid(boolean b)
Sets whether or not using grid lines. Grid lines are lines drawn from tick to tick. They can be enabled/disabled per axis.- Parameters:
b
- true if shown
-
setGrid
public void setGrid(int axis, boolean b)
Sets whether or not using grid lines. Grid lines are lines drawn from tick to tick. They can be enabled/disabled per axis.- Parameters:
axis
- defines to which axis this function applies. 0 means X axis, y means y axisb
- toggle, true if the the grid should be drawn.
-
setGridColor
public void setGridColor(java.awt.Color c)
Sets color of the grid lines for all plots on the same canvas- Parameters:
c
- Color
-
setGridPenWidth
public void setGridPenWidth(double width)
Sets width of the line for the grid- Parameters:
c
- width of the line
-
setGridPenWidth
public void setGridPenWidth(int axis, double width)
Sets the width of the line for grid- Parameters:
axis
- 0 is X axcis, 1 is Y axiswidth
- with of the line
-
setBackgColor
public void setBackgColor(java.awt.Color color)
Sets the actual background color of the entire graph panel. Note that it is possible to set the color of the area within the axes system separately.- Parameters:
color
- New background color.
-
valueLine
public void valueLine(double value, java.lang.String series, java.lang.String category)
Set a value to a Line chart. You should call update() method to display it- Parameters:
value
- Valueseries
- Seriescategory
- category
-
valueBar3D
public void valueBar3D(double value, java.lang.String series, java.lang.String category)
Set a value to a 3D Bar chart. You should call update() method to display it- Parameters:
value
- Valueseries
- Seriescategory
- category
-
update
public void update(int N1, int N2)
Update the chart- Parameters:
N1
- location in XN2
- location in Y
-
getChart
public JFreeChart getChart()
Returns current Chart- Returns:
- current chart
-
getAxisX
public Axis getAxisX()
Get X-axis
-
getAxisY
public Axis getAxisY()
Get Y-axis
-
getPlot
public XYPlot getPlot()
Get XY plot
-
getChartPanel
public ChartPanel getChartPanel()
Returns current Chart panel- Returns:
- current Chart panel
-
close
public void close()
Close the canvas (and dispose all components) Note: a memory leak is found - no time to investigate it. set to null all the stuff
-
quit
public void quit()
Quit the frame
-
doc
public void doc()
Show online documentation.
-
drawToGraphics2D
public void drawToGraphics2D(java.awt.Graphics2D g, int width, int height)
-
export
public void export(java.lang.String filename)
Export graph into an image file. The the image format is given by extension. "png", "jpg", "eps", "pdf", "svg". In case of "eps", "pdf" and "svg", vector graphics is used.
-
export
public void export(java.lang.String filename, int width, int height)
Export graph into an image file. The the image format is given by extension. "png", "jpg", "eps", "pdf", "svg". In case of "eps", "pdf" and "svg", vector graphics is used.- Parameters:
filename
- file namewidth
- widthheight
- hight
-
-
DMelt 3.0 © DataMelt by jWork.ORG