Exemplo n.º 1
0
  public Timer(Element timer) {
    this();

    setTitle(timer.getChildTextNormalize("title"));
    String started = timer.getChildTextNormalize("started");
    this.started = started.isEmpty() ? null : DateTime.parse(started);
    if (this.started != null) {
      this.timer.start();
    }
    period = Period.parse(timer.getChildTextNormalize("total"));

    update_speed = Integer.parseInt(timer.getChildTextNormalize("speed"), 10);
    this.timer.setDelay(update_speed);
    if (this.started != null) {
      this.timer.start();
    }

    setLocation(
        Integer.parseInt(timer.getChildTextNormalize("x"), 10),
        Integer.parseInt(timer.getChildTextNormalize("y"), 10));
    setSize(
        Integer.parseInt(timer.getChildTextNormalize("width"), 10),
        Integer.parseInt(timer.getChildTextNormalize("height"), 10));

    Color foreground =
        new Color((int) Long.parseLong(timer.getChildTextNormalize("foreground"), 16), true);
    total.setForeground(foreground);
    time.setForeground(foreground);
    Color background =
        new Color((int) Long.parseLong(timer.getChildTextNormalize("background"), 16), true);
    panel.setBackground(background);

    Element times = timer.getChild("times");
    for (Element ts : times.getChildren()) {
      this.times.add(new TimeSpan(ts));
    }

    updateTimes();
    setVisible(Boolean.parseBoolean(timer.getChildText("visible")));
  }