Class Histogram
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)
- a blue dashed line over the bar that contains the currently selected event
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
- 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddKeyListener(org.eclipse.swt.events.KeyListener listener) Add a key listener to the histogramvoidaddMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener) Add a mouse wheel listener to the histogramvoidclear()Clear the histogram and reset the datavoidcontrolMoved(org.eclipse.swt.events.ControlEvent event) voidcontrolResized(org.eclipse.swt.events.ControlEvent event) voiddispose()Dispose resources and unregisters listeners.Returns a data model reference.longReturns the end time.intReturns the maximum number of traces the histogram can display with separate colors.intgetOffset(long timestamp) Computes the offset of the timestamp in the histogramintGet 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.intGet the width of the point area.longReturns the start time (equal first bucket time)longReturns the time limit (end of last bucket)longgetTimestamp(int offset) Computes the timestamp of the bucket at [offset]org.eclipse.swt.graphics.ColorgetTraceColor(int traceIndex) Returns the color used to display the trace at the given index.voidkeyPressed(org.eclipse.swt.events.KeyEvent event) voidkeyReleased(org.eclipse.swt.events.KeyEvent event) voidRefresh the histogram displayvoidmouseDoubleClick(org.eclipse.swt.events.MouseEvent event) voidmouseDown(org.eclipse.swt.events.MouseEvent event) voidmouseEnter(org.eclipse.swt.events.MouseEvent event) voidmouseExit(org.eclipse.swt.events.MouseEvent event) voidmouseHover(org.eclipse.swt.events.MouseEvent event) voidmouseMove(org.eclipse.swt.events.MouseEvent event) voidmouseUp(org.eclipse.swt.events.MouseEvent event) voidpaintControl(org.eclipse.swt.events.PaintEvent event) voidremoveKeyListener(org.eclipse.swt.events.KeyListener listener) Remove a key listener from the histogramvoidremoveMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener) Remove a mouse wheel listener from the histogramvoidsetSelection(long beginTime, long endTime) Sets the current selection time range and refresh the displayvoidsetStatusLineManager(org.eclipse.jface.action.IStatusLineManager statusLineManager) Assign the status line managerbooleanReturntrueif the traces must be displayed in the histogram,falseotherwise.voidFormat the timestamp and update the displayvoidupdateTimeRange(long startTime, long endTime) Updates the time range.
-
Constructor Details
-
Histogram
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 compositesendTimeAlignSignals- 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
Returns a data model reference.- Returns:
- data model.
-
showTraces
public boolean showTraces()Returntrueif the traces must be displayed in the histogram,falseotherwise.- 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 timeendTime- 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 selectionendTime- 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:
modelUpdatedin interfaceIHistogramModelListener
-
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:
paintControlin interfaceorg.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:
keyPressedin interfaceorg.eclipse.swt.events.KeyListener
-
keyReleased
public void keyReleased(org.eclipse.swt.events.KeyEvent event) - Specified by:
keyReleasedin interfaceorg.eclipse.swt.events.KeyListener
-
mouseDoubleClick
public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent event) - Specified by:
mouseDoubleClickin interfaceorg.eclipse.swt.events.MouseListener
-
mouseDown
public void mouseDown(org.eclipse.swt.events.MouseEvent event) - Specified by:
mouseDownin interfaceorg.eclipse.swt.events.MouseListener
-
mouseUp
public void mouseUp(org.eclipse.swt.events.MouseEvent event) - Specified by:
mouseUpin interfaceorg.eclipse.swt.events.MouseListener
-
mouseMove
public void mouseMove(org.eclipse.swt.events.MouseEvent event) - Specified by:
mouseMovein interfaceorg.eclipse.swt.events.MouseMoveListener
-
mouseEnter
public void mouseEnter(org.eclipse.swt.events.MouseEvent event) - Specified by:
mouseEnterin interfaceorg.eclipse.swt.events.MouseTrackListener
-
mouseExit
public void mouseExit(org.eclipse.swt.events.MouseEvent event) - Specified by:
mouseExitin interfaceorg.eclipse.swt.events.MouseTrackListener
-
mouseHover
public void mouseHover(org.eclipse.swt.events.MouseEvent event) - Specified by:
mouseHoverin interfaceorg.eclipse.swt.events.MouseTrackListener
-
controlMoved
public void controlMoved(org.eclipse.swt.events.ControlEvent event) - Specified by:
controlMovedin interfaceorg.eclipse.swt.events.ControlListener
-
controlResized
public void controlResized(org.eclipse.swt.events.ControlEvent event) - Specified by:
controlResizedin interfaceorg.eclipse.swt.events.ControlListener
-
timestampFormatUpdated
Format the timestamp and update the display- Parameters:
signal- the incoming signal
-