lttng: Fix sonar warnings in VirtualMachinePresentationProvider
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Mon, 18 Jan 2016 04:18:10 +0000 (23:18 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Wed, 20 Jan 2016 20:36:20 +0000 (15:36 -0500)
Change-Id: I27d475f49da87af2e81337e4ad8ea856b6722d4f
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/64616
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
lttng/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/views/vm/vcpuview/VirtualMachinePresentationProvider.java

index ed29f3846058c209c6af56957bfce5f035cccfaa..b5e641ccc3193426c39af8c3a3788594696fd598 100644 (file)
@@ -33,6 +33,8 @@ import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent;
  */
 public class VirtualMachinePresentationProvider extends TimeGraphPresentationProvider {
 
+    private static final int ALPHA = 70;
+
     /*
      * TODO: Some of it is copy-pasted from the control flow presentation
      * provider because it actually is the same data as from the control flow
@@ -51,10 +53,10 @@ public class VirtualMachinePresentationProvider extends TimeGraphPresentationPro
         THREAD_SYSCALL(new RGB(0, 0, 200)),
         THREAD_INTERRUPTED(new RGB(200, 0, 100));
 
-        public final RGB rgb;
+        private final RGB fRgb;
 
         private State(RGB rgb) {
-            this.rgb = rgb;
+            fRgb = rgb;
         }
     }
 
@@ -141,7 +143,7 @@ public class VirtualMachinePresentationProvider extends TimeGraphPresentationPro
         StateItem[] stateTable = new StateItem[states.length];
         for (int i = 0; i < stateTable.length; i++) {
             State state = states[i];
-            stateTable[i] = new StateItem(state.rgb, state.toString());
+            stateTable[i] = new StateItem(state.fRgb, state.toString());
         }
         return stateTable;
     }
@@ -163,16 +165,13 @@ public class VirtualMachinePresentationProvider extends TimeGraphPresentationPro
 
     @Override
     public void postDrawEvent(@Nullable ITimeEvent event, @Nullable Rectangle bounds, @Nullable GC gc) {
-        if (bounds == null || gc == null) {
+        if (bounds == null || gc == null || !(event instanceof TimeEvent)) {
             return;
         }
         boolean visible = bounds.width == 0 ? false : true;
         if (!visible) {
             return;
         }
-        if (!(event instanceof TimeEvent)) {
-            return;
-        }
         TimeEvent ev = (TimeEvent) event;
         /*
          * FIXME: There seems to be a bug when multiple events should be drawn
@@ -195,7 +194,7 @@ public class VirtualMachinePresentationProvider extends TimeGraphPresentationPro
                     Color background = gc.getBackground();
                     // fill all rect area
                     gc.setBackground(alphaColor);
-                    gc.setAlpha(70);
+                    gc.setAlpha(ALPHA);
                     gc.fillRectangle(bounds);
 
                     gc.setBackground(background);
This page took 0.027402 seconds and 5 git commands to generate.