org.faceless.graph
Class LineGraph

java.lang.Object
  extended by org.faceless.graph.Graph
      extended by org.faceless.graph.AxesGraph
          extended by org.faceless.graph.AbstractLineGraph
              extended by org.faceless.graph.LineGraph

public class LineGraph
extends AbstractLineGraph

A subclass of AbstractLineGraph that plots one or more separate curves - a typical Line Graph.

This class changes the default for optionXAxisAtZero and optionYAxisAtZero to true.

Here is a simple example that graphs two curves - the first, a set of datapoints defined by a DataCurve, the second a Spline curve that's fitted to the DataCurve.

    import org.faceless.graph.output.ImageOutput;
    import org.faceless.graph.math.*;
    import java.awt.Color;

    // Create a simple datacurve with 4 points.
    //
    DataCurve data = new DataCurve();
    data.set(1,10);
    data.set(2,15);
    data.set(3,8);
    data.set(5,11);
    
    // Plot the data in red on a linegraph, with a diamond
    // at each point.
    //
    LineGraph g = new LineGraph();
    g.setCurve("My Data", data, Color.red);
    g.setCurveMarker("My Data", LineGraph.MARKER_DIAMOND);

    // Add a "smoothed" version of this DataCurve in green.
    //
    Curve smooth = new Spline(Spline.CATMULLROM, data);
    g.setCurve("Smoothed Data", smooth, Color.green);

    // Add a title to the graph
    //
    g.optionTitle("My First Line Graph");

    // Render to an image that's 400x400
    //
    ImageOutput out = new ImageOutput(400,400);
    out.render(g);
 


Field Summary
static int KEY_SHOW_MARKERS
          If markers are to be displayed on the key, add this value to the parameter passed to Graph.optionDisplayKey(int).
static int MARKER_BIG
          Add this value to the marker type to double the size of the marker.
static int MARKER_CIRCLE
          A marker in the shape of a circle
static int MARKER_DIAMOND
          A marker in the shape of a diamond
static int MARKER_DOWNTRIANGLE
          A marker in the shape of a triangle pointing down
static int MARKER_LINE
          A marker that looks like a join in the line.
static int MARKER_NOBORDER
          Add this value to the marker type to remove the border from around the marker.
static int MARKER_NONE
          No marker at all.
static int MARKER_OCTAGON
          A marker in the shape of an octagon
static int MARKER_SMALL
          Add this value to the marker type to reduce the size of the marker.
static int MARKER_SQUARE
          A marker in the shape of a square
static int MARKER_UPTRIANGLE
          A marker in the shape of a triangle pointing up
static int MARKERS_ONLY
          A special type of marker indicator that should be OR'ed with the marker type to indicate that only markers should be drawn - i.e. no lines, just markers.
 
Fields inherited from class org.faceless.graph.Graph
KEY_BOXED_BOTTOM, KEY_BOXED_LEFT, KEY_BOXED_RIGHT, KEY_BOXED_TOP, KEY_NONE
 
Constructor Summary
LineGraph()
           
 
Method Summary
 void optionLineThickness(double val)
          Set the "thickness" of the lines when drawing two-dimensional graphs.
 void setCurveMarker(String name, int marker)
          Set a marker to show significant points on the curve Not all points have significant points, but for DataCurve curves there is a significant point at each data item.
 
Methods inherited from class org.faceless.graph.AbstractLineGraph
optionCurveDepth, optionFunctionSmoothness, optionMaxDataPoints, optionMaxX, optionMinX, setCurve, setCurve
 
Methods inherited from class org.faceless.graph.AxesGraph
optionAxisStyle, optionBoxColor, optionFloorStyle, optionMaxY, optionMinY, optionXAxisAtZero, optionXAxisLabel, optionXAxisLabelStyle, optionXAxisStyle, optionXAxisTextRotation, optionXFormatter, optionXStretchToZero, optionYAxisAtZero, optionYAxisLabel, optionYAxisLabelStyle, optionYAxisStyle, optionYAxisTextRotation, optionYFormatter, optionYStretchToZero, optionYWallStyle, optionZAxisStyle, optionZFormatter, optionZWallStyle
 
Methods inherited from class org.faceless.graph.Graph
getDefaultBorderColor, getFontScale, optionDisplayKey, optionFixedAspectRatio, optionKeyBoxStyle, optionKeyStyle, optionSubTitle, optionSubTitleStyle, optionTitle, optionTitleStyle, optionXRotation, optionYRotation, optionZRotation, setDefaultBorderColor, setDefaultColors, setDefaultLineThickness, setFontScale, setLicenseKey, setLightLevel, setLightVector, setPieEdgeDegrees, toCanvas
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_SHOW_MARKERS

public static final int KEY_SHOW_MARKERS
If markers are to be displayed on the key, add this value to the parameter passed to Graph.optionDisplayKey(int). For example, linegraph.optionDisplayKey(Graph.KEY_BOXED_BOTTOM + LineGraph.KEY_SHOW_MARKERS)

Since:
1.0.7
See Also:
Constant Field Values

MARKER_NONE

public static final int MARKER_NONE
No marker at all.

See Also:
Constant Field Values

MARKER_CIRCLE

public static final int MARKER_CIRCLE
A marker in the shape of a circle

Since:
1.0.10
See Also:
Constant Field Values

MARKER_SQUARE

public static final int MARKER_SQUARE
A marker in the shape of a square

See Also:
Constant Field Values

MARKER_OCTAGON

public static final int MARKER_OCTAGON
A marker in the shape of an octagon

See Also:
Constant Field Values

MARKER_DIAMOND

public static final int MARKER_DIAMOND
A marker in the shape of a diamond

See Also:
Constant Field Values

MARKER_LINE

public static final int MARKER_LINE
A marker that looks like a join in the line. This is the default.

See Also:
Constant Field Values

MARKER_UPTRIANGLE

public static final int MARKER_UPTRIANGLE
A marker in the shape of a triangle pointing up

Since:
1.0.7
See Also:
Constant Field Values

MARKER_DOWNTRIANGLE

public static final int MARKER_DOWNTRIANGLE
A marker in the shape of a triangle pointing down

Since:
1.0.7
See Also:
Constant Field Values

MARKER_BIG

public static final int MARKER_BIG
Add this value to the marker type to double the size of the marker. For example, setCurveMarker("mycurve", MARKER_SQUARE+MARKER_BIG)

Since:
1.0.7
See Also:
Constant Field Values

MARKER_SMALL

public static final int MARKER_SMALL
Add this value to the marker type to reduce the size of the marker. For example, setCurveMarker("mycurve", MARKER_SQUARE+MARKER_SMALL)

Since:
1.0.10
See Also:
Constant Field Values

MARKER_NOBORDER

public static final int MARKER_NOBORDER
Add this value to the marker type to remove the border from around the marker. For example, setCurveMarker("mycurve", MARKER_CIRCLE+MARKER_NOBORDER)

Since:
1.0.10
See Also:
Constant Field Values

MARKERS_ONLY

public static final int MARKERS_ONLY
A special type of marker indicator that should be OR'ed with the marker type to indicate that only markers should be drawn - i.e. no lines, just markers. This needs to be used with SQUARES, OCTAGONS, DIAMONDS, CIRCLES and TRIANGLES only - the line will simply disappear if it's used with any other type. For example, to draw a small circle at each point but no line inbetween, do: setCurveMarker("mycurve", MARKER_CIRCLE+MARKER_SMALL+MARKERS_ONLY)

See Also:
Constant Field Values
Constructor Detail

LineGraph

public LineGraph()
Method Detail

setCurveMarker

public void setCurveMarker(String name,
                           int marker)
Set a marker to show significant points on the curve Not all points have significant points, but for DataCurve curves there is a significant point at each data item. Whether a marker is plotted depends on the value passed to this function.

Parameters:
name - The name of the curve
marker - The type if marker. Can be MARKER_NONE, MARKER_LINE (the default), MARKER_SQUARE, MARKER_CIRCLE MARKER_DIAMOND, MARKER_OCTAGON, MARKER_UPTRIANGLE or MARKER_DOWNTRIANGLE

optionLineThickness

public void optionLineThickness(double val)
Set the "thickness" of the lines when drawing two-dimensional graphs. This has no effect if the graph is rotated in the X or Y direction, and may not be supported by all subclasses of Output. It's mainly intended for plotting graphs to high-resolution output devices like PDF or PostScript.



Copyright © 2001-2012 Big Faceless Organization