jcckit
Class GraphicsPlotCanvas

java.lang.Object
  |
  +--jcckit.plot.PlotCanvas
        |
        +--jcckit.GraphicsPlotCanvas
All Implemented Interfaces:
PlotListener
Direct Known Subclasses:
Graphics2DPlotCanvas

public class GraphicsPlotCanvas
extends PlotCanvas

Class which handles plotting into a Graphics context based on the GraphicsRenderer. This class is not a subclass of java.awt.Component. The actual AWT component presenting the plot is an innerclass. Its instance wrapped by GraphicsPlotCanvas can be obtained with getGraphicsCanvas().

The plot is painted by using double-buffering and pre-rendered view of the coordinate system. That is, the coordinate system is drawn into an off-screen image. It will be redrawn only if the size of the embedding AWT component is changed.

Author:
Franz-Josef Elmer

Inner Class Summary
protected  class GraphicsPlotCanvas.GraphicsCanvas
          AWT component which actually shows the rendered plot.
 
Field Summary
protected  GraphicsPlotCanvas.GraphicsCanvas _canvas
          Wrapped AWT component.
static java.lang.String BACKGROUND_KEY
          Key of a configuration parameter.
static java.lang.String FOREGROUND_KEY
          Key of a configuration parameter.
 
Fields inherited from class jcckit.plot.PlotCanvas
HORIZONTAL_ANCHOR_KEY, PAPER_KEY, PLOT_KEY, VERTICAL_ANCHOR_KEY
 
Constructor Summary
GraphicsPlotCanvas(ConfigParameters config)
          Creates an instance from the specfied configuration parameters.
 
Method Summary
protected static void connectDataAndShow(java.lang.String fileName, ConfigParameters config, GraphicsPlotCanvas plotCanvas)
          Connects plotCanvas with data created from config and shows the chart in a Frame where fileName appears in the title.
protected  void createGraphicsCanvas()
          Creates an instance of GraphicsPlotCanvas.GraphicsCanvas.
 java.awt.Canvas getGraphicsCanvas()
          Returns the wrapped AWT component which contains the rendered plot.
static void main(java.lang.String[] args)
          Shows a plot in a Frame.
 GraphPoint mapCursorPosition(int x, int y)
          Maps the cursor position onto a point in device-independent coordinates.
 void plotChanged(PlotEvent event)
          Repaints the wrapped AWT component.
 
Methods inherited from class jcckit.plot.PlotCanvas
connect, getHorizontalAnchor, getPaper, getPlot, getVerticalAnchor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BACKGROUND_KEY

public static final java.lang.String BACKGROUND_KEY
Key of a configuration parameter.

FOREGROUND_KEY

public static final java.lang.String FOREGROUND_KEY
Key of a configuration parameter.

_canvas

protected GraphicsPlotCanvas.GraphicsCanvas _canvas
Wrapped AWT component.
Constructor Detail

GraphicsPlotCanvas

public GraphicsPlotCanvas(ConfigParameters config)
Creates an instance from the specfied configuration parameters.
Key & Default ValueTypeMandatory Description
background = default background color of the wrapped AWT component Colorno Background color of the wrapped AWT component.
foreground = default foreground color of the wrapped AWT component Colorno Foreground color of the wrapped AWT component.
In addition the configuration parameters of the constructor of the superclass PlotCanvas apply.
Method Detail

createGraphicsCanvas

protected void createGraphicsCanvas()
Creates an instance of GraphicsPlotCanvas.GraphicsCanvas.

plotChanged

public void plotChanged(PlotEvent event)
Repaints the wrapped AWT component.
Overrides:
plotChanged in class PlotCanvas

getGraphicsCanvas

public java.awt.Canvas getGraphicsCanvas()
Returns the wrapped AWT component which contains the rendered plot.

mapCursorPosition

public GraphPoint mapCursorPosition(int x,
                                    int y)
Maps the cursor position onto a point in device-independent coordinates.
Parameters:
x - X-coordinate of the cursor.
y - Y-coordinate of the cursor.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Shows a plot in a Frame. The plot (data and layout) is defined in the .properties file specified by the first command line argument.

Usage: java jcckit.GraphicsPlotCanvas <properties file>


connectDataAndShow

protected static void connectDataAndShow(java.lang.String fileName,
                                         ConfigParameters config,
                                         GraphicsPlotCanvas plotCanvas)
Connects plotCanvas with data created from config and shows the chart in a Frame where fileName appears in the title.