Class Widget

java.lang.Object
yearreview.app.grid.widgets.Widget
Direct Known Subclasses:
TestWidget, TestWidgetAnimation

public abstract class Widget extends Object
Abstract class that defines Methods that need to be implemented in every Widget.
Author:
ColdStone37
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Shape that is used to clip the graphic so only the local space can be rendered to.
    protected final float
    Height of the widget.
    protected final float
    Width of the widget.
    private float
    x-position of the widget.
    private float
    y-position of the widget.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Widget(float x, float y, float w, float h)
    Constructor for a GridSegment that initializes the position of the segment and the Shape for the Graphics2D.clip(java.awt.Shape)-function.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Converts the global space to the local space of the widget and sets the clip.
    protected abstract void
    Renders the widget in its local space (meaning that the coordinate system goes from (0, 0) to (w, h)).
    final void
    setPosition(float x, float y)
    Changes the position of the widget.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • x

      private float x
      x-position of the widget.
    • y

      private float y
      y-position of the widget.
    • w

      protected final float w
      Width of the widget.
    • h

      protected final float h
      Height of the widget.
    • clipShape

      private final RoundRectangle2D.Float clipShape
      Shape that is used to clip the graphic so only the local space can be rendered to.
  • Constructor Details

    • Widget

      public Widget(float x, float y, float w, float h)
      Constructor for a GridSegment that initializes the position of the segment and the Shape for the Graphics2D.clip(java.awt.Shape)-function.
      Parameters:
      x - x-position of the widget
      y - y-position of the widget
      w - width of the widget
      h - height of the widget
  • Method Details

    • setPosition

      public final void setPosition(float x, float y)
      Changes the position of the widget.
      Parameters:
      x - new x-position
      y - new y-position
    • renderGlobalSpace

      public final void renderGlobalSpace(Graphics2D graphic, Instant time)
      Converts the global space to the local space of the widget and sets the clip.
      Parameters:
      graphic - graphic to render to
      time - time at which to render the widget
    • renderLocalSpace

      protected abstract void renderLocalSpace(Graphics2D graphic, Instant time)
      Renders the widget in its local space (meaning that the coordinate system goes from (0, 0) to (w, h)).
      Parameters:
      graphic - graphic to render to
      time - time to render the widget at