Android Open Source - AndroidSettlers U I Button






From Project

Back to project page AndroidSettlers.

License

The source code is released under:

GNU General Public License

If you think the Android project AndroidSettlers listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.settlers.hd;
/*www .  j  a  v a 2s.co m*/
public class UIButton {

  public enum Type {
    INFO, TRADE, ROLL, ROAD, TOWN, CITY, DEVCARD, CANCEL, ENDTURN
  }
  
  public enum Background {
    BACKDROP, PRESSED, ACTIVATED
  }

  private Type type;
  private int bitmap;

  private int x;
  private int y;
  private int width;
  private int height;
  private boolean pressed;
  private boolean enabled;

  public UIButton(Type type, int width, int height) {
    this.type = type;
    this.x = 0;
    this.y = 0;
    this.width = width;
    this.height = height;

    pressed = false;
    enabled = false;
  }

  public int getX() {
    return x;
  }

  public int getY() {
    return y;
  }

  public void setPosition(int x, int y) {
    this.x = x;
    this.y = y;
  }

  public int getWidth() {
    return width;
  }

  public int getHeight() {
    return height;
  }
  
  public int getResource() {
    return bitmap;
  }
  
  public boolean isPressed() {
    return pressed;
  }

  public Type getType() {
    return type;
  }

  public void setEnabled(boolean enabled) {
    this.enabled = enabled;
  }

  public boolean isEnabled() {
    return enabled;
  }

  public boolean isWithin(int x, int y) {
    x += width / 2;
    y += height / 2;
    return (x > this.x && x < this.x + width && y > this.y && y < this.y
        + height);
  }

  public boolean press(int x, int y) {
    if (!enabled)
      return false;

    pressed = isWithin(x, y);
    return pressed;
  }

  public boolean release(int x, int y) {
    if (!pressed || !enabled)
      return false;

    pressed = false;
    return isWithin(x, y);
  }
}




Java Source Code List

com.settlers.hd.AcceptTrade.java
com.settlers.hd.AutomatedPlayer.java
com.settlers.hd.BalancedAI.java
com.settlers.hd.Board.java
com.settlers.hd.CounterOffer.java
com.settlers.hd.Discard.java
com.settlers.hd.Edge.java
com.settlers.hd.GameActivity.java
com.settlers.hd.GameRenderer.java
com.settlers.hd.GameView.java
com.settlers.hd.Geometry.java
com.settlers.hd.Hexagon.java
com.settlers.hd.LocalGame.java
com.settlers.hd.Main.java
com.settlers.hd.PlayerTrade.java
com.settlers.hd.Player.java
com.settlers.hd.Reference.java
com.settlers.hd.ResourceView.java
com.settlers.hd.Rules.java
com.settlers.hd.Settings.java
com.settlers.hd.Settlers.java
com.settlers.hd.Square.java
com.settlers.hd.Stats.java
com.settlers.hd.Status.java
com.settlers.hd.TextureManager.java
com.settlers.hd.Trader.java
com.settlers.hd.UIButton.java
com.settlers.hd.Vertex.java