Exemplo n.º 1
0
 // SETTERS
 public void setBody(ColorRect body) {
   if (this.body != null) {
     if (body.getColor() == null) {
       body.setColor(this.body.getColor());
     }
   }
   this.body = body;
   this.sizeXMAX = this.body.getSizeX();
 }
Exemplo n.º 2
0
 @Override
 public void draw(Graphics g, ColorRect body) {
   if (body.getMinX() != -1) {
     if (this.body != null && body.getColor() == null) {
       body.setColor(this.body.getColor());
     }
     body.draw(g);
     if (this.animatorController != null && this.animatorController.isPrintable()) {
       Pair<Float, Float> position = this.getChoicePosition(body);
       g.drawAnimation(
           this.animatorController.currentAnimation(), position.getV1(), position.getV2());
     }
   }
 }
Exemplo n.º 3
0
  private Pair<Float, Float> getChoicePosition(ColorRect body) {
    float x = body.getMinX();
    float y = body.getMinY();

    if (this.position == PositionInBody.MIDDLE_MID) {
      float sizeX =
          (body.getSizeX() / 2) - (this.animatorController.currentAnimation().getWidth() / 2);
      float sizeY =
          (body.getSizeY() / 2) - (this.animatorController.currentAnimation().getHeight() / 2);

      sizeX = (sizeX < 0 ? 0 : sizeX);
      sizeY = (sizeY < 0 ? 0 : sizeY);
      x += sizeX;
      y += sizeY;
    } else if (this.position == PositionInBody.RIGHT_MID) {
      float sizeX = (body.getSizeX() - this.animatorController.currentAnimation().getWidth());
      float sizeY =
          (body.getSizeY() / 2) - (this.animatorController.currentAnimation().getHeight() / 2);

      sizeX = (sizeX < 0 ? 0 : sizeX);
      sizeY = (sizeY < 0 ? 0 : sizeY);
      x += sizeX;
      y += sizeY;
    } else if (this.position == PositionInBody.MIDDLE_DOWN) {
      float sizeX =
          (body.getSizeX() / 2) - (this.animatorController.currentAnimation().getWidth() / 2);
      float sizeY = (body.getSizeY() - this.animatorController.currentAnimation().getHeight());

      sizeX = (sizeX < 0 ? 0 : sizeX);
      sizeY = (sizeY < 0 ? 0 : sizeY);
      x += sizeX;
      y += sizeY;
    } else if (this.position == PositionInBody.RIGHT_DOWN) {
      float sizeX = (body.getSizeX() - this.animatorController.currentAnimation().getWidth());
      float sizeY = (body.getSizeY() - this.animatorController.currentAnimation().getHeight());

      sizeX = (sizeX < 0 ? 0 : sizeX);
      sizeY = (sizeY < 0 ? 0 : sizeY);
      x += sizeX;
      y += sizeY;
    } else if (this.position == PositionInBody.LEFT_DOWN) {
      float sizeY = (body.getSizeY() - this.animatorController.currentAnimation().getHeight());

      sizeY = (sizeY < 0 ? 0 : sizeY);
      y += sizeY;
    } else if (this.position == PositionInBody.MIDDLE_UP) {
      float sizeX =
          (body.getSizeX() / 2) - (this.animatorController.currentAnimation().getWidth() / 2);

      sizeX = (sizeX < 0 ? 0 : sizeX);
      x += sizeX;
    } else if (this.position == PositionInBody.RIGHT_UP) {
      float sizeX = (body.getSizeX() - this.animatorController.currentAnimation().getWidth());

      sizeX = (sizeX < 0 ? 0 : sizeX);
      x += sizeX;
    }

    return new Pair<>(x, y);
  }
Exemplo n.º 4
0
 public ImageElement(ColorRect body, String id, PositionInBody position) {
   this.init(body, id, position, EnumOverlayElement.IMAGE);
   this.animatorController = null;
   this.sizeXMAX = body.getSizeX();
 }
Exemplo n.º 5
0
 public ImageElement(
     ColorRect body, AnimatorController animatorController, PositionInBody position) {
   this.init(body, "", position, EnumOverlayElement.IMAGE);
   this.animatorController = animatorController;
   this.sizeXMAX = body.getSizeX();
 }