sk.baka.webvm.misc
Class AbstractGraph

java.lang.Object
  extended by sk.baka.webvm.misc.AbstractGraph
Direct Known Subclasses:
BluffGraph

public abstract class AbstractGraph
extends Object

An abstract graph, intended to be extended by classes drawing graphs.

Author:
Martin Vysny

Field Summary
 boolean makeAscending
          Automatically make incoming values ascending.
protected  int max
          The maximum value.
protected  GraphStyle style
          The graph style.
protected  List<int[]> values
          The graph values.
 
Constructor Summary
AbstractGraph(int max, GraphStyle style)
          Constructs a new graph instance.
 
Method Summary
 void add(int[] values)
          Adds given value array to the graph.
 String draw()
          Draws the graph and returns the html code.
abstract  void draw(StringBuilder sb)
          Draws the graph and returns the html code.
 void fillWithZero(int desiredLength, boolean fillToRight)
          Append several zero values until a desired data length is reached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

max

protected final int max
The maximum value.


values

protected final List<int[]> values
The graph values.


style

protected final GraphStyle style
The graph style.


makeAscending

public boolean makeAscending
Automatically make incoming values ascending.

Constructor Detail

AbstractGraph

public AbstractGraph(int max,
                     GraphStyle style)
Constructs a new graph instance.

Parameters:
max - the maximum value.
style - the graph style, must be valid.
Method Detail

add

public final void add(int[] values)
Adds given value array to the graph. The array must be ascending.

Parameters:
values - the values to add. There must be exactly one value for each graph column.

fillWithZero

public final void fillWithZero(int desiredLength,
                               boolean fillToRight)
Append several zero values until a desired data length is reached.

Parameters:
desiredLength - desired length of X axis.
fillToRight - if true then the zero values are appended to the value list. If false then the zero values are prepended before all list values.

draw

public final String draw()
Draws the graph and returns the html code.

Returns:
the html code of the graph.

draw

public abstract void draw(StringBuilder sb)
Draws the graph and returns the html code.

Parameters:
sb - draw the graph here


Copyright © 2010 Baka. All Rights Reserved.