/**********************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * Copyright (c) 2011, 2012 Ericsson.
- *
+ * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
- *
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ * Bernd Hufmann - Updated for TMF
**********************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.views.uml2sd;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessageReturn;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage;
* <p>
* The time compression bar implementation.
* </p>
- *
+ *
* @version 1.0
* @author sveyrier
- *
*/
public class TimeCompressionBar extends ScrollView implements DisposeListener {
*/
protected DrawableToolTip fTooltip = null;
/**
- * Array of colors for displaying wight of time deltas.
+ * Array of colors for displaying wight of time deltas.
*/
protected ColorImpl[] fColors;
/**
*/
protected int fFocusedWidget = -1;
/**
- * The sequence diagram view reference.
+ * The sequence diagram view reference.
*/
protected SDView view = null;
/**
*/
protected int fLifelineNumEvents = 0;
/**
- * The Current color of range to display.
+ * The Current color of range to display.
*/
protected IColor fLifelineColor = null;
/**
- * The next graph node y coordinate.
+ * The next graph node y coordinate.
*/
protected int fNextNodeY = 0;
/**
- * The previous graph node y coordinate.
+ * The previous graph node y coordinate.
*/
protected int fPrevNodeY = 0;
// ------------------------------------------------------------------------
/**
* Standard constructor
- *
+ *
* @param parent The parent composite
* @param s The style bits
*/
/**
* Sets the focus widget
- *
+ *
* @param newFocusShape widget reference to set
*/
void setFocus(int newFocusShape) {
/**
* Sets the current frame.
- *
+ *
* @param theFrame The frame to set
*/
public void setFrame(Frame theFrame) {
for (int i = firstVisible; i < fFrame.syncMessageCount(); i = i + messageArraysStep) {
SyncMessage m = fFrame.getSyncMessage(i);
if (m.hasTimeInfo()) {
- SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), (ITimeRange) m);
+ SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), m);
fNodeList.add(t);
if (m.getY() * fZoomValue > getContentsY() + getVisibleHeight()) {
break;
for (int i = firstVisible; i < fFrame.syncMessageReturnCount(); i = i + messageArraysStep) {
SyncMessage m = fFrame.getSyncMessageReturn(i);
if (m.hasTimeInfo()) {
- SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), (ITimeRange) m);
+ SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), m);
fNodeList.add(t);
if (m.getY() * fZoomValue > getContentsY() + getVisibleHeight()) {
break;
for (int i = firstVisible; i < fFrame.asyncMessageCount(); i = i + messageArraysStep) {
AsyncMessage m = fFrame.getAsyncMessage(i);
if (m.hasTimeInfo()) {
- SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getStartOccurrence(), (ITimeRange) m);
+ SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getStartOccurrence(), m);
fNodeList.add(t);
- t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), (ITimeRange) m);
+ t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), m);
fNodeList.add(t);
if (m.getY() * fZoomValue > getContentsY() + getVisibleHeight()) {
break;
for (int i = firstVisible; i < fFrame.asyncMessageReturnCount(); i = i + messageArraysStep) {
AsyncMessageReturn m = fFrame.getAsyncMessageReturn(i);
if (m.hasTimeInfo()) {
- SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getStartOccurrence(), (ITimeRange) m);
+ SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getStartOccurrence(), m);
fNodeList.add(t);
- t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), (ITimeRange) m);
+ t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), m);
fNodeList.add(t);
if (m.getY() * fZoomValue > getContentsY() + getVisibleHeight()) {
break;
try {
dbuffer = new Image(getDisplay(), getClientArea().width, getClientArea().height);
} catch (Exception e) {
- TmfUiPlugin.getDefault().logError("Error creating image", e); //$NON-NLS-1$
+ Activator.getDefault().logError("Error creating image", e); //$NON-NLS-1$
}
gcim = new GC(dbuffer);
for (int i = 0; i < fNodeList.size() - 1; i++) {
- SDTimeEvent m1 = (SDTimeEvent) fNodeList.get(i);
- SDTimeEvent m2 = (SDTimeEvent) fNodeList.get(i + 1);
+ SDTimeEvent m1 = fNodeList.get(i);
+ SDTimeEvent m2 = fNodeList.get(i + 1);
if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime()).getDelta(fMinTime);
long absDelta = Math.abs(delta.getValue());
-
+
ColorImpl color;
if (gr != 0) {
int colIndex = Math.round((float) (absDelta / gr));
try {
gc.drawImage(dbuffer, 0, 0, getClientArea().width, getClientArea().height, 0, 0, getClientArea().width, getClientArea().height);
} catch (Exception e) {
- TmfUiPlugin.getDefault().logError("Error drawing image", e); //$NON-NLS-1$
+ Activator.getDefault().logError("Error drawing image", e); //$NON-NLS-1$
}
gcim.dispose();
if (dbuffer != null) {
/**
* Checks for focus of children.
- *
- * @param children Control to check
+ *
+ * @param children
+ * Control to check
* @return true if child is on focus else false
*/
- protected boolean checkFocusOnChilds(Control childs) {
- if (childs instanceof Composite) {
- Control[] child = ((Composite) childs).getChildren();
+ protected boolean checkFocusOnChilds(Control children) {
+ if (children instanceof Composite) {
+ Control[] child = ((Composite) children).getChildren();
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
- } else {
- checkFocusOnChilds(child[i]);
}
+ checkFocusOnChilds(child[i]);
}
}
return false;
for (int i = 0; i < child.length; i++) {
if (child[i].isFocusControl()) {
return true;
- } else {
- checkFocusOnChilds(child[i]);
}
+ checkFocusOnChilds(child[i]);
}
return false;
}
if (fFrame != null) {
setFocus(0);
for (int i = 0; i < fNodeList.size() - 1; i++) {
- SDTimeEvent m1 = (SDTimeEvent) fNodeList.get(i);
- SDTimeEvent m2 = (SDTimeEvent) fNodeList.get(i + 1);
+ SDTimeEvent m1 = fNodeList.get(i);
+ SDTimeEvent m2 = fNodeList.get(i + 1);
if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
*/
@Override
protected void contentsMouseExit(MouseEvent e) {
- if (fTooltip != null)
+ if (fTooltip != null) {
fTooltip.hideToolTip();
+ }
}
/*
}
/**
- * Force the time compression bar to highlight the event occurrences between the two given messages. The event
- * occurrences are highlighted on the first message's end lifeline
- *
- * @param mes1 the first message
- * @param localMes2 the second message
+ * Force the time compression bar to highlight the event occurrences between
+ * the two given messages. The event occurrences are highlighted on the
+ * first message's end lifeline
+ *
+ * @param mes1
+ * the first message
+ * @param mes2
+ * the second message
*/
public void highlightRegion(BaseMessage mes1, BaseMessage mes2) {
- BaseMessage localMes1 = mes1;
+ BaseMessage localMes1 = mes1;
BaseMessage localMes2 = mes2;
-
+
if (fFrame == null) {
return;
}
colIndex = 0;
}
for (int j = 0; j < fListenerList.size(); j++) {
- ITimeCompressionListener list = (ITimeCompressionListener) fListenerList.get(j);
+ ITimeCompressionListener list = fListenerList.get(j);
if (localMes1.getEndLifeline() != null) {
list.deltaSelected(localMes1.getEndLifeline(), event1, event2 - event1, fColors[colIndex]);
} else if (localMes2.getStartLifeline() != null) {
/**
* Force the time compression bar to highlight the event occurrences between the two given messages. The event
* occurrences are highlighted on the first message's end lifeline
- *
+ *
* @param mes1 the first message
* @param mes2 the second message
*/
/**
* Sets the zoom value.
- *
+ *
* @param value The zoom value to set.
*/
public void setZoom(float value) {
/**
* Adds a listener to the time compression listener list to be notified about selected deltas.
- *
+ *
* @param listener The listener to add
*/
public void addTimeCompressionListener(ITimeCompressionListener listener) {
/**
* Removes a time compression listener.
- *
+ *
* @param listener The listener to remove.
*/
public void removeSelectionChangedListener(ITimeCompressionListener listener) {
}
if ((fFrame != null) && (fNextNodeY == 0)) {
for (int i = 0; i < fNodeList.size() - 1 && i < 1; i++) {
- SDTimeEvent m1 = (SDTimeEvent) fNodeList.get(i);
- SDTimeEvent m2 = (SDTimeEvent) fNodeList.get(i + 1);
+ SDTimeEvent m1 = fNodeList.get(i);
+ SDTimeEvent m2 = fNodeList.get(i + 1);
if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
if (fLifeline != null) {
for (int j = 0; j < fListenerList.size(); j++) {
- ITimeCompressionListener list = (ITimeCompressionListener) fListenerList.get(j);
+ ITimeCompressionListener list = fListenerList.get(j);
list.deltaSelected(fLifeline, fLifelineStart, fLifelineNumEvents, fLifelineColor);
}
}
/**
* Selects the time delta for given delta y coordinate and direction.
- *
- * @param dy The delta in y coordinate.
+ *
+ * @param dy The delta in y coordinate.
* @param direction 0 no direction, 1 = down, 2 = up
*/
protected void selectTimeDelta(int dy, int direction) {
boolean done = false;
if (fFrame != null) {
for (int i = 0; i < fNodeList.size() - 1; i++) {
- SDTimeEvent m1 = (SDTimeEvent) fNodeList.get(i);
- SDTimeEvent m2 = (SDTimeEvent) fNodeList.get(i + 1);
+ SDTimeEvent m1 = fNodeList.get(i);
+ SDTimeEvent m2 = fNodeList.get(i + 1);
if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
}
}
for (int j = 0; j < fListenerList.size(); j++) {
- ITimeCompressionListener list = (ITimeCompressionListener) fListenerList.get(j);
+ ITimeCompressionListener list = fListenerList.get(j);
list.deltaSelected(fLifeline, fLifelineStart, fLifelineNumEvents, fLifelineColor);
}
break;
- } else {
- lastM1 = m1;
- lastM2 = m2;
- lastY1 = m1Y;
- lastY2 = m2Y;
}
+ lastM1 = m1;
+ lastM2 = m2;
+ lastY1 = m1Y;
+ lastY2 = m2Y;
}
}
}
/**
- * Creates a fake tool tip.
+ * Creates a fake tool tip.
*/
protected void createFakeTooltip() {
if (fTooltip == null) {
if (fFrame != null) {
setFocus(0);
for (int i = 0; i < fNodeList.size() - 1; i++) {
- SDTimeEvent m1 = (SDTimeEvent) fNodeList.get(i);
- SDTimeEvent m2 = (SDTimeEvent) fNodeList.get(i + 1);
+ SDTimeEvent m1 = fNodeList.get(i);
+ SDTimeEvent m2 = fNodeList.get(i + 1);
if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) {
BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
}
}
}
-
+
/**
* Traverse Listener implementation.
*/