jfig.canvas
Interface FigCanvas

All Superinterfaces:
java.util.EventListener, FullRedraw, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, ObjectPainter, SyncPainter
All Known Subinterfaces:
ObjectCanvas
All Known Implementing Classes:
AWTObjectCanvas, FigBasicCanvas, FigSwingCanvas, JObjectCanvas

public interface FigCanvas
extends java.awt.event.MouseListener, java.awt.event.MouseMotionListener, FullRedraw, ObjectPainter, SyncPainter

an interface to define the basic operations required to draw FIG objects.


Field Summary
static int FullRedraw
           
static int MouseMotionRedraw
           
static int NoChanges
           
static int ObjectRedraw
           
static int panDOWN
           
static int panHOME
           
static int panLEFT
           
static int panRIGHT
           
static int panUP
           
static int SyncRedraw
           
static int SystemRedraw
           
static int TmpObjectRedraw
           
static int TmpTextRedraw
           
 
Method Summary
 void addCanvasListener(FigCanvasListener listener)
           
 void addZoomListener(ZoomListener zl)
           
 void blitOffscreenBuffer(java.awt.Graphics g)
           
 void blitOffscreenBufferClipped(java.awt.Graphics g)
           
 void changeRubberbandMode(int new_mode)
           
 void changeRubberbandMode(int mode, FigTrafo2D t, java.lang.Object b)
           
 void changeRubberbandMode(int new_mode, GeometryManager gm)
           
 void clippedDrawTmpObject(java.awt.Graphics g)
           
 void doFullRedraw()
          doFullRedraw(): redraw everything...
 void doFullRedraw(long millis)
           
 void doMotionRedraw()
           
 void doObjectRedraw()
           
 void doPanning(int direction, boolean shift)
           
 void doSimpleRedraw()
           
 void doSyncRedraw()
          method stub for synchronous repaints: FigCanvas itself just provides a doSimpleRedraw().
 void doSystemRedraw()
           
 void doTextRedraw()
           
 void doToggleRubberbandDebug()
           
 void doZoom11()
          restore to zoom-factor 1 and origin (0,0)
 void doZoomFit()
          doZoomFit(): calculate the bounding box of all objects from our FigDrawableEnumerator, then set the zoom and panning so that all objects are visible.
 void doZoomFull()
          restore to zoom factor 1
 void doZoomIn()
          zoom in by a factor of two.
 void doZoomOut()
           
 void doZoomRegion(int wx, int wy, int wx2, int wy2)
          doZoomRegion(): zoom into the world coordinate region given by corners (wx,wy) and (wx2, wy2).
 void drawAllObjects(java.awt.Graphics g)
          drawAllObjects(): This traverses the parent's object list and draws all objects found and visible.
 void drawObject(java.awt.Graphics g, FigObject object)
           
 void drawSlidersAndCursor(java.awt.Graphics g, boolean erase)
           
 void drawTmpObjects(java.awt.Graphics g)
           
 void eraseObject(java.awt.Graphics g, FigObject object)
           
 void flush()
          call flush() on any offscreen buffers this canvas might have used.
 java.awt.Color getBackground()
           
 java.awt.Component getComponent()
          return the AWT/Swing component that actually implements the canvas
 java.awt.Cursor getCursor()
           
 boolean getDebug()
           
 java.awt.Color getGridColor()
           
 java.awt.Point getMousePosition()
           
 FigDrawableEnumerator getObjectEnumerator()
           
 java.awt.Graphics getOffscreenGraphics()
          return a reference to the offscreen Graphics when double-buffering
 java.awt.Dimension getSize()
           
 FigTrafo2D getTrafo()
          return the current coordinate transformation used for this canvas.
 java.awt.Point getViewportWCmax()
          return the world coordinates of the right-bottom corner of this canvas (depending on it's size and the zoom-factor).
 FigBbox getVisibleRegionBoundingBox()
           
 boolean gotFocus()
           
 void handleRedraw(java.awt.Graphics g)
           
 void mouseClicked(java.awt.event.MouseEvent evt)
           
 void mouseDragged(java.awt.event.MouseEvent evt)
           
 void mouseEntered(java.awt.event.MouseEvent evt)
           
 void mouseExited(java.awt.event.MouseEvent evt)
           
 void mouseMoved(java.awt.event.MouseEvent evt)
           
 void mousePressed(java.awt.event.MouseEvent evt)
           
 void mouseReleased(java.awt.event.MouseEvent evt)
           
 void msg(java.lang.String msg)
          print msgs to console window or stdout
 void notifyZoomListeners()
           
 void paint(FigDrawable obj)
          a method that allows animated objects to update their current state.
 void paint(FigDrawable obj, int millis)
          repaint an (animated) object within millis milliseconds.
 void paint(java.awt.Graphics g)
           
 void printTimingStats()
           
 void removeZoomListener(ZoomListener zl)
           
 void repaint(int millis)
          request a standard repaint after (at most) millis milliseconds.
 void requestAntiAliasing(boolean b)
           
 void requestRenderQuality(boolean b)
           
 void setBackground(java.awt.Color c)
           
 void setConsole(ConsoleMessage printer)
          set the msg console
 void setCursor(java.awt.Cursor c)
           
 void setDebug(boolean debug)
           
 void setDefaultCursor(java.awt.Cursor c)
           
 void setEnableRulerDragging(boolean b)
           
 void setGrid(int gridMode)
          set a new grid spacing.
 void setGridColor(java.awt.Color c)
           
 void setObjectEnumerator(FigDrawableEnumerator enumerator)
          specify the object that will provide this canvas with the Enumeration of drawable objects.
 void setRubberbandAspect(double d)
           
 void setRubberbandBasePoint(int sx, int sy)
           
 void setRubberbandBasePoint(java.awt.Point sp)
           
 void setRubberbandBasePoint2(int sx, int sy)
           
 void setRubberbandBasePoint2(java.awt.Point P)
           
 void setRubberbandShowLineLengths(boolean b)
           
 void setRulerOffsets()
          calculate the offsets required when using rulers on this canvas.
 void setStatusMessage(StatusMessage helper)
           
 void setTrafo(FigTrafo2D trafo)
          set the coordinate transformation for this canvas.
 void showRulers(boolean b)
           
 void statusMessage(java.lang.String msg)
          show or print status msgs
 void synchronousRepaint()
          request a synchronous repaint of all pending animation repaints.
 void update(java.awt.Graphics g)
           
 

Field Detail

NoChanges

public static final int NoChanges
See Also:
Constant Field Values

MouseMotionRedraw

public static final int MouseMotionRedraw
See Also:
Constant Field Values

SyncRedraw

public static final int SyncRedraw
See Also:
Constant Field Values

TmpTextRedraw

public static final int TmpTextRedraw
See Also:
Constant Field Values

TmpObjectRedraw

public static final int TmpObjectRedraw
See Also:
Constant Field Values

SystemRedraw

public static final int SystemRedraw
See Also:
Constant Field Values

ObjectRedraw

public static final int ObjectRedraw
See Also:
Constant Field Values

FullRedraw

public static final int FullRedraw
See Also:
Constant Field Values

panHOME

public static final int panHOME
See Also:
Constant Field Values

panLEFT

public static final int panLEFT
See Also:
Constant Field Values

panRIGHT

public static final int panRIGHT
See Also:
Constant Field Values

panUP

public static final int panUP
See Also:
Constant Field Values

panDOWN

public static final int panDOWN
See Also:
Constant Field Values
Method Detail

setRulerOffsets

public void setRulerOffsets()
calculate the offsets required when using rulers on this canvas. For example, the basic xfig-compatibly canvas uses rulers on the top and right sides of the canvas, and Graphics operations might want to clip drawing operations only to the central part of the canvas.


setDebug

public void setDebug(boolean debug)

getDebug

public boolean getDebug()

getTrafo

public FigTrafo2D getTrafo()
return the current coordinate transformation used for this canvas.


setTrafo

public void setTrafo(FigTrafo2D trafo)
set the coordinate transformation for this canvas.


getComponent

public java.awt.Component getComponent()
return the AWT/Swing component that actually implements the canvas


getOffscreenGraphics

public java.awt.Graphics getOffscreenGraphics()
return a reference to the offscreen Graphics when double-buffering


flush

public void flush()
call flush() on any offscreen buffers this canvas might have used.


setDefaultCursor

public void setDefaultCursor(java.awt.Cursor c)

setCursor

public void setCursor(java.awt.Cursor c)

getCursor

public java.awt.Cursor getCursor()

getSize

public java.awt.Dimension getSize()

addCanvasListener

public void addCanvasListener(FigCanvasListener listener)

setObjectEnumerator

public void setObjectEnumerator(FigDrawableEnumerator enumerator)
specify the object that will provide this canvas with the Enumeration of drawable objects.


getObjectEnumerator

public FigDrawableEnumerator getObjectEnumerator()

statusMessage

public void statusMessage(java.lang.String msg)
show or print status msgs


setStatusMessage

public void setStatusMessage(StatusMessage helper)

msg

public void msg(java.lang.String msg)
print msgs to console window or stdout


setConsole

public void setConsole(ConsoleMessage printer)
set the msg console


setBackground

public void setBackground(java.awt.Color c)

getBackground

public java.awt.Color getBackground()

setGridColor

public void setGridColor(java.awt.Color c)

getGridColor

public java.awt.Color getGridColor()

getMousePosition

public java.awt.Point getMousePosition()

showRulers

public void showRulers(boolean b)

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evt)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent evt)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent evt)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent evt)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

gotFocus

public boolean gotFocus()

doPanning

public void doPanning(int direction,
                      boolean shift)

paint

public void paint(java.awt.Graphics g)

paint

public void paint(FigDrawable obj)
a method that allows animated objects to update their current state. The object is drawn to both the background buffer and the screen.

Specified by:
paint in interface ObjectPainter

paint

public void paint(FigDrawable obj,
                  int millis)
repaint an (animated) object within millis milliseconds. To improve performance and smooth drawing, only the region covered by the object, calculated by its screen-coordinates bounding-box, is paint()ed.

Specified by:
paint in interface ObjectPainter

repaint

public void repaint(int millis)
request a standard repaint after (at most) millis milliseconds.

Specified by:
repaint in interface ObjectPainter

synchronousRepaint

public void synchronousRepaint()
request a synchronous repaint of all pending animation repaints. This request is ignored by FigCanvas, but might be implemented as required by subclasses.

Specified by:
synchronousRepaint in interface SyncPainter

update

public void update(java.awt.Graphics g)

handleRedraw

public void handleRedraw(java.awt.Graphics g)

drawTmpObjects

public void drawTmpObjects(java.awt.Graphics g)

clippedDrawTmpObject

public void clippedDrawTmpObject(java.awt.Graphics g)

blitOffscreenBuffer

public void blitOffscreenBuffer(java.awt.Graphics g)

blitOffscreenBufferClipped

public void blitOffscreenBufferClipped(java.awt.Graphics g)

printTimingStats

public void printTimingStats()

doFullRedraw

public void doFullRedraw()
doFullRedraw(): redraw everything... Usually, we want to do this in the calling thread, while the AWT repaint-Thread should only bitblt the offscreen-Buffer.

Specified by:
doFullRedraw in interface FullRedraw

doFullRedraw

public void doFullRedraw(long millis)
Specified by:
doFullRedraw in interface FullRedraw

doSimpleRedraw

public void doSimpleRedraw()

doTextRedraw

public void doTextRedraw()

doObjectRedraw

public void doObjectRedraw()

doMotionRedraw

public void doMotionRedraw()

doSystemRedraw

public void doSystemRedraw()

doSyncRedraw

public void doSyncRedraw()
method stub for synchronous repaints: FigCanvas itself just provides a doSimpleRedraw().

This method should be overridden by subclasses as necessary.


drawSlidersAndCursor

public void drawSlidersAndCursor(java.awt.Graphics g,
                                 boolean erase)

eraseObject

public void eraseObject(java.awt.Graphics g,
                        FigObject object)

drawObject

public void drawObject(java.awt.Graphics g,
                       FigObject object)

getViewportWCmax

public java.awt.Point getViewportWCmax()
return the world coordinates of the right-bottom corner of this canvas (depending on it's size and the zoom-factor).


getVisibleRegionBoundingBox

public FigBbox getVisibleRegionBoundingBox()

drawAllObjects

public void drawAllObjects(java.awt.Graphics g)
drawAllObjects(): This traverses the parent's object list and draws all objects found and visible.

Parameters:
g - the graphics-context to draw into (e.g. the FigCanvas screen or the offscreenImage buffer).

setGrid

public void setGrid(int gridMode)
set a new grid spacing. See class FigTrafo2D for a list of the possible values.

This function implies a full redraw, in order to generate the new grid.


doZoomOut

public void doZoomOut()

doZoomIn

public void doZoomIn()
zoom in by a factor of two. Fixed point is the viewport center.


doZoomFull

public void doZoomFull()
restore to zoom factor 1


doZoom11

public void doZoom11()
restore to zoom-factor 1 and origin (0,0)


doZoomRegion

public void doZoomRegion(int wx,
                         int wy,
                         int wx2,
                         int wy2)
doZoomRegion(): zoom into the world coordinate region given by corners (wx,wy) and (wx2, wy2).


doZoomFit

public void doZoomFit()
doZoomFit(): calculate the bounding box of all objects from our FigDrawableEnumerator, then set the zoom and panning so that all objects are visible. This method currently assumes a 10 pixel border.


addZoomListener

public void addZoomListener(ZoomListener zl)

removeZoomListener

public void removeZoomListener(ZoomListener zl)

notifyZoomListeners

public void notifyZoomListeners()

changeRubberbandMode

public void changeRubberbandMode(int new_mode)

changeRubberbandMode

public void changeRubberbandMode(int new_mode,
                                 GeometryManager gm)

changeRubberbandMode

public void changeRubberbandMode(int mode,
                                 FigTrafo2D t,
                                 java.lang.Object b)

setRubberbandBasePoint

public void setRubberbandBasePoint(java.awt.Point sp)

setRubberbandBasePoint

public void setRubberbandBasePoint(int sx,
                                   int sy)

setRubberbandBasePoint2

public void setRubberbandBasePoint2(java.awt.Point P)

setRubberbandBasePoint2

public void setRubberbandBasePoint2(int sx,
                                    int sy)

setRubberbandAspect

public void setRubberbandAspect(double d)

doToggleRubberbandDebug

public void doToggleRubberbandDebug()

setRubberbandShowLineLengths

public void setRubberbandShowLineLengths(boolean b)

requestRenderQuality

public void requestRenderQuality(boolean b)

requestAntiAliasing

public void requestAntiAliasing(boolean b)

setEnableRulerDragging

public void setEnableRulerDragging(boolean b)