Class Event
- java.lang.Object
-
- com.metsci.glimpse.core.plot.timeline.event.Event
-
- Direct Known Subclasses:
AggregateEvent
public class Event extends Object implements Iterable<Event>
Event represents an occurrence with a start and end time and is usually created by anEventPlotInfo
(which represents a row or column of aStackedTimePlot2D
. In addition to time bounds, Events can have text labels, icons, and tool tips associated with them. EventPlotInfo allows registering of listeners which report when the mouse interacts with an Event. Events can also be adjusted by the user by click and dragging on their bounds.- Author:
- ulman
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Event.OverlapRenderingMode
Indicates what types of overlaps should be considered when determining whether to shorten Event box text.static class
Event.TextRenderingMode
Indicates how text which is too large to fit in the Event box should be shortened.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConstraint(EventConstraint constraint)
Adds an EventConstraint which determines whether proposed changes to the min and max time bounds of an Event are allowed.boolean
contains(TimeStamp time)
Returns whether the provided Timestamp is inside the bounds of this Event.static Event
createDummyEvent(Event event)
static Event
createDummyEvent(TimeStamp time)
boolean
equals(Object obj)
float[]
getBackgroundColor()
float[]
getBorderColor()
float
getBorderThickness()
double
getDuration()
TimeStamp
getEndTime()
static Comparator<Event>
getEndTimeComparator()
int
getEventCount()
Gets the number of aggregated events that make up this event.EventPainter
getEventPainter()
EventPlotInfo
getEventPlotInfo()
Object
getIconId()
int
getIconSize()
Object
getId()
An Event's id may be any Object, but itsequals(Object)
andhashCode()
methods should be properly implemented and it should be unique among the Events of anEventPlotInfo
timeline.String
getLabel()
float[]
getLabelColor()
double
getMaxTimeSpan()
double
getMinTimeSpan()
Event.OverlapRenderingMode
getOverlapRenderingMode()
double
getOverlapTime(Event event)
int
getRow()
EventPlotInfo
plots on aStackedTimePlot2D
can place events into multiple rows to prevent them from overlapping with one another if they overlap in time.TimeStamp
getStartTime()
static Comparator<Event>
getStartTimeComparator()
Event.TextRenderingMode
getTextRenderingMode()
TimeSpan
getTimeSpan()
String
getToolTipText()
boolean
hasChildren()
Events can be aggregated when many Events are close together in time and the timeline view is zoomed out very far.int
hashCode()
boolean
isEditable()
boolean
isEndTimeMoveable()
boolean
isFixedRow()
Events may either be assigned a fixed row to be displayed on, or may float automatically between rows to ensure that no Events overlap in time.boolean
isResizeable()
boolean
isSelectable()
boolean
isShowBackground()
return if true, the event box is filled with the background color.boolean
isShowBorder()
boolean
isShowIcon()
return whether the icon associated with this event should be shown when room permits.boolean
isShowLabel()
return whether the label associated with this event should be shown when room permits.boolean
isStartTimeMoveable()
boolean
isUseDefaultBorderThickness()
boolean
isUseDefaultIconSize()
Iterator<Event>
iterator()
EventPlotInfo can automatically create synthetic groups of Events when the timeline is zoomed out far enough that a bunch of Events are crowded into the same space.void
paint(GlimpseContext context, EventPainter defaultPainter, Event nextEvent, EventPlotInfo info, int posMin, int posMax)
void
removeConstraint(EventConstraint constraint)
void
setBackgroundColor(float[] backgroundColor)
void
setBorderColor(float[] borderColor)
void
setBorderThickness(float thickness)
void
setEditable(boolean isEditable)
Sets whether or not the Event start and end times are modifiable by the user via mouse interaction.void
setEndTime(TimeStamp endTime)
void
setEndTimeMoveable(boolean isEndTimeMoveable)
If true, the endTime of the Event cannot be adjusted by user mouse gestures.void
setEventPainter(EventPainter painter)
Sets a custom painter for this event.void
setFixedRow(int rowIndex)
This event will appear on the requested row index in the timeline regardless of whether that causes it to overlap with other Events.void
setFloatingRow()
The row this Event appears on will be managed by itsEventPlotInfo
parent.void
setIconId(Object iconId)
Sets the icon displayed inside the Event box on the timeline.void
setIconSize(int iconSize)
Sets the height of the Event's icon (for horizontal timeline layouts) or the width (for vertical timeline layouts).void
setLabel(String name)
Sets the text displayed inside the Event box on the timeline.void
setLabelColor(float[] textColor)
void
setMaxTimeSpan(double maxTimeSpan)
Sets the maximum time span between the start and end times.void
setMinTimeSpan(double minTimeSpan)
Sets the minimum (inclusive) span between the start and end times.void
setOverlapMode(Event.OverlapRenderingMode mode)
Set what types of overlaps should be considered when determining whether to shorten Event box text and whether to display the Event's icon.void
setResizeable(boolean isResizeable)
If true, the time span of the Event (the amount of time between the start and end times) cannot be adjusted by user mouse gestures.void
setSelectable(boolean isSelectable)
Sets whether or not this Event can be selected via mouse clicks.void
setShowBackground(boolean showBorder)
void
setShowBorder(boolean showBorder)
void
setShowIcon(boolean showIcon)
void
setShowLabel(boolean showName)
void
setStartTime(TimeStamp startTime)
void
setStartTimeMoveable(boolean isStartTimeMoveable)
If true, the startTime of the Event cannot be adjusted by user mouse gestures.void
setTextRenderingMode(Event.TextRenderingMode mode)
Sets how text and icons should be handled when this Event's box is too small or when it overlaps with another Event's box.void
setTimes(GlimpseMouseEvent mouseEvent, TimeStamp startTime, TimeStamp endTime, boolean force)
void
setTimes(TimeStamp startTime, TimeStamp endTime)
void
setTimes(TimeStamp startTime, TimeStamp endTime, boolean force)
Sets the start and end time for this Event.void
setToolTipText(String text)
Sets the tooltip text to be displayed when the user mouses over this Event.void
setUseDefaultBorderThickness(boolean value)
void
setUseDefaultIconSize(boolean useDefaultSize)
If a specific icon size has not been set, the default icon size is used.String
toString()
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
paint
public void paint(GlimpseContext context, EventPainter defaultPainter, Event nextEvent, EventPlotInfo info, int posMin, int posMax)
- See Also:
EventPainter#paint(GL, Event, Event, EventPlotInfo, GlimpseBounds, Axis1D, int, int)
-
setIconSize
public void setIconSize(int iconSize)
Sets the height of the Event's icon (for horizontal timeline layouts) or the width (for vertical timeline layouts).- Parameters:
iconSize
- the icon size in pixels
-
getIconSize
public int getIconSize()
- Returns:
- the icon size in pixels
- See Also:
setIconSize(int)
-
setUseDefaultIconSize
public void setUseDefaultIconSize(boolean useDefaultSize)
If a specific icon size has not been set, the default icon size is used. The default size is the minimum of the actual size of the icon and the height of the event row.
-
isUseDefaultIconSize
public boolean isUseDefaultIconSize()
- See Also:
setUseDefaultIconSize(boolean)
-
hasChildren
public boolean hasChildren()
Events can be aggregated when many Events are close together in time and the timeline view is zoomed out very far. This method will return true for aggregate events.- Returns:
- true if the event is an aggregate event, false otherwise
-
getEventCount
public int getEventCount()
Gets the number of aggregated events that make up this event.
-
iterator
public Iterator<Event> iterator()
EventPlotInfo can automatically create synthetic groups of Events when the timeline is zoomed out far enough that a bunch of Events are crowded into the same space. The individual constituent Events can be accessed via this method. User created Events never have children.
-
setEventPainter
public void setEventPainter(EventPainter painter)
Sets a custom painter for this event. In addition to modifying the look of a single Event,EventPlotInfo#setEventPainter(EventPainter)
can be used to modify the default EventPainter used for all events in the EventPlotInfo. However, the EventPainter set here takes precedence.- Parameters:
painter
- the EventPainter to use to render this event on the timeline
-
getEventPainter
public EventPainter getEventPainter()
- See Also:
setEventPainter(EventPainter)
-
addConstraint
public void addConstraint(EventConstraint constraint)
Adds an EventConstraint which determines whether proposed changes to the min and max time bounds of an Event are allowed.
This method should be used for specialized constraints. Events support basic constraints by default via setEditable, setResizeable, setEndTimeMoveable, setStartTimeMoveable, setMinTimeSpan, and setMaxTimeSpan.
- Parameters:
constraint
- the EventConstraint to add
-
removeConstraint
public void removeConstraint(EventConstraint constraint)
- Parameters:
constraint
- the EventConstraint to remove- See Also:
addConstraint(EventConstraint)
-
setToolTipText
public void setToolTipText(String text)
Sets the tooltip text to be displayed when the user mouses over this Event.
-
getToolTipText
public String getToolTipText()
- See Also:
getToolTipText()
-
setSelectable
public void setSelectable(boolean isSelectable)
Sets whether or not this Event can be selected via mouse clicks. Setting selectable to false does not prevent the event from being selected programmatically viaEventPlotInfo#setSelectedEvents(java.util.Set)
.- Parameters:
isSelectable
-
-
isSelectable
public boolean isSelectable()
- See Also:
isSelectable()
-
setEditable
public void setEditable(boolean isEditable)
Sets whether or not the Event start and end times are modifiable by the user via mouse interaction. This does not prevent programmatically changing the mouse bounds. For finer control over what the user is allowed to do when modifying the start and end time of an Event (without disallowing it completely) seesetStartTimeMoveable(boolean)
,setResizeable(boolean)
, andsetMinTimeSpan(double)
.
-
isEditable
public boolean isEditable()
- Returns:
- See Also:
setEditable(boolean)
-
isEndTimeMoveable
public boolean isEndTimeMoveable()
- Returns:
- See Also:
setEndTimeMoveable(boolean)
-
setEndTimeMoveable
public void setEndTimeMoveable(boolean isEndTimeMoveable)
If true, the endTime of the Event cannot be adjusted by user mouse gestures.
-
isStartTimeMoveable
public boolean isStartTimeMoveable()
- Returns:
- See Also:
setStartTimeMoveable(boolean)
-
setStartTimeMoveable
public void setStartTimeMoveable(boolean isStartTimeMoveable)
If true, the startTime of the Event cannot be adjusted by user mouse gestures.
-
isResizeable
public boolean isResizeable()
- Returns:
-
setResizeable
public void setResizeable(boolean isResizeable)
If true, the time span of the Event (the amount of time between the start and end times) cannot be adjusted by user mouse gestures. However, the Event may still be dragged.
-
getMaxTimeSpan
public double getMaxTimeSpan()
- Returns:
-
setMaxTimeSpan
public void setMaxTimeSpan(double maxTimeSpan)
Sets the maximum time span between the start and end times. By default the maximum is Double.MAX_VALUE.
-
getMinTimeSpan
public double getMinTimeSpan()
- Returns:
-
setMinTimeSpan
public void setMinTimeSpan(double minTimeSpan)
Sets the minimum (inclusive) span between the start and end times. By default the minimum is 0.
-
getLabel
public String getLabel()
- Returns:
- the text displayed inside the Event box on the timeline.
-
setLabel
public void setLabel(String name)
Sets the text displayed inside the Event box on the timeline.- Parameters:
name
-
-
getIconId
public Object getIconId()
- Returns:
- the identifier for the icon displayed inside the Event box on the timeline.
- See Also:
setIconId(Object)
-
setIconId
public void setIconId(Object iconId)
Sets the icon displayed inside the Event box on the timeline. The iconId corresponds to an icon loaded into theTextureAtlas
associated with theEventPlotInfo
parent of this Event.- Parameters:
iconId
- the identifier for the icon displayed inside the Event box on the timeline.
-
setBorderThickness
public void setBorderThickness(float thickness)
- Parameters:
thickness
- the thickness (in pixels) of the border around the box for this Event on the timeline.
-
getBorderThickness
public float getBorderThickness()
- Returns:
- See Also:
setBorderThickness(float)
-
setUseDefaultBorderThickness
public void setUseDefaultBorderThickness(boolean value)
-
isUseDefaultBorderThickness
public boolean isUseDefaultBorderThickness()
-
getBackgroundColor
public float[] getBackgroundColor()
- Returns:
-
setBackgroundColor
public void setBackgroundColor(float[] backgroundColor)
- Parameters:
backgroundColor
- the fill color of the box for this Event on the timeline.
-
getBorderColor
public float[] getBorderColor()
- Returns:
-
setBorderColor
public void setBorderColor(float[] borderColor)
- Parameters:
borderColor
- the border color of the box for this Event on the timeline.
-
getLabelColor
public float[] getLabelColor()
- Returns:
- See Also:
setLabelColor(float[])
-
setLabelColor
public void setLabelColor(float[] textColor)
- Parameters:
textColor
- the color for the label text display for this Event on the timeline.
-
setTimes
public void setTimes(TimeStamp startTime, TimeStamp endTime, boolean force)
Sets the start and end time for this Event.
If force is false, then the constraints (see
addConstraint(EventConstraint)
) are taken into account and the final Event bounds might not be equal to the input arguments.- Parameters:
startTime
-endTime
-force
-
-
setTimes
public void setTimes(GlimpseMouseEvent mouseEvent, TimeStamp startTime, TimeStamp endTime, boolean force)
-
getRow
public int getRow()
EventPlotInfo
plots on aStackedTimePlot2D
can place events into multiple rows to prevent them from overlapping with one another if they overlap in time. This method allows querying for the row that this Event has been assigned.
-
isFixedRow
public boolean isFixedRow()
Events may either be assigned a fixed row to be displayed on, or may float automatically between rows to ensure that no Events overlap in time.- See Also:
getRow()
-
setFloatingRow
public void setFloatingRow()
The row this Event appears on will be managed by itsEventPlotInfo
parent. IfEventPlotInfo.setStackOverlappingEvents(boolean)
is set to true, then the row will be set to avoid overlaps with other events, otherwise the Event will be placed in the first row.
-
setFixedRow
public void setFixedRow(int rowIndex)
This event will appear on the requested row index in the timeline regardless of whether that causes it to overlap with other Events.
-
setTimes
public void setTimes(TimeStamp startTime, TimeStamp endTime)
- Parameters:
startTime
-endTime
-
-
getStartTime
public TimeStamp getStartTime()
- Returns:
- the start / earliest / left-edge TimeStamp for this Event.
-
setStartTime
public void setStartTime(TimeStamp startTime)
- Parameters:
startTime
-- See Also:
setTimes(TimeStamp, TimeStamp, boolean)
-
getEndTime
public TimeStamp getEndTime()
- Returns:
- the end / latest / right-edge TimeStamp for this Event.
-
setEndTime
public void setEndTime(TimeStamp endTime)
- Parameters:
startTime
-- See Also:
setTimes(TimeStamp, TimeStamp, boolean)
-
getTimeSpan
public TimeSpan getTimeSpan()
- Returns:
- the start and end times of the Event packaged in a TimeSpan
-
isShowLabel
public boolean isShowLabel()
return whether the label associated with this event should be shown when room permits.
-
setShowLabel
public void setShowLabel(boolean showName)
- Parameters:
showName
- whether to show the label text in this Event's box on the timeline.
-
setOverlapMode
public void setOverlapMode(Event.OverlapRenderingMode mode)
Set what types of overlaps should be considered when determining whether to shorten Event box text and whether to display the Event's icon.- Parameters:
mode
-
-
getOverlapRenderingMode
public Event.OverlapRenderingMode getOverlapRenderingMode()
- See Also:
setOverlapMode(OverlapRenderingMode)
-
setTextRenderingMode
public void setTextRenderingMode(Event.TextRenderingMode mode)
Sets how text and icons should be handled when this Event's box is too small or when it overlaps with another Event's box.- Parameters:
mode
-
-
getTextRenderingMode
public Event.TextRenderingMode getTextRenderingMode()
- See Also:
setTextRenderingMode(TextRenderingMode)
-
isShowIcon
public boolean isShowIcon()
return whether the icon associated with this event should be shown when room permits.
-
setShowIcon
public void setShowIcon(boolean showIcon)
- Parameters:
showIcon
- whether to show the icon associated with this event.
-
isShowBackground
public boolean isShowBackground()
return if true, the event box is filled with the background color. If false, the box is transparent.
-
setShowBackground
public void setShowBackground(boolean showBorder)
- Parameters:
showBorder
- whether to fill the event box with the background color.
-
isShowBorder
public boolean isShowBorder()
- Returns:
- if true, a line border is drawn around the event box.
-
setShowBorder
public void setShowBorder(boolean showBorder)
- Parameters:
showBorder
- whether to draw a line border around the event box.
-
getId
public Object getId()
An Event's id may be any Object, but its
equals(Object)
andhashCode()
methods should be properly implemented and it should be unique among the Events of anEventPlotInfo
timeline.EventPlotListener
will use this id when reporting events occurring on this Event.- Returns:
- the unique id for this Event.
-
getEventPlotInfo
public EventPlotInfo getEventPlotInfo()
- Returns:
- the timeline which this Event is attached to.
-
getOverlapTime
public double getOverlapTime(Event event)
- Returns:
- the amount of overlap between this event and the given event in system units (minutes)
-
getDuration
public double getDuration()
- Returns:
- the duration of the event (time between start and end TimeStamps) in system units (minutes)
-
contains
public boolean contains(TimeStamp time)
Returns whether the provided Timestamp is inside the bounds of this Event. The startTime is treated as inclusive and the endTime is treated as exclusive. This means that instantaneous events (with startTime equal to endTime) will always return false.
This method is equivalent to event.getStartTime().isBeforeOrEquals( time ) && event.getEndTime().isAfter( time )
- Parameters:
time
- the TimeStamp to test- Returns:
- whether the TimeStamp is inside this Event's time bounds
-
getStartTimeComparator
public static Comparator<Event> getStartTimeComparator()
-
getEndTimeComparator
public static Comparator<Event> getEndTimeComparator()
-
-