]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/connection/Path2DOutlineShape.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / elementclass / connection / Path2DOutlineShape.java
index e04de9cf1dc776eb8d043015db1d448b1a6f7305..a5befdb2e10c2dc218c435fa646359642e4a3574 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.g2d.elementclass.connection;\r
-\r
-import java.awt.Rectangle;\r
-import java.awt.Shape;\r
-import java.awt.geom.AffineTransform;\r
-import java.awt.geom.Path2D;\r
-import java.awt.geom.PathIterator;\r
-import java.awt.geom.Point2D;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-public class Path2DOutlineShape implements Shape {\r
-\r
-       Path2D path;\r
-       \r
-       public Path2DOutlineShape(Path2D path) {\r
-               this.path = path;\r
-       }\r
-\r
-       @Override\r
-       public boolean contains(Point2D p) {\r
-               return false;\r
-       }\r
-\r
-       @Override\r
-       public boolean contains(Rectangle2D r) {\r
-               return false;\r
-       }\r
-\r
-       @Override\r
-       public boolean contains(double x, double y) {           \r
-               return false;\r
-       }\r
-\r
-       @Override\r
-       public boolean contains(double x, double y, double w, double h) {               \r
-               return false;\r
-       }\r
-\r
-       @Override\r
-       public Rectangle getBounds() {\r
-               return path.getBounds();\r
-       }\r
-\r
-       @Override\r
-       public Rectangle2D getBounds2D() {\r
-               return path.getBounds2D();\r
-       }\r
-\r
-       @Override\r
-       public PathIterator getPathIterator(AffineTransform at) {\r
-               return path.getPathIterator(at);\r
-       }\r
-\r
-       @Override\r
-       public PathIterator getPathIterator(AffineTransform at, double flatness) {\r
-               return path.getPathIterator(at, flatness);\r
-       }\r
-\r
-       @Override\r
-       public boolean intersects(Rectangle2D r) {\r
-               return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());\r
-       }\r
-\r
-       @Override\r
-       public boolean intersects(double x, double y, double w, double h) {\r
-               PathIterator it = path.getPathIterator(new AffineTransform(), 1.0);\r
-               double[] coords = new double[2];\r
-               double x0, y0, x1=0.0, y1=0.0;\r
-               while(!it.isDone()) {\r
-                       x0 = x1;\r
-                       y0 = y1;\r
-                       switch(it.currentSegment(coords)) {\r
-                       case PathIterator.SEG_MOVETO:\r
-                               x1 = coords[0];\r
-                               y1 = coords[1];\r
-                               break;\r
-                               \r
-                       case PathIterator.SEG_LINETO:\r
-                               x1 = coords[0];\r
-                               y1 = coords[1];\r
-                               \r
-                               // Lines are approximated by their bounding boxes. This works for\r
-                               // orthogonal paths.\r
-                               if(x0 < x1) {\r
-                                       if(x > x1 || x+w < x0)\r
-                                               break;                                          \r
-                               }\r
-                               else {\r
-                                       if(x > x0 || x+w < x1)\r
-                                               break;\r
-                               }\r
-\r
-                               if(y0 < y1) {\r
-                                       if(y > y1 || y+h < y0)\r
-                                               break;                                          \r
-                               }\r
-                               else {\r
-                                       if(y > y0 || y+h < y1)\r
-                                               break;\r
-                               }       \r
-                               return true;\r
-                       }                       \r
-                       it.next();\r
-               }\r
-               return false;\r
-       }\r
-       \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.g2d.elementclass.connection;
+
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Path2D;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+public class Path2DOutlineShape implements Shape {
+
+       Path2D path;
+       
+       public Path2DOutlineShape(Path2D path) {
+               this.path = path;
+       }
+
+       @Override
+       public boolean contains(Point2D p) {
+               return false;
+       }
+
+       @Override
+       public boolean contains(Rectangle2D r) {
+               return false;
+       }
+
+       @Override
+       public boolean contains(double x, double y) {           
+               return false;
+       }
+
+       @Override
+       public boolean contains(double x, double y, double w, double h) {               
+               return false;
+       }
+
+       @Override
+       public Rectangle getBounds() {
+               return path.getBounds();
+       }
+
+       @Override
+       public Rectangle2D getBounds2D() {
+               return path.getBounds2D();
+       }
+
+       @Override
+       public PathIterator getPathIterator(AffineTransform at) {
+               return path.getPathIterator(at);
+       }
+
+       @Override
+       public PathIterator getPathIterator(AffineTransform at, double flatness) {
+               return path.getPathIterator(at, flatness);
+       }
+
+       @Override
+       public boolean intersects(Rectangle2D r) {
+               return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+       }
+
+       @Override
+       public boolean intersects(double x, double y, double w, double h) {
+               PathIterator it = path.getPathIterator(new AffineTransform(), 1.0);
+               double[] coords = new double[2];
+               double x0, y0, x1=0.0, y1=0.0;
+               while(!it.isDone()) {
+                       x0 = x1;
+                       y0 = y1;
+                       switch(it.currentSegment(coords)) {
+                       case PathIterator.SEG_MOVETO:
+                               x1 = coords[0];
+                               y1 = coords[1];
+                               break;
+                               
+                       case PathIterator.SEG_LINETO:
+                               x1 = coords[0];
+                               y1 = coords[1];
+                               
+                               // Lines are approximated by their bounding boxes. This works for
+                               // orthogonal paths.
+                               if(x0 < x1) {
+                                       if(x > x1 || x+w < x0)
+                                               break;                                          
+                               }
+                               else {
+                                       if(x > x0 || x+w < x1)
+                                               break;
+                               }
+
+                               if(y0 < y1) {
+                                       if(y > y1 || y+h < y0)
+                                               break;                                          
+                               }
+                               else {
+                                       if(y > y0 || y+h < y1)
+                                               break;
+                               }       
+                               return true;
+                       }                       
+                       it.next();
+               }
+               return false;
+       }
+       
+}