elge.engine
Class Graph

java.lang.Object
  |
  +--elge.engine.Graph

public class Graph
extends Object

Graph is a data vizualizer object. It is used by an gui component to vizualize the data. This object is some sort of model for the gui object.

The graph has several properties that must be set before displaying it.

Author:
Pavol Žibrita

Constructor Summary
Graph()
          Creates a new instance of Graph.
Graph(Project pt)
          Creates a new instance of Graph with a project
 
Method Summary
 void addProp(String prop)
          adds a source to the graph
protected  com.jrefinery.data.CategoryDataset createCategoryData()
          Creates data for graph from this graph setting.
protected  com.jrefinery.data.XYDataset createData()
          Creates data for graph from this graph setting.
protected  com.jrefinery.data.XYDataset createFirstData()
          Creates data for graph from this graph setting.
protected  com.jrefinery.chart.JFreeChart createJFreeChart()
          Create the JFreeChart of a type and properties that defines this instance.
protected  com.jrefinery.data.XYDataset createOtherData()
          Creates data for graph from this graph setting.
protected  com.jrefinery.data.PieDataset createPieCategoryData()
          Creates data for graph from this graph setting.
 void dispose()
          Disposes the graph.
 Project getProject()
          gets the project that the graph is in.
 Vector getProps()
          Get the sources
 String getTitle()
          gets the graph title.
 int getType()
          The type of the graph
 int getWindow()
          Gets the window the graph is using (the tick step)
 String getXLabel()
          gets the x axis label
 String getYLabel()
          gets the y axis label
 void hide()
          hides the graph view
 boolean isVisible()
          check if it is displayed and visible.
 void removeProp(int idx)
          removes a source from the graph
 void removeProp(String prop)
          removes a source from the graph
 void repaint()
          repaints the graph
 void restart()
          restarts the graph.
 void setProject(Project pt)
          sets the project for the graph.
 void setProps(Vector props)
          Sets the graph source names
 void setTitle(String name)
          Sets the graph title
 void setType(int type)
          Sets the type of the graph
 void setWindow(int win)
          Sets the tick step
 void setXLabel(String label)
          gets the x axis label
 void setYLabel(String label)
          gets the y axis label
 void show()
          If the viewer was not created, it creates the graph and shows it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph

public Graph(Project pt)
Creates a new instance of Graph with a project

Parameters:
pt - the project the graph is in.

Graph

public Graph()
Creates a new instance of Graph. (must exist for the xml peristence)

Method Detail

getProject

public Project getProject()
gets the project that the graph is in.

Returns:
the project the graph is in

setProject

public void setProject(Project pt)
sets the project for the graph.

Parameters:
pt - Project the graph is in.

getTitle

public String getTitle()
gets the graph title.

Returns:
the graph title

setTitle

public void setTitle(String name)
Sets the graph title

Parameters:
name - title of the graph

setProps

public void setProps(Vector props)
Sets the graph source names

Parameters:
props - List of String objects, the source name..

getProps

public Vector getProps()
Get the sources

Returns:
all values that should graph display...

addProp

public void addProp(String prop)
adds a source to the graph

Parameters:
prop - the source name

removeProp

public void removeProp(String prop)
removes a source from the graph

Parameters:
prop - the source name

removeProp

public void removeProp(int idx)
removes a source from the graph

Parameters:
idx - the source index

getType

public int getType()
The type of the graph

Returns:
the graph type

setType

public void setType(int type)
Sets the type of the graph

Parameters:
type - the graph type to set

getWindow

public int getWindow()
Gets the window the graph is using (the tick step)

Returns:
get the tick step

setWindow

public void setWindow(int win)
Sets the tick step

Parameters:
win - the tick step.

getXLabel

public String getXLabel()
gets the x axis label

Returns:
name of x axis

setXLabel

public void setXLabel(String label)
gets the x axis label

Parameters:
label - name of x axis

getYLabel

public String getYLabel()
gets the y axis label

Returns:
name of y axis

setYLabel

public void setYLabel(String label)
gets the y axis label

Parameters:
label - name of x axis

dispose

public void dispose()
Disposes the graph.


isVisible

public boolean isVisible()
check if it is displayed and visible.

Returns:
true if displayed and visible

show

public void show()
If the viewer was not created, it creates the graph and shows it. If it is possible. If not, message should be displayed.


createData

protected com.jrefinery.data.XYDataset createData()
Creates data for graph from this graph setting. From sources

Returns:
XYDataset for the line graph

createCategoryData

protected com.jrefinery.data.CategoryDataset createCategoryData()
Creates data for graph from this graph setting. From sources

Returns:
CategoryDataset for bar

createPieCategoryData

protected com.jrefinery.data.PieDataset createPieCategoryData()
Creates data for graph from this graph setting. From sources

Returns:
PieDataset for pie graph

createFirstData

protected com.jrefinery.data.XYDataset createFirstData()
Creates data for graph from this graph setting. From sources

Returns:
XYDataset for left y axis

createOtherData

protected com.jrefinery.data.XYDataset createOtherData()
Creates data for graph from this graph setting. From sources

Returns:
XYDataset for right axis

createJFreeChart

protected com.jrefinery.chart.JFreeChart createJFreeChart()
Create the JFreeChart of a type and properties that defines this instance.

Returns:
If possible the JFreeChart instance is returned or null.

repaint

public void repaint()
repaints the graph


hide

public void hide()
hides the graph view


restart

public void restart()
restarts the graph. It creates a new fresh instance of JFreeChart.