Ejemplo n.º 1
0
  @Override
  public void paint(Graphics2D gfx) {
    if (_scaleFactor <= 0) {
      return;
    }
    // If we are flipping the card, scale it horizontally.
    AffineTransform otrans = gfx.getTransform();
    if (_scaleFactor < 1.0) {
      int xtrans = getX() + getWidth() / 2;
      gfx.translate(xtrans, 0);
      gfx.scale(_scaleFactor, 1.0);
      gfx.translate(-xtrans, 0);
    }

    super.paint(gfx);

    gfx.setTransform(otrans);
  }
Ejemplo n.º 2
0
  @Override
  public void tick(long tickStamp) {
    super.tick(tickStamp);

    // Take care of any flipping we might be doing.
    if (_flipDuration != -1) {
      if (_flipStamp == 0) {
        _flipStamp = tickStamp;
      }

      long diff = tickStamp - _flipStamp;

      // Set the new scale while we're flipping
      if (diff < _flipDuration / 2) {
        _scaleFactor = 1.0 - ((float) diff * 2) / _flipDuration;
      } else {
        // Switch the image to the card we're flipping to.
        if (_flipCard != null) {
          setCard(_flipCard);
          _flipCard = null;
        }
        _scaleFactor = ((float) diff * 2) / _flipDuration - 1.0;
      }

      // If we're done, stop flipping.
      if (_scaleFactor > 1.0) {
        _scaleFactor = 1.0;
        _flipDuration = -1;
      }

      // Make sure we flag our location as needing redrawing
      if (_mgr != null) {
        _mgr.getRegionManager().invalidateRegion(_bounds);
      }
    }
  }