Package org.graphstream.ui.graphicGraph.stylesheet

Examples of org.graphstream.ui.graphicGraph.stylesheet.Style


        events = eventSet.events;
      }
    }

    for (int i = 1; i < n; i++) {
      Style style = rules.get(i).getStyle();

      if (style.hasValue(property, events))
        return style.getValue(property, events);
    }

    return rules.get(0).getStyle().getValue(property, events);
  }
View Full Code Here


    assertTrue(sgs.getGroupCount() == 6);

    System.err.printf("----%n");
    System.err.printf(sgs.toString());

    Style sG = sgs.getStyleForElement(graph);
    Style sA = sgs.getStyleForElement(A);
    Style sB = sgs.getStyleForElement(B);
    Style sC = sgs.getStyleForElement(C);
    Style sD = sgs.getStyleForElement(D);

    Style sAB = sgs.getStyleForElement(AB);
    Style sBC = sgs.getStyleForElement(BC);
    Style sCD = sgs.getStyleForElement(CD);
    Style sDA = sgs.getStyleForElement(DA);

    assertEquals(2, sG.getFillColorCount());
    assertEquals(1, sA.getFillColorCount());
    assertEquals(1, sB.getFillColorCount());
    assertEquals(1, sC.getFillColorCount());
    assertEquals(1, sD.getFillColorCount());
    assertTrue(sG.getFillColor(0).getRed() == 255
        && sG.getFillColor(0).getGreen() == 255
        && sG.getFillColor(0).getBlue() == 255);
    assertTrue(sG.getFillColor(1).getRed() == 0
        && sG.getFillColor(1).getGreen() == 0
        && sG.getFillColor(1).getBlue() == 0);
    assertTrue(sA.getFillColor(0).getRed() == 255
        && sA.getFillColor(0).getGreen() == 0
        && sA.getFillColor(0).getBlue() == 255);
    assertTrue(sB.getFillColor(0).getRed() == 255
        && sB.getFillColor(0).getGreen() == 165
        && sB.getFillColor(0).getBlue() == 0);
    assertTrue(sC.getFillColor(0).getRed() == 255
        && sC.getFillColor(0).getGreen() == 165
        && sC.getFillColor(0).getBlue() == 0);
    assertTrue(sD.getFillColor(0).getRed() == 190
        && sD.getFillColor(0).getGreen() == 190
        && sD.getFillColor(0).getBlue() == 190);

    assertEquals(1, sA.getStrokeWidth().value, 0);
    assertEquals(1, sB.getStrokeWidth().value, 0);
    assertEquals(1, sC.getStrokeWidth().value, 0);
    assertEquals(1, sD.getStrokeWidth().value, 0);

    assertTrue(sAB.getFillColor(0).getRed() == 255
        && sAB.getFillColor(0).getGreen() == 255
        && sAB.getFillColor(0).getBlue() == 0);
    assertTrue(sBC.getFillColor(0).getRed() == 0
        && sBC.getFillColor(0).getGreen() == 255
        && sBC.getFillColor(0).getBlue() == 0);
    assertTrue(sCD.getFillColor(0).getRed() == 0
        && sCD.getFillColor(0).getGreen() == 255
        && sCD.getFillColor(0).getBlue() == 0);
    assertTrue(sDA.getFillColor(0).getRed() == 0
        && sDA.getFillColor(0).getGreen() == 255
        && sDA.getFillColor(0).getBlue() == 0);

    sgs.release();
  }
View Full Code Here

    assertEquals(0, stylesheet.getSpriteStyleNameSpace()
        .getClassRulesCount());

    // All nodes should have a border of 10px except the clicked ones.

    Style sA = sgs.getStyleForElement(A);
    Style sB = sgs.getStyleForElement(B);
    Style sC = sgs.getStyleForElement(C);
    Style sD = sgs.getStyleForElement(D);

    assertEquals(10, sA.getStrokeWidth().value, 0);
    assertEquals(10, sB.getStrokeWidth().value, 0);
    assertEquals(10, sC.getStrokeWidth().value, 0);
    assertEquals(10, sD.getStrokeWidth().value, 0);

    sgs.pushEvent("clicked");
    sA = sgs.getStyleForElement(A);
    sB = sgs.getStyleForElement(B);
    sC = sgs.getStyleForElement(C);
    sD = sgs.getStyleForElement(D);

    assertEquals(2, sA.getStrokeWidth().value, 0);
    assertEquals(3, sB.getStrokeWidth().value, 0);
    assertEquals(3, sC.getStrokeWidth().value, 0);
    assertEquals(3, sD.getStrokeWidth().value, 0);

    sgs.popEvent("clicked");
    sA = sgs.getStyleForElement(A);
    sB = sgs.getStyleForElement(B);
    sC = sgs.getStyleForElement(C);
    sD = sgs.getStyleForElement(D);

    assertEquals(10, sA.getStrokeWidth().value, 0);
    assertEquals(10, sB.getStrokeWidth().value, 0);
    assertEquals(10, sC.getStrokeWidth().value, 0);
    assertEquals(10, sD.getStrokeWidth().value, 0);

    // Now augment the style sheet with a change that applies only to node
    // B.

    stylesheet.parseFromString(styleSheet3);

    assertEquals(7, sgs.getGroupCount());
    assertEquals(0, stylesheet.getGraphStyleNameSpace().getIdRulesCount());
    assertEquals(0, stylesheet.getGraphStyleNameSpace()
        .getClassRulesCount());
    assertEquals(2, stylesheet.getNodeStyleNameSpace().getIdRulesCount()); // <--
                                        // +1
    assertEquals(2, stylesheet.getNodeStyleNameSpace().getClassRulesCount());
    assertEquals(1, stylesheet.getEdgeStyleNameSpace().getIdRulesCount());
    assertEquals(0, stylesheet.getEdgeStyleNameSpace().getClassRulesCount());
    assertEquals(0, stylesheet.getSpriteStyleNameSpace().getIdRulesCount());
    assertEquals(0, stylesheet.getSpriteStyleNameSpace()
        .getClassRulesCount());

    sA = sgs.getStyleForElement(A);
    sB = sgs.getStyleForElement(B);
    sC = sgs.getStyleForElement(C);
    sD = sgs.getStyleForElement(D);

    assertEquals(10, sA.getStrokeWidth().value, 0);
    assertEquals(5, sB.getStrokeWidth().value, 0); // <-- The specific style
                          // changed.
    assertEquals(10, sC.getStrokeWidth().value, 0);
    assertEquals(10, sD.getStrokeWidth().value, 0);

    // Now augment the style sheet with a change that applies to all edges
    // with the ".foo" class.

    stylesheet.parseFromString(styleSheet4);

    assertEquals(8, sgs.getGroupCount()); // (e_AB disappears, e_AB(foo) and
                        // e(foo) appear)
    assertEquals(0, stylesheet.getGraphStyleNameSpace().getIdRulesCount());
    assertEquals(0, stylesheet.getGraphStyleNameSpace()
        .getClassRulesCount());
    assertEquals(2, stylesheet.getNodeStyleNameSpace().getIdRulesCount());
    assertEquals(2, stylesheet.getNodeStyleNameSpace().getClassRulesCount());
    assertEquals(1, stylesheet.getEdgeStyleNameSpace().getIdRulesCount());
    assertEquals(1, stylesheet.getEdgeStyleNameSpace().getClassRulesCount()); // <--
                                          // +1
    assertEquals(0, stylesheet.getSpriteStyleNameSpace().getIdRulesCount());
    assertEquals(0, stylesheet.getSpriteStyleNameSpace()
        .getClassRulesCount());

    Style sAB = sgs.getStyleForElement(AB);
    Style sBC = sgs.getStyleForElement(BC);
    Style sCD = sgs.getStyleForElement(CD);
    Style sDA = sgs.getStyleForElement(DA);

    assertEquals(2, sAB.getStrokeWidth().value, 0);
    assertEquals(2, sBC.getStrokeWidth().value, 0);
    assertEquals(1, sCD.getStrokeWidth().value, 0);
    assertEquals(1, sDA.getStrokeWidth().value, 0);

    System.err.printf(
        "After adding new style sheets, there are %d groups !!%n",
        sgs.getGroupCount());
    Iterator<? extends StyleGroup> i = sgs.getGroupIterator();
View Full Code Here

TOP

Related Classes of org.graphstream.ui.graphicGraph.stylesheet.Style

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.