Exemplo n.º 1
0
  private Component buildSparkCards() {
    CssLayout sparks = new CssLayout();
    sparks.addStyleName("sparks");
    sparks.setWidth("100%");
    Responsive.makeResponsive(sparks);

    float totalKm = getTotalKm();
    SparkCard worldTripsSparkCard =
        new SparkCard("trips around the world", Float.toString(totalKm / ECUATOR_LENGTH_KM));
    sparks.addComponent(worldTripsSparkCard);

    SparkCard moonTripsSparkCard =
        new SparkCard("trips to the moon", Float.toString(totalKm / DISTANCE_TO_THE_MOON_KM));
    sparks.addComponent(moonTripsSparkCard);

    float totalCalories = getTotalCalories();

    SparkCard burgersBurnedSparkCard =
        new SparkCard("burgers burned", Float.toString(totalCalories / CALORIES_PER_BURGER));
    sparks.addComponent(burgersBurnedSparkCard);

    SparkCard biersBurnedSparkCard =
        new SparkCard("beers burned", Long.toString(Math.round(totalCalories / CALORIES_PER_BEER)));
    sparks.addComponent(biersBurnedSparkCard);

    return sparks;
  }
Exemplo n.º 2
0
  private void fillScatter(DataSeries series, int points) {
    Random random = new Random();
    for (int i = 0; i < points; i++) {
      double x = random.nextDouble() * 30 + 150;
      double y = 60;
      if (random.nextBoolean()) {
        y += random.nextDouble() * 15;
        if (random.nextBoolean() && x > 170) {
          y += random.nextDouble() * 30;
        }
      } else {
        y -= random.nextDouble() * 20;
      }
      x = Math.floor(x * 10) / 10;
      y = Math.floor(y * 10) / 10;

      int colorNumber = (int) Math.floor((x - 150) / 30 * 255);

      Color color = new SolidColor(colorNumber, 0, 255 - colorNumber);
      DataSeriesItem item = new DataSeriesItem(x, y);
      // item.setColor(color);
      series.add(item);
    }
  }
Exemplo n.º 3
0
 private void setTablePageLengths() {
   myTranscoderTable.setPageLength(Math.min(myTranscoderTable.getItemIds().size(), 10));
 }