de.matthiasmann.twl.model
Class SimpleGraphModel

java.lang.Object
  extended by de.matthiasmann.twl.model.SimpleGraphModel
All Implemented Interfaces:
GraphModel

public class SimpleGraphModel
extends java.lang.Object
implements GraphModel


Constructor Summary
SimpleGraphModel()
           
SimpleGraphModel(java.util.Collection<GraphLineModel> lines)
           
SimpleGraphModel(GraphLineModel... lines)
           
 
Method Summary
 void addLine(GraphLineModel line)
          Adds a new line at the end of the list
 GraphLineModel getLine(int idx)
          Returns the specified line model.
 int getNumLines()
          Returns the number of lines in this graph.
 boolean getScaleLinesIndependant()
          The Y axis of the graph is based on min/max values.
 int indexOfLine(GraphLineModel line)
          Returns the index of the specified line in this list or -1 if not found.
 void insertLine(int idx, GraphLineModel line)
          Inserts a new line before the specified index in the list
 GraphLineModel removeLine(int idx)
          Removes the line at the specified index
 void setScaleLinesIndependant(boolean scaleLinesIndependant)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleGraphModel

public SimpleGraphModel()

SimpleGraphModel

public SimpleGraphModel(GraphLineModel... lines)

SimpleGraphModel

public SimpleGraphModel(java.util.Collection<GraphLineModel> lines)
Method Detail

getLine

public GraphLineModel getLine(int idx)
Description copied from interface: GraphModel
Returns the specified line model.

Specified by:
getLine in interface GraphModel
Parameters:
idx - The line index. Must be >= 0 and < getNumLines()
Returns:
the specified line model

getNumLines

public int getNumLines()
Description copied from interface: GraphModel
Returns the number of lines in this graph.

Specified by:
getNumLines in interface GraphModel
Returns:
the number of lines in this graph

getScaleLinesIndependant

public boolean getScaleLinesIndependant()
Description copied from interface: GraphModel
The Y axis of the graph is based on min/max values. The scaling for an axis can be compute from the combined min/max values or using it's own min/max value. The combined min values is the smallest min value of all lines. The combined max values is the largest max value of all lines.

Specified by:
getScaleLinesIndependant in interface GraphModel
Returns:
true if the Y scale is independant or false if it is combined.

setScaleLinesIndependant

public void setScaleLinesIndependant(boolean scaleLinesIndependant)

addLine

public void addLine(GraphLineModel line)
Adds a new line at the end of the list

Parameters:
line - the new line

insertLine

public void insertLine(int idx,
                       GraphLineModel line)
Inserts a new line before the specified index in the list

Parameters:
idx - the index before which the new line will be inserted
line - the new line
Throws:
java.lang.NullPointerException - if line is null
java.lang.IllegalArgumentException - if the line is already part of this model

indexOfLine

public int indexOfLine(GraphLineModel line)
Returns the index of the specified line in this list or -1 if not found.

Parameters:
line - the line to locate
Returns:
the index or -1 if not found

removeLine

public GraphLineModel removeLine(int idx)
Removes the line at the specified index

Parameters:
idx - the index of the line to remove
Returns:
the line that was removed