*/
public abstract class BaseMessage extends GraphNode {
+ private static final int ARROW_LENGTH = 7;
+ private static final double ARROW_ANGLE = 0.75;
+ private static final Double ARROW_HEAD_Y = Double.valueOf(Math.sin(ARROW_ANGLE) * ARROW_LENGTH);
+ private static final Double ARROW_HEAD_X = Double.valueOf(Math.cos(ARROW_ANGLE) * ARROW_LENGTH);
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
// Draw the message main line
context.drawLine(x, y, x + width, y + height);
// Draw the two little lines which make a arrow part of the message
- Double xt = Double.valueOf(Math.cos(0.75) * 7);
- Double yt = Double.valueOf(Math.sin(0.75) * 7);
+ Double xt = ARROW_HEAD_X;
+ Double yt = ARROW_HEAD_Y;
if (context.getLineStyle() == context.getLineSolidStyle()) {
IColor backcolor = context.getBackground();
context.setBackground(context.getForeground());
// Part 5
context.drawLine(x, y + height + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT, x + Metrics.INTERNAL_MESSAGE_WIDTH / 2, y + height + Metrics.SYNC_INTERNAL_MESSAGE_HEIGHT);
- Double xt = Double.valueOf(Math.cos(0.75) * 7);
- Double yt = Double.valueOf(Math.sin(0.75) * 7);
+ Double xt = ARROW_HEAD_X;
+ Double yt = ARROW_HEAD_Y;
fX = x;
fY = y;
if (spaceBTWStartEnd < 0) {
sign = -1;
}
- Double x1 = Double.valueOf(sign * Math.cos(angle - 0.75) * 7);
- Double y1 = Double.valueOf(sign * Math.sin(angle - 0.75) * 7);
- Double x2 = Double.valueOf(sign * Math.cos(angle + 0.75) * 7);
- Double y2 = Double.valueOf(sign * Math.sin(angle + 0.75) * 7);
+ Double x1 = Double.valueOf(sign * Math.cos(angle - ARROW_ANGLE) * ARROW_LENGTH);
+ Double y1 = Double.valueOf(sign * Math.sin(angle - ARROW_ANGLE) * ARROW_LENGTH);
+ Double x2 = Double.valueOf(sign * Math.cos(angle + ARROW_ANGLE) * ARROW_LENGTH);
+ Double y2 = Double.valueOf(sign * Math.sin(angle + ARROW_ANGLE) * ARROW_LENGTH);
fX = getX();
fY = y + height - y2.intValue();
*/
private class LocalSD extends SDWidget {
+ private final RGB FOCUS_COLOR = new RGB(0, 0, 128);
+ private final RGB NON_FOCUS_COLOR = new RGB(221, 208, 200);
+
/**
* Constructor
* @param c Parent composite
Image toDel = over;
if (fOverviewCanvas.isFocusControl()) {
over = new Image(super.getShell().getDisplay(), drawRegionSelected(toDel, new Rectangle(contentsToViewX((int) (row * stepX * fOverviewCanvas.getZoomValue())), contentsToViewY((int) (line * stepY * fOverviewCanvas.getZoomValue())),
- ((int) (stepX * fOverviewCanvas.getZoomValue())), ((int) (stepY * fOverviewCanvas.getZoomValue()))), new RGB(0, 0, 128)));
+ ((int) (stepX * fOverviewCanvas.getZoomValue())), ((int) (stepY * fOverviewCanvas.getZoomValue()))), FOCUS_COLOR));
} else {
over = new Image(super.getShell().getDisplay(), drawRegionSelected(toDel, new Rectangle(contentsToViewX((int) (row * stepX * fOverviewCanvas.getZoomValue())), contentsToViewY((int) (line * stepY * fOverviewCanvas.getZoomValue())),
- ((int) (stepX * fOverviewCanvas.getZoomValue())), ((int) (stepY * fOverviewCanvas.getZoomValue()))), new RGB(221, 208, 200)));
+ ((int) (stepX * fOverviewCanvas.getZoomValue())), ((int) (stepY * fOverviewCanvas.getZoomValue()))), NON_FOCUS_COLOR));
}
toDel.dispose();
}
Image toDel = over;
over = new Image(super.getShell().getDisplay(), drawRegionSelected(toDel, new Rectangle(contentsToViewX((int) (row * stepX * fOverviewCanvas.getZoomValue())), contentsToViewY((int) (line * stepY * fOverviewCanvas.getZoomValue())),
- ((int) (stepX * fOverviewCanvas.getZoomValue())), ((int) (stepY * fOverviewCanvas.getZoomValue()))), new RGB(221, 208, 200)));
+ ((int) (stepX * fOverviewCanvas.getZoomValue())), ((int) (stepY * fOverviewCanvas.getZoomValue()))), NON_FOCUS_COLOR));
toDel.dispose();
}
if (!isEnabled()) {
Image toDel = d;
- d = new Image(super.getShell().getDisplay(), drawRegionSelected(d, new Rectangle(0, 0, lw, lh), new RGB(221, 208, 200)));
+ d = new Image(super.getShell().getDisplay(), drawRegionSelected(d, new Rectangle(0, 0, lw, lh), NON_FOCUS_COLOR));
toDel.dispose();
}
package org.eclipse.tracecompass.tmf.ui.views.uml2sd.drawings.impl;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.eclipse.tracecompass.tmf.ui.views.uml2sd.drawings.IColor;
fColor = new Color(display, r, g, b);
}
+ /**
+ * Constructor
+ *
+ * @param display The display to use
+ * @param color the RGB color
+ */
+ public ColorImpl(Display display, RGB color) {
+ fColor = new Color(display, color.red, color.green, color.blue);
+ }
+
/**
* Copy constructor
*
import org.eclipse.tracecompass.tmf.ui.views.uml2sd.util.Messages;
/**
- * This is the Sequence Diagram preference handler. This class is responsible for accessing the current user preferences
- * selection This class also provider getters for each modifiable preferences.
+ * This is the Sequence Diagram preference handler. This class is responsible
+ * for accessing the current user preferences selection This class also provider
+ * getters for each modifiable preferences.
*
* @version 1.0
* @author sveyrier
*/
public class SDViewPref implements ISDPreferences, IPropertyChangeListener {
+ private static final RGB DEFAULT_TIME_COMP_RGB = new RGB(218, 232, 238);
+ private static final RGB DEFAULT_RGB = new RGB(134, 176, 212);
+ private static final RGB DEFAULT_LIFELINE_HEADER_RGB = new RGB(129, 127, 137);
+ private static final RGB DEFAULT_FRAME_RGB = new RGB(0, 0, 0);
+ private static final RGB DEFAULT_LIFELINE_RGB = new RGB(129, 129, 129);
+ private static final RGB FOREGROUND_LIFELINE_RGB = new RGB(129, 129, 129);
+ private static final RGB FOREGROUND_FRAME_RGB = new RGB(81, 153, 200);
+ private static final RGB FOREGROUND_LIFELINE_HEADER_RGB = new RGB(129, 127, 137);
+ private static final RGB FOREGROUND_RGB = new RGB(134, 176, 212);
+ private static final RGB BACKGROUND_DEFAULT_RGB = new RGB(255, 255, 255);
+ private static final RGB BACKGROUND_LIFELINE_HEADER_RGB = new RGB(245, 244, 244);
+ private static final RGB BACKGROUND_LIFELINE_RGB = new RGB(220, 220, 220);
+ private static final RGB BACKGROUND_FRAME_RGB = new RGB(201, 222, 233);
// ------------------------------------------------------------------------
// Constants
// ------------------------------------------------------------------------
/**
* A 2nd array of preference names
*/
- private static final String[] FONT_LIST2 = { Messages.SequenceDiagram_Lifeline, Messages.SequenceDiagram_ExecutionOccurrence, Messages.SequenceDiagram_SyncMessage, Messages.SequenceDiagram_SyncMessageReturn, Messages.SequenceDiagram_AsyncMessage, Messages.SequenceDiagram_AsyncMessageReturn, Messages.SequenceDiagram_Frame, Messages.SequenceDiagram_LifelineHeader, Messages.SequenceDiagram_FrameTitle };
+ private static final String[] FONT_LIST2 = { Messages.SequenceDiagram_Lifeline, Messages.SequenceDiagram_ExecutionOccurrence, Messages.SequenceDiagram_SyncMessage, Messages.SequenceDiagram_SyncMessageReturn,
+ Messages.SequenceDiagram_AsyncMessage, Messages.SequenceDiagram_AsyncMessageReturn, Messages.SequenceDiagram_Frame, Messages.SequenceDiagram_LifelineHeader, Messages.SequenceDiagram_FrameTitle };
/**
* Array of background color preference names
*/
private static final String[] PREF_TEXT_COLOR_LIST = { PREF_LIFELINE, PREF_SYNC_MESS, PREF_SYNC_MESS_RET, PREF_ASYNC_MESS, PREF_ASYNC_MESS_RET, PREF_LIFELINE_HEADER, PREF_FRAME_NAME };
/**
* Temporary tag
+ *
* @since 2.0
*/
public static final String TEMP_TAG = "_TEMP";//$NON-NLS-1$
// ------------------------------------------------------------------------
/**
- * Builds the Sequence Diagram preference handler: - Define the preference default values. - Load the currently used
- * preferences setting
+ * Builds the Sequence Diagram preference handler: - Define the preference
+ * default values. - Load the currently used preferences setting
*/
protected SDViewPref() {
fPrefStore = Activator.getDefault().getPreferenceStore();
for (int i = 0; i < PREF_BACK_COLOR_LIST.length; i++) {
IColor color;
if ((PREF_BACK_COLOR_LIST[i].equals(PREF_EXEC)) || PREF_BACK_COLOR_LIST[i].equals(PREF_FRAME_NAME)) {
- color = new ColorImpl(Display.getDefault(), 201, 222, 233);
+ color = new ColorImpl(Display.getDefault(), BACKGROUND_FRAME_RGB);
} else if (PREF_BACK_COLOR_LIST[i].equals(PREF_LIFELINE)) {
- color = new ColorImpl(Display.getDefault(), 220, 220, 220);
+ color = new ColorImpl(Display.getDefault(), BACKGROUND_LIFELINE_RGB);
} else if (PREF_BACK_COLOR_LIST[i].equals(PREF_LIFELINE_HEADER)) {
- color = new ColorImpl(Display.getDefault(), 245, 244, 244);
+ color = new ColorImpl(Display.getDefault(), BACKGROUND_LIFELINE_HEADER_RGB);
} else {
- color = new ColorImpl(Display.getDefault(), 255, 255, 255);
+ color = new ColorImpl(Display.getDefault(), BACKGROUND_DEFAULT_RGB);
}
PreferenceConverter.setDefault(fPrefStore, PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX, ((Color) color.getColor()).getRGB());
PreferenceConverter.setDefault(fPrefStore, PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX + TEMP_TAG, ((Color) color.getColor()).getRGB());
for (int i = 0; i < PREF_FORE_COLOR_LIST.length; i++) {
IColor color;
if (PREF_FORE_COLOR_LIST[i].equals(PREF_LIFELINE)) {
- color = new ColorImpl(Display.getDefault(), 129, 129, 129);
+ color = new ColorImpl(Display.getDefault(), FOREGROUND_LIFELINE_RGB);
} else if (PREF_FORE_COLOR_LIST[i].equals(PREF_FRAME_NAME)) {
- color = new ColorImpl(Display.getDefault(), 81, 153, 200);
+ color = new ColorImpl(Display.getDefault(), FOREGROUND_FRAME_RGB);
} else if (PREF_FORE_COLOR_LIST[i].equals(PREF_LIFELINE_HEADER)) {
- color = new ColorImpl(Display.getDefault(), 129, 127, 137);
+ color = new ColorImpl(Display.getDefault(), FOREGROUND_LIFELINE_HEADER_RGB);
} else {
- color = new ColorImpl(Display.getDefault(), 134, 176, 212);
+ color = new ColorImpl(Display.getDefault(), FOREGROUND_RGB);
}
PreferenceConverter.setDefault(fPrefStore, PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX, ((Color) color.getColor()).getRGB());
PreferenceConverter.setDefault(fPrefStore, PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX + TEMP_TAG, ((Color) color.getColor()).getRGB());
for (int i = 0; i < PREF_TEXT_COLOR_LIST.length; i++) {
IColor color;
if (PREF_TEXT_COLOR_LIST[i].equals(PREF_LIFELINE)) {
- color = new ColorImpl(Display.getDefault(), 129, 129, 129);
+ color = new ColorImpl(Display.getDefault(), DEFAULT_LIFELINE_RGB);
} else if (PREF_TEXT_COLOR_LIST[i].equals(PREF_FRAME_NAME)) {
- color = new ColorImpl(Display.getDefault(), 0, 0, 0);
+ color = new ColorImpl(Display.getDefault(), DEFAULT_FRAME_RGB);
} else if (PREF_TEXT_COLOR_LIST[i].equals(PREF_LIFELINE_HEADER)) {
- color = new ColorImpl(Display.getDefault(), 129, 127, 137);
+ color = new ColorImpl(Display.getDefault(), DEFAULT_LIFELINE_HEADER_RGB);
} else {
- color = new ColorImpl(Display.getDefault(), 134, 176, 212);
+ color = new ColorImpl(Display.getDefault(), DEFAULT_RGB);
}
PreferenceConverter.setDefault(fPrefStore, PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX, ((Color) color.getColor()).getRGB());
PreferenceConverter.setDefault(fPrefStore, PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX + TEMP_TAG, ((Color) color.getColor()).getRGB());
color.dispose();
}
- IColor color = new ColorImpl(Display.getDefault(), 218, 232, 238);
+ IColor color = new ColorImpl(Display.getDefault(), DEFAULT_TIME_COMP_RGB);
PreferenceConverter.setDefault(fPrefStore, PREF_TIME_COMP, ((Color) color.getColor()).getRGB());
color.dispose();
}
/**
- * Return true if the user do not want to take external time (basically found and lost messages with time) into
- * account in the min max computation
+ * Return true if the user do not want to take external time (basically
+ * found and lost messages with time) into account in the min max
+ * computation
*
* @return true if checked false otherwise
*/
}
/**
- * Builds the new colors and fonts according the current user selection when the OK or Apply button is clicked
+ * Builds the new colors and fonts according the current user selection when
+ * the OK or Apply button is clicked
*/
private void buildFontsAndColors() {
public class TimeGraphScale extends TimeGraphBaseControl implements
MouseListener, MouseMoveListener {
+ private static final int BASE_10 = 10;
+ private static final int X_OFFSET = 4;
+ private static final int Y_OFFSET = 4;
+
+ private static final int MIN_SECOND_FACTOR = 20;
+ private static final int SECOND_FACTOR = 30;
+ private static final int MAX_SECOND_FACTOR = 30;
+
+ private static final int MIN_MINUTE_FACTOR = 10;
+ private static final int MINUTE_FACTOR = 15;
+ private static final int MAX_MINUTE_FACTOR = 30;
+
+ private static final int MIN_HOUR_FACTOR = 3;
+ private static final int HOUR_FACTOR = 6;
+ private static final int MAX_HOUR_FACTOR = 12;
+
+ private static final int MAX_DAY_FACTOR = 10;
+
+ private static final int MAX_MONTH_FACTOR = 6;
+ private static final int MONTH_FACTOR = 6;
+ private static final int MIN_MONTH_FACTOR = 3;
+
private static final long MICROSEC_IN_NS = 1000;
private static final long MILLISEC_IN_NS = 1000000;
private static final long SEC_IN_NS = 1000000000;
double minDelta = (pixelsPerNanoSec == 0) ? YEAR_IN_NS : width / pixelsPerNanoSec;
long unit = 1;
if (fTimeProvider != null && fTimeProvider.getTimeFormat() == TimeFormat.CALENDAR) {
- if (minDelta > 6 * MONTH_IN_NS) {
+ if (minDelta > MAX_MONTH_FACTOR * MONTH_IN_NS) {
unit = YEAR_IN_NS;
- } else if (minDelta > 3 * MONTH_IN_NS) {
- unit = 6 * MONTH_IN_NS;
- } else if (minDelta > 10 * DAY_IN_NS) {
+ } else if (minDelta > MIN_MONTH_FACTOR * MONTH_IN_NS) {
+ unit = MONTH_FACTOR * MONTH_IN_NS;
+ } else if (minDelta > MAX_DAY_FACTOR * DAY_IN_NS) {
unit = MONTH_IN_NS;
- } else if (minDelta > 12 * HOUR_IN_NS) {
+ } else if (minDelta > MAX_HOUR_FACTOR * HOUR_IN_NS) {
unit = DAY_IN_NS;
- } else if (minDelta > 3 * HOUR_IN_NS) {
- unit = 6 * HOUR_IN_NS;
- } else if (minDelta > 30 * MIN_IN_NS) {
+ } else if (minDelta > MIN_HOUR_FACTOR * HOUR_IN_NS) {
+ unit = HOUR_FACTOR * HOUR_IN_NS;
+ } else if (minDelta > MAX_MINUTE_FACTOR * MIN_IN_NS) {
unit = HOUR_IN_NS;
- } else if (minDelta > 10 * MIN_IN_NS) {
- unit = 15 * MIN_IN_NS;
- } else if (minDelta > 30 * SEC_IN_NS) {
+ } else if (minDelta > MIN_MINUTE_FACTOR * MIN_IN_NS) {
+ unit = MINUTE_FACTOR * MIN_IN_NS;
+ } else if (minDelta > MAX_SECOND_FACTOR * SEC_IN_NS) {
unit = MIN_IN_NS;
- } else if (minDelta > 20 * SEC_IN_NS) {
- unit = 30 * SEC_IN_NS;
+ } else if (minDelta > MIN_SECOND_FACTOR * SEC_IN_NS) {
+ unit = SECOND_FACTOR * SEC_IN_NS;
} else if (minDelta <= 1) {
timeDelta = 1;
return timeDelta;
long pow10 = (long) log;
double remainder = log - pow10;
if (remainder < LOG10_1) {
- timeDelta = (long) Math.pow(10, pow10) * unit;
+ timeDelta = (long) Math.pow(BASE_10, pow10) * unit;
} else if (remainder < LOG10_2) {
- timeDelta = 2 * (long) Math.pow(10, pow10) * unit;
+ timeDelta = 2 * (long) Math.pow(BASE_10, pow10) * unit;
} else if (remainder < LOG10_3 && unit >= HOUR_IN_NS && unit < YEAR_IN_NS) {
- timeDelta = 3 * (long) Math.pow(10, pow10) * unit;
+ timeDelta = 3 * (long) Math.pow(BASE_10, pow10) * unit;
} else if (remainder < LOG10_5) {
- timeDelta = 5 * (long) Math.pow(10, pow10) * unit;
+ timeDelta = 5 * (long) Math.pow(BASE_10, pow10) * unit;
} else {
- timeDelta = 10 * (long) Math.pow(10, pow10) * unit;
+ timeDelta = 10 * (long) Math.pow(BASE_10, pow10) * unit;
}
if (timeDelta <= 0) {
timeDelta = 1;
// draw top left area
rect0.width = leftSpace;
- rect0.x += 4;
- rect0.width -= 4;
+ rect0.x += X_OFFSET;
+ rect0.width -= X_OFFSET;
Rectangle absHeaderRect = new Rectangle(rect0.x, rect0.y, rect0.width, rect0.height);
- rect0.x -= 4;
- rect0.width += 4;
+ rect0.x -= X_OFFSET;
+ rect0.width += X_OFFSET;
// prepare and draw right rect of the timescale
rect0.x += leftSpace;
// draw time scale ticks
rect0.y = rect.y;
- rect0.height = rect.height - 4;
+ rect0.height = rect.height - Y_OFFSET;
rect0.width = labelWidth;
long time;
break;
}
if (x >= rect.x + leftSpace) {
- gc.drawLine(x, y, x, y + 4);
+ gc.drawLine(x, y, x, y + Y_OFFSET);
rect0.x = x;
if (x + rect0.width <= rect.x + rect.width) {
timeDraw.draw(gc, time, rect0);