Class ScreenPresence

java.lang.Object
org.oddjob.arooa.design.view.ScreenPresence
All Implemented Interfaces:
Serializable

public class ScreenPresence extends Object implements Serializable
Represent location and size information for a screen component.
Author:
rob
See Also:
  • Method Details

    • atLocation

      public static ScreenPresence.AtPoint atLocation(int x, int y)
    • ofSize

      public static ScreenPresence.OfSize ofSize(int width, int height)
    • resize

      public void resize(Component component)
      Fit a component to the location and size of this screen presence.
      Parameters:
      component - The componennt.
    • getLocation

      public Point getLocation()
      Get the location of this screen presence.
      Returns:
      The location. Never null.
    • getSize

      public Dimension getSize()
      Get the size of this screen presence.
      Returns:
      The size. Never null.
    • locationToCenter

      public Point locationToCenter(Dimension size)
      Return the location relative to this screen area that would centre something of the given size within this screen area. If the width of the component is wider than this screen presence it will be positioned at the left of this screen presences. If the height is greater than this screen presence it will be positioned at the top of this screen presence.
      Parameters:
      size - The size of the thing to position.
      Returns:
      The position of the thing to be centered relative to this screen presence.
    • resize

      public ScreenPresence resize(double factor)
      Create ScreenPresence a factor the size of this. The location will be adjusted so that it is offset equally in both x and y direction from this ScreenPresence.
      Parameters:
      factor - The factor to size the new ScreenPresence by.
      Returns:
      A new screen presence resized relative to this one.
    • isOnAnyScreen

      public boolean isOnAnyScreen()
      Is this screen presence currently on any screen currently attached. When working on a laptop that is moved between docking stations a screen presence that was visible may now not be.
      Returns:
      True if this screen presence top left location is on any screen.
    • of

      public static ScreenPresence of(Component component)
      Create a screen presence the size of the given component.
      Parameters:
      component - The component to create a screen presence from.
      Returns:
      A screen presence. Never null.
    • defaultSize

      public static ScreenPresence defaultSize(Dimension screenSize)
      Create a screen presence the default size within the give dimensions.
      Parameters:
      screenSize - The dimensions in which to fit the default screen presence.
      Returns:
      A screen presence fitting within the given screen size.
    • defaultSize

      public static ScreenPresence defaultSize()
      Provide a screen presence the default size for the current screen.
      Returns:
      A new screen presence. Never null.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object