Package app.media
Class Media
java.lang.Object
app.media.Media
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
FileMedia
,GenericShape
,MediaHyperlink
,MediaText
,PenStroke
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
TypePropertyDescriptionfinal 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
-
Constructor Summary
ConstructorDescriptionInstantiate 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.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 TypeMethodDescriptionfinal javafx.beans.property.DoubleProperty
final double
getAngle()
Gets the value of the property angle.final double
Gets the value of the property height.final long
getID()
Return the unique identifier for this Media.final String
getName()
Gets the value of the property name.final javafx.collections.ObservableSet<String>
getTags()
final double
getWidth()
Gets the value of the property width.final double
getX()
Gets the value of the property x.final double
getY()
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) toString()
final javafx.beans.property.DoubleProperty
final javafx.beans.property.DoubleProperty
final javafx.beans.property.DoubleProperty
final javafx.beans.property.IntegerProperty
-
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
-
-
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 medianame
- The inital name for this mediatags
- The initial tags for this mediax
- The initial horizontal position for this mediay
- The initial vertical position for this mediawidth
- The initial width of this mediaheight
- The initial height of this mediaangle
- The initial angle of rotation of this mediazIndex
- 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 mediatags
- The initial tags for this mediax
- The initial horizontal position for this mediay
- The initial vertical position for this mediawidth
- The initial width of this mediaheight
- The initial height of this mediaangle
- The initial angle of rotation of this mediazIndex
- The initial Z-index of this media
-
Media
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 medianame
- The inital name for this mediax
- The initial horizontal position for this mediay
- The initial vertical position for this mediawidth
- The initial width of this mediaheight
- The initial height of this media
-
Media
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 mediax
- The initial horizontal position for this mediay
- The initial vertical position for this mediawidth
- The initial width of this mediaheight
- The initial height of this media
-
-
Method Details
-
getID
public final long getID()Return the unique identifier for this Media. -
setID
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
Gets the value of the property name.- Property description:
-
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
Sets the value of the property name.- Property description:
-
setTags
-
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
-