Package org.graphstream.ui.graphicGraph

Examples of org.graphstream.ui.graphicGraph.GraphicEdge


  protected String getEdgeStyle(Edge e) {
    String style = "tikzgsnode";

    if (e instanceof GraphicEdge) {
      GraphicEdge ge = (GraphicEdge) e;

      style = classNames.get(ge.style.getId());

      if (ge.style.getFillMode() == FillMode.DYN_PLAIN) {
        double uicolor = ge.getNumber("ui.color");

        if (Double.isNaN(uicolor))
          uicolor = 0;

        int c = ge.style.getFillColorCount();
        int s = 1;
        double d = 1.0 / (c - 1);

        while (s * d < uicolor && s < c)
          s++;

        uicolor -= (s - 1) * d;
        uicolor *= c;

        style += String.format(Locale.ROOT, ", draw=%s!%d!%s",
            checkColor(ge.style.getFillColor(s - 1)),
            (int) (uicolor * 100),
            checkColor(ge.style.getFillColor(s)));
      }

      if (ge.style.getSizeMode() == SizeMode.DYN_SIZE) {
        double uisize = ge.getNumber("ui.size");

        if (Double.isNaN(uisize) || uisize < 0.01)
          uisize = 1;

        style += String
View Full Code Here


  }

  @Override
  protected void renderElement(StyleGroup group, Graphics2D g, Camera camera,
      GraphicElement element) {
    GraphicEdge edge = (GraphicEdge) element;
    GraphicNode node0 = (GraphicNode) edge.getNode0();
    GraphicNode node1 = (GraphicNode) edge.getNode1();

    shape.setLine(node0.x, node0.y, node1.x, node1.y);
    g.draw(shape);
    renderArrow(group, g, camera, edge);
    renderText(group, g, camera, element);
View Full Code Here

    protected Point2D.Double getSpritePositionEdge(GraphicSprite sprite,
                                                   Point2D.Double pos, Units units) {
        if (pos == null)
            pos = new Point2D.Double();

        GraphicEdge edge = sprite.getEdgeAttachment();

        if (edge.isCurve()) {
            double ctrl[] = edge.getControlPoints();
            Point2 p0 = new Point2(edge.from.getX(), edge.from.getY());
            Point2 p1 = new Point2(ctrl[0], ctrl[1]);
            Point2 p2 = new Point2(ctrl[1], ctrl[2]);
            Point2 p3 = new Point2(edge.to.getX(), edge.to.getY());
            Vector2 perp = CubicCurve.perpendicular(p0, p1, p2, p3,
                sprite.getX());
            double y = metrics.lengthToGu(sprite.getY(), sprite.getUnits());

            perp.normalize();
            perp.scalarMult(y);

            pos.x = CubicCurve.eval(p0.x, p1.x, p2.x, p3.x, sprite.getX())
                - perp.data[0];
            pos.y = CubicCurve.eval(p0.y, p1.y, p2.y, p3.y, sprite.getX())
                - perp.data[1];
        } else {
            double x = ((GraphicNode) edge.getSourceNode()).x;
            double y = ((GraphicNode) edge.getSourceNode()).y;
            double dx = ((GraphicNode) edge.getTargetNode()).x - x;
            double dy = ((GraphicNode) edge.getTargetNode()).y - y;
            double d = sprite.getX(); // Percent on the edge.
            double o = metrics.lengthToGu(sprite.getY(), sprite.getUnits());
            // Offset from the position given by percent, perpendicular to the
            // edge.
View Full Code Here

TOP

Related Classes of org.graphstream.ui.graphicGraph.GraphicEdge

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.