SHARE
TWEET

Untitled

AishaAli Nov 19th, 2019 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   @(#)ChopBoxConnector.java 5.2
  3.   */
  4.  
  5. package CH.ifa.draw.standard;
  6.  
  7. import java.awt.*;
  8. import CH.ifa.draw.framework.*;
  9. import CH.ifa.draw.util.Geom;
  10.  
  11. public class ChopBoxConnector extends AbstractConnector {
  12.  
  13.     private static final long serialVersionUID = -1461450322712345462L;
  14.  
  15.     public ChopBoxConnector() { // only used for Storable implementation
  16.     }
  17.  
  18.     public ChopBoxConnector(Figure owner) {
  19.         super(owner);
  20.     }
  21.  
  22.     public Point findStart(ConnectionFigure connection) {
  23.         Figure startFigure = connection.start().owner();
  24.         Rectangle r2 = connection.end().displayBox();
  25.         Point r2c = null;
  26.  
  27.         if (connection.pointCount() == 2)
  28.             r2c = new Point(r2.x + r2.width/2, r2.y + r2.height/2);
  29.          else
  30.             r2c = connection.pointAt(1);
  31.  
  32.         return chop(startFigure, r2c);
  33.     }
  34.  
  35.     public Point findEnd(ConnectionFigure connection) {
  36.         Figure endFigure = connection.end().owner();
  37.         Rectangle r1 = connection.start().displayBox();
  38.         Point r1c = null;
  39.  
  40.         if (connection.pointCount() == 2)
  41.             r1c = new Point(r1.x + r1.width/2, r1.y + r1.height/2);
  42.          else
  43.             r1c = connection.pointAt(connection.pointCount()-2);
  44.  
  45.         return chop(endFigure, r1c);
  46.     }
  47.  
  48.     protected Point chop(Figure target, Point from) {
  49.         Rectangle r = target.displayBox();
  50.         return Geom.angleToPoint(r, (Geom.pointToAngle(r, from)));
  51.     }
  52.            public ChopPolygonConnector(Figure owner) {
  53.         super(owner);
  54.     }
  55.  
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top