예제 #1
0
  private FigureMovableImpl createFigure(InputStream is) throws Exception {
    FigureType figureType = unmarshall(is);

    Map<String, Vertex> vertices = new HashMap<String, Vertex>();
    for (VertexType vertexType : figureType.getVertices()) {
      vertices.put(vertexType.getName(), createVertexFrom(vertexType));
    }

    Map<String, Edge> edges = new HashMap<String, Edge>();
    Map<Vertex, Set<Edge>> verticesEdges = new HashMap<Vertex, Set<Edge>>();
    for (EdgeType edgeType : figureType.getEdges()) {
      Edge edge = createEdgeFrom(edgeType, vertices);

      putEdgeIntoVerticesEdgesMap(verticesEdges, edge.getA(), edge);
      putEdgeIntoVerticesEdgesMap(verticesEdges, edge.getB(), edge);
      edges.put(edgeType.getName(), edge);
    }

    Map<String, Face> faces = new HashMap<String, Face>();
    for (FaceType faceType : figureType.getFaces()) {
      faces.put(faceType.getName(), createFaceFrom(faceType, edges, vertices, verticesEdges));
    }

    Double givenPrecision = figureType.getPrecision();
    double precision = (givenPrecision != null) ? givenPrecision : Pointable.PRECISION;

    return new FigureMovableImpl(
        new HashSet<Face>(faces.values()), new HashSet<Edge>(edges.values()), precision);
  }
예제 #2
0
 private void setEdgeFaces() {
   for (Face face : getFaces()) {
     for (Edge edge : face.getEdges()) {
       edge.getFaces().add(face);
     }
   }
 }