Package net.sf.graphiti.model

Examples of net.sf.graphiti.model.Vertex


            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


        new VertexDirectEditPolicy());
  }

  @Override
  protected IFigure createFigure() {
    Vertex vertex = (Vertex) getModel();

    // Get default width and height
    int width = (Integer) vertex.getAttribute(ObjectType.ATTRIBUTE_WIDTH);
    int height = (Integer) vertex.getAttribute(ObjectType.ATTRIBUTE_HEIGHT);

    // Get dimension, color, shape
    Dimension dimension = new Dimension(width, height);
    Color color = (Color) vertex.getAttribute(ObjectType.ATTRIBUTE_COLOR);
    String name = (String) vertex.getAttribute(ObjectType.ATTRIBUTE_SHAPE);
    IShape shape = ShapeFactory.createShape(name);

    // Creates the figure with the specified properties, sets its id
    Font font = ((GraphicalEditPart) getParent()).getFigure().getFont();
    VertexFigure figure = new VertexFigure(font, dimension, color, shape);
    String id = (String) vertex.getValue(ObjectType.PARAMETER_ID);
    figure.setId(id);

    // update the figure position (if the graph has layout information)
    if ((Boolean) vertex.getParent().getValue(Graph.PROPERTY_HAS_LAYOUT)) {
      Rectangle bounds = (Rectangle) vertex
          .getValue(Vertex.PROPERTY_SIZE);
      if (bounds != null) {
        figure.setBounds(bounds);
      }
    }
View Full Code Here

  @Override
  @SuppressWarnings({ "rawtypes", "unchecked" })
  protected List getModelSourceConnections() {
    if (getModel() instanceof Vertex) {
      Vertex vertex = (Vertex) getModel();
      Graph parent = vertex.getParent();

      // we get the *output* dependencies of vertex
      Set<Edge> edges = parent.outgoingEdgesOf(vertex);

      // return the dependencies
View Full Code Here

  @Override
  @SuppressWarnings({ "rawtypes", "unchecked" })
  protected List getModelTargetConnections() {
    if (getModel() instanceof Vertex) {
      Vertex vertex = (Vertex) getModel();
      Graph parent = vertex.getParent();

      // we get the *input* dependencies of vertex
      Set<Edge> edges = parent.incomingEdgesOf(vertex);

      // dependencies
View Full Code Here

      if (propertyName.equals(ObjectType.PARAMETER_ID)) {
        refreshVisuals();
      }

      // updates the figure size
      Vertex vertex = (Vertex) getModel();
      ((VertexFigure) getFigure()).adjustSize();
      Rectangle bounds = getFigure().getBounds().getCopy();
      vertex.setValue(Vertex.PROPERTY_SIZE, bounds);
    }
  }
View Full Code Here

    }
  }

  @Override
  protected void refreshVisuals() {
    Vertex vertex = (Vertex) getModel();

    VertexFigure figure = (VertexFigure) getFigure();
    figure.setId((String) vertex.getValue(ObjectType.PARAMETER_ID));
  }
View Full Code Here

   * This method is called by the {@link GraphLayoutManager}, and applies back
   * the changes of the {@link CompoundDirectedGraphLayout} algorithm to the
   * different figures, by setting their bounds.
   */
  void updateFigures() {
    Vertex vertex = (Vertex) getModel();
    Rectangle bounds = (Rectangle) vertex.getValue(Vertex.PROPERTY_SIZE);
    if (bounds == null) {
      bounds = getFigure().getBounds();
    }

    Rectangle newBounds = bounds.getCopy();
    newBounds.x = node.x;
    newBounds.y = node.y;
    vertex.setValue(Vertex.PROPERTY_SIZE, newBounds);

    // Updates edges
    for (Object connection : getSourceConnections()) {
      if (connection instanceof EdgeEditPart) {
        EdgeEditPart part = (EdgeEditPart) connection;
View Full Code Here

   * getFigure() at this time returns null.
   *
   * @param fig
   */
  private void updatePorts(IFigure fig) {
    Vertex vertex = (Vertex) getModel();
    VertexFigure figure = (VertexFigure) fig;
    Graph parent = vertex.getParent();

    figure.resetPorts();

    for (Edge edge : parent.incomingEdgesOf(vertex)) {
      String port = (String) edge
          .getValue(ObjectType.PARAMETER_TARGET_PORT);
      figure.addInputPort(port);
    }

    for (Edge edge : parent.outgoingEdgesOf(vertex)) {
      String port = (String) edge
          .getValue(ObjectType.PARAMETER_SOURCE_PORT);
      figure.addOutputPort(port);
    }

    figure.adjustSize();
    vertex.setValue(Vertex.PROPERTY_SIZE, figure.getBounds().getCopy());
  }
View Full Code Here

    List<Vertex> vertices = new ArrayList<Vertex>();

    for (Object obj : list) {
      if (obj instanceof VertexEditPart) {
        VertexEditPart part = (VertexEditPart) obj;
        Vertex vertex = (Vertex) part.getModel();

        // remove from parent
        Graph parent = vertex.getParent();
        parent.removeVertex(vertex);

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

        // for undo
        parents.add(parent);
      }
View Full Code Here

  public void undo() {
    Iterator<Graph> it = parents.iterator();
    for (Object obj : list) {
      if (obj instanceof VertexEditPart) {
        VertexEditPart part = (VertexEditPart) obj;
        Vertex vertex = (Vertex) part.getModel();
        Graph parent = it.next();
        parent.addVertex(vertex);

        // update bounds
        Rectangle bounds = (Rectangle) vertex
            .getValue(Vertex.PROPERTY_SIZE);
        vertex.firePropertyChange(Vertex.PROPERTY_SIZE, null, bounds);
      }
    }

    parents = null;
  }
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.