Examples of Polyline


Examples of project.gluebooster.graphics.PolyLine

      for (Edge edge : graph.getEdges())
      {
         RectangularShape source = vertexMap.get(graph.getSource(edge));
         RectangularShape destination = vertexMap.get(graph.getDest(edge));

         PolyLine line = new PolyLine(new Line2D.Double(source.getCenterX(),
               source.getCenterY(), destination.getCenterX(), destination
                     .getCenterY()));
         edgeMap.put(edge, new Pair<RectangularShape, PolyLine>(null, line));
         polyLines.add(line);
      }

      // avoid collisions with the vertices
      for (PolyLine line : polyLines)
      {
         for (RectangleWithRef<Vertex,?> vertex : nodeMapping.values())
         {
            int equalityDistance = 5;
            if (line.intersects(vertex)
                  && !(line.startsWith(vertex.getCenter(), equalityDistance) || (line
                        .endsWith(vertex.getCenter(), equalityDistance))))
            {
               // determine which diagonale part is intersected and add another
               // point to the polyline
               Line2D.Double diagonalePart = vertex.getUpperLeftDiagonaleLine();
               Pair<Line2D, Point2D> intersection = line
                     .getIntersection(diagonalePart);
               if (intersection != null)
               {
                  line.splitLine(intersection.getFirst(), GeometryBoostUtils
                        .translate(vertex.getUpperLeftCorner(),
                              GeometryBoostUtils.getVector(vertex.getCenter(),
                                    intersection.getSecond())));
               }

               diagonalePart = vertex.getUpperRightDiagonaleLine();
               intersection = line.getIntersection(diagonalePart);
               if (intersection != null)
               {
                  line.splitLine(intersection.getFirst(), GeometryBoostUtils
                        .translate(vertex.getUpperRightCorner(),
                              GeometryBoostUtils.getVector(vertex.getCenter(),
                                    intersection.getSecond())));
               }

               diagonalePart = vertex.getLowerRightDiagonaleLine();
               intersection = line.getIntersection(diagonalePart);
               if (intersection != null)
               {
                  line.splitLine(intersection.getFirst(), GeometryBoostUtils
                        .translate(vertex.getLowerRightCorner(),
                              GeometryBoostUtils.getVector(vertex.getCenter(),
                                    intersection.getSecond())));
               }

               diagonalePart = vertex.getLowerLeftDiagonaleLine();
               intersection = line.getIntersection(diagonalePart);
               if (intersection != null)
               {
                  line.splitLine(intersection.getFirst(), GeometryBoostUtils
                        .translate(vertex.getLowerLeftCorner(),
                              GeometryBoostUtils.getVector(vertex.getCenter(),
                                    intersection.getSecond())));
               }
View Full Code Here

Examples of project.gluebooster.graphics.PolyLine

      for (Edge edge : graph.getEdges())
      {
         Rectangle source = vertexMap.get(graph.getSource(edge));
         Rectangle destination = vertexMap.get(graph.getDest(edge));

         PolyLine line = new PolyLine(new Line2D.Double(source.getCenterX(),
               source.getCenterY(), destination.getCenterX(), destination
                     .getCenterY()));
         edgeMap.put(edge, new Pair<Rectangle, PolyLine>(null, line));
         polyLines.add(line);
      }

      // avoid collisions with the vertices
      for (PolyLine line : polyLines)
      {
         for (RectangleWithRef vertex : shapes)
         {
            int equalityDistance = 5;
            if (line.intersects(vertex)
                  && !(line.startsWith(vertex.getCenter(), equalityDistance) || (line
                        .endsWith(vertex.getCenter(), equalityDistance))))
            {
               // determine which diagonale part is intersected and add another
               // point to the polyline
               Line2D.Double diagonalePart = vertex.getUpperLeftDiagonaleLine();
               Pair<Line2D, Point2D> intersection = line
                     .getIntersection(diagonalePart);
               if (intersection != null)
               {
                  line.splitLine(intersection.getFirst(), GeometryBoostUtils
                        .translate(vertex.getUpperLeftCorner(),
                              GeometryBoostUtils.getVector(vertex.getCenter(),
                                    intersection.getSecond())));
               }

               diagonalePart = vertex.getUpperRightDiagonaleLine();
               intersection = line.getIntersection(diagonalePart);
               if (intersection != null)
               {
                  line.splitLine(intersection.getFirst(), GeometryBoostUtils
                        .translate(vertex.getUpperRightCorner(),
                              GeometryBoostUtils.getVector(vertex.getCenter(),
                                    intersection.getSecond())));
               }

               diagonalePart = vertex.getLowerRightDiagonaleLine();
               intersection = line.getIntersection(diagonalePart);
               if (intersection != null)
               {
                  line.splitLine(intersection.getFirst(), GeometryBoostUtils
                        .translate(vertex.getLowerRightCorner(),
                              GeometryBoostUtils.getVector(vertex.getCenter(),
                                    intersection.getSecond())));
               }

               diagonalePart = vertex.getLowerLeftDiagonaleLine();
               intersection = line.getIntersection(diagonalePart);
               if (intersection != null)
               {
                  line.splitLine(intersection.getFirst(), GeometryBoostUtils
                        .translate(vertex.getLowerLeftCorner(),
                              GeometryBoostUtils.getVector(vertex.getCenter(),
                                    intersection.getSecond())));
               }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.