tmf: Handle 'null' active pages in views
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / histogram / FullTraceHistogram.java
index d6d7d711bff49d1d4ea618e782efb529df1cf143..2591c1e64a189abdab83e3feca9db2404084456d 100644 (file)
@@ -27,8 +27,8 @@ import org.eclipse.swt.widgets.Display;
  * A histogram widget that displays the event distribution of a whole trace.
  * <p>
  * It also features a selected range window that can be dragged and zoomed.
- * 
- * @version 1.0
+ *
+ * @version 1.1
  * @author Francois Chouinard
  */
 public class FullTraceHistogram extends Histogram implements MouseMoveListener {
@@ -46,7 +46,7 @@ public class FullTraceHistogram extends Histogram implements MouseMoveListener {
 
     private final HistogramZoom fZoom;
 
-    private long fRangeStartTime;
+    private long fRangeStartTime = 0L;
     private long fRangeDuration;
 
     // ------------------------------------------------------------------------
@@ -54,9 +54,9 @@ public class FullTraceHistogram extends Histogram implements MouseMoveListener {
     // ------------------------------------------------------------------------
 
     /**
-     * Standard Constructor.
-     * 
-     * @param view A reference to the parent histogram view 
+     * Full Constructor
+     *
+     * @param view A reference to the parent histogram view
      * @param parent A reference to the parent composite
      */
     public FullTraceHistogram(HistogramView view, Composite parent) {
@@ -76,8 +76,8 @@ public class FullTraceHistogram extends Histogram implements MouseMoveListener {
     // ------------------------------------------------------------------------
 
     /**
-     * Sets the time range of the full histogram.  
-     * 
+     * Sets the time range of the full histogram.
+     *
      * @param startTime A start time
      * @param endTime A end time
      */
@@ -87,9 +87,9 @@ public class FullTraceHistogram extends Histogram implements MouseMoveListener {
 
     /**
      * Sets the selected time range.
-     * 
-     * @param startTime A start time
-     * @param duration A window duration
+     *
+     * @param startTime The histogram start time
+     * @param duration The histogram duration
      */
     public void setTimeRange(long startTime, long duration) {
         fRangeStartTime = startTime;
@@ -98,6 +98,9 @@ public class FullTraceHistogram extends Histogram implements MouseMoveListener {
         fDataModel.complete();
     }
 
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.views.histogram.Histogram#updateTimeRange(long, long)
+     */
     @Override
     public void updateTimeRange(long startTime, long endTime) {
         ((HistogramView) fParentView).updateTimeRange(startTime, endTime);
@@ -115,7 +118,7 @@ public class FullTraceHistogram extends Histogram implements MouseMoveListener {
         fMouseDown = true;
         fStartPosition = event.x;
     }
+
     @Override
     public void mouseUp(MouseEvent event) {
         if (fMouseDown) {
@@ -125,13 +128,13 @@ public class FullTraceHistogram extends Histogram implements MouseMoveListener {
                 super.mouseDown(event);
                 return;
             }
-            ((HistogramView) fParentView).updateTimeRange(fRangeStartTime, fRangeStartTime + fZoom.getDuration());
+
+            ((HistogramView) fParentView).updateTimeRange(fRangeStartTime, fRangeStartTime + fRangeDuration);
 
         }
     }
-    
+
+
     // ------------------------------------------------------------------------
     // MouseMoveListener
     // ------------------------------------------------------------------------
@@ -171,7 +174,7 @@ public class FullTraceHistogram extends Histogram implements MouseMoveListener {
         GC rangeWindowGC = new GC(rangeRectangleImage);
 
         if ((fScaledData != null) && (fRangeStartTime != 0)) {
-            drawTimeRangeWindow(rangeWindowGC, rangeRectangleImage);
+            drawTimeRangeWindow(rangeWindowGC);
         }
 
         // Draws the buffer image onto the canvas.
@@ -181,16 +184,16 @@ public class FullTraceHistogram extends Histogram implements MouseMoveListener {
         rangeRectangleImage.dispose();
     }
 
-    private void drawTimeRangeWindow(GC imageGC, Image image) {
+    private void drawTimeRangeWindow(GC imageGC) {
 
         // Map times to histogram coordinates
-        long bucketSpan = Math.max(fScaledData.fBucketDuration,1);
+        long bucketSpan = Math.max(fScaledData.fBucketDuration, 1);
         int rangeWidth = (int) (fRangeDuration / bucketSpan);
 
         int left = (int) ((fRangeStartTime - fDataModel.getFirstBucketTime()) / bucketSpan);
         int right = left + rangeWidth;
         int center = (left + right) / 2;
-        int height = fCanvas.getSize().y - 2;
+        int height = fCanvas.getSize().y;
 
         // Draw the selection window
         imageGC.setForeground(fTimeRangeColor);
This page took 0.027463 seconds and 5 git commands to generate.