Package project.gluebooster.graphics

Examples of project.gluebooster.graphics.PolyLine


            result.getFirst().put((Vertex) keyRef, entry.getValue());
         } else if (EDGE.equals(key.getInternalInformation().getType()))
         {
            Pair<RectangularShape, PolyLine> pair = new Pair<RectangularShape, PolyLine>();
            pair.setFirst(entry.getValue());
            pair.setSecond(new PolyLine());
            result.getSecond().put((Edge) keyRef, pair);
         } else
            throw new IllegalStateException();
      }
View Full Code Here


      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

      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

Related Classes of project.gluebooster.graphics.PolyLine

Copyright © 2018 www.massapicom. 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.