Esempio n. 1
0
 /**
  * Returns an array of exact copies of the provided vertices.
  *
  * @param vertices the vertices
  * @return the deep vertex array copy
  */
 public static Vertex[] getDeepVertexArrayCopy(Vertex[] vertices) {
   Vertex[] copy = new Vertex[vertices.length];
   for (int i = 0; i < vertices.length; i++) {
     Vertex vertex = vertices[i];
     copy[i] = (Vertex) vertex.getCopy();
   }
   return copy;
 }
Esempio n. 2
0
 /**
  * Returns a list of exact copies of the provided vertices.
  *
  * @param vertices the vertices
  * @return the deep vertex array copy
  */
 public static ArrayList<Vertex[]> getDeepVertexArrayCopy(ArrayList<Vertex[]> vertices) {
   ArrayList<Vertex[]> returnList = new ArrayList<Vertex[]>();
   for (Vertex[] vs : vertices) {
     Vertex[] copy = new Vertex[vs.length];
     for (int i = 0; i < vs.length; i++) {
       Vertex vertex = vs[i];
       copy[i] = (Vertex) vertex.getCopy();
     }
     returnList.add(copy);
   }
   return returnList;
 }
  /* (non-Javadoc)
   * @see org.apache.batik.parser.PathHandler#movetoAbs(float, float)
   */
  public void movetoAbs(float x, float y) throws ParseException {
    if (verbose) System.out.println("movetoAbs: x:" + x + " y:" + y);

    // If the last contour wasnt closed with Z,
    // we save the last contour here,but without closing it
    if (!currentSubPath.isEmpty()) {
      Vertex[] currentSplitPathArr =
          (Vertex[]) currentSubPath.toArray(new Vertex[currentSubPath.size()]);
      subPaths.add(currentSplitPathArr);
      currentSubPath.clear();
    }

    Vertex moveTo = new Vertex(x, y, 0);
    pathPoints.add(moveTo);
    currentSubPath.add(moveTo);
    reverseMoveToStack.push((Vertex) moveTo.getCopy());
  }
  /* (non-Javadoc)
   * @see org.apache.batik.parser.PathHandler#movetoRel(float, float)
   */
  public void movetoRel(float x, float y) throws ParseException {
    if (verbose) System.out.println("movetoRel: " + x + "," + y);

    // If the last contour wasnt closed with Z,
    // we save the last contour here, without closing it
    if (!currentSubPath.isEmpty()) {
      Vertex[] currentSplitPathArr =
          (Vertex[]) currentSubPath.toArray(new Vertex[currentSubPath.size()]);
      subPaths.add(currentSplitPathArr);
      currentSubPath.clear();
    }

    Vertex moveTo;
    if (!pathPoints.isEmpty() && pathPoints.getLast() != null) {
      moveTo = new Vertex(pathPoints.getLast().getX() + x, pathPoints.getLast().getY() + y, 0);
    } else {
      moveTo = new Vertex(x, y, 0);
    }
    pathPoints.add(moveTo);
    currentSubPath.add(moveTo);
    reverseMoveToStack.push((Vertex) moveTo.getCopy());
  }