Examples of EdgeView


Examples of org.jgraph.graph.EdgeView

    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

Examples of org.jgraph.graph.EdgeView

    }

    // 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

Examples of org.jgraph.graph.EdgeView

  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

Examples of org.jgraph.graph.EdgeView

        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

Examples of org.jgraph.graph.EdgeView

      // 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
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.