org.rosuda.ibase.toolkit
Class PGSCanvas

java.lang.Object
  extended by org.rosuda.ibase.toolkit.PlotComponent
      extended by org.rosuda.ibase.toolkit.PGSCanvas
All Implemented Interfaces:
java.awt.print.Printable, Commander, Dependent
Direct Known Subclasses:
BaseCanvas, DevCanvas, FluctCanvas, LineCanvas, MCPCanvas, TreeCanvas, TreeFlowCanvas

public class PGSCanvas
extends PlotComponent
implements Commander, Dependent, java.awt.print.Printable

PGScanvas - extends LayerCanvas by adding generic functionality for exporting the content to PGS metafile or PostScript format. Any implementing class must use PoGraSS methods instead of Graphics.

Version:
$Id: PGSCanvas.java 2832 2007-09-07 16:57:52Z urbanek $

Nested Class Summary
 class PGSCanvas.IDlgCL
           
 
Field Summary
protected  Axis ax
          X-axis of the plot coordinates. beware that it may be null
protected  Axis ay
          Y-axis of the plot coordinates. beware that it may be null
protected  boolean cancel
           
protected  java.lang.String desc
          description of this canvas.
protected  boolean inProgress
          inProgress flag to avoid recursions in paint methods
protected  java.awt.Dialog intDlg
           
protected  java.awt.Frame myFrame
          frame that owns this canvas. can be null if none does. it is mainly used to identify current frame in calls to dialogs
 java.awt.print.PageFormat pageFormat
           
protected  int paintLayerCounter
           
protected  PlotManager pm
          plot manager for any additional objects
 
Fields inherited from class org.rosuda.ibase.toolkit.PlotComponent
AWTGrDevID, GrDevID, JOGLGrDevID, layers, SWINGGrDevID
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
PGSCanvas()
          equals to using PGSCanvas(-1, 1)
PGSCanvas(int layers)
          equals to using PGSCanvas(-1, layers)
PGSCanvas(int gd, int layers)
          equals to using PGSCanvas(gd, layers, null, null)
PGSCanvas(int gd, int layers, Axis x, Axis y)
          creates a new PoGraSS-capable driver consisting of layers to draw on, using ps plot component as its target, specified number of layers and the axes x and y.
 
Method Summary
protected  void beginPaint(PoGraSS p)
          before using paintPoGraSS(org.rosuda.pograss.PoGraSS) this method should be called to ensure that a consistent state while painting.
 void dispose()
           
protected  void endPaint(PoGraSS p)
          this methods finalizes painting tasks.
protected  void finalize()
           
 void forcedFlush()
           
 SVar getData(int id)
          this method provides an API to fetch data contents of the plot.
 java.awt.Frame getFrame()
          returns corresponding frame containing this canvas as set by setFrame(java.awt.Frame)
static Notifier getGlobalNotifier()
          returns the global notifier common to all PGSCanvas descendants.
 PlotManager getPlotManager()
          get the PlotManager associated with this plot
 java.lang.String getTitle()
          return canvas title
 Axis getXAxis()
           
 Axis getYAxis()
           
protected  void nextLayer(PoGraSS p)
           
 void Notifying(NotifyMsg msg, java.lang.Object o, java.util.Vector path)
          This method will be called when an even occured.
 void paintLayer(java.awt.Graphics g, int layer)
          paintBuffer simply calls paintPoGraSS(org.rosuda.pograss.PoGraSS) on the supplied Graphics.
 void paintPoGraSS(PoGraSS g)
          abstract paint class to be implemented by any descendants.
 int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pi)
           
 java.lang.Object run(java.lang.Object o, java.lang.String cmd)
          default handing of commands "exportPGS" and "exportPS".
 void setFrame(java.awt.Frame owner)
          set the corresponding frame that contains this canvas.
 void setOption(java.lang.String variable, boolean value)
           
 void setOption(java.lang.String variable, double value)
           
 void setOption(java.lang.String variable, double[] values)
           
 void setOption(java.lang.String variable, int value)
           
 void setOption(java.lang.String variable, int[] values)
           
 void setOption(java.lang.String variable, java.lang.String value)
           
 void setTitle(java.lang.String t)
          set canvas title
 
Methods inherited from class org.rosuda.ibase.toolkit.PlotComponent
addKeyListener, addMouseListener, addMouseMotionListener, getBounds, getComponent, getHeight, getLocation, getParent, getSize, getWidth, newQueryPopup, newQueryPopup, paintLayer, repaint, setBackground, setCursor, setSize, setSize, setToolTipText, setUpdateRoot
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myFrame

protected java.awt.Frame myFrame
frame that owns this canvas. can be null if none does. it is mainly used to identify current frame in calls to dialogs


desc

protected java.lang.String desc
description of this canvas.


pm

protected PlotManager pm
plot manager for any additional objects


inProgress

protected boolean inProgress
inProgress flag to avoid recursions in paint methods


ax

protected Axis ax
X-axis of the plot coordinates. beware that it may be null


ay

protected Axis ay
Y-axis of the plot coordinates. beware that it may be null


cancel

protected boolean cancel

intDlg

protected java.awt.Dialog intDlg

pageFormat

public java.awt.print.PageFormat pageFormat

paintLayerCounter

protected int paintLayerCounter
Constructor Detail

PGSCanvas

public PGSCanvas(int gd,
                 int layers,
                 Axis x,
                 Axis y)
creates a new PoGraSS-capable driver consisting of layers to draw on, using ps plot component as its target, specified number of layers and the axes x and y. If pc is set to null then a plot component of the default type (see Common.defaultPlotComponentType) is created automatically. Axes can be null if not used.


PGSCanvas

public PGSCanvas(int gd,
                 int layers)
equals to using PGSCanvas(gd, layers, null, null)


PGSCanvas

public PGSCanvas(int layers)
equals to using PGSCanvas(-1, layers)


PGSCanvas

public PGSCanvas()
equals to using PGSCanvas(-1, 1)

Method Detail

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

getGlobalNotifier

public static Notifier getGlobalNotifier()
returns the global notifier common to all PGSCanvas descendants. It is mainly used by routines which change some user settings and need to notify all plots regardless of content.


paintLayer

public void paintLayer(java.awt.Graphics g,
                       int layer)
paintBuffer simply calls paintPoGraSS(org.rosuda.pograss.PoGraSS) on the supplied Graphics. Any further classes should override paintPoGraSS(org.rosuda.pograss.PoGraSS) instead of paintLayer(java.awt.Graphics, int)


print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pf,
                 int pi)
Specified by:
print in interface java.awt.print.Printable

setFrame

public void setFrame(java.awt.Frame owner)
set the corresponding frame that contains this canvas. It is used mainly for dialog boxes to raise the correct frame before entering modal state. If no frame is set, default common frame is used by the dialogs.


getFrame

public java.awt.Frame getFrame()
returns corresponding frame containing this canvas as set by setFrame(java.awt.Frame)

Returns:
associated frame

setTitle

public void setTitle(java.lang.String t)
set canvas title


getTitle

public java.lang.String getTitle()
return canvas title

Returns:
canvas title

paintPoGraSS

public void paintPoGraSS(PoGraSS g)
abstract paint class to be implemented by any descendants.

Specified by:
paintPoGraSS in class PlotComponent

getPlotManager

public PlotManager getPlotManager()
get the PlotManager associated with this plot


dispose

public void dispose()

getXAxis

public Axis getXAxis()

getYAxis

public Axis getYAxis()

getData

public SVar getData(int id)
this method provides an API to fetch data contents of the plot. The id is implementation-dependent, but first two variables x and y should be mapped to 0 and 1 correspondingly. Therefore every plot containting data must support getData(0). For invalid ids null is returned.


nextLayer

protected void nextLayer(PoGraSS p)

beginPaint

protected void beginPaint(PoGraSS p)
before using paintPoGraSS(org.rosuda.pograss.PoGraSS) this method should be called to ensure that a consistent state while painting. Currently the main goal of this function is to reset the paintLayerCounter.

Specified by:
beginPaint in class PlotComponent

endPaint

protected void endPaint(PoGraSS p)
this methods finalizes painting tasks. If paintPoGraSS(org.rosuda.pograss.PoGraSS) is called directly this method should not be ommitted.

Specified by:
endPaint in class PlotComponent

forcedFlush

public void forcedFlush()

run

public java.lang.Object run(java.lang.Object o,
                            java.lang.String cmd)
default handing of commands "exportPGS" and "exportPS". Any descendant should call super.run(o,cmd) to retain this functionality

Specified by:
run in interface Commander
Parameters:
o - origin of the command
cmd - command string
Returns:
any object, the actual interpretation is up to the calling object

Notifying

public void Notifying(NotifyMsg msg,
                      java.lang.Object o,
                      java.util.Vector path)
Description copied from interface: Dependent
This method will be called when an even occured. Currently SMarker and Axis use this method of notification. There's no generic class for implemention the notification-list yet.

Specified by:
Notifying in interface Dependent
o - Object that sent the notification. The actual content is implementation-dependent.
path - This parameter is null for non-cascaded notify - in that case further calls to NotifyAll are not allowed. Otherwise it contains a Vector with all objects notified so far during cascaded notify. To aviod cyclic notifications every instance must either reject cascaded notifications (i.e. no calls to NotifyAll at all) or check for occurence of itself in the chain before calling NotifyAll. The only valid recursive calls in Notifying are NotifyAll(path) and NotifyAll(..,path), because only these two pass the "path" parameter to avoid cyclic loops.

setOption

public void setOption(java.lang.String variable,
                      boolean value)

setOption

public void setOption(java.lang.String variable,
                      int value)

setOption

public void setOption(java.lang.String variable,
                      int[] values)

setOption

public void setOption(java.lang.String variable,
                      double[] values)

setOption

public void setOption(java.lang.String variable,
                      double value)

setOption

public void setOption(java.lang.String variable,
                      java.lang.String value)