Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2012-02-27 14:52:59 +0000
committerMarc Khouzam2012-02-29 16:07:18 +0000
commit511770363448e9c3fe9622852984ee9276d15332 (patch)
treecca17ac0a5d5aba2cabbd5b3cec7dbd02ad87473 /visualizer
parentb2a621616a64288c180d6869ecbf5bcb7ceec6d2 (diff)
downloadorg.eclipse.cdt-511770363448e9c3fe9622852984ee9276d15332.tar.gz
org.eclipse.cdt-511770363448e9c3fe9622852984ee9276d15332.tar.xz
org.eclipse.cdt-511770363448e9c3fe9622852984ee9276d15332.zip
Cleanup with javadoc and such.
Diffstat (limited to 'visualizer')
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.java11
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.properties6
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer.java93
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/VisualizerExamplesPlugin.java10
4 files changed, 75 insertions, 45 deletions
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.java b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.java
index 98888dacde7..11bc82633ce 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.java
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.java
@@ -1,13 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Ericsson and others.
+ * Copyright (c) 2012 Ericsson and others.
* 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:
- * Ericsson - initial API and implementation
- * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
+ * Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.visualizer.examples;
@@ -17,9 +16,9 @@ import org.eclipse.osgi.util.NLS;
* Preference strings.
*/
class Messages extends NLS {
- public static String CounterVisualizer_Name;
- public static String CounterVisualizer_DisplayName;
- public static String CounterVisualizer_Description;
+ public static String ProblemCountVisualizer_Name;
+ public static String ProblemCountVisualizer_DisplayName;
+ public static String ProblemCountVisualizer_Description;
static {
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.properties b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.properties
index 979fbbd49d5..666395673cd 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.properties
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/Messages.properties
@@ -9,6 +9,6 @@
# Marc Khouzam (Ericsson) - initial API and implementation
###############################################################################
-CounterVisualizer_Name=counter
-CounterVisualizer_DisplayName=Counter Visualizer
-CounterVisualizer_Description=Visualizer displaying the count of errors/warnings/info \ No newline at end of file
+ProblemCountVisualizer_Name=ProblemCounter
+ProblemCountVisualizer_DisplayName=Problem Count Visualizer
+ProblemCountVisualizer_Description=Visualizer displaying the count of errors/warnings/info \ No newline at end of file
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer.java b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer.java
index dcfe2b19fd6..f1fb9501330 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer.java
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/ProblemVisualizer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Tilera Corporation and others.
+ * Copyright (c) 2012 Ericsson and others.
* 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
@@ -27,33 +27,41 @@ import org.eclipse.swt.widgets.Composite;
public class ProblemVisualizer extends GraphicCanvasVisualizer {
+ /** The width of the side margins */
private static final int MARGIN_WIDTH = 10;
+ /** The height of the top and bottom margins */
private static final int MARGIN_HEIGHT = 10;
+ /** The default space between bars in the chart */
private static final int SPACING_HEIGHT = 40;
+ /** The predefined number of severities */
private static final int NUM_SEVERITY = 3;
+ /* The different colors to use for the different severities */
+ private static final Color ERROR_OUTLINE_COLOR = Colors.DARK_RED;
+ private static final Color ERROR_INSIDE_COLOR = Colors.DARK_RED;
+ private static final Color WARNING_OUTLINE_COLOR = Colors.DARK_YELLOW;
+ private static final Color WARNING_INSIDE_COLOR = Colors.DARK_YELLOW;
+ private static final Color INFO_OUTLINE_COLOR = Colors.DARK_BLUE;
+ private static final Color INFO_INSIDE_COLOR = Colors.DARK_BLUE;
+
+ private static final Color MAIN_BACKGROUND_COLOR = Colors.WHITE;
+ private static final Color MAIN_FOREGROUND_COLOR = Colors.BLACK;
+
+ /**
+ * A class that draws a bar or a bar outline in the specified color.
+ */
private class BarGraphicObject extends GraphicObject {
private boolean m_outline;
- public BarGraphicObject(int severity, int x, int y, int w, int h, boolean outline) {
+ public BarGraphicObject(Color color, int x, int y, int w, int h, boolean outline) {
super(x, y, w, h);
m_outline = outline;
- Color color = Colors.BLACK;
-
- switch (severity) {
- case IMarker.SEVERITY_ERROR:
- color = Colors.DARK_RED;
- break;
- case IMarker.SEVERITY_WARNING:
- color = Colors.DARK_YELLOW;
- break;
- case IMarker.SEVERITY_INFO:
- color = Colors.DARK_BLUE;
- break;
+ if (m_outline) {
+ setForeground(color);
+ } else {
+ setBackground(color);
}
- if (!m_outline) setBackground(color);
- setForeground(color);
}
@Override
@@ -66,9 +74,14 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
}
}
-
+ /** The canvas on which we'll draw our bars */
private GraphicCanvas m_canvas;
+ /**
+ * The model containing the data to be displayed.
+ * In this case, it is the number of the three
+ * different types of problem markers.
+ */
private int[] m_markerCount = new int[NUM_SEVERITY];
public ProblemVisualizer() {
@@ -77,17 +90,17 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
@Override
public String getName() {
- return Messages.CounterVisualizer_Name;
+ return Messages.ProblemCountVisualizer_Name;
}
@Override
public String getDisplayName() {
- return Messages.CounterVisualizer_DisplayName;
+ return Messages.ProblemCountVisualizer_DisplayName;
}
@Override
public String getDescription() {
- return Messages.CounterVisualizer_Description;
+ return Messages.ProblemCountVisualizer_Description;
}
@Override
@@ -97,9 +110,9 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
}
@Override
- protected void initializeCanvas(GraphicCanvas canvas) {
- // TODO Auto-generated method stub
- super.initializeCanvas(canvas);
+ protected void initializeCanvas(GraphicCanvas canvas) {
+ m_canvas.setBackground(MAIN_BACKGROUND_COLOR);
+ m_canvas.setForeground(MAIN_FOREGROUND_COLOR);
}
@Override
@@ -115,16 +128,17 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
@Override
public void visualizerDeselected() {
- // TODO Auto-generated method stub
- super.visualizerDeselected();
}
@Override
public void visualizerSelected() {
- // TODO Auto-generated method stub
- super.visualizerSelected();
}
+ /**
+ * Actually create the graphics bars for the different severities.
+ * @param outline Should the bars be created, or the bar outline
+ * @return The bars to be drawn.
+ */
private BarGraphicObject[] getBars(boolean outline) {
BarGraphicObject[] bars = new BarGraphicObject[3];
@@ -142,37 +156,45 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
}
int maxWidth = bounds.width - 2 * MARGIN_WIDTH;
-
+
if (outline) {
- bars[0] = new BarGraphicObject(IMarker.SEVERITY_ERROR, x, y, maxWidth, height, outline);
+ // The bar outlines take the entire width of the view
+ bars[0] = new BarGraphicObject(ERROR_OUTLINE_COLOR, x, y, maxWidth, height, outline);
y = y + height + spacing;
- bars[1] = new BarGraphicObject(IMarker.SEVERITY_WARNING, x, y, maxWidth, height, outline);
+ bars[1] = new BarGraphicObject(WARNING_OUTLINE_COLOR, x, y, maxWidth, height, outline);
y = y + height + spacing;
- bars[2] = new BarGraphicObject(IMarker.SEVERITY_INFO, x, y, maxWidth, height, outline);
+ bars[2] = new BarGraphicObject(INFO_OUTLINE_COLOR, x, y, maxWidth, height, outline);
} else {
+ // The inside of the bars use a proportional width with the maximum width and
+ // the largest amount of markers for one severity.
+
// Find the maximum marker count to dictate the width
int maxCount = Math.max(m_markerCount[0], m_markerCount[1]);
maxCount = Math.max(maxCount, m_markerCount[2]);
if (maxCount == 0) maxCount = 1; // Set to anything but 0. It will be multiplied by 0 and not matter.
int width = maxWidth * m_markerCount[IMarker.SEVERITY_ERROR] / maxCount;
- bars[0] = new BarGraphicObject(IMarker.SEVERITY_ERROR, x, y, width, height, outline);
+ bars[0] = new BarGraphicObject(ERROR_INSIDE_COLOR, x, y, width, height, outline);
y = y + height + spacing;
width = maxWidth * m_markerCount[IMarker.SEVERITY_WARNING] / maxCount;
- bars[1] = new BarGraphicObject(IMarker.SEVERITY_WARNING, x, y, width, height, outline);
+ bars[1] = new BarGraphicObject(WARNING_INSIDE_COLOR, x, y, width, height, outline);
y = y + height + spacing;
width = maxWidth * m_markerCount[IMarker.SEVERITY_INFO] / maxCount;
- bars[2] = new BarGraphicObject(IMarker.SEVERITY_INFO, x, y, width, height, outline);
+ bars[2] = new BarGraphicObject(INFO_INSIDE_COLOR, x, y, width, height, outline);
}
return bars;
}
+ /**
+ * Get the count of problem markers for each severity for the
+ * specified resource.
+ */
private void setMarkerCount(IResource resource) {
m_markerCount[IMarker.SEVERITY_ERROR] = 0;
m_markerCount[IMarker.SEVERITY_WARNING] = 0;
@@ -224,6 +246,5 @@ public class ProblemVisualizer extends GraphicCanvasVisualizer {
public SelectionManager getSelectionManager() {
return m_selectionManager;
- }
-
+ }
}
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/VisualizerExamplesPlugin.java b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/VisualizerExamplesPlugin.java
index b53090bae69..7793412a733 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/VisualizerExamplesPlugin.java
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/VisualizerExamplesPlugin.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson and others.
+ * 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:
+ * Marc Khouzam (Ericsson) - initial API and implementation
+ *******************************************************************************/
package org.eclipse.cdt.visualizer.examples;
import org.eclipse.ui.plugin.AbstractUIPlugin;

Back to the top