Exemplo n.º 1
0
 protected void deactivate() {
   deactivate(1);
 }
Exemplo n.º 2
0
  /** @param theWindow */
  void draw(ControlWindow theWindow) {
    // System.out.println(previousPosition+"\t"+currentPosition+"\t"+position);
    if (enabled) {

      if (mode >= Skatolo.WAIT) {

        previousPosition.set(currentPosition);
        currentPosition.set(theWindow.getPointerX(), theWindow.getPointerY(), 0);

        if (controller != null) {
          if (controller.getControlWindow().equals(theWindow)) {
            switch (mode) {
              case (Skatolo.WAIT):
                if (moved()) {
                  startTime = System.nanoTime();
                }

                if (System.nanoTime() > startTime + (delayInMillis * 1000000)) {

                  position.set(currentPosition);
                  alignH = Skatolo.RIGHT;
                  if (position.x
                      > (controller.getControlWindow().papplet().width - (getWidth() + 20))) {
                    position.sub(new PVector(getWidth(), 0, 0));
                    alignH = Skatolo.LEFT;
                  }
                  mode = Skatolo.FADEIN;
                  startTime = System.nanoTime();
                  currentAlpha = 0;
                }
                break;
              case (Skatolo.FADEIN):
                float t1 = System.nanoTime() - startTime;
                currentAlpha = (int) PApplet.map(t1, 0, 200 * 1000000, 0, maxAlpha);
                if (currentAlpha >= 250) {
                  mode = Skatolo.IDLE;
                  currentAlpha = 255;
                }
                break;
              case (Skatolo.IDLE):
                break;
              case (Skatolo.FADEOUT):
                float t2 = System.nanoTime() - startTime;
                currentAlpha = (int) PApplet.map(t2, 0, 200 * 1000000, maxAlpha, 0);
                if (currentAlpha <= 0) {
                  mode = Skatolo.DONE;
                }
                break;
              case (Skatolo.DONE):
                controller = null;
                mode = Skatolo.INACTIVE;
                position.set(-1000, -1000, 0);
            }

            currentAlpha = PApplet.max(0, PApplet.min(currentAlpha, maxAlpha));

            if (mode >= Skatolo.WAIT) {
              currentAlpha = (mode == Skatolo.WAIT) ? 0 : currentAlpha;
              theWindow.graphics().pushMatrix();
              theWindow.graphics().translate(position.x, position.y);
              theWindow.graphics().translate(offset.x, offset.y);
              controllerView.display(theWindow.graphics(), null); // TODO: Warning HERE !
              theWindow.graphics().popMatrix();
            }
            if (mode < Skatolo.FADEOUT) {
              if (moved()) {
                deactivate(0);
              }
            }
          }
        }
      }
    }
  }