com.brusoftware.plot4j
Class Diagram

java.lang.Object
  extended by com.brusoftware.plot4j.Diagram

public class Diagram
extends java.lang.Object

This class represents a multi-graph diagram on a Cartesian plan.

Version:
0.1
Author:
Alessandro Brunelli

Constructor Summary
Diagram()
          Creates a new Diagram.
 
Method Summary
 void addGraphToDiagram(Graph g)
          Adds a new Graph to this Diagram.
 void exportAsImage(java.io.File file, java.lang.String format, int width, int height)
          Exports this Diagram to an image.
 java.lang.String[] getAvailableImageFormats()
          Returns the available image formats for the exporting.
 java.awt.Color getAxesColor()
          Returns the axes Color of this Diagram.
 java.awt.Color getBackgroundColor()
          Returns the background Color of this Diagram.
 java.awt.Font getBigStepFont()
          Returns the Font of the numeric labels.
 double getBigStepInterval()
          Returns the interval between two numeric labels.
 java.util.ArrayList<Graph> getGraphs()
          Returns the Graphs of this Diagram.
 java.awt.Color getGridColor()
          Gets the Color of the grid
 double getLittleStepInterval()
          Returns the interval between two hyphens.
 double getMaxX()
          Returns the ending x-coordinate of this Diagram.
 double getMaxY()
          Returns the ending y-coordinate of this Diagram.
 double getMinX()
          Returns the starting x-coordinate of this Diagram.
 double getMinY()
          Returns the starting y-coordinate of this Diagram.
 boolean isGridShown()
          Returns true if the grid is visible, false otherwise.
 void refresh()
          Refreshes this Diagram after a change of any type.
 void setAxesColor(java.awt.Color c)
          Sets the axes Color of this Diagram.
 void setBackgroundColor(java.awt.Color c)
          Sets the background Color of this Diagram.
 void setBigStepFont(java.awt.Font f)
          Sets the Font of the numeric labels.
 void setBigStepInterval(double d)
          Sets the interval between two numeric labels.
 void setGridColor(java.awt.Color c)
          Sets the Color of the grid.
 void setLittleStepInterval(double d)
          Sets the interval between two hyphens.
 void setMaxX(double d)
          Sets the ending x-coordinate of this Diagram.
 void setMaxY(double d)
          Sets the ending y-coordinate of this Diagram.
 void setMinX(double d)
          Sets the starting x-coordinate of this Diagram.
 void setMinY(double d)
          Sets the starting y-coordinate of this Diagram.
 void setShowGrid(boolean b)
          Sets the visibility of the grid.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Diagram

public Diagram()
Creates a new Diagram.

Method Detail

addGraphToDiagram

public void addGraphToDiagram(Graph g)
                       throws ParseException
Adds a new Graph to this Diagram.

Parameters:
g - the new Graph
Throws:
ParseException - if the function syntax of a FunctionGraph is wrong

getGraphs

public java.util.ArrayList<Graph> getGraphs()
Returns the Graphs of this Diagram.

Returns:
the Graphs of this Diagram

refresh

public void refresh()
             throws ParseException
Refreshes this Diagram after a change of any type.
Everytime a change on this Diagram or on one of the Graphs of this Diagram is performed, this method must be called.

Throws:
ParseException - if the function syntax of a FunctionGraph is wrong

setBigStepFont

public void setBigStepFont(java.awt.Font f)
Sets the Font of the numeric labels.

Parameters:
f - the Font of the numeric labels
See Also:
setBigStepInterval(double)

getBigStepFont

public java.awt.Font getBigStepFont()
Returns the Font of the numeric labels.

Returns:
the Font of the numeric labels
See Also:
setBigStepInterval(double)

getBackgroundColor

public java.awt.Color getBackgroundColor()
Returns the background Color of this Diagram.

Returns:
the background Color of this Diagram

setBackgroundColor

public void setBackgroundColor(java.awt.Color c)
Sets the background Color of this Diagram.

Parameters:
c - the background Color of this Diagram

getAxesColor

public java.awt.Color getAxesColor()
Returns the axes Color of this Diagram.

Returns:
the axes Color of this Diagram

setAxesColor

public void setAxesColor(java.awt.Color c)
Sets the axes Color of this Diagram.

Parameters:
c - axes Color of this Diagram

setMinX

public void setMinX(double d)
             throws WrongValueException
Sets the starting x-coordinate of this Diagram.
This Diagram will be evaluated and displayed in a rectangle whose upper-left corner is (min_x, max_y) and the bottom-right corner is (max_x, min_y).
If d >= max_x an Exception will be thrown.

Parameters:
d - the starting x-coordinate of this Diagram
Throws:
WrongValueException - if d >= max_x

getMinX

public double getMinX()
Returns the starting x-coordinate of this Diagram.

Returns:
the starting x-coordinate of this Diagram
See Also:
setMinX(double)

setMinY

public void setMinY(double d)
             throws WrongValueException
Sets the starting y-coordinate of this Diagram.
This Diagram will be evaluated and displayed in a rectangle whose upper-left corner is (min_x, max_y) and the bottom-right corner is (max_x, min_y).
If d >= max_y an Exception will be thrown.

Parameters:
d - the starting y-coordinate of this Diagram
Throws:
WrongValueException - if d >= max_y

getMinY

public double getMinY()
Returns the starting y-coordinate of this Diagram.

Returns:
the starting y-coordinate of this Diagram
See Also:
setMinY(double)

setMaxX

public void setMaxX(double d)
             throws WrongValueException
Sets the ending x-coordinate of this Diagram.
This Diagram will be evaluated and displayed in a rectangle whose upper-left corner is (min_x, max_y) and the bottom-right corner is (max_x, min_y).
If d <= min_x an Exception will be thrown.

Parameters:
d - the ending x-coordinate of this Diagram
Throws:
WrongValueException - if d <= min_x

getMaxX

public double getMaxX()
Returns the ending x-coordinate of this Diagram.

Returns:
the ending x-coordinate of this Diagram
See Also:
setMaxX(double)

setMaxY

public void setMaxY(double d)
             throws WrongValueException
Sets the ending y-coordinate of this Diagram.
This Diagram will be evaluated and displayed in a rectangle whose upper-left corner is (min_x, max_y) and the bottom-right corner is (max_x, min_y).
If d <= min_y an Exception will be thrown.

Parameters:
d - the ending y-coordinate of this Diagram
Throws:
WrongValueException - if d <= min_y

getMaxY

public double getMaxY()
Returns the ending y-coordinate of this Diagram.

Returns:
the ending y-coordinate of this Diagram
See Also:
setMaxY(double)

setBigStepInterval

public void setBigStepInterval(double d)
                        throws WrongValueException
Sets the interval between two numeric labels.
The value d will be the interval between the numeric labels on the axes.
If d < 0 or d <= little_step_interval an Exception will be thrown.

Parameters:
d - the interval between two numeric labels
Throws:
WrongValueException - if d < 0 or d <= little_step_interval
See Also:
setLittleStepInterval(double)

getBigStepInterval

public double getBigStepInterval()
Returns the interval between two numeric labels.

Returns:
the interval between two numeric labels
See Also:
setBigStepInterval(double)

setLittleStepInterval

public void setLittleStepInterval(double d)
                           throws WrongValueException
Sets the interval between two hyphens.
The value d will be the interval between the hyphens on the axes.
If d < 0 or d >= big_step_interval an Exception will be thrown.

Parameters:
d - the interval between two hyphens
Throws:
WrongValueException - if d < 0 or d >= big_step_interval
See Also:
setBigStepInterval(double)

getLittleStepInterval

public double getLittleStepInterval()
Returns the interval between two hyphens.

Returns:
the interval between two hyphens
See Also:
setLittleStepInterval(double)

setShowGrid

public void setShowGrid(boolean b)
Sets the visibility of the grid.

Parameters:
b - true to show the grid, false otherwise

isGridShown

public boolean isGridShown()
Returns true if the grid is visible, false otherwise.

Returns:
true if the grid is visible, false otherwise

setGridColor

public void setGridColor(java.awt.Color c)
Sets the Color of the grid.

Parameters:
c - the new Color of the grid

getGridColor

public java.awt.Color getGridColor()
Gets the Color of the grid

Returns:
the Color of the grid

exportAsImage

public void exportAsImage(java.io.File file,
                          java.lang.String format,
                          int width,
                          int height)
                   throws java.io.IOException
Exports this Diagram to an image.
To know the available image formats the method getAvailableImageFormats() must be called.

Parameters:
file - the destination File
format - the format of the image
width - the width of the image
height - the height of the image
Throws:
java.io.IOException - if the export fails
See Also:
getAvailableImageFormats()

getAvailableImageFormats

public java.lang.String[] getAvailableImageFormats()
Returns the available image formats for the exporting.

Returns:
the available image formats for the exporting
See Also:
exportAsImage(File, String, int, int)