Package org.graphstream.ui.graphicGraph

Examples of org.graphstream.ui.graphicGraph.GraphicNode


  protected String getNodeStyle(Node n) {
    String style = "tikzgsnode";

    if (n instanceof GraphicNode) {
      GraphicNode gn = (GraphicNode) n;

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

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

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

        int c = gn.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, ", fill=%s!%d!%s",
            checkColor(gn.style.getFillColor(0)),
            (int) (uicolor * 100),
            checkColor(gn.style.getFillColor(1)));
      }

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

        if (Double.isNaN(uisize))
          uisize = minSize;

        uisize = (uisize - minSize) / (maxSize - minSize);
View Full Code Here


     *         nothing found.
     */
    public GraphicElement findNodeOrSpriteAt(GraphicGraph graph, double x,
                                             double y) {
        for (Node n : graph) {
            GraphicNode node = (GraphicNode) n;

            if (nodeContains(node, x, y))
                return node;
        }

View Full Code Here

     * @param edge
     *            The edge to check.
     * @return True if visible.
     */
    protected boolean isEdgeVisible(GraphicEdge edge) {
        GraphicNode node0 = edge.getNode0();
        GraphicNode node1 = edge.getNode1();

        if (edge.hidden)
            return false;

        if ((!node1.positionned) || (!node0.positionned))
            return false;

        boolean node0Invis = nodeInvisible.contains(node0.getId());
        boolean node1Invis = nodeInvisible.contains(node1.getId());

        return !(node0Invis && node1Invis);
    }
View Full Code Here

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

        GraphicNode node = sprite.getNodeAttachment();
        double radius = metrics.lengthToGu(sprite.getX(), sprite.getUnits());
        double z = (double) (sprite.getZ() * (Math.PI / 180f));

        pos.x = node.x + ((double) Math.cos(z) * radius);
        pos.y = node.y + ((double) Math.sin(z) * radius);
 
View Full Code Here

  }

  @Override
  protected void renderElement(StyleGroup group, Graphics2D g, Camera camera,
      GraphicElement element) {
    GraphicNode node = (GraphicNode) element;

    shape.setFrame(node.x - w2, node.y - h2, width, height);
    g.fill(shape);
    renderText(group, g, camera, element);
  }
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 void renderArrow(StyleGroup group, Graphics2D g, Camera camera,
      GraphicEdge edge) {
    if (edge.isDirected() && arrowWidth > 0 && arrowLength > 0) {
      if (group.getArrowShape() != ArrowShape.NONE) {
        Path2D shape = new Path2D.Double();
        GraphicNode node0 = (GraphicNode) edge.getNode0();
        GraphicNode node1 = (GraphicNode) edge.getNode1();
        double off = evalEllipseRadius(edge, node0, node1, camera);
        Vector2 theDirection = new Vector2(node1.getX() - node0.getX(),
            node1.getY() - node0.getY());

        theDirection.normalize();

        double x = node1.x - (theDirection.data[0] * off);
        double y = node1.y - (theDirection.data[1] * off);
 
View Full Code Here

   *            The metrics.
   * @return The length from the node centre along the edge to position the
   *         arrow.
   */
  protected double evalTargetRadius(GraphicEdge edge, GraphMetrics metrics) {
    GraphicNode target = edge.to;
    StyleGroup group = target.getStyle();
    double w = metrics.lengthToGu(group.getSize(), 0);
    double h = group.getSize().size() > 1 ? metrics.lengthToGu(
        group.getSize(), 1) : w;

    if (w == h) {
View Full Code Here

TOP

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

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.