Merge branch 'master' into lttng-kepler
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / widgets / timegraph / widgets / TimeGraphBaseControl.java
index 96d818911614c18092318e7e14bcb76d81804f73..3be2c0a5b67942ccf2d084005afb2d65b2b363f7 100644 (file)
-/*****************************************************************************\r
- * Copyright (c) 2007 Intel Corporation, 2009, 2012 Ericsson.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Intel Corporation - Initial API and implementation\r
- *   Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *   Alvaro Sanchez-Leon - Updated for TMF\r
- *   Patrick Tasse - Refactoring\r
- *\r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.PaintEvent;\r
-import org.eclipse.swt.events.PaintListener;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.widgets.Canvas;\r
-import org.eclipse.swt.widgets.Composite;\r
-\r
-/**\r
- * Base control abstract class for the time graph widget\r
- *\r
- * @version 1.0\r
- * @author Alvaro Sanchez-Leon\r
- * @author Patrick Tasse\r
- */\r
-public abstract class TimeGraphBaseControl extends Canvas implements PaintListener {\r
-\r
-    /** Default left margin size */\r
-    static public final int MARGIN = 4;\r
-\r
-    /** Default expanded size */\r
-    static public final int EXPAND_SIZE = 9; // the [+] or [-] control size\r
-\r
-    /** Default size of the right margin */\r
-    static public final int RIGHT_MARGIN = 1; // 1 pixels less to make sure end time is visible\r
-\r
-    /** Default size for small icons */\r
-    static public final int SMALL_ICON_SIZE = 16;\r
-\r
-    protected TimeGraphColorScheme _colors;\r
-    protected int _fontHeight = 0;\r
-\r
-    /**\r
-     * Basic constructor. Uses a default style value\r
-     *\r
-     * @param parent\r
-     *            The parent composite object\r
-     * @param colors\r
-     *            The color scheme to use\r
-     */\r
-    public TimeGraphBaseControl(Composite parent, TimeGraphColorScheme colors) {\r
-        this(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS);\r
-    }\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param parent\r
-     *            The parent composite object\r
-     * @param colors\r
-     *            The color scheme to use\r
-     * @param style\r
-     *            The index of the style to use\r
-     */\r
-    public TimeGraphBaseControl(Composite parent, TimeGraphColorScheme colors, int style) {\r
-        super(parent, style);\r
-        _colors = colors;\r
-        addPaintListener(this);\r
-    }\r
-\r
-    @Override\r
-    public void dispose() {\r
-        super.dispose();\r
-    }\r
-\r
-    @Override\r
-    public void paintControl(PaintEvent e) {\r
-        if (e.widget != this) {\r
-            return;\r
-        }\r
-        _fontHeight = e.gc.getFontMetrics().getHeight();\r
-        Rectangle bound = getClientArea();\r
-        if (!bound.isEmpty()) {\r
-            Color colBackup = e.gc.getBackground();\r
-            paint(bound, e);\r
-            e.gc.setBackground(colBackup);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Retrieve the current font's height\r
-     *\r
-     * @return The height\r
-     */\r
-    public int getFontHeight() {\r
-        return _fontHeight;\r
-    }\r
-\r
-    abstract void paint(Rectangle bound, PaintEvent e);\r
-}\r
+/*****************************************************************************
+ * Copyright (c) 2007 Intel Corporation, 2009, 2012 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:
+ *   Intel Corporation - Initial API and implementation
+ *   Ruslan A. Scherbakov, Intel - Initial API and implementation
+ *   Alvaro Sanchez-Leon - Updated for TMF
+ *   Patrick Tasse - Refactoring
+ *
+ *****************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Base control abstract class for the time graph widget
+ *
+ * @version 1.0
+ * @author Alvaro Sanchez-Leon
+ * @author Patrick Tasse
+ */
+public abstract class TimeGraphBaseControl extends Canvas implements PaintListener {
+
+    /** Default left margin size */
+    static public final int MARGIN = 4;
+
+    /** Default expanded size */
+    static public final int EXPAND_SIZE = 9; // the [+] or [-] control size
+
+    /** Default size of the right margin */
+    static public final int RIGHT_MARGIN = 1; // 1 pixels less to make sure end time is visible
+
+    /** Default size for small icons */
+    static public final int SMALL_ICON_SIZE = 16;
+
+    protected TimeGraphColorScheme _colors;
+    protected int _fontHeight = 0;
+
+    /**
+     * Basic constructor. Uses a default style value
+     *
+     * @param parent
+     *            The parent composite object
+     * @param colors
+     *            The color scheme to use
+     */
+    public TimeGraphBaseControl(Composite parent, TimeGraphColorScheme colors) {
+        this(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS);
+    }
+
+    /**
+     * Standard constructor
+     *
+     * @param parent
+     *            The parent composite object
+     * @param colors
+     *            The color scheme to use
+     * @param style
+     *            The index of the style to use
+     */
+    public TimeGraphBaseControl(Composite parent, TimeGraphColorScheme colors, int style) {
+        super(parent, style);
+        _colors = colors;
+        addPaintListener(this);
+    }
+
+    @Override
+    public void dispose() {
+        super.dispose();
+    }
+
+    @Override
+    public void paintControl(PaintEvent e) {
+        if (e.widget != this) {
+            return;
+        }
+        _fontHeight = e.gc.getFontMetrics().getHeight();
+        Rectangle bound = getClientArea();
+        if (!bound.isEmpty()) {
+            Color colBackup = e.gc.getBackground();
+            paint(bound, e);
+            e.gc.setBackground(colBackup);
+        }
+    }
+
+    /**
+     * Retrieve the current font's height
+     *
+     * @return The height
+     */
+    public int getFontHeight() {
+        return _fontHeight;
+    }
+
+    abstract void paint(Rectangle bound, PaintEvent e);
+}
This page took 0.028983 seconds and 5 git commands to generate.