jhplot
Class HChart

java.lang.Object
  extended by jhplot.GHPanel
      extended by jhplot.GHFrame
          extended by jhplot.HChart
All Implemented Interfaces:
ComponentListener, Serializable, EventListener

public class HChart
extends GHFrame

Create various charts, such as pie, histograms, bar charts including 3D emulation, lines.

See Also:
Serialized Form

Field Summary
static int IndexPlot
           
 boolean set
           
 
Constructor Summary
HChart()
          Construct a HChart canvas with a plot with the default parameters 600 by 400, and 10% space for the global title "Default"
HChart(String title)
          Construct a HChart canvas with a plot with the default parameters 600 by 400, and 10% space for the global title
HChart(String title, int xs, int ys)
          Construct a HChart canvas with a single plot/graph
HChart(String title, int xs, int ys, boolean set)
          Construct a HChart canvas with a single plot/graph
HChart(String title, int xs, int ys, int n1, int n2)
          Construct a HChart canvas with plots/graphs
HChart(String title, int xsize, int ysize, int n1, int n2, boolean set)
          Create HChart canvas with a several chart plots
 
Method Summary
 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 data
 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 frame
 void doc()
          Show online documentation.
 void draw(ArrayList<Double> x, ArrayList<Double> y)
          Draw X-Y data from arrays
 void draw(double[] x, double[] y)
          Draw X-Y data from arrays
 void draw(F1D f1)
          Draw a F1D function on the canvas.
 void draw(H1D f1)
          Draw a H1D histogram on the canvas.
 boolean getAntiAlias()
          Get antialiasing for the graphics of the current plot
 ValueAxis getAxis(int axis)
          Get the axis
 Axis getAxisX()
          Get X-axis
 Axis getAxisY()
          Get Y-axis
 JFreeChart getChart()
          Returns current Chart
 ChartPanel getChartPanel()
          Returns current Chart panel
 Color getLabelColor()
          Get label color.
 XYPlot getPlot()
          Get XY plot
 Color getTickColor()
          Get color of ticks.
 Font getTickFont()
          Get font of ticks.
 void quit()
          Quit the frame
 void setAntiAlias(boolean setit)
          Set antialiasing for the graphics of the current plot
 void setAutoRange()
          Set autorange in X and Y at the same time
 void setAutoRange(boolean b)
          Set auto-range in X and Y at the same time
 void setAxis(int axis, ValueAxis a)
          Sets axis
 void setBackgColor(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 setChartPie()
          Make a Pie chart.
 void setChartPie3D()
          Make a Pie 3D chart.
 void setChartPolar()
          Make a chart using polar coordinates.
 void setFontAxisX(Font f, Color c)
          Set font and color for X-axis (for X-Y plots)
 void setFontAxisY(Font f, Color c)
          Set font and color for Y-axis (for X-Y plots)
 void setFontLegent(Font f)
          Set font for legend title
 void setFontTitle(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(Color c)
          Sets color of the grid lines for all plots on the same canvas
 void setGridPenWidth(double width)
          Sets width of the line for the grid
 void setGridPenWidth(int axis, double width)
          Sets the width of the line for grid
 void setLabelColor(Color labelColor)
          Se5t color of the lebales.
 void setLabelFont(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 position
 void setLogScale(int axis, boolean b)
          Sets true or false to plot on a log scale.
 void setName(String title)
          Set global title to the current chart.
 void setNameX(String s)
          Sets the name for X axis.
 void setNameY(String s)
          Sets the name for Y axis.
 void setRange(int axis, double min, double max)
          Sets the range (min-max) displayed on the axis.
 void setTheme(String s)
          Set a custom theme for chart..
 void setTickColor(int axis, Color tickColor)
          Set tick color
 void setTickFont(Font tickFont)
          Set font of ticks
 void update()
          Update all plots
 void update(int N1, int N2)
          Update the chart
 void valueBar(double value, String series, String category)
          Set a value to a Bar chart.
 void valueBar3D(double value, String series, String category)
          Set a value to a 3D Bar chart.
 void valueLine(double value, String series, String category)
          Set a value to a Line chart.
 void valuePie(String name, double value)
          Set a value to pie data set
 void valuePie3D(String name, double value)
          Set a value to 3D pie data set.
 void visible()
          Set the canvas frame visible
 void visible(boolean vs)
          Set the canvas frame visible or not
 
Methods inherited from class jhplot.GHFrame
addGraph, cd, componentHidden, componentMoved, componentShown, getCdX, getCdY, getFrame, getHTMLUrl, getNtotX, getNtotY, setPlotsNum, updateFrame
 
Methods inherited from class jhplot.GHPanel
addComp, componentResized, disableDoubleBuffering, enableDoubleBuffering, export, exportDialog, exportImage, 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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IndexPlot

public static int IndexPlot

set

public boolean set
Constructor Detail

HChart

public HChart(String title,
              int xsize,
              int ysize,
              int n1,
              int n2,
              boolean set)
Create HChart canvas with a several chart plots

Parameters:
title - Title
xsize - size in x direction
ysize - size in y direction
n1 - number of plots/graphs in x
n2 - number of plots/graphs in y
set - set or not the graph

HChart

public HChart(String title,
              int xs,
              int ys)
Construct a HChart canvas with a single plot/graph

Parameters:
title - Title for the canvas
xs - size in x
ys - size in y

HChart

public HChart(String title,
              int xs,
              int ys,
              boolean set)
Construct a HChart canvas with a single plot/graph

Parameters:
title - Title for the canvas
xs - size in x
ys - size in y
set - set or not the graph (boolean)

HChart

public HChart(String title,
              int xs,
              int ys,
              int n1,
              int n2)
Construct a HChart canvas with plots/graphs

Parameters:
title - Title for the canvas
xs - size in x
ys - size in y
n1 - number of plots/graphs in x
n2 - number of plots/graphs in y

HChart

public HChart(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

setLabelColor

public void setLabelColor(Color labelColor)
Se5t color of the lebales.

Parameters:
labelColor -

setLabelFont

public void setLabelFont(Font font)
Set fonts of the labels.

Parameters:
font -

getLabelColor

public Color getLabelColor()
Get label color.

Returns:
color

setTickColor

public void setTickColor(int axis,
                         Color tickColor)
Set tick color

Parameters:
tickColor -

getTickColor

public Color getTickColor()
Get color of ticks.

Returns:
color

setTickFont

public void setTickFont(Font tickFont)
Set font of ticks

Parameters:
tickFont -

getTickFont

public 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


setTheme

public void setTheme(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(Font f,
                         Color c)
Set font and color for X-axis (for X-Y plots)

Parameters:
f - font
c - color

setFontAxisY

public void setFontAxisY(Font f,
                         Color c)
Set font and color for Y-axis (for X-Y plots)

Parameters:
f - font
c - 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.


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.


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 X
i2 - 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(String title)
Set global title to the current chart. Should be called before setChart* methods.

Parameters:
title - title

setNameX

public void setNameX(String s)
Sets the name for X axis. Should be called before setChart* methods.

Parameters:
s - Title for X axis.

setNameY

public void setNameY(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.

Parameters:
axis - defines to which axis this function applies, generally something like X_AXIS or Y_AXIS.
b - toggle, true if the scaling is logarithmic

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(Font f)
Set font for legend title

Parameters:
f -

setFontTitle

public void setFontTitle(Font f)
Set font for legend title

Parameters:
f -

draw

public void draw(double[] x,
                 double[] y)
Draw X-Y data from arrays

Parameters:
x - X values
y - 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

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(ArrayList<Double> x,
                 ArrayList<Double> y)
Draw X-Y data from arrays

Parameters:
x - X values
y - 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.

Parameters:
d - input P1D container

valuePie

public void valuePie(String name,
                     double value)
Set a value to pie data set

Parameters:
name - Name for this number
value - Number

valuePie3D

public void valuePie3D(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 number
value - Number

valueBar

public void valueBar(double value,
                     String series,
                     String category)
Set a value to a Bar chart. You should call update() method to display it

Parameters:
value - Value
series - Series
category - category

setRange

public void setRange(int axis,
                     double min,
                     double max)
Sets the range (min-max) displayed on the axis.

Parameters:
axis - defines to which axis this function applies, generally something like X_AXIS or Y_AXIS.
min - minimum value on the axis
max - maximum value 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 axis
b - toggle, true if the the grid should be drawn.

setGridColor

public void setGridColor(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 axis
width - with of the line

setBackgColor

public void setBackgColor(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,
                      String series,
                      String category)
Set a value to a Line chart. You should call update() method to display it

Parameters:
value - Value
series - Series
category - category

valueBar3D

public void valueBar3D(double value,
                       String series,
                       String category)
Set a value to a 3D Bar chart. You should call update() method to display it

Parameters:
value - Value
series - Series
category - category

update

public void update(int N1,
                   int N2)
Update the chart

Parameters:
N1 - location in X
N2 - 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.



jHepWork 3.4 © jWork.org