Skip to content

UIObject.java

Raphael Lutz edited this page Jul 10, 2018 · 2 revisions

Abstract class representing all kind of user interface objects.

Fields

  • float x,y : position of the UIObject on screen.
  • int width,height : dimensions of the UIObject.
  • Rectangle bounds : bounds of the UIObject. Can be different than dimensions.
  • boolean hovering = false : store if UIObject is hovered by mouse pointer.

Methods

  • UIObject(float x, float y, int width, int height) : constructor with position and dimensions.
  • abstract void tick() : method called by UIManager at each step of time (represents a "tick" of a clock)
  • abstract void render(Graphics g) : method for rendering the UIObject
  • abstract void onClick() : method called when object is clicked (interface ClickListener)
  • void onMouseMove(MouseEvent e) : updates hovering when mouse moves
  • void onMouseRelease(MouseEvent e) : calls onClick()
  • float getX() : getter for x
  • void setX(float x) : setter for x
  • float getY() : getter for y
  • void setY(float y) : setter for y
  • int getWidth() : getter for width
  • void setWidth(int width) : setter for width
  • int getHeight() : getter for height
  • void setHeight(int height) : setter for height
  • boolean isHovering() : getter for hovering
  • void setHovering(boolean hovering) : setter for hovering

Clone this wiki locally