Package net.sf.graphiti.model

Examples of net.sf.graphiti.model.Vertex


        String typeName = element.getAttribute("type");
        ObjectType type = configuration.getEdgeType(typeName);

        String sourceId = element.getAttribute("source");
        Vertex source = graph.findVertex(sourceId);

        String targetId = element.getAttribute("target");
        Vertex target = graph.findVertex(targetId);

        if (source == null && target == null) {
          throw new TransformedDocumentParseError("In the edge \""
              + sourceId + "\" -> \"" + targetId + "\", \""
              + sourceId + "\" nor \"" + targetId
View Full Code Here


    Node child = node.getFirstChild();
    while (child != null) {
      if (child.getNodeName().equals("vertex")) {
        String typeName = ((Element) child).getAttribute("type");
        ObjectType type = configuration.getVertexType(typeName);
        Vertex vertex = new Vertex(type);

        // set layout information if present
        String xAttr = ((Element) child).getAttribute("x");
        String yAttr = ((Element) child).getAttribute("y");
        if (!xAttr.isEmpty() && !yAttr.isEmpty()) {
          int x = Integer.parseInt(xAttr);
          int y = Integer.parseInt(yAttr);
          vertex.setValue(Vertex.PROPERTY_SIZE, new Rectangle(x, y,
              0, 0));
        }

        parseParameters(vertex, type, child.getFirstChild());
        graph.addVertex(vertex);
View Full Code Here

    editor.setValidator(new ICellEditorValidator() {

      @Override
      public String isValid(Object value) {
        VertexEditPart part = (VertexEditPart) getHost();
        Vertex vertex = (Vertex) part.getModel();
        Graph graph = vertex.getParent();

        String vertexId = (String) value;
        if (vertexId.isEmpty()) {
          return "";
        }

        vertex = graph.findVertex(vertexId);
        if (vertex != null && !vertex.equals(getHost().getModel())) {
          return "A vertex already exists with the same identifier";
        }

        return null;
      }

    });

    Vertex vertex = (Vertex) getHost().getModel();
    if (editor.getValidator().isValid(editor.getValue()) == null) {
      VertexRenameCommand cmd = new VertexRenameCommand(vertex);
      cmd.setName((String) editor.getValue());
      return cmd;
    } else {
      String id = (String) vertex.getValue(ObjectType.PARAMETER_ID);
      VertexFigure figure = (VertexFigure) getHostFigure();
      figure.getLabelId().setText(id);
      figure.adjustSize();
      return null;
    }
View Full Code Here

    this.type = type;
  }

  @Override
  public Object getNewObject() {
    return new Vertex(type);
  }
View Full Code Here

      Object constraint) {
    VertexMoveCommand command = null;

    if (child instanceof VertexEditPart) {
      VertexEditPart editPart = (VertexEditPart) child;
      Vertex vertex = (Vertex) editPart.getModel();

      command = new VertexMoveCommand(vertex, (Rectangle) constraint);
    }

    return command;
View Full Code Here

    // copy vertices
    List<Vertex> vertices = new ArrayList<Vertex>();
    for (Object obj : list) {
      if (obj instanceof VertexEditPart) {
        VertexEditPart vertexEditPart = (VertexEditPart) obj;
        Vertex vertex = (Vertex) vertexEditPart.getModel();

        // copy vertex and add to list
        vertex = new Vertex(vertex);
        vertices.add(vertex);
      }
    }

    // prepare transfer
View Full Code Here

    this.vertices = vertices;
  }

  private String checkVertexId(Graph graph, Vertex vertex) {
    String id = (String) vertex.getValue(ObjectType.PARAMETER_ID);
    Vertex existing = graph.findVertex(id);
    if (existing != vertex) {
      id = getVertexId(id);
      if (id != null) {
        vertex.setValue(ObjectType.PARAMETER_ID, id);
      }
View Full Code Here

            if (vertexId.isEmpty()) {
              return "";
            }

            if (graph != null) {
              Vertex vertex = graph.findVertex(vertexId);
              if (vertex != null) {
                return "A vertex already exists with the same identifier";
              }
            }
View Full Code Here

        edge = new Edge(edge);
        String sourceId = (String) edge.getSource().getValue(
            ObjectType.PARAMETER_ID);
        String targetId = (String) edge.getTarget().getValue(
            ObjectType.PARAMETER_ID);
        Vertex source = graph.findVertex(sourceId);
        Vertex target = graph.findVertex(targetId);

        if (source != null && target != null) {
          edge.setSource(source);
          edge.setTarget(target);
          edge.setType(newType);
View Full Code Here

      Map<ObjectType, ObjectType> vertexTypes) {
    Set<Vertex> vertices = originalGraph.vertexSet();
    for (Vertex vertex : vertices) {
      ObjectType newType = vertexTypes.get(vertex.getType());
      if (newType != null) {
        vertex = new Vertex(vertex);
        vertex.setType(newType);
        graph.addVertex(vertex);
      }
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.graphiti.model.Vertex

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.