Пример #1
0
 public Component getRendererComponent(
     JGraph graph, CellView view, boolean sel, boolean focus, boolean preview) {
   return RenderComponentManager.retrievePanel(
       "Plan",
       ((Entity) ((DefaultGraphCell) (view.getCell())).getUserObject())
           .getPrefs(graph.getModel().getAttributes(view.getCell()))
           .getView());
 }
Пример #2
0
 /**
  * This method checks to determine whether the specified port can have outgoing flows drawn from
  * it.
  *
  * @param portView
  * @return true if flows can start from this port, false otherwise.
  */
 private boolean generatesOutgoingFlows(PortView portView) {
   CellView parentView = portView.getParentView();
   YAWLPort yawlPort = (YAWLPort) portView.getCell();
   YAWLCell vertex = (YAWLCell) parentView.getCell();
   return yawlPort.generatesOutgoingFlows()
       && vertex.generatesOutgoingFlows()
       && getNet().generatesOutgoingFlows(vertex);
 }
Пример #3
0
 /**
  * This method checks to determine whether the specified port is allowed to have incoming flows
  * attached to it.
  *
  * @param portView
  * @return true if flows can end at this port, false otherwise.
  */
 private boolean acceptsIncomingFlows(PortView portView) {
   CellView parentView = portView.getParentView();
   YAWLPort yawlPort = (YAWLPort) portView.getCell();
   YAWLCell vertex = (YAWLCell) parentView.getCell();
   return yawlPort.acceptsIncomingFlows()
       && vertex.acceptsIncomingFlows()
       && getNet().acceptsIncomingFlows(vertex);
 }
Пример #4
0
  /**
   * If it is a Vertex and it has no source, it must be a root vertex.
   *
   * <p>!!!todo I will need to enforce that there is always at least one vertex, and that is the acq
   * portal.
   *
   * @return all the tree root vertices
   */
  protected ArrayList getRootVertices(Object[] selectedCells) {
    HashSet potentialRoot = new HashSet();
    HashSet notARoot = new HashSet();
    CellView viewTargetPort;
    CellView viewTarget;

    /*
     * Loop through all the vertex and edge cells
     */
    for (int i = 0; i < selectedCells.length; i++) {
      if (canceled) return null;

      Object view = graph.getGraphLayoutCache().getMapping(selectedCells[i], false);

      /*
       * If the vertex is not in the notARoot bucket, it is a potential
       * root.
       */
      if (view instanceof VertexView) {
        if (!(notARoot.contains(view))) {
          potentialRoot.add(view);
        }
      }
      /*
       * The target of an edge is not a root.
       */
      else if (view instanceof EdgeView) {
        viewTargetPort = ((EdgeView) view).getTarget();
        viewTarget = viewTargetPort.getParentView();
        potentialRoot.remove(viewTarget);
        notARoot.add(viewTarget);
      } else if (view instanceof PortView) {
        // Ignore ports
      }
      /*
       * It should be impossible to get to the next statement
       */
      else {
        throw new RuntimeException("Cell is other than Vertex or Edge.");
      }
    }

    /*
     * When the loop ends, only tree roots are left
     */
    return new ArrayList(potentialRoot);
  }
Пример #5
0
    public TreeNode(CellView view) {
      this.view = view;

      if ((orientation == SwingConstants.NORTH) || (orientation == SwingConstants.SOUTH)) {
        width = (int) view.getBounds().getWidth();
        height = (int) view.getBounds().getHeight();
      } else {
        width = (int) view.getBounds().getHeight();
        height = (int) view.getBounds().getWidth();
      }

      this.children = new ArrayList();
      this.leftContour = new PolyLine(width / 2);
      this.rightContour = new PolyLine(width / 2);
      this.depth = 0;
      this.done = false;
    }
Пример #6
0
  public Component getRendererComponent(
      JGraph graph, CellView view, boolean sel, boolean focus, boolean preview) {

    ConflictCell cc = (ConflictCell) view.getCell();
    Conflict conflict = (Conflict) cc.getUserObject();

    if (conflict.getTopic().length() > 0) {
      conflictLabel.setText("<html><center>" + conflict.getTopic() + "</center></html>");
    } else {
      conflictLabel.setText("<html><center>Konflikt</center></html>");
    }

    return component;
  }
Пример #7
0
  protected List getChildren(CellView view) {
    ArrayList children = new ArrayList();
    GraphModel model = graph.getModel();
    Object cell = view.getCell();

    for (int i = 0; i < model.getChildCount(cell); i++) {
      if (canceled) return null;

      Object port = model.getChild(cell, i);

      for (Iterator edges = model.edges(port); edges.hasNext(); ) {
        Object edge = edges.next();

        if (port == model.getSource(edge)) {
          Object targetPort = model.getTarget(edge);
          Object targetVertex = model.getParent(targetPort);
          children.add(graph.getGraphLayoutCache().getMapping(targetVertex, false));
        }
      }
    }

    return children;
  }
Пример #8
0
    public void setPosition(Point parent, int levelHeight) {
      int nextLevelHeight = 0;

      for (Iterator it = children.iterator(); it.hasNext(); ) {
        nextLevelHeight = Math.max(nextLevelHeight, ((TreeNode) it.next()).height);
      }

      if (parent == null) {
        Rectangle2D b = view.getBounds();
        Rectangle bounds =
            new Rectangle(
                (int) b.getX(), (int) b.getY(),
                (int) b.getWidth(), (int) b.getHeight());
        Point p = bounds.getLocation();

        if (centerRoot) {
          int lw = getLeftWidth();
          int rw = getRightWidth();
          int h = getHeight();

          Insets i = graph.getInsets();

          if (orientation == SwingConstants.NORTH) {
            bounds.x = lw - (width / 2);
            bounds.y = i.top;
          } else if (orientation == SwingConstants.EAST) {
            bounds.x = (i.left + h) - width;
            bounds.y = lw - (height / 2);
          } else if (orientation == SwingConstants.SOUTH) {
            bounds.x = lw - (width / 2);
            bounds.y = i.top + h;
          } else if (orientation == SwingConstants.WEST) {
            bounds.x = i.right;
            bounds.y = lw - (width / 2);
          }

          Object cell = view.getCell();
          Map attributes = GraphConstants.createAttributes(cell, GraphConstants.BOUNDS, bounds);
          graph.getGraphLayoutCache().edit(attributes, null, null, null);

          if ((orientation == SwingConstants.WEST) || (orientation == SwingConstants.EAST)) {
            graph.setPreferredSize(new Dimension(h + i.left + i.right, lw + rw + i.top + i.bottom));
          } else {
            graph.setPreferredSize(new Dimension(lw + rw + i.left + i.right, h + i.top + i.bottom));
          }

          p = bounds.getLocation();
        }

        if ((orientation == SwingConstants.WEST) || (orientation == SwingConstants.EAST)) {
          int tmp = p.x;
          p.x = p.y;
          p.y = tmp;
        }

        if ((orientation == SwingConstants.NORTH) || (orientation == SwingConstants.WEST)) {
          parent = new Point(p.x + (width / 2), p.y + height);
        } else if ((orientation == SwingConstants.SOUTH) || (orientation == SwingConstants.EAST)) {
          parent = new Point(p.x + (width / 2), p.y);
        }

        for (Iterator it = children.iterator(); it.hasNext(); ) {
          ((TreeNode) it.next()).setPosition(parent, nextLevelHeight);
        }

        return;
      }

      if (combineLevelNodes) {
        levelHeight = this.levelheight;
      }

      Rectangle cellBounds = new Rectangle(width, height);

      if ((orientation == SwingConstants.NORTH) || (orientation == SwingConstants.WEST)) {
        cellBounds.x = (x + parent.x) - (width / 2);
        cellBounds.y = parent.y + levelDistance;
      } else {
        cellBounds.x = (x + parent.x) - (width / 2);
        cellBounds.y = parent.y - levelDistance - levelheight;
      }

      if (alignment == SwingConstants.CENTER) {
        cellBounds.y += ((levelHeight - height) / 2);
      } else if (alignment == SwingConstants.BOTTOM) {
        cellBounds.y += (levelHeight - height);
      }

      if ((orientation == SwingConstants.WEST) || (orientation == SwingConstants.EAST)) {
        int tmp = cellBounds.x;
        cellBounds.x = cellBounds.y;
        cellBounds.y = tmp;

        tmp = cellBounds.width;
        cellBounds.width = cellBounds.height;
        cellBounds.height = tmp;
      }

      Object cell = view.getCell();
      Map attributes = GraphConstants.createAttributes(cell, GraphConstants.BOUNDS, cellBounds);
      graph.getGraphLayoutCache().edit(attributes, null, null, null);

      if ((orientation == SwingConstants.NORTH) || (orientation == SwingConstants.WEST)) {
        y = parent.y + levelDistance + levelHeight;
      } else {
        y = parent.y - levelDistance - levelHeight;
      }

      for (Iterator it = children.iterator(); it.hasNext(); ) {
        ((TreeNode) it.next()).setPosition(new Point(x + parent.x, y), nextLevelHeight);
      }
    }
 public Component getRendererComponent(
     JGraph graph, CellView view, boolean sel, boolean focus, boolean preview) {
   return RenderComponentManager.retrievePanel(
       "DeploymentUnitByTypeMSEntity",
       ((Entity) ((DefaultGraphCell) (view.getCell())).getUserObject()).getPrefs().getView());
 }