Package app.media

Class Media

java.lang.Object
app.media.Media
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
FileMedia, GenericShape, MediaHyperlink, MediaText, PenStroke

public class Media extends Object implements Serializable
Core entity representing a piece of media which can be displayed on a page.

Media and its sub-classes all have the following properties:

  • `id`: A unique identifier. This may initially be the placeholder value given by `EMPTY_ID`, but once it has been set to a non-placeholder value it can no longer be changed.
  • `name`: The name of the Media. This does not have to be unique.
  • `tags`: A set of strings which further identify the media.
  • `x`: X-coordinate of a point within the media
  • `y`: Y-coordinate of a point within the media
  • `width`: Width of the media
  • `height`: Height of the media
  • `angle`: Angle of rotation of the media
  • `zIndex`: Z-index defines the "order" of Media. Media with a lower Z-index should be displayed "above" Media with a higher Z-index.
See Also:
  • Property Summary

    Properties
    Type
    Property
    Description
    final javafx.beans.property.DoubleProperty
     
    final javafx.beans.property.DoubleProperty
     
    final javafx.beans.property.StringProperty
     
    final javafx.beans.property.DoubleProperty
     
    final javafx.beans.property.DoubleProperty
     
    final javafx.beans.property.DoubleProperty
     
    final javafx.beans.property.IntegerProperty
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Media(long id, String name, double x, double y, double width, double height)
    Instantiate a new Media object given only ID, name, position and size.
    Media(long id, String name, Set<String> tags, double x, double y, double width, double height, double angle, int zIndex)
    Instantiate a new Media object given all fields.
    Media(String name, double x, double y, double width, double height)
    Instantiate a new Media object given only name, position and size.
    Media(String name, Set<String> tags, double x, double y, double width, double height, double angle, int zIndex)
    Instantiate a new Media object given all fields except ID.
  • Method Summary

    Modifier and Type
    Method
    Description
    final javafx.beans.property.DoubleProperty
     
    final double
    Gets the value of the property angle.
    final double
    Gets the value of the property height.
    final long
    Return the unique identifier for this Media.
    final String
    Gets the value of the property name.
    final javafx.collections.ObservableSet<String>
     
    final double
    Gets the value of the property width.
    final double
    Gets the value of the property x.
    final double
    Gets the value of the property y.
    final int
     
    final javafx.beans.property.DoubleProperty
     
    final boolean
    isWithin(double x, double y, double w, double h)
    Check if this media lies within the given rectangular region.
    final javafx.beans.property.StringProperty
     
    void
    setAngle(double angle)
    Sets the value of the property angle.
    void
    setHeight(double height)
    Sets the value of the property height.
    final void
    setID(long id)
    Set the unique identifier on this Media.
    void
    Sets the value of the property name.
    void
     
    void
    setWidth(double width)
    Sets the value of the property width.
    void
    setX(double x)
    Sets the value of the property x.
    void
    setY(double y)
    Sets the value of the property y.
    void
    setZindex(int zIndex)
     
     
    final javafx.beans.property.DoubleProperty
     
    final javafx.beans.property.DoubleProperty
     
    final javafx.beans.property.DoubleProperty
     
    final javafx.beans.property.IntegerProperty
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Property Details

    • name

      public final javafx.beans.property.StringProperty nameProperty
      See Also:
    • x

      public final javafx.beans.property.DoubleProperty xProperty
      See Also:
    • y

      public final javafx.beans.property.DoubleProperty yProperty
      See Also:
    • width

      public final javafx.beans.property.DoubleProperty widthProperty
      See Also:
    • height

      public final javafx.beans.property.DoubleProperty heightProperty
      See Also:
    • angle

      public final javafx.beans.property.DoubleProperty angleProperty
      See Also:
    • zIndex

      public final javafx.beans.property.IntegerProperty zIndexProperty
  • Field Details

    • EMPTY_ID

      public static final Long EMPTY_ID
  • Constructor Details

    • Media

      public Media(long id, String name, Set<String> tags, double x, double y, double width, double height, double angle, int zIndex)
      Instantiate a new Media object given all fields.
      Parameters:
      id - The unique identifier for this media
      name - The inital name for this media
      tags - The initial tags for this media
      x - The initial horizontal position for this media
      y - The initial vertical position for this media
      width - The initial width of this media
      height - The initial height of this media
      angle - The initial angle of rotation of this media
      zIndex - The initial Z-index of this media
    • Media

      public Media(String name, Set<String> tags, double x, double y, double width, double height, double angle, int zIndex)
      Instantiate a new Media object given all fields except ID.

      The Media's ID will be initialized to a placeholder value and can be set later.

      Parameters:
      name - The inital name for this media
      tags - The initial tags for this media
      x - The initial horizontal position for this media
      y - The initial vertical position for this media
      width - The initial width of this media
      height - The initial height of this media
      angle - The initial angle of rotation of this media
      zIndex - The initial Z-index of this media
    • Media

      public Media(long id, String name, double x, double y, double width, double height)
      Instantiate a new Media object given only ID, name, position and size.

      The tags will be initialized to the empty set while Z-index and angle will be initialized to 0.

      Parameters:
      id - The unique identifier for this media
      name - The inital name for this media
      x - The initial horizontal position for this media
      y - The initial vertical position for this media
      width - The initial width of this media
      height - The initial height of this media
    • Media

      public Media(String name, double x, double y, double width, double height)
      Instantiate a new Media object given only name, position and size.

      The tags will be initialized to the empty set while Z-index and angle will be initialized to 0. The ID will be initialized to the placeholder value.

      Parameters:
      name - The inital name for this media
      x - The initial horizontal position for this media
      y - The initial vertical position for this media
      width - The initial width of this media
      height - The initial height of this media
  • Method Details

    • getID

      public final long getID()
      Return the unique identifier for this Media.
    • setID

      public final void setID(long id) throws UnsupportedOperationException
      Set the unique identifier on this Media. Setting the ID is only a valid operation if the media has not yet been assigned an ID.
      Throws:
      UnsupportedOperationException - if the placeholder ID is assigned, or if an ID is assigned when the Media already has a non-placeholder ID.
    • nameProperty

      public final javafx.beans.property.StringProperty nameProperty()
      See Also:
    • getName

      public final String getName()
      Gets the value of the property name.
      Property description:
    • getTags

      public final javafx.collections.ObservableSet<String> getTags()
    • xProperty

      public final javafx.beans.property.DoubleProperty xProperty()
      See Also:
    • getX

      public final double getX()
      Gets the value of the property x.
      Property description:
    • yProperty

      public final javafx.beans.property.DoubleProperty yProperty()
      See Also:
    • getY

      public final double getY()
      Gets the value of the property y.
      Property description:
    • widthProperty

      public final javafx.beans.property.DoubleProperty widthProperty()
      See Also:
    • getWidth

      public final double getWidth()
      Gets the value of the property width.
      Property description:
    • heightProperty

      public final javafx.beans.property.DoubleProperty heightProperty()
      See Also:
    • getHeight

      public final double getHeight()
      Gets the value of the property height.
      Property description:
    • angleProperty

      public final javafx.beans.property.DoubleProperty angleProperty()
      See Also:
    • getAngle

      public final double getAngle()
      Gets the value of the property angle.
      Property description:
    • zIndexProperty

      public final javafx.beans.property.IntegerProperty zIndexProperty()
    • getZindex

      public final int getZindex()
    • setName

      public void setName(String name)
      Sets the value of the property name.
      Property description:
    • setTags

      public void setTags(Set<String> tags)
    • setX

      public void setX(double x)
      Sets the value of the property x.
      Property description:
    • setY

      public void setY(double y)
      Sets the value of the property y.
      Property description:
    • setWidth

      public void setWidth(double width)
      Sets the value of the property width.
      Property description:
    • setHeight

      public void setHeight(double height)
      Sets the value of the property height.
      Property description:
    • setAngle

      public void setAngle(double angle)
      Sets the value of the property angle.
      Property description:
    • setZindex

      public void setZindex(int zIndex)
    • isWithin

      public final boolean isWithin(double x, double y, double w, double h)
      Check if this media lies within the given rectangular region.
      Parameters:
      x - The X-coordinate of the top-left corner of the rectangular region.
      y - The Y-coordinate of the top-left corner of the rectangular region.
      w - The width of the rectangular region.
      h - The height of the rectangular region.
      Returns:
      Whether or not the Media object is within the rectangle with width `w`, height `h`, and top-left corner at (`x`, `y`).
    • toString

      public String toString()
      Overrides:
      toString in class Object