Package org.jgraph.graph

Examples of org.jgraph.graph.EdgeView$EdgeHandle


    }

    // Override Superclass Method to Return Custom EdgeView
    protected EdgeView createEdgeView(Object cell) {
      // Return Custom EdgeView
      return new EdgeView(cell) {

        /**
         * Returns a cell handle for the view.
         */
        public CellHandle getHandle(GraphContext context) {
View Full Code Here


        for (int i = 0; i < cells.length; i++) {
          if (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);
                if (pt != null) {
                  if (ret == null)
                    ret = new Rectangle2D.Double(pt.getX(),
                        pt.getY(), 0, 0);
                  else
                    Rectangle2D.union(ret,
                        new Rectangle2D.Double(pt
                            .getX(), pt.getY(), 0,
                            0), ret);
                }
              }
              if (edgeView.getTarget() == null) {
                Point2D pt = edgeView.getPoint(edgeView
                    .getPointCount() - 1);
                if (pt != null) {
                  if (ret == null)
                    ret = new Rectangle2D.Double(pt.getX(),
                        pt.getY(), 0, 0);
View Full Code Here

  protected Point2D getEditorLocation(Object cell, Dimension2D editorSize,
      Point2D pt) {
    // Edges have different editor position and size
    CellView view = graphLayoutCache.getMapping(cell, false);
    if (view instanceof EdgeView) {
      EdgeView edgeView = (EdgeView) view;
      CellViewRenderer renderer = edgeView.getRenderer();
      if (renderer instanceof EdgeRenderer) {
        Point2D tmp = ((EdgeRenderer) renderer).getLabelPosition(edgeView);
        if (tmp != null) {
          pt = tmp;
          pt.setLocation(Math.max(0, pt.getX() - editorSize.getWidth()
View Full Code Here

  //  Giuseppe De Cicco & Fabio Granara
  public boolean intersectsEdge(EdgeView otherEdgeView) {
    boolean sourcesame = false;
    //      edgeView del lato uno
    EdgeView edgeView = (EdgeView) (mediator.getGraph().getGraphLayoutCache()).getMapping(this, false);
    JmtEdge edge2 = (JmtEdge) otherEdgeView.getCell();

    JmtCell sourceOfEdge1 = null;
    JmtCell targetOfEdge1 = null;
    JmtCell sourceOfEdge2 = null;
    JmtCell targetOfEdge2 = null;

    //      if inseriti per evitare eccezioni di tipo nullPointerException
    if ((DefaultPort) edge2.getSource() != null) {
      sourceOfEdge2 = (JmtCell) ((DefaultPort) edge2.getSource()).getParent();
    }
    if ((DefaultPort) edge2.getTarget() != null) {
      targetOfEdge2 = (JmtCell) ((DefaultPort) edge2.getTarget()).getParent();
    }
    if ((DefaultPort) this.getSource() != null) {
      sourceOfEdge1 = (JmtCell) ((DefaultPort) this.getSource()).getParent();
    }
    if ((DefaultPort) this.getTarget() != null) {
      targetOfEdge1 = (JmtCell) ((DefaultPort) this.getTarget()).getParent();
    }

    if (edgeView == null) {
      return false;
    }

    int controlPoint = edgeView.getPointCount();
    int controlPoint2 = otherEdgeView.getPointCount();

    //control point del lato
    Point2D[] controlPoints = new Point2D[controlPoint];
    for (int i = 0; i < controlPoint; i++) {

      controlPoints[i] = edgeView.getPoint(i);
      if ((controlPoints[i] == null)) {
        return false;
      }
      //ho inserito il BigDecimal per approssimare i valori a due cifre ma poi mi sono accorto che occorre approx a intero purche le computazioni
      //siano efficenti per cui ho richiamato il metodo intValue
View Full Code Here

    //      Questo mi restituisce la lista dei lati che ho da analizzare per l intersezione   
    listEdges = listEdges2.toArray();

    for (Object listEdge : listEdges) {
      Object[] celle = null;
      EdgeView edgeView = (EdgeView) (mediator.getGraph().getGraphLayoutCache()).getMapping(listEdge, false);
      Rectangle2D rett = edgeView.getBounds();
      //        Questo metodo mi ritorna sia le porte che il lato e i vertici sorgenti, devo quindi
      //          per questione di pesantezza fare un controllo di istanze
      celle = (mediator.getGraph()).getDescendants(mediator.getGraph().getRoots(rett.getBounds()));
      //        System.out.println("le celle che intersecano sono : "+celle.length);
      ArrayList<Object> celle2 = new ArrayList<Object>();
      JmtCell sourceOfEdge = (JmtCell) ((DefaultPort) ((JmtEdge) listEdge).getSource()).getParent();
      JmtCell targetOfEdge = (JmtCell) ((DefaultPort) ((JmtEdge) listEdge).getTarget()).getParent();

      for (int j = 0; j < celle.length; j++) {
        if (celle[j] instanceof JmtCell && !(celle[j] == sourceOfEdge) && !(celle[j] == targetOfEdge)) {
          celle2.add(celle[j]);
        }
      }
      //        System.out.println("le celle che intersecano modificate sono: "+ celle2.size());
      Object[] cellsfinal = celle2.toArray();
      int contatore = 0;
      //        System.out.println("Sono in JmtOverlapping grandezza delle celle che interseco: "+cellsfinal.length);
      for (Object element : cellsfinal) {

        Rectangle2D cellBound = GraphConstants.getBounds(((JmtCell) element).getAttributes());
        EdgeView viewtmp = (EdgeView) (mediator.getGraph().getGraphLayoutCache()).getMapping(listEdge, false);
        //        Point2D[] intersectionPoints=(Point2D[]) ((JmtEdge)listEdges[i]).intersects2(viewtmp,cellBound);
        if (((JmtEdge) listEdge).intersects(viewtmp, cellBound)) {
          //          ________________DATI APPARTENENTI AL VERTICE
          double vertexMinX = (int) cellBound.getMinX();
          double vertexMinY = (int) cellBound.getMinY();
View Full Code Here

        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);
                if (pt != null) {
                  if (ret == null)
                    ret = new Rectangle2D.Double(pt.getX(),
                        pt.getY(), 0, 0);
                  else
                    Rectangle2D.union(ret,
                        new Rectangle2D.Double(pt
                            .getX(), pt.getY(), 0,
                            0), ret);
                }
              }
              if (edgeView.getTarget() == null) {
                Point2D pt = edgeView.getPoint(edgeView
                    .getPointCount() - 1);
                if (pt != null) {
                  if (ret == null)
                    ret = new Rectangle2D.Double(pt.getX(),
                        pt.getY(), 0, 0);
View Full Code Here

  protected Point2D getEditorLocation(Object cell, Dimension2D editorSize,
      Point2D pt) {
    // Edges have different editor position and size
    CellView view = graphLayoutCache.getMapping(cell, false);
    if (view instanceof EdgeView) {
      EdgeView edgeView = (EdgeView) view;
      CellViewRenderer renderer = edgeView.getRenderer();
      if (renderer instanceof EdgeRenderer) {
        Point2D tmp = ((EdgeRenderer) renderer)
            .getLabelPosition(edgeView);
        if (tmp != null)
          pt = tmp;
View Full Code Here

    if (view instanceof EdgeView) {
     
      // ******** Start Path element **************
      Element path = (Element) document.createElement("path");
      EdgeView edge = (EdgeView) view;

      path.setAttribute("fill", "none");
      Color lineColor = GraphConstants.getLineColor(attributes);
      String hexLineColor = null;
      if (lineColor != null) {
        hexLineColor = SVGUtils.getHexEncoding(lineColor);
      } else {
        hexLineColor = DEFAULT_LINE_COLOR;
      }
      path.setAttribute("stroke", hexLineColor);
      float lineWidth = GraphConstants.getLineWidth(attributes);
      path.setAttribute("stroke-width", String.valueOf(lineWidth));
      // Dash pattern
      float[] dash = GraphConstants.getDashPattern(attributes);
      if (dash != null) {
        // Convert float array to string
        String dashValue = "";
        for (int i = 0; i < dash.length; i++) {
          Float wrapperFloat = new Float(dash[i]);
          dashValue += wrapperFloat.toString();
          if (i != dash.length-1) {
            dashValue += ", ";
          }
        }
        path.setAttribute("stroke-dasharray", dashValue);
      }

      // Computes the d attribute
      Point2D point = edge.getPoint(0);
      String d = "M " + (point.getX() - dx) + " " + (point.getY() - dy);
      for (int i = 1; i < edge.getPointCount(); i++) {
        point = edge.getPoint(i);
        d += " L " + (point.getX() - dx) + " " + (point.getY() - dy);
      }
      path.setAttribute("d", d);
      int lineBegin = GraphConstants.getLineBegin(attributes);
      int lineEnd = GraphConstants.getLineEnd(attributes);
      String styleAttributes = new String("");
      // TODO should draw arrows correctly instead of only having one type
      if (true) {
        styleAttributes += "marker-start: url(#endMarker);";
//        Element startMarker = (Element) document.createElement("marker-start");
//        startMarker.setAttribute("stroke", hexLineColor);
////        path.setAttribute("marker-start", "url(#endMarker)");
////        path.setAttribute("stroke", hexLineColor);
//        href.appendChild(startMarker);
       
      }
      // TODO should draw arrows correctly instead of only having one type
      if (true) {
        styleAttributes += "marker-end: url(#startMarker);";
//        path.setAttribute("marker-end", "url(#startMarker)");
//        path.setAttribute("stroke", hexLineColor);
      }
      styleAttributes += " stroke: " + hexLineColor + ";";
      path.setAttribute("style", styleAttributes);

      // Finds center point for labels
      Point center = null;
      int mid = edge.getPointCount() / 2;
      if (edge.isLoop()) {
        Point2D tmp = edge.getPoint(0);
        Point2D tmp2 = edge.getLabelVector();
        center = new Point((int) (tmp.getX() + tmp2.getX() - dx),
            (int) (tmp.getY() + tmp2.getY() - dy));
      } else if (edge.getPointCount() % 2 == 1) {
        Point2D tmp = edge.getPoint(mid);
        center = new Point((int) (tmp.getX() - dx),
            (int) (tmp.getY() - dy));
      } else {
        Point2D p1 = edge.getPoint(mid - 1);
        Point2D p2 = edge.getPoint(mid);
        center = new Point((int) (p1.getX() + (p2.getX() - p1.getX())
            / 2 - dx), (int) (p1.getY() + (p2.getY() - p1.getY())
            / 2 - dy));
      }
      href.appendChild(path);
View Full Code Here

    }

    // Override Superclass Method to Return Custom EdgeView
    protected EdgeView createEdgeView(Object cell) {
      // Return Custom EdgeView
      return new EdgeView(cell) {

        /**
         * Returns a cell handle for the view.
         */
        public CellHandle getHandle(GraphContext context) {
View Full Code Here

  protected Point2D getEditorLocation(Object cell, Dimension2D editorSize,
      Point2D pt) {
    // Edges have different editor position and size
    CellView view = graphLayoutCache.getMapping(cell, false);
    if (view instanceof EdgeView) {
      EdgeView edgeView = (EdgeView) view;
      CellViewRenderer renderer = edgeView.getRenderer();
      if (renderer instanceof EdgeRenderer) {
        Point2D tmp = ((EdgeRenderer) renderer)
            .getLabelPosition(edgeView);
        if (tmp != null)
          pt = tmp;
View Full Code Here

TOP

Related Classes of org.jgraph.graph.EdgeView$EdgeHandle

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.