View Javadoc
1 package com.bonevich.erj.diagram; 2 3 import java.awt.Color; 4 import java.awt.Rectangle; 5 6 import org.tigris.gef.presentation.FigPoly; 7 import org.tigris.gef.presentation.Handle; 8 9 /*** 10 * Overrides FigPoly to provide a simpler, more robust rectilinear 11 * polyline. 12 */ 13 public class FigRectiline extends FigPoly 14 { 15 //////////////////////////////////////////////////////////////// 16 // Constructors 17 18 /*** Construct a new FigRectiline. 19 */ 20 public FigRectiline() 21 { 22 super(); 23 _rectilinear = true; 24 } 25 26 /*** Construct a new FigRectiline with the given line color. 27 */ 28 public FigRectiline(Color lineColor) 29 { 30 this(); 31 setLineColor(lineColor); 32 } 33 34 /*** Construct a new FigRectiline with the given line color and fill color. 35 */ 36 public FigRectiline(Color lineColor, Color fillColor) 37 { 38 this(lineColor); 39 setFillColor(fillColor); 40 } 41 42 /*** Construct a new FigRectiline with the given point. 43 */ 44 public FigRectiline(int x, int y) 45 { 46 this(); 47 addPoint(x, y); 48 } 49 50 //////////////////////////////////////////////////////////////// 51 // Accessors 52 53 /*** Always returns true. 54 */ 55 public boolean getRectilinear() { return true; } 56 57 /*** Set the rectilinear flag. This is a no-op since we are rectilinear 58 * by definition. 59 */ 60 public void setRectilinear(boolean r) { } 61 62 63 //////////////////////////////////////////////////////////////// 64 // Geomertric manipulations 65 66 /*** Move the point indicated by the given Handle object to the given 67 * location. Fixed handles cannot be moved, unless ov is set to 68 * true to override the fixed handle constaint. Fires 69 * PropertyChange with "bounds". 70 */ 71 public void moveVertex(Handle h, int x, int y, boolean ov) { 72 int i = h.index; 73 if (ov) { _xpoints[i] = x; _ypoints[i] = y; } 74 75 if ( (i > 0 && _xpoints[i] == _xpoints[i-1]) || 76 (i < _npoints-1 && _ypoints[i] == _ypoints[i+1]) ) 77 { 78 if (canMoveVertex(i-1, ov)) { _xpoints[i-1] = x; _xpoints[i] = x; } 79 if (canMoveVertex(i+1, ov)) { _ypoints[i+1] = y; _ypoints[i] = y; } 80 } else { 81 if (canMoveVertex(i-1, ov)) { _ypoints[i-1] = y; _ypoints[i] = y; } 82 if (canMoveVertex(i+1, ov)) { _xpoints[i+1] = x; _xpoints[i] = x; } 83 } 84 85 Rectangle oldBounds = getBounds(); 86 calcBounds(); 87 firePropChange("bounds", oldBounds, getBounds()); 88 } 89 90 /*** No-op override of superclass cleanUp. 91 */ 92 public void cleanUp() { } 93 94 } /* end class FigRectiline */

This page was automatically generated by Maven