Class Event

  • All Implemented Interfaces:
    Iterable<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 an EventPlotInfo (which represents a row or column of a StackedTimePlot2D. 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
    • 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.
      • 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.
        Specified by:
        iterator in interface Iterable<Event>
      • 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
      • 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
      • setToolTipText

        public void setToolTipText​(String text)
        Sets the tooltip text to be displayed when the user mouses over this Event.
      • 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 via EventPlotInfo#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) see setStartTimeMoveable(boolean), setResizeable(boolean), and setMinTimeSpan(double).
      • setEndTimeMoveable

        public void setEndTimeMoveable​(boolean isEndTimeMoveable)
        If true, the endTime of the Event cannot be adjusted by user mouse gestures.
      • setStartTimeMoveable

        public void setStartTimeMoveable​(boolean isStartTimeMoveable)
        If true, the startTime of the Event cannot be adjusted by user mouse gestures.
      • 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.
      • 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.
      • 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 the TextureAtlas associated with the EventPlotInfo 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.
      • setUseDefaultBorderThickness

        public void setUseDefaultBorderThickness​(boolean value)
      • isUseDefaultBorderThickness

        public boolean isUseDefaultBorderThickness()
      • setBackgroundColor

        public void setBackgroundColor​(float[] backgroundColor)
        Parameters:
        backgroundColor - the fill color of the box for this Event on the timeline.
      • setBorderColor

        public void setBorderColor​(float[] borderColor)
        Parameters:
        borderColor - the border color of the box for this Event on the timeline.
      • 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 -
      • getRow

        public int getRow()
        EventPlotInfo plots on a StackedTimePlot2D 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 its EventPlotInfo parent. If EventPlotInfo.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.
      • getStartTime

        public TimeStamp getStartTime()
        Returns:
        the start / earliest / left-edge TimeStamp for this Event.
      • getEndTime

        public TimeStamp getEndTime()
        Returns:
        the end / latest / right-edge TimeStamp for this Event.
      • 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 -
      • 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 -
      • 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) and hashCode() methods should be properly implemented and it should be unique among the Events of an EventPlotInfo 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
      • hashCode

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

        public static Event createDummyEvent​(Event event)
      • createDummyEvent

        public static Event createDummyEvent​(TimeStamp time)
      • getStartTimeComparator

        public static Comparator<Event> getStartTimeComparator()
      • getEndTimeComparator

        public static Comparator<Event> getEndTimeComparator()