Examples of CellView


Examples of org.jgraph.graph.CellView

              Xmax[i] = new Integer((int) rett.getMaxX());
              Ymax[i] = new Integer((int) rett.getMaxY());
              moved = true;
            }
            if (cells[i] instanceof BlockingRegion) {
              CellView groupview = (graphtmp.getGraphLayoutCache()).getMapping(cells[i], false);
              Rectangle2D rett2 = groupview.getBounds();

              Object[] celgru = new Object[1];
              celgru[0] = cells[i];
              //celle presenti nel blocking region incluse port e regione
View Full Code Here

Examples of org.jgraph.graph.CellView

    public IconGraph(GraphModel model) {
      super(model);
      getGraphLayoutCache().setAutoSizeOnValueChange(true);
      getGraphLayoutCache().setFactory(new DefaultCellViewFactory() {
        public CellView createView(GraphModel model, Object c) {
          CellView view = null;
          if (c instanceof CustomCell) {
            return new JGraphIconView(c);
          } else if (c instanceof Port) {
            view = new InvisiblePortView(c);
          } else {
View Full Code Here

Examples of org.jgraph.graph.CellView

      boolean leafsOnly) {
    Rectangle2D r = new Rectangle2D.Double(x, y, 1, 1);
    Object[] cells = getDescendants(getRoots());
    for (int i = (reverse) ? cells.length - 1 : 0; i >= 0
        && i < cells.length; i += (reverse) ? -1 : +1) {
      CellView view = getGraphLayoutCache().getMapping(cells[i], false);
      if (view != null
          && (!leafsOnly || view.isLeaf())
          && ((view.isLeaf() && view.intersects(this, r)) || (!view
              .isLeaf() && view.getBounds().contains(x, y))))
        return view;
    }
    return null;
  }
View Full Code Here

Examples of org.jgraph.graph.CellView

   *            Edge for which routing is demanding
   */
  public List<Object> routeEdge(EdgeView edge) {
    List<Object> newPoints = new ArrayList<Object>();

    CellView nodeFrom = edge.getSource();
    CellView nodeTo = edge.getTarget();
    // Check presence of source/target nodes
    if (null == nodeFrom) {
      nodeFrom = edge.getSourceParentView();
    }
   
    if (null == nodeTo) {
      nodeTo = edge.getTargetParentView();
    }
   
    if ((null == nodeFrom) || (null == nodeTo)) {
      //LoggerManager.debug(Constants.QUALANALYSIS_LOGGER, "-- route() " + this.getClass().getName() + "EdgeView has no source or target view : " + edge.toString());
      return null;
    }
   
    if (nodeFrom == nodeTo) {
      return null;
    }

    List<?> points = edge.getPoints();
    Object startPort = points.get(0);
    Object endPort = points.get(points.size() - 1);
    newPoints.add(startPort);

    // Promote edges up to first visible connected parents

//    if (graph == null) {
//      System.out
//          .println("graph variable not correctly set, must be set to obtain parallel routing");
//    }
    // Check presence of parallel edges
    Object[] edges = getParallelEdges(cache, edge, nodeFrom, nodeTo);
    if (edges == null) {
      return null;
    }

    // For one edge, no intermediate point
    if (edges.length >= 2) {
    // Looking for position of edge
      int position = 0;
      for (int i = 0; i < edges.length; i++) {
        Object e = edges[i];
        if (e == edge.getCell()) {
          position = i + 1;
        }
      }
    // Looking for position of source/target nodes (edge=>port=>vertex)
      Point2D from;
      Point2D perimeterPoint = edge.getTarget() != null ? edge
          .getPoint(edge.getPointCount() - 1) : AbstractCellView
          .getCenterPoint(nodeTo);
      if (perimeterPoint == null) {
        perimeterPoint = AbstractCellView.getCenterPoint(nodeTo);
      }
      if (edge.getSource() == null || edge.getSource().getParentView() == null) {
        from = nodeFrom.getPerimeterPoint(edge,
            AbstractCellView.getCenterPoint(nodeFrom),
            perimeterPoint);
      } else {
        from = edge.getSource().getParentView().getPerimeterPoint(edge,
            AbstractCellView.getCenterPoint(edge.getSource().getParentView()),
            (edge.getTarget() != null && edge.getTarget().getParentView() != null) ?
                AbstractCellView.getCenterPoint(edge.getTarget().getParentView()) :
                AbstractCellView.getCenterPoint(nodeTo));
      }
      Point2D to;
      if (edge.getTarget() == null || edge.getTarget().getParentView() == null) { // INV: nodeTo != null
        to = nodeTo.getPerimeterPoint(edge, AbstractCellView.getCenterPoint(nodeTo), from);
      } else {
        to = edge.getTarget().getParentView().getPerimeterPoint
          (edge, AbstractCellView.getCenterPoint(edge.getTarget().getParentView()), from);
      }

      if (from != null && to != null) {
        double dy = from.getY() - to.getY();
        double dx = from.getX() - to.getX();

        if (dy == 0 && dx == 0) {
          return null;
        }
        double theta = 0;
        if (dy == 0) {
          theta = Math.PI / 2.0;
        } else if (dx == 0) {
          theta = 0;
        } else {
          double m = dy / dx;
          theta = Math.atan(-1 / m);
        }
        // Calc of radius

        double length = Math.sqrt(dx * dx + dy * dy);
        double rx = dx / length;
        double ry = dy / length;

        // Memorize size of source/target nodes
        double sizeFrom = Math.max(nodeFrom.getBounds().getWidth(),
            nodeFrom.getBounds().getHeight()) / 2.;
        double sizeTo = Math.max(nodeTo.getBounds().getWidth(), nodeTo
            .getBounds().getHeight()) / 2.;

        // Calc position of central point
        double edgeMiddleDeparture = (Math.sqrt(dx * dx + dy * dy)
            - sizeFrom - sizeTo)
View Full Code Here

Examples of org.jgraph.graph.CellView

   *            Edge for which routing is demanding
   */
  public List routeEdge(GraphLayoutCache cache, EdgeView edge) {
    List newPoints = new ArrayList();

    CellView nodeFrom = edge.getSource();
    CellView nodeTo = edge.getTarget();
    // Check presence of source/target nodes
    if (null == nodeFrom) {
      nodeFrom = edge.getSourceParentView();
    }
    if (null == nodeTo) {
      nodeTo = edge.getTargetParentView();
    }
    if ((null == nodeFrom) || (null == nodeTo)) {
//      System.out.println("EdgeView has no source or target view : "
//          + edge.toString());
      return null;
    }
    if (nodeFrom == nodeTo) {
//      System.out.println("nodeFrom and NodeTo are the same cell view");
      return null;
    }

    List points = edge.getPoints();
    Object startPort = points.get(0);
    Object endPort = points.get(points.size() - 1);
    newPoints.add(startPort);

    // Promote edges up to first visible connected parents

//    if (graph == null) {
//      System.out
//          .println("graph variable not correctly set, must be set to obtain parallel routing");
//    }
    // Check presence of parallel edges
    Object[] edges = getParallelEdges(cache, edge, nodeFrom, nodeTo);
    if (edges == null) {
      return null;
    }

    // For one edge, no intermediate point
    if (edges.length >= 2) {
//      System.out.println("EdgeView indicates " + edges.length
//          + " parallel edges");
      // Looking for position of edge
      int position = 0;
//      System.out.println();
//      System.out.println("edges.length = " + edges.length);
      for (int i = 0; i < edges.length; i++) {
//        System.out
//        .println("edge value = "
//            + String.valueOf(((DefaultGraphCell) edges[i])
//                .getUserObject()));
//        System.out
//        .println("compared edge value = "
//            + String.valueOf(((DefaultGraphCell) edge.getCell())
//                .getUserObject()));
        Object e = edges[i];
        if (e == edge.getCell()) {
          position = i + 1;
        }
      }
//      System.out.println("position = " + position);
      // Looking for position of source/target nodes (edge=>port=>vertex)
      Point2D from;
      Point2D perimeterPoint = edge.getTarget() != null ? edge
          .getPoint(edge.getPointCount() - 1) : AbstractCellView
          .getCenterPoint(nodeTo);
      if (perimeterPoint == null) {
        perimeterPoint = AbstractCellView.getCenterPoint(nodeTo);
      }
      if (edge.getSource() == null || edge.getSource().getParentView() == null) {
//        System.out.println(edge+"-source promoted");
        from = nodeFrom.getPerimeterPoint(edge,
            AbstractCellView.getCenterPoint(nodeFrom),
            perimeterPoint);
      } else {
        from = edge.getSource().getParentView().getPerimeterPoint(edge,
            AbstractCellView.getCenterPoint(edge.getSource().getParentView()),
            (edge.getTarget() != null && edge.getTarget().getParentView() != null) ?
                AbstractCellView.getCenterPoint(edge.getTarget().getParentView()) :
                AbstractCellView.getCenterPoint(nodeTo));
      }
      Point2D to;
      if (edge.getTarget() == null || edge.getTarget().getParentView() == null) { // INV: nodeTo != null
//        System.out.println(edge+"-target promoted");
        to = nodeTo.getPerimeterPoint(edge, AbstractCellView.getCenterPoint(nodeTo), from);
      } else {
        to = edge.getTarget().getParentView().getPerimeterPoint
          (edge, AbstractCellView.getCenterPoint(edge.getTarget().getParentView()), from);
      }

//      System.out.println("from Point = " + String.valueOf(from));
//      System.out.println("to Point = " + String.valueOf(to));

      if (from != null && to != null) {
        double dy = from.getY() - to.getY();
        double dx = from.getX() - to.getX();

        if (dy == 0 && dx == 0) {
          return null;
        }
        double theta = 0;
        if (dy == 0) {
          theta = Math.PI / 2.0;
        } else if (dx == 0) {
          theta = 0;
        } else {
          double m = dy / dx;
          theta = Math.atan(-1 / m);
        }
        // Calc of radius

        double length = Math.sqrt(dx * dx + dy * dy);
//        System.out.println("length = " + length);
        double rx = dx / length;
        double ry = dy / length;

        // Memorize size of source/target nodes
        double sizeFrom = Math.max(nodeFrom.getBounds().getWidth(),
            nodeFrom.getBounds().getHeight()) / 2.;
        double sizeTo = Math.max(nodeTo.getBounds().getWidth(), nodeTo
            .getBounds().getHeight()) / 2.;

        // Calc position of central point
        double edgeMiddleDeparture = (Math.sqrt(dx * dx + dy * dy)
            - sizeFrom - sizeTo)
View Full Code Here

Examples of org.jgraph.graph.CellView

    protected Point2D getInitialLocation(Object[] cells) {
      if (cells != null && cells.length > 0) {
        Rectangle2D ret = null;
        for (int i = 0; i < cells.length; i++) {
          if (graphModel != null && graphModel.isEdge(cells[i])) {
            CellView cellView = graphLayoutCache.getMapping(
                cells[i], false);
            if (cellView instanceof EdgeView) {
              EdgeView edgeView = (EdgeView) cellView;
              if (edgeView.getSource() == null) {
                Point2D pt = edgeView.getPoint(0);
View Full Code Here

Examples of org.jgraph.graph.CellView

        }
        if (views != null) { // Start Move if over cell
          Point2D screenPoint = event.getPoint();
          Point2D pt = graph
              .fromScreen((Point2D) screenPoint.clone());
          CellView view = findViewForPoint(pt);
          if (view != null) {
            if (snapSelectedView) {
              Rectangle2D bounds = view.getBounds();
              start = graph.toScreen(new Point2D.Double(bounds
                  .getX(), bounds.getY()));
              snapStart = graph.snap((Point2D) start.clone());
              _mouseToViewDelta_x = screenPoint.getX()
                  - start.getX();
View Full Code Here

Examples of org.jgraph.graph.CellView

     * Used for move into group to find the target group.
     */
    protected CellView findUnselectedInnermostGroup(double x, double y) {
      Object[] cells = graph.getDescendants(graph.getRoots());
      for (int i = cells.length - 1; i >= 0; i--) {
        CellView view = graph.getGraphLayoutCache().getMapping(
            cells[i], false);
        if (view != null && !view.isLeaf()
            && !context.contains(view.getCell())
            && view.getBounds().contains(x, y))
          return view;
      }
      return null;
    }
View Full Code Here

Examples of org.jgraph.graph.CellView

              if (constrained && cachedBounds == null) {
                // Reset Initial Positions
                CellView[] all = graphLayoutCache
                    .getAllDescendants(views);
                for (int i = 0; i < all.length; i++) {
                  CellView orig = graphLayoutCache
                      .getMapping(all[i].getCell(), false);
                  AttributeMap attr = orig.getAllAttributes();
                  all[i].changeAttributes(graph
                      .getGraphLayoutCache(),
                      (AttributeMap) attr.clone());
                  all[i].refresh(graph.getGraphLayoutCache(),
                      context, false);
View Full Code Here

Examples of org.jgraph.graph.CellView

              Map hiddenMapping = graphLayoutCache
                  .getHiddenMapping();
              for (int i = 0; i < cells.length; i++) {
                Object witness = attributes.get(cells[i]);
                if (witness == null) {
                  CellView view = (CellView) hiddenMapping
                      .get(cells[i]);
                  if (view != null
                      && !graphModel.isPort(view
                          .getCell())) {
                    // TODO: Clone required? Same in
                    // GraphConstants.
                    AttributeMap attrs = (AttributeMap) view
                        .getAllAttributes().clone();
                    // Maybe translate?
                    // attrs.translate(dx, dy);
                    attributes.put(cells[i], attrs.clone());
                  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.