Example #1
0
 private void refresh(Timer timer) {
   if (ach == goal) {
     timer.cancel();
     return;
   } else if (goal > ach) {
     ach++;
     if (ach > pot + 1) {
       ach = goal;
     }
     if (pot < ach) {
       bluRect.setFillColor(CANVASCOLORDARKGREEN);
       greenRect.setFillColor(CANVASCOLORDARKGREEN);
     }
   } else {
     ach--;
     if (ach > pot + 1) {
       ach = pot;
     }
     if (pot == ach) {
       greenRect.setFillColor(CANVASCOLORGREEN);
       bluRect.setFillColor(CANVASCOLORBLUE);
     }
   }
   String achStr = String.valueOf(ach);
   achText.setX(getTextPosition(achStr));
   achText.setText(achStr);
   if (pot != 0) {
     greenRect.setHeight(istogramHeight - (istogramHeight * ach / pot));
   } else greenRect.setHeight(0);
 }
Example #2
0
  public void setIstogramWidget(int pot, int ach, int hMax, String productNameLabel) {
    goal = ach;
    this.pot = pot;
    this.ach = ach;
    int paddingTop = AREAHEIGTH - hMax;
    istogramHeight = hMax - CANVASMARGINTOP;
    String potStr = ViewUtils.format(pot);
    String achStr = ViewUtils.format(ach);
    bluRect.setY(paddingTop + CANVASMARGINTOP);
    bluRect.setHeight(istogramHeight);
    greenRect.setY(paddingTop + CANVASMARGINTOP);
    greenRect.setHeight(convertToPixel(pot, ach));
    achText.setX(getTextPosition(achStr));
    achText.setY(paddingTop + CANVASMARGINTOP + (istogramHeight + TEXTSIZE / 2) / 2);
    achText.setText(achStr);
    potText.setX(getTextPosition(potStr));
    potText.setY(paddingTop + TEXTSIZE);
    potText.setText(potStr);
    productName.setHTML("<p>" + productNameLabel + "</p>");

    if (ach == 0) {
      achText.setVisible(false);
    } else {
      achText.setVisible(true);
    }
    if (pot == 0) {
      potText.setVisible(false);
    } else {
      potText.setVisible(true);
    }

    if (pot == 0 && ach == 0) { // prodotto non lavorato o nessun ach disponibile
      bluRect.setFillColor(CANVASCOLORDARKGREY);
      greenRect.setFillColor(CANVASCOLORDARKGREY);
    } else if (ach >= pot) {
      bluRect.setFillColor(CANVASCOLORDARKGREEN);
      greenRect.setFillColor(CANVASCOLORDARKGREEN);
    } else if (ach < pot) {
      greenRect.setFillColor(CANVASCOLORGREEN);
      bluRect.setFillColor(CANVASCOLORBLUE);
    }
  }