Exemplo n.º 1
0
  private void testEach() {
    Selection selection = givenAMultipleSelection(new LabelFactory("1"), new LabelFactory("2"));
    final StringBuilder stringBuilder = new StringBuilder();

    selection.each(new StringBuilderFunction(webEngine, stringBuilder));
    assertEquals("12", stringBuilder.toString());
  }
Exemplo n.º 2
0
  protected void testEmpty() {
    Selection selection = d3.select("svg");

    selection.append("myelement");

    assertEquals(false, selection.select("myelement").empty());
    assertEquals(true, selection.select("unknown").empty());
  }
Exemplo n.º 3
0
 @Override
 public Void apply(final Object context, final Object d, final int index) {
   int n = valueList.size() - 1;
   int i = (int) Math.floor((Math.random() * n) / 2);
   int j = i + (int) Math.floor((Math.random() * n) / 2) + 1;
   JSObject firstObj = valueList.get(i).getDate().getJsObject();
   JSObject secondObj = valueList.get(j).getDate().getJsObject();
   xScale.domain(Array.fromJavaScriptObjects(webEngine, firstObj, secondObj));
   Transition transition = svg.transition().duration(750);
   transition.select("." + "x" + "." + "axis").call(xAxis);
   transition.select("." + "area").attr("d", area.apply(valueList));
   transition.select("." + "line").attr("d", line.generate(valueList));
   return null;
 };
Exemplo n.º 4
0
 /**
  * Immediately dispatches a zoom gesture to registered listeners, as the three event sequence
  * {@link ZoomEventType#ZOOMSTART}, {@link ZoomEventType#ZOOM} and {@link ZoomEventType#ZOOMEND}.
  *
  * <p>This can be useful in triggering listeners after setting the #translate(Array) or {@link
  * #scale(double)} programmatically.
  *
  * <p>
  *
  * @param selection the selection to triggers the events to.
  * @return the current zoom
  */
 public Zoom event(Selection selection) {
   JSObject jsObject = selection.getJsObject();
   JSObject result = call("event", jsObject);
   return new Zoom(webEngine, result);
 }
Exemplo n.º 5
0
 private void testNode() {
   Selection selection = givenAMultipleSelection(new LabelFactory("1"), new LabelFactory("2"));
   assertEquals("1", selection.node().getInnerText());
   selection = selection.selectAll("unknown");
   assertNull(selection.node());
 }
Exemplo n.º 6
0
 private void testCount() {
   Selection selection = givenAMultipleSelection(new LabelFactory("1"), new LabelFactory("2"));
   assertEquals(2, selection.size());
 }
Exemplo n.º 7
0
 private void testInterrupt() {
   Selection selection = givenAMultipleSelection(new LabelFactory("1"), new LabelFactory("2"));
   selection.interrupt();
 }