1 /*******************************************************************************
2 * Copyright (c) 2009, 2010, 2012 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alvaro Sanchez-Leon - Initial API and implementation
11 * Patrick Tasse - Refactoring
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
;
18 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Messages
;
19 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeEvent
;
20 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeGraphEntry
;
21 import org
.eclipse
.swt
.graphics
.GC
;
22 import org
.eclipse
.swt
.graphics
.Image
;
23 import org
.eclipse
.swt
.graphics
.Rectangle
;
25 public abstract class TimeGraphPresentationProvider
implements ITimeGraphPresentationProvider
{
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
30 private static final int DEFAULT_ITEM_HEIGHT
= 19;
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
37 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getStateTypeName()
40 public String
getStateTypeName() {
41 return Messages
.TmfTimeLegend_TRACE_STATES
;
46 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphProvider#postDrawItems(org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)
49 public void postDrawControl(Rectangle bounds
, GC gc
) {
50 // Override to add own drawing code
55 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphProvider#postDrawItem(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry, org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)
58 public void postDrawEntry(ITimeGraphEntry entry
, Rectangle bounds
, GC gc
) {
59 // Override to add own drawing code
64 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphProvider#drawState(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent, org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)
67 public void postDrawEvent(ITimeEvent event
, Rectangle bounds
, GC gc
) {
68 // Override to add own drawing code
72 // * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphProvider#getEventColorTable()
75 // public RGB[] getEventColorTable() {
81 // * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventNameTable()
84 // public String[] getEventNameTable() {
90 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getStateItems()
93 public StateItem
[] getStateTable() {
99 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventTableIndex(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
102 public int getEventTableIndex(ITimeEvent event
) {
108 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getItemHeight(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)
111 public int getItemHeight(ITimeGraphEntry entry
) {
112 return DEFAULT_ITEM_HEIGHT
;
117 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphProvider#getTraceClassName(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)
120 public String
getTraceClassName(ITimeGraphEntry trace
) {
125 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphProvider#getEventName(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
128 public abstract String
getEventName(ITimeEvent event
);
132 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphProvider#composeTraceName(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry, boolean)
135 public String
composeTraceName(ITimeGraphEntry trace
, boolean inclState
) {
136 String name
= trace
.getName();
137 String threadClass
= getTraceClassName(trace
);
138 if (threadClass
!= null && threadClass
.length() > 0) {
139 name
+= " [" + threadClass
+ "]"; //$NON-NLS-1$ //$NON-NLS-2$
145 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphProvider#composeEventName(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
148 public String
composeEventName(ITimeEvent event
) {
149 String name
= event
.getEntry().getName();
150 String threadClass
= getTraceClassName(event
.getEntry());
151 if (threadClass
!= null && threadClass
.length() > 0) {
152 name
+= " [" + threadClass
+ "]"; //$NON-NLS-1$ //$NON-NLS-2$
154 name
+= " (" + getEventName(event
) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
159 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphProvider#getEventHoverToolTipInfo(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
162 public abstract Map
<String
, String
> getEventHoverToolTipInfo(ITimeEvent event
);
165 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphProvider#getItemImage(java.lang.Object)
168 public Image
getItemImage(Object obj
) {