java.lang.Object
org.eclipse.tracecompass.tmf.ui.views.histogram.Histogram
All Implemented Interfaces:
EventListener, org.eclipse.swt.events.ControlListener, org.eclipse.swt.events.KeyListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.MouseMoveListener, org.eclipse.swt.events.MouseTrackListener, org.eclipse.swt.events.PaintListener, org.eclipse.swt.internal.SWTEventListener, IHistogramModelListener
Direct Known Subclasses:
FullTraceHistogram, TimeRangeHistogram

public abstract class Histogram extends Object implements org.eclipse.swt.events.ControlListener, org.eclipse.swt.events.PaintListener, org.eclipse.swt.events.KeyListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.MouseMoveListener, org.eclipse.swt.events.MouseTrackListener, IHistogramModelListener
Re-usable histogram widget. It has the following features:
  • Y-axis labels displaying min/max count values
  • X-axis labels displaying time range
  • a histogram displaying the distribution of values over time (note that the histogram might not necessarily fill the whole canvas)
The widget also has 1 'marker' to identify:
  • a blue dashed line over the bar that contains the currently selected event
Clicking on the histogram will select the current event at the mouse location.

Once the histogram is selected, there is some limited keyboard support:

  • Home: go to the first histogram bar
  • End: go to the last histogram bar
  • Left: go to the previous histogram
  • Right: go to the next histogram bar
Finally, when the mouse hovers over the histogram, a tool tip showing the following information about the corresponding histogram bar time range:
  • start of the time range
  • end of the time range
  • number of events in that time range
Version:
1.1
Author:
Francois Chouinard
  • Constructor Summary

    Constructors
    Constructor
    Description
    Histogram(TmfView view, org.eclipse.swt.widgets.Composite parent)
    Constructor.
    Histogram(TmfView view, org.eclipse.swt.widgets.Composite parent, boolean sendTimeAlignSignals)
    Full constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addKeyListener(org.eclipse.swt.events.KeyListener listener)
    Add a key listener to the histogram
    void
    addMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)
    Add a mouse wheel listener to the histogram
    void
    Clear the histogram and reset the data
    void
    controlMoved(org.eclipse.swt.events.ControlEvent event)
     
    void
    controlResized(org.eclipse.swt.events.ControlEvent event)
     
    void
    Dispose resources and unregisters listeners.
    Returns a data model reference.
    long
    Returns the end time.
    int
    Returns the maximum number of traces the histogram can display with separate colors.
    int
    getOffset(long timestamp)
    Computes the offset of the timestamp in the histogram
    int
    Get the offset of the point area, relative to the histogram canvas We consider the point area to be from where the first point could be drawn to where the last point could be drawn.
    int
    Get the width of the point area.
    long
    Returns the start time (equal first bucket time)
    long
    Returns the time limit (end of last bucket)
    long
    getTimestamp(int offset)
    Computes the timestamp of the bucket at [offset]
    org.eclipse.swt.graphics.Color
    getTraceColor(int traceIndex)
    Returns the color used to display the trace at the given index.
    void
    keyPressed(org.eclipse.swt.events.KeyEvent event)
     
    void
    keyReleased(org.eclipse.swt.events.KeyEvent event)
     
    void
    Refresh the histogram display
    void
    mouseDoubleClick(org.eclipse.swt.events.MouseEvent event)
     
    void
    mouseDown(org.eclipse.swt.events.MouseEvent event)
     
    void
    mouseEnter(org.eclipse.swt.events.MouseEvent event)
     
    void
    mouseExit(org.eclipse.swt.events.MouseEvent event)
     
    void
    mouseHover(org.eclipse.swt.events.MouseEvent event)
     
    void
    mouseMove(org.eclipse.swt.events.MouseEvent event)
     
    void
    mouseUp(org.eclipse.swt.events.MouseEvent event)
     
    void
    paintControl(org.eclipse.swt.events.PaintEvent event)
     
    void
    removeKeyListener(org.eclipse.swt.events.KeyListener listener)
    Remove a key listener from the histogram
    void
    removeMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)
    Remove a mouse wheel listener from the histogram
    void
    setSelection(long beginTime, long endTime)
    Sets the current selection time range and refresh the display
    void
    setStatusLineManager(org.eclipse.jface.action.IStatusLineManager statusLineManager)
    Assign the status line manager
    boolean
    Return true if the traces must be displayed in the histogram, false otherwise.
    void
    Format the timestamp and update the display
    void
    updateTimeRange(long startTime, long endTime)
    Updates the time range.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Histogram

      public Histogram(TmfView view, org.eclipse.swt.widgets.Composite parent)
      Constructor.
      Parameters:
      view - A reference to the parent TMF view.
      parent - A parent composite
    • Histogram

      public Histogram(TmfView view, org.eclipse.swt.widgets.Composite parent, boolean sendTimeAlignSignals)
      Full constructor.
      Parameters:
      view - A reference to the parent TMF view.
      parent - A parent composite
      sendTimeAlignSignals - Flag to send time alignment signals or not
      Since:
      1.0
  • Method Details

    • dispose

      public void dispose()
      Dispose resources and unregisters listeners.
    • setStatusLineManager

      public void setStatusLineManager(org.eclipse.jface.action.IStatusLineManager statusLineManager)
      Assign the status line manager
      Parameters:
      statusLineManager - The status line manager, or null to disable status line messages
      Since:
      4.0
    • getStartTime

      public long getStartTime()
      Returns the start time (equal first bucket time)
      Returns:
      the start time.
    • getEndTime

      public long getEndTime()
      Returns the end time.
      Returns:
      the end time.
    • getTimeLimit

      public long getTimeLimit()
      Returns the time limit (end of last bucket)
      Returns:
      the time limit.
    • getDataModel

      public HistogramDataModel getDataModel()
      Returns a data model reference.
      Returns:
      data model.
    • showTraces

      public boolean showTraces()
      Return true if the traces must be displayed in the histogram, false otherwise.
      Returns:
      whether the traces should be displayed
    • getMaxNbTraces

      public int getMaxNbTraces()
      Returns the maximum number of traces the histogram can display with separate colors. If there is more traces, histogram will use only one color to display them.
      Returns:
      the maximum number of traces the histogram can display.
    • getTraceColor

      public org.eclipse.swt.graphics.Color getTraceColor(int traceIndex)
      Returns the color used to display the trace at the given index.
      Parameters:
      traceIndex - a trace index
      Returns:
      a Color
    • updateTimeRange

      public void updateTimeRange(long startTime, long endTime)
      Updates the time range.
      Parameters:
      startTime - A start time
      endTime - A end time.
    • clear

      public void clear()
      Clear the histogram and reset the data
    • setSelection

      public void setSelection(long beginTime, long endTime)
      Sets the current selection time range and refresh the display
      Parameters:
      beginTime - The begin time of the current selection
      endTime - The end time of the current selection
    • getTimestamp

      public long getTimestamp(int offset)
      Computes the timestamp of the bucket at [offset]
      Parameters:
      offset - offset from the left on the histogram
      Returns:
      the start timestamp of the corresponding bucket
    • getOffset

      public int getOffset(long timestamp)
      Computes the offset of the timestamp in the histogram
      Parameters:
      timestamp - the timestamp
      Returns:
      the offset of the corresponding bucket (-1 if invalid)
    • modelUpdated

      public void modelUpdated()
      Refresh the histogram display
      Specified by:
      modelUpdated in interface IHistogramModelListener
    • addMouseWheelListener

      public void addMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)
      Add a mouse wheel listener to the histogram
      Parameters:
      listener - the mouse wheel listener
    • removeMouseWheelListener

      public void removeMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)
      Remove a mouse wheel listener from the histogram
      Parameters:
      listener - the mouse wheel listener
    • addKeyListener

      public void addKeyListener(org.eclipse.swt.events.KeyListener listener)
      Add a key listener to the histogram
      Parameters:
      listener - the key listener
    • removeKeyListener

      public void removeKeyListener(org.eclipse.swt.events.KeyListener listener)
      Remove a key listener from the histogram
      Parameters:
      listener - the key listener
    • paintControl

      public void paintControl(org.eclipse.swt.events.PaintEvent event)
      Specified by:
      paintControl in interface org.eclipse.swt.events.PaintListener
    • getPointAreaOffset

      public int getPointAreaOffset()
      Get the offset of the point area, relative to the histogram canvas We consider the point area to be from where the first point could be drawn to where the last point could be drawn.
      Returns:
      the offset in pixels
      Since:
      1.0
    • getPointAreaWidth

      public int getPointAreaWidth()
      Get the width of the point area. We consider the point area to be from where the first point could be drawn to where the last point could be drawn. The point area differs from the plot area because there might be a gap between where the plot area start and where the fist point is drawn. This also matches the width that the use can select.
      Returns:
      the width in pixels
      Since:
      1.0
    • keyPressed

      public void keyPressed(org.eclipse.swt.events.KeyEvent event)
      Specified by:
      keyPressed in interface org.eclipse.swt.events.KeyListener
    • keyReleased

      public void keyReleased(org.eclipse.swt.events.KeyEvent event)
      Specified by:
      keyReleased in interface org.eclipse.swt.events.KeyListener
    • mouseDoubleClick

      public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent event)
      Specified by:
      mouseDoubleClick in interface org.eclipse.swt.events.MouseListener
    • mouseDown

      public void mouseDown(org.eclipse.swt.events.MouseEvent event)
      Specified by:
      mouseDown in interface org.eclipse.swt.events.MouseListener
    • mouseUp

      public void mouseUp(org.eclipse.swt.events.MouseEvent event)
      Specified by:
      mouseUp in interface org.eclipse.swt.events.MouseListener
    • mouseMove

      public void mouseMove(org.eclipse.swt.events.MouseEvent event)
      Specified by:
      mouseMove in interface org.eclipse.swt.events.MouseMoveListener
    • mouseEnter

      public void mouseEnter(org.eclipse.swt.events.MouseEvent event)
      Specified by:
      mouseEnter in interface org.eclipse.swt.events.MouseTrackListener
    • mouseExit

      public void mouseExit(org.eclipse.swt.events.MouseEvent event)
      Specified by:
      mouseExit in interface org.eclipse.swt.events.MouseTrackListener
    • mouseHover

      public void mouseHover(org.eclipse.swt.events.MouseEvent event)
      Specified by:
      mouseHover in interface org.eclipse.swt.events.MouseTrackListener
    • controlMoved

      public void controlMoved(org.eclipse.swt.events.ControlEvent event)
      Specified by:
      controlMoved in interface org.eclipse.swt.events.ControlListener
    • controlResized

      public void controlResized(org.eclipse.swt.events.ControlEvent event)
      Specified by:
      controlResized in interface org.eclipse.swt.events.ControlListener
    • timestampFormatUpdated

      public void timestampFormatUpdated(TmfTimestampFormatUpdateSignal signal)
      Format the timestamp and update the display
      Parameters:
      signal - the incoming signal