jfig.canvas
Class FigCanvasRubberband

java.lang.Object
  extended byjfig.canvas.FigCanvasRubberband

public class FigCanvasRubberband
extends java.lang.Object

manage rubberband redrawing on a FigCanvas.

FigCanvasRubberband implements rubberbanding with double buffering for jfig.canvas.FigCanvas. The following modes are supported: lines, rectangles, bbox, circles, lines2 (xfig move-polyline-point), and possibly polylines (for xfig object-moves).

For performance reasons, all coordinates in FigCanvasRubberband are in screen coordinates.

See Also:
FigCanvas

Field Summary
static int arcRubber
           
(package private)  double aspect
           
(package private)  int base_x
           
(package private)  int base_y
           
(package private)  int base2_x
           
(package private)  int base2_y
           
(package private)  FigBbox bbox
           
static int bboxRubber
           
static int CB
           
static int CC
           
static int circle2Rubber
           
static int circleRubber
           
static int CT
           
(package private)  boolean debug
           
(package private)  int dx
           
(package private)  int dy
           
static int ellipseRubber
           
static int geometryManagedRubber
           
(package private)  GeometryManager geometryManager
           
static int LB
           
static int LC
           
static int line2Rubber
           
static int lineRubber
           
static int LT
           
(package private)  java.awt.Font mfont
           
(package private)  int mode
           
static int noRubber
           
(package private)  java.lang.Object obj
           
(package private)  int offset_x
           
(package private)  int offset_y
           
(package private)  int old_x
           
(package private)  int old_y
           
(package private)  java.awt.Polygon pg
           
static int pointRubber
           
static int polylineRubber
           
static int RB
           
static int RC
           
static int rectRubber
           
static int restrictedBboxRubber
           
static int restrictedScaleRubber
           
static int RT
           
static int scaleRubber
           
(package private)  boolean showLineLengthsEnable
           
(package private)  FigTrafo2D trafo
           
(package private)  int x
           
(package private)  int y
           
 
Constructor Summary
FigCanvasRubberband(FigTrafo2D trafo)
          constructor: nothing to do.
 
Method Summary
 void changeMode(int mode)
          set a new mode for the rubberbanding.
 void changeMode(int mode, FigTrafo2D trafo, java.lang.Object obj)
          set a new mode for the rubberbanding.
 void changeMode(int mode, GeometryManager manager)
           
 java.awt.Point getBasePoint()
           
 boolean getDebug()
           
 int getMode()
           
 java.awt.Rectangle getRubberBoundingBox(int old_x, int old_y, int cur_x, int cur_y)
          calculate the bounding box Rectangle which needs to be redrawn.
static int max(int a, int b, int c)
           
static int max(int a, int b, int c, int d)
           
static int max(int a, int b, int c, int d, int e)
           
(package private)  void measure(java.awt.Graphics g, int delta, int x, int y, int align)
          utility function to format and draw a numerical value label as required by the "show line length" rubberbanding modi.
static int min(int a, int b, int c)
           
static int min(int a, int b, int c, int d)
           
static int min(int a, int b, int c, int d, int e)
           
 void paint(java.awt.Graphics g, int x, int y, boolean erase_old)
          draw the rubberband (in the current mode) at new position (x,y), XOR mode should probably be set by the calling parent.
 void paintOnce(java.awt.Graphics g, int x, int y)
           
 void setAspect(double d)
          set the aspect ratio (y vs.
 void setBasePoint(int x, int y)
           
 void setBasePoint(java.awt.Point p)
          set a new basepoint for the rubberband, use Point or two integers as arguments.
 void setBasePoint2(java.awt.Point p)
          set the second basepoint for the line movePoint rubberband
 boolean setDebug(boolean debug)
          toggle debug messages on or off
 void setGeometryManager(GeometryManager manager)
           
 void setShowLineLengths(boolean b)
           
 void setTrafo(FigTrafo2D trafo)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

noRubber

public static final int noRubber
See Also:
Constant Field Values

pointRubber

public static final int pointRubber
See Also:
Constant Field Values

lineRubber

public static final int lineRubber
See Also:
Constant Field Values

line2Rubber

public static final int line2Rubber
See Also:
Constant Field Values

rectRubber

public static final int rectRubber
See Also:
Constant Field Values

bboxRubber

public static final int bboxRubber
See Also:
Constant Field Values

circleRubber

public static final int circleRubber
See Also:
Constant Field Values

ellipseRubber

public static final int ellipseRubber
See Also:
Constant Field Values

polylineRubber

public static final int polylineRubber
See Also:
Constant Field Values

scaleRubber

public static final int scaleRubber
See Also:
Constant Field Values

arcRubber

public static final int arcRubber
See Also:
Constant Field Values

restrictedBboxRubber

public static final int restrictedBboxRubber
See Also:
Constant Field Values

restrictedScaleRubber

public static final int restrictedScaleRubber
See Also:
Constant Field Values

geometryManagedRubber

public static final int geometryManagedRubber
See Also:
Constant Field Values

circle2Rubber

public static final int circle2Rubber
See Also:
Constant Field Values

RC

public static final int RC
See Also:
Constant Field Values

LC

public static final int LC
See Also:
Constant Field Values

CC

public static final int CC
See Also:
Constant Field Values

CT

public static final int CT
See Also:
Constant Field Values

CB

public static final int CB
See Also:
Constant Field Values

RT

public static final int RT
See Also:
Constant Field Values

RB

public static final int RB
See Also:
Constant Field Values

LB

public static final int LB
See Also:
Constant Field Values

LT

public static final int LT
See Also:
Constant Field Values

mode

int mode

obj

java.lang.Object obj

bbox

FigBbox bbox

trafo

FigTrafo2D trafo

pg

java.awt.Polygon pg

base_x

int base_x

base_y

int base_y

base2_x

int base2_x

base2_y

int base2_y

old_x

int old_x

old_y

int old_y

x

int x

y

int y

dx

int dx

dy

int dy

offset_x

int offset_x

offset_y

int offset_y

aspect

double aspect

debug

boolean debug

showLineLengthsEnable

boolean showLineLengthsEnable

mfont

java.awt.Font mfont

geometryManager

GeometryManager geometryManager
Constructor Detail

FigCanvasRubberband

public FigCanvasRubberband(FigTrafo2D trafo)
constructor: nothing to do. Just initialize the mode to pointRubber.

Method Detail

setDebug

public boolean setDebug(boolean debug)
toggle debug messages on or off


getDebug

public boolean getDebug()

setTrafo

public void setTrafo(FigTrafo2D trafo)

setShowLineLengths

public void setShowLineLengths(boolean b)

setBasePoint

public void setBasePoint(java.awt.Point p)
set a new basepoint for the rubberband, use Point or two integers as arguments.


setBasePoint

public void setBasePoint(int x,
                         int y)

setGeometryManager

public void setGeometryManager(GeometryManager manager)

setBasePoint2

public void setBasePoint2(java.awt.Point p)
set the second basepoint for the line movePoint rubberband


setAspect

public void setAspect(double d)
set the aspect ratio (y vs. x) for an object to be scaled proportionally.


getMode

public int getMode()

changeMode

public void changeMode(int mode)
set a new mode for the rubberbanding. Use the full parameter form of changeMode for bboxRubber and polylineRubber.


changeMode

public void changeMode(int mode,
                       GeometryManager manager)

changeMode

public void changeMode(int mode,
                       FigTrafo2D trafo,
                       java.lang.Object obj)
set a new mode for the rubberbanding. Some modes (e.g. polyline) use the second argument to set the object to draw.


paint

public void paint(java.awt.Graphics g,
                  int x,
                  int y,
                  boolean erase_old)
draw the rubberband (in the current mode) at new position (x,y), XOR mode should probably be set by the calling parent.


getBasePoint

public java.awt.Point getBasePoint()

paintOnce

public void paintOnce(java.awt.Graphics g,
                      int x,
                      int y)

getRubberBoundingBox

public java.awt.Rectangle getRubberBoundingBox(int old_x,
                                               int old_y,
                                               int cur_x,
                                               int cur_y)
calculate the bounding box Rectangle which needs to be redrawn. This takes the union of the base point(s) and the old and current mouse position


measure

void measure(java.awt.Graphics g,
             int delta,
             int x,
             int y,
             int align)
utility function to format and draw a numerical value label as required by the "show line length" rubberbanding modi. This function takes the current Graphics context, a screen coordinate length (=delta), and the (x,y) coordinates for the String base point. The align parameter specifies the relative orientation of the value String with respect to the (x,y) base point, e.g. LT specifies that the String extends to the left and on top of the base point.

The "delta" value is converted from screen (pixel) coordinates to the current world coordinates via our "trafo" transformation instance, and then converted to the currently selected user units (e.g. inches). Next, the resulting value is converted via jfig.utils.Format( "%4.3f" ) into a String, which is then drawn.

Note that the resulting numerical value may be sligthly "off grid" due to 0.5-pixel rounding errors for the screen coordinate grid. This should probably be fixed to be more user-friendly.


min

public static final int min(int a,
                            int b,
                            int c)

min

public static final int min(int a,
                            int b,
                            int c,
                            int d)

min

public static final int min(int a,
                            int b,
                            int c,
                            int d,
                            int e)

max

public static final int max(int a,
                            int b,
                            int c)

max

public static final int max(int a,
                            int b,
                            int c,
                            int d)

max

public static final int max(int a,
                            int b,
                            int c,
                            int d,
                            int e)