Changed all the "java primitive" to basic type due to casting issue, implemented...
authorWilliam Bourque <william.bourque@polymtl.ca>
Tue, 4 May 2010 17:16:39 +0000 (17:16 +0000)
committerWilliam Bourque <william.bourque@polymtl.ca>
Tue, 4 May 2010 17:16:39 +0000 (17:16 +0000)
15 files changed:
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ChildrenHistogramCanvas.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvas.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasControlListener.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasKeyListener.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasMouseListener.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasPaintListener.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramConstant.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramContent.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramElement.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramRequest.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramSelectedWindow.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvas.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasPaintListener.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/TimeTextGroup.java

index c401ffe67c8e90f82e83aa281ae9d358b74d78e0..87464d0c65535aec3ac8aad36a1efea7ab7d803b 100644 (file)
@@ -31,7 +31,7 @@ public class ChildrenHistogramCanvas extends HistogramCanvas {
         * @param parent                Composite control which will be the parent of the new instance (cannot be null)
         * @param                               Style the style of control to construct
         */
-       public ChildrenHistogramCanvas(HistogramView newParentWindow, Composite parent, Integer style) {
+       public ChildrenHistogramCanvas(HistogramView newParentWindow, Composite parent, int style) {
                super(parent, style);
                
                parentHistogramWindow = newParentWindow;
index ddfc2bc5ced3d4af35972febd0c449312ae253e3..b3623674462d0745856e9f0f56181bf7762f869c 100644 (file)
@@ -43,7 +43,7 @@ public class HistogramCanvas extends Canvas
         * @param parent                Composite control which will be the parent of the new instance (cannot be null)
         * @param                               Style the style of control to construct
         */
-       public HistogramCanvas(Composite parent, Integer style) {
+       public HistogramCanvas(Composite parent, int style) {
                super(parent, style);
                addNeededListeners();
                
@@ -139,7 +139,7 @@ public class HistogramCanvas extends Canvas
         * @param barsHeight                                    Height of the histogram "bars"
         * @param maxBarsDifferenceToAverage    Factor used to "chop" bars that are too tall. Set to something big (100.0?) if not needed.
         */
-       public void createNewHistogramContent(Integer canvasSize, Integer widthPerBar, Integer barsHeight, Double maxBarsDifferenceToAverage) {
+       public void createNewHistogramContent(int canvasSize, int widthPerBar, int barsHeight, double maxBarsDifferenceToAverage) {
                histogramContent = new HistogramContent( canvasSize / widthPerBar, canvasSize, widthPerBar, barsHeight, maxBarsDifferenceToAverage);
        }
        
@@ -150,7 +150,7 @@ public class HistogramCanvas extends Canvas
         * 
         * @param windowTimeDuration    Time width (in nanosecond) of the window.
         */
-       public void createNewSelectedWindow(Long windowTimeDuration) {
+       public void createNewSelectedWindow(long windowTimeDuration) {
                currentWindow = new HistogramSelectedWindow(histogramContent);
                
                currentWindow.setWindowTimeWidth(windowTimeDuration);
@@ -177,7 +177,7 @@ public class HistogramCanvas extends Canvas
         * 
         * @return Time width (in nanosecond) of the selection window.
         */
-       public Long getSelectedWindowSize() {
+       public long getSelectedWindowSize() {
                return currentWindow.getWindowTimeWidth();
        }
        
@@ -189,12 +189,11 @@ public class HistogramCanvas extends Canvas
         * 
         * @param newSelectedWindowSize New time width (in nanosecond) of the selection window.
         */
-       public void setSelectedWindowSize(Long newSelectedWindowSize) {
+       public void setSelectedWindowSize(long newSelectedWindowSize) {
                
-               if ( newSelectedWindowSize < histogramContent.getElementsTimeInterval() ) {
-                       newSelectedWindowSize = histogramContent.getElementsTimeInterval();
+               if ( newSelectedWindowSize <= 0 ) {
+                       newSelectedWindowSize = 1L;
                }
-               
                else if ( newSelectedWindowSize > (2*histogramContent.getCompleteTimeInterval()) ) {
                        newSelectedWindowSize = (2*histogramContent.getCompleteTimeInterval());
                }
@@ -252,7 +251,7 @@ public class HistogramCanvas extends Canvas
         * 
         * @param newRelativeXPosition  New position relative to the last known absolute position.
         */
-       public void moveWindow(Integer newRelativeXPosition) {
+       public void moveWindow(int newRelativeXPosition) {
                // Nothing : function is a place holder
        }
        
@@ -264,7 +263,7 @@ public class HistogramCanvas extends Canvas
         * 
         * @param newRelativeXPosition  New absolute position.
         */
-       public void centerWindow(Integer newAbsoluteXPosition) {
+       public void setWindowCenterPosition(int newAbsoluteXPosition) {
                // Nothing : function is a place holder
        }
        
@@ -276,7 +275,7 @@ public class HistogramCanvas extends Canvas
         * 
         * @param newTime        New absoulte time (in nanoseconds) to apply to the window.
         */
-       public void resizeWindowByAbsoluteTime(Long newTime) {
+       public void resizeWindowByAbsoluteTime(long newTime) {
                // Nothing : function is a place holder
        }
        
index 6df72388cb35fbe58c6bdd74e1a93c8657f9992a..f361717efb8c8bb0fdd90cd83ffc41f35c88a137 100644 (file)
@@ -57,7 +57,7 @@ public class HistogramCanvasControlListener implements ControlListener {
                        //              and what it really points to. The user should reclick by himself to refresh it. 
                        int oldWindowCenter = parentCanvas.getCurrentWindow().getWindowXPositionCenter();
                        int newWindowCenter = (int)Math.ceil((double)newSize * ((double)oldWindowCenter / (double)oldSize));
-                       parentCanvas.centerWindow(newWindowCenter);
+                       parentCanvas.setWindowCenterPosition(newWindowCenter);
                }
        }
 }
index 90232189d8d617a47e2ba655f5515f075b24c20d..84408e15ca48c69de98e1bbd392a7b1df2ad7799 100644 (file)
@@ -82,7 +82,7 @@ public class HistogramCanvasKeyListener implements KeyListener
         * 
         * @param displacementFactor    The basic displacement to perform (positive or negative value)
         */
-       public void moveWindowPosition(Integer displacementFactor) {
+       public void moveWindowPosition(int displacementFactor) {
                
                // If we are in "fast move mode", multiply the basic displacement by a factor
                if ( isShiftPressed == true ) {
index 8ee4c80da5f9335965d65d1edb777a87120531a8..7c06cd6ae0e3429de6d5bcc6fb37361f33832e44 100644 (file)
@@ -46,7 +46,7 @@ public class HistogramCanvasMouseListener implements MouseMoveListener, MouseLis
         */
        public void mouseMove(MouseEvent event) {
                if ( isWindowMoving == true ) {
-                       parentCanvas.centerWindow(event.x);
+                       parentCanvas.setWindowCenterPosition(event.x);
                }
        }
        
@@ -59,7 +59,7 @@ public class HistogramCanvasMouseListener implements MouseMoveListener, MouseLis
        public void mouseDown(MouseEvent event) {
                if ( event.button == 1) {
                        isWindowMoving = true;
-                       parentCanvas.centerWindow(event.x);
+                       parentCanvas.setWindowCenterPosition(event.x);
                }
        }
        
index 7c69bfcf57df7c0de4922ec6e7bc0a7c0e1f4387..5b5cc86b0098560b05973ce2e95cd99719619548 100644 (file)
@@ -130,7 +130,7 @@ public class HistogramCanvasPaintListener implements PaintListener
        
        /**
         * Draw the selection window in the canvas.<p>
-        * This draw a square ober the selected section with a crosshair in the middle.
+        * This draw a square around the selected section with a crosshair in the middle.
         * The square cannot be smaller than "MINIMUM_WINDOW_WIDTH"
         * 
         * @param event The generated paint event when redraw is called.
index ec194a3d306497b0cbe1a208715dcced82764ed1..0d42a611e732972446f32d5d6d33447473e24a30 100644 (file)
@@ -23,58 +23,58 @@ import org.eclipse.swt.widgets.Composite;
  */
 public abstract class HistogramConstant {
        // Constants relative to requests
-       public final static Integer MAX_EVENTS_PER_READ = 1;
-       public final static Integer REDRAW_EVERY_NB_EVENTS = 10000;
+       public final static int MAX_EVENTS_PER_READ = 1;
+       public final static int REDRAW_EVERY_NB_EVENTS = 10000;
        public final static Boolean SKIP_EMPTY_INTERVALS_WHEN_CALCULATING_AVERAGE = true;
        
        
        // Constant relative to the content
-       public final static Double DEFAULT_DIFFERENCE_TO_AVERAGE = 1000.0;
+       public final static double DEFAULT_DIFFERENCE_TO_AVERAGE = 1000.0;
        
        
        
        // Constants relative to zoom. Factors need to be a percentage ( 0 < factors < 1 )
-       public final static Double ZOOM_IN_FACTOR = 0.1;
-       public final static Double ZOOM_OUT_FACTOR = 0.1;
+       public final static double ZOOM_IN_FACTOR = 0.1;
+       public final static double ZOOM_OUT_FACTOR = 0.1;
        
        
        // Constants relative to wait time while listening for scroll events
        // "FULL" is time to wait to stop "to count" mouse scroll click events
        // "INTERVAL" is time to wait between polling for scroll click events
-       public final static Long FULL_WAIT_MS_TIME_BETWEEN_MOUSE_SCROLL = 500L;
-       public final static Long INTERVAL_WAIT_MS_TIME_BETWEEN_POLL = 100L;
+       public final static long FULL_WAIT_MS_TIME_BETWEEN_MOUSE_SCROLL = 500L;
+       public final static long INTERVAL_WAIT_MS_TIME_BETWEEN_POLL = 100L;
        
        
        // Constants relative to the displacement in the trace
        // Factor represent a number of HistogramContent interval
        // Multiple is the factor to multiply to basic during "fast" displacement 
-       public final static Integer BASIC_DISPLACEMENT_FACTOR = 1;
-       public final static Double  FAST_DISPLACEMENT_MULTIPLE = 10.0;
+       public final static int BASIC_DISPLACEMENT_FACTOR = 1;
+       public final static double  FAST_DISPLACEMENT_MULTIPLE = 10.0;
        
        
        // Constants relative to the drawing of the Histogram
        // Colors for the histogram. Background should be the same as the background in use
-       public final static Integer EMPTY_BACKGROUND_COLOR = SWT.COLOR_WHITE;
-       public final static Integer HISTOGRAM_BARS_COLOR = SWT.COLOR_DARK_CYAN;
-       public final static Integer SELECTED_EVENT_COLOR = SWT.COLOR_RED;
-       public final static Integer SELECTION_WINDOW_COLOR = SWT.COLOR_RED;
+       public final static int EMPTY_BACKGROUND_COLOR = SWT.COLOR_WHITE;
+       public final static int HISTOGRAM_BARS_COLOR = SWT.COLOR_DARK_CYAN;
+       public final static int SELECTED_EVENT_COLOR = SWT.COLOR_RED;
+       public final static int SELECTION_WINDOW_COLOR = SWT.COLOR_RED;
        
        // Dimension for the line of the "Selection Window"
-       public final static Integer MINIMUM_WINDOW_WIDTH = 3;
-       public final static Integer SELECTION_LINE_WIDTH = 2;
-       public final static Integer SELECTION_CROSSHAIR_LENGTH = 3;
+       public final static int MINIMUM_WINDOW_WIDTH = 3;
+       public final static int SELECTION_LINE_WIDTH = 2;
+       public final static int SELECTION_CROSSHAIR_LENGTH = 3;
        
        
        /**
-        * Method to format a Long representing nanosecond into a proper String.<p>
+        * Method to format a long representing nanosecond into a proper String.<p>
         * The returned String will always be like "0.000000000", missing decimal will be added.
         * 
         * @param nanosecTime   This time to format
         * 
         * @return      The formatted string
         */
-       public static String formatNanoSecondsTime(Long nanosecTime) {
-               String returnedTime = nanosecTime.toString();
+       public static String formatNanoSecondsTime(long nanosecTime) {
+               String returnedTime = Long.toString(nanosecTime);
                
                // If our number has over 9 digits, just add a dot after the ninth digits
                if ( returnedTime.length() > 9 ) {
@@ -93,17 +93,17 @@ public abstract class HistogramConstant {
        }
        
        /**
-        * Convert a String representing nanoseconds into a valid Long.<p>
+        * Convert a String representing nanoseconds into a valid long.<p>
         * This can handle number like "0.5", "0.123456789" as well as plain number like "12".<p>
         * 
         * Note : This function ALWAYS return a number, if conversion failed, 0 will be returned.<p>
         * 
         * @param timeString    The string to convert
         * 
-        * @return                              The converted nanoseconds time as Long
+        * @return                              The converted nanoseconds time as long
         */
-       public static Long convertStringToNanoseconds( String timeString ) {
-               Long returnedNumber = 0L;
+       public static long convertStringToNanoseconds( String timeString ) {
+               long returnedNumber = 0L;
                
            try {
                // Avoid simple commat/dot mistake
@@ -135,7 +135,7 @@ public abstract class HistogramConstant {
                }
                
                // Conversion into decimal seconds
-               Double dblMaxTimerange = Double.parseDouble(timeString);
+               double dblMaxTimerange = Double.parseDouble(timeString);
                // Conversion into nanoseconds
                returnedNumber = (long)(dblMaxTimerange * 1000000000.0);
            }
@@ -156,7 +156,7 @@ public abstract class HistogramConstant {
         * 
         * @return                      The size calculated.
         */
-       public static Integer getTextSizeInControl(Composite parent, String text) {
+       public static int getTextSizeInControl(Composite parent, String text) {
                GC graphicContext = new GC(parent);
         int textSize = 0;
         for ( int pos=0; pos<text.length(); pos++ ) {
index 6e6ab7a007f9748a0a35ffd2f11a8c1fae3c4658..0513818b4a461d8ad10ad491d10911a262d6ffbb 100644 (file)
@@ -19,36 +19,37 @@ package org.eclipse.linuxtools.lttng.ui.views.histogram;
  * <p>
  */
 public class HistogramContent {
+       
        // Start and end time of the content
-       protected Long          startTime = 0L;
-       protected Long          endTime   = 0L;
+       protected long          startTime = 0L;
+       protected long          endTime   = 0L;
        
        // Some information about the content
        // Most of them are required to calculate position and/or draw
        // Make sure they stay consistent!
-       protected Long          elementsTimeInterval = 0L;
-       protected Double        heightFactor = 0.0;
-       protected Long          heighestEventCount = 0L;
-       protected Integer       maxHeight        = 0;
-       protected Integer       canvasWindowSize = 0;
-       protected Integer       barsWidth = 0;
+       protected long          elementsTimeInterval = 1L;
+       protected double        heightFactor = 100.0;
+       protected long          heighestEventCount = 0L;
+       protected int   maxHeight        = 0;
+       protected int   canvasWindowSize = 0;
+       protected int   barsWidth = 0;
        
        // This value is used to calculate at which point we should "cut" bar that are too tall.
        // Default value is large enought so that no bar should be cut
-       protected Double  maxDifferenceToAverage = HistogramConstant.DEFAULT_DIFFERENCE_TO_AVERAGE;
+       protected double  maxDifferenceToAverage = HistogramConstant.DEFAULT_DIFFERENCE_TO_AVERAGE;
        // This is a factor we might apply on the max difference to average, as example if we concatenate interval together
-       protected Double  maxDifferenceFactor = 1.0;
+       protected double  maxDifferenceFactor = 1.0;
        
        // By default we will only consider element up to this position 
-       protected Integer       readyUpToPosition = 0;
+       protected int   readyUpToPosition = 0;
        
        // The average number of events in the content
        // Note : this IS needed to draw
-       protected Integer       averageNumberOfEvents = 0;
+       protected int   averageNumberOfEvents = 0;
        
        // This is to draw the selected event of the TMF framework in another color
        // Set the 0 to ignore
-       protected Long selectedEventTimeInWindow = -1L;
+       protected long selectedEventTimeInWindow = -1L;
        
        // The table that hold the elements
        protected HistogramElement[] elementTable;
@@ -61,7 +62,7 @@ public class HistogramContent {
         * @param newCanvasSize         The full size of the canvas. Used for positionning; need to be consistent with canvas.
         * @param newMaxHeight          The maximum height of a bar, usually same as the height of the canvas.
         */
-       public HistogramContent(Integer tableSize, Integer newCanvasSize, Integer newBarWidth, Integer newMaxHeight) {
+       public HistogramContent(int tableSize, int newCanvasSize, int newBarWidth, int newMaxHeight) {
                this(tableSize, newCanvasSize, newBarWidth, newMaxHeight, HistogramConstant.DEFAULT_DIFFERENCE_TO_AVERAGE);
        }
        
@@ -73,7 +74,7 @@ public class HistogramContent {
         * @param newMaxHeight          The maximum height of a bar, usually same as the height of the canvas.
         * @param newDiffToAverage  This value at which point we "cut" bar that are too tall.
         */
-       public HistogramContent(Integer tableSize, Integer newCanvasSize, Integer newBarWidth, Integer newMaxHeight, Double newDiffToAverage) {
+       public HistogramContent(int tableSize, int newCanvasSize, int newBarWidth, int newMaxHeight, double newDiffToAverage) {
                canvasWindowSize = newCanvasSize;
                barsWidth = newBarWidth;
                maxHeight = newMaxHeight;
@@ -90,7 +91,7 @@ public class HistogramContent {
         * 
         * @param newTableSize  The size (number of element) of the table.
         */
-       public void createNewTable(Integer newTableSize) {
+       public void createNewTable(int newTableSize) {
                elementTable = new HistogramElement[newTableSize];
                
                for ( int x=0; x<elementTable.length; x++) {
@@ -106,8 +107,8 @@ public class HistogramContent {
                startTime = 0L;
                endTime = 0L;
                
-               elementsTimeInterval = 0L;
-               heightFactor = 0.0;
+               elementsTimeInterval = 1L;
+               heightFactor = 100.0;
                heighestEventCount = 0L;
                
                readyUpToPosition = 0;
@@ -133,7 +134,7 @@ public class HistogramContent {
         *  @param      newStartTime    The new start time to use 
         *  @param      newEndTime              The new stop time to use
         */
-       public void resetTable(Long newStartTime, Long newEndTime) {
+       public void resetTable(long newStartTime, long newEndTime) {
                recalculateElementsTimeInterval(newStartTime, newEndTime);
                resetTable(newStartTime, newEndTime, elementsTimeInterval);
        }
@@ -146,7 +147,7 @@ public class HistogramContent {
         *  @param      newEndTime              The new stop time to use
         *  @param  newTimeInterval The new time interval to use
         */
-       public void resetTable(Long newStartTime, Long newEndTime, Long newTimeInterval) {
+       public void resetTable(long newStartTime, long newEndTime, long newTimeInterval) {
                
                startTime = newStartTime;
                endTime = newEndTime;
@@ -202,7 +203,7 @@ public class HistogramContent {
         * 
         * @return      The time of the event.
         */
-       public Long getSelectedEventTimeInWindow() {
+       public long getSelectedEventTimeInWindow() {
                return selectedEventTimeInWindow;
        }
        
@@ -214,7 +215,7 @@ public class HistogramContent {
         * 
         * @param newPosition The new event time.
         */
-       public void setSelectedEventTimeInWindow(Long newTime) {
+       public void setSelectedEventTimeInWindow(long newTime) {
                this.selectedEventTimeInWindow = newTime;
        }
        
@@ -227,7 +228,7 @@ public class HistogramContent {
         * 
         * @return The element found or null if the index is wrong.
         */
-       public HistogramElement getElementByIndex(Integer index) {
+       public HistogramElement getElementByIndex(int index) {
                HistogramElement returnedElement = null;
                
                if ( (index >= 0) && (index < elementTable.length) ) {
@@ -248,7 +249,7 @@ public class HistogramContent {
         * 
         * @return      The <i>closest</i> element found.
         */
-       public HistogramElement getClosestElementFromXPosition(Integer position) {
+       public HistogramElement getClosestElementFromXPosition(int position) {
                
                int index = (int)Math.round((double)elementTable.length * ((double)position / (double)canvasWindowSize) );
                
@@ -274,7 +275,7 @@ public class HistogramContent {
         * 
         * @return      The <i>closest</i> timestamp found.
         */
-       public Long getClosestTimestampFromXPosition(Integer position) {
+       public long getClosestTimestampFromXPosition(int position) {
                return getClosestElementFromXPosition(position).firstIntervalTimestamp;
        }
        
@@ -304,7 +305,7 @@ public class HistogramContent {
         * 
         * @return      The <i>closest</i> element found.
         */
-       public HistogramElement getClosestElementFromTimestamp(Long timestamp) {
+       public HistogramElement getClosestElementFromTimestamp(long timestamp) {
                int index = (int)( (timestamp - startTime)/elementsTimeInterval );
                
                // If we are out of bound, return the closest border (first or last element)
@@ -329,7 +330,7 @@ public class HistogramContent {
         * 
         * @return      The <i>closest</i> position found.
         */
-       public Integer getClosestXPositionFromTimestamp(Long timestamp) {
+       public int getClosestXPositionFromTimestamp(long timestamp) {
                return getXPositionFromElement(getClosestElementFromTimestamp(timestamp));
        }
        
@@ -344,11 +345,11 @@ public class HistogramContent {
         * 
         * @return      The <i>closest</i> found element, or null if given data are wrong.
         */
-       public HistogramElement getClosestElementByElementAndTimeInterval(HistogramElement targetElement, Long intervalToElement) {
+       public HistogramElement getClosestElementByElementAndTimeInterval(HistogramElement targetElement, long intervalToElement) {
                
                // Get the timestamp of the target element
                // This should always be valid as long the table is initialized
-               Long elementTime = targetElement.firstIntervalTimestamp;
+               long elementTime = targetElement.firstIntervalTimestamp;
                elementTime = elementTime + intervalToElement;
                
                return getClosestElementFromTimestamp(elementTime);
@@ -365,7 +366,7 @@ public class HistogramContent {
         * 
         * @return      The <i>closest</i> found element, or null if given data are wrong.
         */
-       public int getClosestElementByTimestampAndTimeInterval(Long timestamp, Long intervalToElement) {
+       public int getClosestElementByTimestampAndTimeInterval(long timestamp, long intervalToElement) {
                HistogramElement targetElement = getClosestElementFromTimestamp(timestamp);
                HistogramElement newElement = getClosestElementByElementAndTimeInterval(targetElement, intervalToElement);
                
@@ -383,7 +384,7 @@ public class HistogramContent {
         * 
         * @return      The <i>closest</i> found element, or null if given data are wrong.
         */
-       public int getXPositionByPositionAndTimeInterval(int targetPosition, Long intervalToElement) {
+       public int getXPositionByPositionAndTimeInterval(int targetPosition, long intervalToElement) {
                HistogramElement targetElement = getClosestElementFromXPosition(targetPosition);
                HistogramElement newElement = getClosestElementByElementAndTimeInterval(targetElement, intervalToElement);
                
@@ -456,7 +457,7 @@ public class HistogramContent {
         * 
         * @return The start time we currently use.
         */
-       public Long getStartTime() {
+       public long getStartTime() {
                return startTime;
        }
        
@@ -466,7 +467,7 @@ public class HistogramContent {
         * 
         * @param newStartTime  the new start time
         */
-       public void setStartTime(Long newStartTime) {
+       public void setStartTime(long newStartTime) {
                this.startTime = newStartTime;
        }
        
@@ -476,7 +477,7 @@ public class HistogramContent {
         * 
         * @return The end time we currently use.
         */
-       public Long getEndTime() {
+       public long getEndTime() {
                return endTime;
        }
        
@@ -486,7 +487,7 @@ public class HistogramContent {
         * 
         * @param newStartTime  the new end time
         */
-       public void setEndTime(Long newEndTime) {
+       public void setEndTime(long newEndTime) {
                this.endTime = newEndTime;
        }
        
@@ -496,7 +497,7 @@ public class HistogramContent {
         * 
         * @return      The complete time interval
         */
-       public Long getCompleteTimeInterval() {
+       public long getCompleteTimeInterval() {
                return ( endTime - startTime );
        }
        
@@ -506,7 +507,7 @@ public class HistogramContent {
         * 
         * @return      The time interval of the position that are ready.
         */
-       public Long getReadyTimeInterval() {
+       public long getReadyTimeInterval() {
                return ( elementTable[readyUpToPosition].firstIntervalTimestamp - elementTable[0].firstIntervalTimestamp );
        }
        
@@ -516,7 +517,7 @@ public class HistogramContent {
         * 
         * @return      Height factor currently used. 
         */
-       public Double getHeightFactor() {
+       public double getHeightFactor() {
                return heightFactor;
        }
        
@@ -528,7 +529,8 @@ public class HistogramContent {
                // Recalculate the new HeightFactor for the element; 
                //              the highest bar will get "maxHeight" and other bar a fraction of it.
                double diffToConsider = (maxDifferenceToAverage * maxDifferenceFactor * (double)barsWidth);
-               if ( heighestEventCount > (int)(diffToConsider * (double)averageNumberOfEvents) ) {
+               
+               if ( heighestEventCount > (long)(diffToConsider * (double)averageNumberOfEvents) ) {
                        heightFactor = (double)maxHeight/( diffToConsider * (double)averageNumberOfEvents);
                }
                else {
@@ -555,7 +557,7 @@ public class HistogramContent {
         * Unlike recalculateEventHeight(), this only recalculate for the given range, not the whole table.
         * 
         */
-       public void recalculateEventHeightInInterval(Integer startPosition, Integer stopPosition) {
+       public void recalculateEventHeightInInterval(int startPosition, int stopPosition) {
                // Basic error checking on start : should be bigger than 0
                if ( startPosition < 0 ) {
                        startPosition = 0;
@@ -578,7 +580,7 @@ public class HistogramContent {
         * 
         * @return      Size of the canvas we currently use.
         */
-       public Integer getCanvasWindowSize() {
+       public int getCanvasWindowSize() {
                return canvasWindowSize;
        }
        
@@ -588,7 +590,7 @@ public class HistogramContent {
         * 
         * @param       newSize New canvas size;
         */
-       public void setCanvasWindowSize(Integer newSize) {
+       public void setCanvasWindowSize(int newSize) {
                canvasWindowSize = newSize;
        }
        
@@ -599,7 +601,7 @@ public class HistogramContent {
         * 
         * @return Current heighestEventCount
         */
-       public Long getHeighestEventCount() {
+       public long getHeighestEventCount() {
                return heighestEventCount;
        }
        
@@ -611,7 +613,7 @@ public class HistogramContent {
         * 
         * @param newHeighestEventCount Heighest event count for a single interval.
         */
-       public void setHeighestEventCount(Long newHeighestEventCount) {
+       public void setHeighestEventCount(long newHeighestEventCount) {
                this.heighestEventCount = newHeighestEventCount;
        }
        
@@ -634,7 +636,7 @@ public class HistogramContent {
         * 
         * @return      maximum height for a bar we currently use.
         */
-       public Integer getMaxHeight() {
+       public int getMaxHeight() {
                return maxHeight;
        }
        
@@ -646,7 +648,7 @@ public class HistogramContent {
         * 
         * @param maxHeight     The new maximum height for a bar to use.
         */
-       public void setMaxHeight(Integer maxHeight) {
+       public void setMaxHeight(int maxHeight) {
                this.maxHeight = maxHeight;
        }
        
@@ -656,7 +658,7 @@ public class HistogramContent {
         * 
         * @return      maximum difference to the average we currently use.
         */
-       public Double getMaxDifferenceToAverage() {
+       public double getMaxDifferenceToAverage() {
                return maxDifferenceToAverage;
        }
        
@@ -669,7 +671,7 @@ public class HistogramContent {
         * 
         * @param newDiffToAverage      The new maximum difference to the average to use.
         */
-       public void setMaxDifferenceToAverage(Double newDiffToAverage) {
+       public void setMaxDifferenceToAverage(double newDiffToAverage) {
                maxDifferenceToAverage = newDiffToAverage;
        }
        
@@ -682,7 +684,7 @@ public class HistogramContent {
         * 
         * @return      maximum difference to the average we currently use.
         */
-       public Double getMaxDifferenceToAverageFactor() {
+       public double getMaxDifferenceToAverageFactor() {
                return maxDifferenceFactor;
        }
        
@@ -695,7 +697,7 @@ public class HistogramContent {
         * 
         * @param newFactor             The new factor to use.
         */
-       public void setMaxDifferenceToAverageFactor(Double newFactor) {
+       public void setMaxDifferenceToAverageFactor(double newFactor) {
                maxDifferenceFactor = newFactor;
        }
        
@@ -706,7 +708,7 @@ public class HistogramContent {
         * 
         * @return      Currently used interval time.
         */
-       public Long getElementsTimeInterval() {
+       public long getElementsTimeInterval() {
                return elementsTimeInterval;
        }
        
@@ -719,7 +721,7 @@ public class HistogramContent {
         * 
         * @return New interval time.
         */
-       public void setElementsTimeInterval(Long newInterval) {
+       public void setElementsTimeInterval(long newInterval) {
                this.elementsTimeInterval = newInterval;
        }
        
@@ -729,8 +731,14 @@ public class HistogramContent {
         * 
         * @return      The complete time interval
         */
-       public void recalculateElementsTimeInterval(Long startTime, Long endTime) {
-               this.elementsTimeInterval = ((endTime - startTime)/getNbElement());
+       public void recalculateElementsTimeInterval(long startTime, long endTime) {
+               long tmpInterval = ((endTime - startTime)/getNbElement());
+               
+               if ( tmpInterval <= 0 ) {
+                       tmpInterval = 1L;
+               }
+               
+               this.elementsTimeInterval = tmpInterval;
        }
        
        
@@ -740,7 +748,7 @@ public class HistogramContent {
         * 
         * @return Last position processed so far.
         */
-       public Integer getReadyUpToPosition() {
+       public int getReadyUpToPosition() {
                return readyUpToPosition;
        }
        
@@ -760,7 +768,7 @@ public class HistogramContent {
         * 
         * @return current bars width;
         */
-       public Integer getBarsWidth() {
+       public int getBarsWidth() {
                return barsWidth;
        }
        
@@ -770,7 +778,7 @@ public class HistogramContent {
         * 
         * @param newBarsWidth new bars width;
         */
-       public void setBarsWidth(Integer newBarsWidth) {
+       public void setBarsWidth(int newBarsWidth) {
                this.barsWidth = newBarsWidth;
        }
        
index a5948699af817f379b8a1447a7e8d9797ceac2eb..eb907d4a9c407b6c3298f83a0cce829818a0eb9d 100644 (file)
@@ -20,8 +20,8 @@ package org.eclipse.linuxtools.lttng.ui.views.histogram;
  * Each "element" should represent a certain time interval
  */
 public class HistogramElement {
-       public Integer index = 0;                                       // Position of the element in the table (table index, obviously)
-       public Long firstIntervalTimestamp = 0L;        // The first timestamp recorded for this interval 
-       public Long intervalNbEvents = 0L;                      // Number of events recorded in this interval
-       public Integer intervalHeight = 0;                      // Height (in the canvas) of this element. Should be smaller than the canvas height.
+       public int index = 0;                                   // Position of the element in the table (table index, obviously)
+       public long firstIntervalTimestamp = 0L;        // The first timestamp recorded for this interval 
+       public long intervalNbEvents = 0L;                      // Number of events recorded in this interval
+       public int intervalHeight = 0;                  // Height (in the canvas) of this element. Should be smaller than the canvas height.
 }
index db8db7cc797d95d3f2de23f6a7326bf7bd6f602c..e2880ad30cdefde5437a1f5a4d51cab7402b471f 100644 (file)
@@ -25,14 +25,14 @@ import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
 public class HistogramRequest extends TmfEventRequest<LttngEvent> {
        protected HistogramContent histogramContent = null;
        
-       protected Integer       lastInterval = 0;
-       protected Long          lastRangeTime = 0L;
-       protected Long          nbEventsInInterval = 1L;
+       protected int   lastInterval = 0;
+       protected long          lastRangeTime = 0L;
+       protected long          nbEventsInInterval = 1L;
        
-       protected Integer       nbIntervalNotEmpty = 1;
-       protected Integer       nbEventRead = 0;
+       protected int   nbIntervalNotEmpty = 1;
+       protected int   nbEventRead = 0;
        
-       protected Integer       lastDrawPosition = 0;
+       protected int   lastDrawPosition = 0;
        
        protected HistogramCanvas parentCanvas = null;
        
@@ -47,7 +47,7 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
         * 
         * @see org.eclipse.linuxtools.tmf.request.TmfEventRequest
         */
-       public HistogramRequest(TmfTimeRange range, Integer nbRequested, HistogramCanvas newParentCanvas, Long timeInterval) {
+       public HistogramRequest(TmfTimeRange range, int nbRequested, HistogramCanvas newParentCanvas, long timeInterval) {
         super((Class<LttngEvent>)LttngEvent.class, range, nbRequested, HistogramConstant.MAX_EVENTS_PER_READ);
         
         // *** FIXME ***
@@ -129,11 +129,11 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
                                // We are still in the same interval, just keep counting
                                else {
                                        nbEventsInInterval++;
-                                       if ( nbEventsInInterval > histogramContent.getHeighestEventCount() ) {
-                                               histogramContent.setHeighestEventCount(nbEventsInInterval);
-                                       }
                                }
                                
+                               if ( nbEventsInInterval > histogramContent.getHeighestEventCount() ) {
+                                       histogramContent.setHeighestEventCount(nbEventsInInterval);
+                               }
                                nbEventRead++;
                                
                                // Call an asynchronous redraw every REDRAW_EVERY_NB_EVENTS events
@@ -202,11 +202,12 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
        // The average number of event is calculated while skipping empty interval if asked
        int averageNumberOfEvents = 0;
        if ( HistogramConstant.SKIP_EMPTY_INTERVALS_WHEN_CALCULATING_AVERAGE ) {
-               averageNumberOfEvents = nbEventRead / nbIntervalNotEmpty;
+               averageNumberOfEvents = (int)Math.ceil((double)nbEventRead / (double)nbIntervalNotEmpty);
        }
        else {
-               averageNumberOfEvents = nbEventRead / histogramContent.getNbElement();
+               averageNumberOfEvents = (int)Math.ceil((double)nbEventRead / (double)histogramContent.getNbElement());
        }
+       
        histogramContent.setAverageNumberOfEvents(averageNumberOfEvents);
        
        // It is possible that the height factor didn't change; 
index 543fba7a6909542ccf93764b90439814761b49d2..75b7390d39ac8fbb9c5ab697021f6cbaf3638836 100644 (file)
@@ -27,8 +27,8 @@ package org.eclipse.linuxtools.lttng.ui.views.histogram;
  */
 public class HistogramSelectedWindow {
        
-       protected Integer windowCenterPosition = 0;
-       protected Long  windowTimeWidth = 0L;
+       protected int windowCenterPosition = 0;
+       protected long  windowTimeWidth = 0L;
        
        protected Boolean isSelectedWindowVisible = false;
        
@@ -52,7 +52,7 @@ public class HistogramSelectedWindow {
         * @param centralPosition       Central X Position of the selection window in the canvas (0 to canvasWidth)
         * @param newWindowWidth        Time width (size) of the window. (0 or greater)
         */
-       public HistogramSelectedWindow(HistogramContent newTraceContent, Integer centralPosition, Long newWindowWidth) {
+       public HistogramSelectedWindow(HistogramContent newTraceContent, int centralPosition, long newWindowWidth) {
                histogramContent = newTraceContent;
                windowCenterPosition = centralPosition;
                windowTimeWidth = newWindowWidth;
@@ -114,7 +114,7 @@ public class HistogramSelectedWindow {
         * 
         * @param newWindowTimeWidth    The new time width
         */
-       public void setWindowTimeWidth(Long newWindowTimeWidth) {
+       public void setWindowTimeWidth(long newWindowTimeWidth) {
                this.windowTimeWidth = newWindowTimeWidth;
        }
        
@@ -134,7 +134,7 @@ public class HistogramSelectedWindow {
         * 
         * @param newPosCenter  The new central position.
         */
-       public void setWindowXPositionCenter(Integer newPosCenter) {
+       public void setWindowXPositionCenter(int newPosCenter) {
                this.windowCenterPosition = newPosCenter;
        }
        
@@ -144,8 +144,15 @@ public class HistogramSelectedWindow {
         * 
         * @return The left position of the window, or 0 if it cannot compute it. 
         */
-       public Integer getWindowXPositionLeft() {
-               return histogramContent.getXPositionByPositionAndTimeInterval(windowCenterPosition, -(windowTimeWidth / 2) );
+       public int getWindowXPositionLeft() {
+               int tmpLeftPosition = histogramContent.getXPositionByPositionAndTimeInterval(windowCenterPosition, -(windowTimeWidth / 2) );
+               if ( (tmpLeftPosition == windowCenterPosition ) && (tmpLeftPosition>0) ) {
+                       tmpLeftPosition = tmpLeftPosition-1;
+               }
+               
+               return tmpLeftPosition;
+               
+               //return histogramContent.getXPositionByPositionAndTimeInterval(windowCenterPosition, -(windowTimeWidth / 2) );
        }
        
        /**
@@ -154,8 +161,16 @@ public class HistogramSelectedWindow {
         * 
         * @return The right position of the window, or 0 if it cannot compute it. 
         */
-       public Integer getWindowXPositionRight() {
-               return histogramContent.getXPositionByPositionAndTimeInterval(windowCenterPosition, +(windowTimeWidth / 2) );
+       public int getWindowXPositionRight() {
+               
+               int tmpRightPosition = histogramContent.getXPositionByPositionAndTimeInterval(windowCenterPosition, +(windowTimeWidth / 2) );
+               if ( (tmpRightPosition == windowCenterPosition ) && (tmpRightPosition<(histogramContent.getNbElement()-1) ) ) {
+                       tmpRightPosition = tmpRightPosition+1;
+               }
+               
+               return tmpRightPosition;
+               
+               //return histogramContent.getXPositionByPositionAndTimeInterval(windowCenterPosition, +(windowTimeWidth / 2) );
        }
        
        /**
@@ -164,7 +179,7 @@ public class HistogramSelectedWindow {
         * 
         * @return  The left timestamp of the window, or 0 if it cannot compute it. 
         */
-       public Long getTimestampLeft() {
+       public long getTimestampLeft() {
                return histogramContent.getClosestElementFromXPosition( getWindowXPositionLeft() ).firstIntervalTimestamp;
        }
        
@@ -174,7 +189,7 @@ public class HistogramSelectedWindow {
         * 
         * @return  The center timestamp of the window, or 0 if it cannot compute it. 
         */
-       public Long getTimestampCenter() {
+       public long getTimestampCenter() {
                return histogramContent.getClosestElementFromXPosition( getWindowXPositionCenter() ).firstIntervalTimestamp;
        }
        
@@ -184,7 +199,7 @@ public class HistogramSelectedWindow {
         * 
         * @return  The right timestamp of the window, or 0 if it cannot compute it. 
         */
-       public Long getTimestampRight() {
+       public long getTimestampRight() {
                return histogramContent.getClosestElementFromXPosition( getWindowXPositionRight() ).firstIntervalTimestamp;
        }
 }
index 4eab98c8a69ed4b727d80120d0cef2f1702cd5c7..3ea9395ef2bc76af2d6f3d728ef1353065e0ffc5 100644 (file)
@@ -80,7 +80,7 @@ public class HistogramView extends TmfView implements ControlListener {
     
     // *** TODO ***
     // This need to be changed as soon the framework implement a "window"
-    private static long DEFAULT_WINDOW_SIZE = (1L * 1000000000);
+    private static long DEFAULT_WINDOW_SIZE = (1L * 100 * 1000 * 1000); // 0.1sec
     
     // The last experiment received/used by the view
     private TmfExperiment<LttngEvent> lastUsedExperiment = null;
@@ -99,9 +99,9 @@ public class HistogramView extends TmfView implements ControlListener {
     // Content of the timeTextGroup
     // Since the user can modify them with erroneous value, 
     // we will keep track of the value internally 
-       private Long selectedWindowTime = 0L;
-       private Long selectedWindowTimerange = 0L;
-       private Long currentEventTime = 0L;
+       private long selectedWindowTime = 0L;
+       private long selectedWindowTimerange = 0L;
+       private long currentEventTime = 0L;
        
     // *** All the UI control below
        //
@@ -311,14 +311,14 @@ public class HistogramView extends TmfView implements ControlListener {
                //
                // *** SUB-HACK ***
                // Other interesting fact about SWT : the way it draws (Fill/Expand control in grid) will change if 
-               //              the control is a Text of a Label. 
+               //              the control is a Text or a Label. 
                // A Label here will be "pushed" by startTime/stopTime Text and won't fill the full space as NbEventText.
                // A Text  here will NOT be "pushed" and would give a nice visual output.
                //              (NB : No, I am NOT kidding, try it for yourself!)
                //
                // Soooooo I guess I will use a Text here. Way to go SWT!
                // Downside is that disabled textbox has a slightly different color (even if you change it) so if I want
-               //              to make the text "invisible", I have to keep it editable, so it can be selected.
+               //              to make the text "invisible", I have to keep it selectable, so it can be clicked on.
                //
                // Label uselessControlToByPassSWTStupidBug = new Label(layoutSelectionWindow, SWT.BORDER); // WON'T align correctly!!!
                Text uselessControlToByPassSWTStupidBug = new Text(layoutSelectionWindow, SWT.READ_ONLY); // WILL align correctly!!!
@@ -445,27 +445,61 @@ public class HistogramView extends TmfView implements ControlListener {
             
             // If the given event is outside the selection window, recenter the window
             if ( isGivenTimestampInSelectedWindow( currentEventTime ) == false) {
-               fullExperimentCanvas.centerWindow( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(currentEventTime) );
+               fullExperimentCanvas.setWindowCenterPosition( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(currentEventTime) );
                // Notify control that the window changed
                windowChangedNotification();
+               // Send a broadcast to the framework about the window change
+                       sendTmfRangeSynchSignalBroadcast();
             }
        }
     }
     
+    @TmfSignalHandler
+       public void synchToTimeRange(TmfRangeSynchSignal signal) {
+               if ( (signal != null) && (signal.getSource() != this) ) {
+                       if ( lastUsedExperiment != null ) {
+                               long currentTime                = signal.getCurrentTime().getValue();
+                               long windowStart                = signal.getCurrentRange().getStartTime().getValue();
+                               long windowEnd                  = signal.getCurrentRange().getEndTime().getValue();
+                               long windowTimeWidth    = (windowEnd - windowStart); 
+                               
+                               // Recenter the window
+                               fullExperimentCanvas.setWindowCenterPosition( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(windowStart + (windowTimeWidth/2)) );
+                               fullExperimentCanvas.setSelectedWindowSize(windowTimeWidth);
+                               
+                               // *** HACK ***
+                               // Views could send us incorrect current event value (event outside the current window)
+                               // Here we make sure the value is sane, otherwise, we force it as the left border of the window
+                               if ( isGivenTimestampInSelectedWindow( currentTime ) == false ) {
+                                       currentTime = windowStart;
+                               }
+                               currentEventTime = currentTime;
+                               
+                               // Notify control that the window changed
+               windowChangedNotification();
+               
+               fullExperimentCanvas.redraw();
+               selectedWindowCanvas.redraw();
+                       }
+               }
+       }
+    
+    
     /*
      * Create the canvas needed and issue the requests
      * 
      * @param newExperiment    Experiment we will use for the request
      */
     private void createCanvasAndRequests(TmfExperiment<LttngEvent> newExperiment) {
-       lastUsedExperiment = newExperiment;
        
        TmfExperiment<LttngEvent> experimentCopy = newExperiment.createTraceCopy();
+       lastUsedExperiment = experimentCopy;
        
        // Create the content for the full experiment. 
        // This NEED to be created first, as we use it in the selectedWindowCanvas
                fullExperimentCanvas.createNewHistogramContent(fullExperimentCanvas.getSize().x, FULL_TRACE_BAR_WIDTH, FULL_TRACE_CANVAS_HEIGHT, FULL_TRACE_DIFFERENCE_TO_AVERAGE);
                fullExperimentCanvas.createNewSelectedWindow(DEFAULT_WINDOW_SIZE);
+               currentEventTime = newExperiment.getStartTime().getValue();
        // Set the window of the fullTrace canvas visible.
                fullExperimentCanvas.getCurrentWindow().setSelectedWindowVisible(true);
                fullExperimentCanvas.getHistogramContent().resetTable(newExperiment.getStartTime().getValue(), newExperiment.getEndTime().getValue());
@@ -474,9 +508,10 @@ public class HistogramView extends TmfView implements ControlListener {
                selectedWindowCanvas.createNewHistogramContent(selectedWindowCanvas.getSize().x ,SELECTED_WINDOW_BAR_WIDTH, SELECTED_WINDOW_CANVAS_HEIGHT, SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE);
                selectedWindowCanvas.getHistogramContent().resetTable(fullExperimentCanvas.getCurrentWindow().getTimestampLeft(), fullExperimentCanvas.getCurrentWindow().getTimestampRight());
                
-               // Make sure the UI object are sane
+       // Make sure the UI object are sane
                resetControlsContent();
                
+               
                // Redraw the canvas right away to have something "clean" as soon as we can
        if ( dataBackgroundFullRequest != null ) {
                fullExperimentCanvas.redraw();
@@ -573,7 +608,7 @@ public class HistogramView extends TmfView implements ControlListener {
        
         // *** FIXME ***
         // EVIL BUG!
-           // We use integer.MAX_VALUE because we want every events BUT we don't know the number inside the range.
+           // We use int.MAX_VALUE because we want every events BUT we don't know the number inside the range.
         // HOWEVER, this would cause the request to run forever (or until it reach the end of trace).
         // Seeting an EndTime does not seems to stop the request
         returnedRequest = new HistogramRequest(newRange, Integer.MAX_VALUE, targetCanvas, newInterval );
@@ -603,14 +638,11 @@ public class HistogramView extends TmfView implements ControlListener {
                selectedWindowTimerange = fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth();
                
                // If the current event time is outside the new window, change the current event
-               //              The new current event will be the one closest to the center of the new window
+               //              The new current event will be the one closest to the LEFT side of the new window
                if ( isGivenTimestampInSelectedWindow(currentEventTime) == false ) {
-                       currentEventChangeNotification( selectedWindowTime );
+                       currentEventChangeNotification( fullExperimentCanvas.getCurrentWindow().getTimestampLeft() );
                }
                
-               // Tell the framework that the timerange (time window) changed
-               currentTimerangeChangeNotification();
-               
                // Perform a new request to read data about the new window
                performSelectedWindowEventsRequest(lastUsedExperiment);
        }
@@ -625,7 +657,8 @@ public class HistogramView extends TmfView implements ControlListener {
      * 
      * @param newCurrentEventTime
      */
-    public void currentEventChangeNotification(Long newCurrentEventTime) {
+    public void currentEventChangeNotification(long newCurrentEventTime) {
+       
        // Notify other views in the framework
         if (currentEventTime != newCurrentEventTime) {
                currentEventTime = newCurrentEventTime;
@@ -634,22 +667,56 @@ public class HistogramView extends TmfView implements ControlListener {
                updateSelectedEventTime();
                
                // Send a signal to the framework
-            LttngTimestamp tmpTimestamp = new LttngTimestamp(newCurrentEventTime);
-            broadcast(new TmfTimeSynchSignal(this, tmpTimestamp));
+               //sendTmfTimeSynchSignalBroadcast();
         }
     }
     
+    public void sendTmfTimeSynchSignalBroadcast() {
+       
+//     System.out.println("sendTmfTimeSynchSignalBroadcast " + System.currentTimeMillis());
+       
+       // Send a signal to the framework
+        LttngTimestamp tmpTimestamp = new LttngTimestamp(currentEventTime);
+        broadcast(new TmfTimeSynchSignal(this, tmpTimestamp));
+    }
+    
     /**
      * Function used to tell that the timerange (window) changed.<p>
      * This will most likely be called if the time window is resized.
      * 
      * We send a signal to notify other views of the new timerange.
      */
-    public void currentTimerangeChangeNotification() {
-        LttngTimestamp tmpStartTime = new LttngTimestamp(fullExperimentCanvas.getCurrentWindow().getTimestampLeft());
-        LttngTimestamp tmpEndTime = new LttngTimestamp(fullExperimentCanvas.getCurrentWindow().getTimestampRight());
+    public void sendTmfRangeSynchSignalBroadcast() {
+       
+//     System.out.println("sendTmfRangeSynchSignalBroadcast " + System.currentTimeMillis());
+       
+       // *** TODO ***
+       // Not very elegant... we need to chance this below.
+       //
+       
+       long centerTime = fullExperimentCanvas.getCurrentWindow().getTimestampCenter();
+       long windowWidth = fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth();
+       
+       long startTime = centerTime-windowWidth;
+       if ( startTime < fullExperimentCanvas.getHistogramContent().getStartTime() ) {
+               startTime = fullExperimentCanvas.getHistogramContent().getStartTime();
+       }
+        LttngTimestamp tmpStartTime = new LttngTimestamp(startTime);
+        
+        long endTime = centerTime+windowWidth;
+       if ( endTime > fullExperimentCanvas.getHistogramContent().getEndTime() ) {
+               endTime = fullExperimentCanvas.getHistogramContent().getEndTime();
+       }
+       LttngTimestamp tmpEndTime = new LttngTimestamp(endTime);
+        
+       /*
+       LttngTimestamp tmpStartTime = new LttngTimestamp(fullExperimentCanvas.getCurrentWindow().getTimestampLeft());
+       LttngTimestamp tmpEndTime = new LttngTimestamp(fullExperimentCanvas.getCurrentWindow().getTimestampRight());
+       */
+       
         TmfTimeRange tmpTimeRange = new TmfTimeRange(tmpStartTime, tmpEndTime);
         LttngTimestamp tmpEventTime = new LttngTimestamp(currentEventTime);
+        
         // Send a signal to the framework
         broadcast(new TmfRangeSynchSignal(this, tmpTimeRange, tmpEventTime));
     }
@@ -661,20 +728,24 @@ public class HistogramView extends TmfView implements ControlListener {
     public void timeTextGroupChangeNotification() {
        
        // Get all the time text group value
-       Long newCurrentTime = ntgCurrentEventTime.getValue();
-       Long newSelectedWindowTime = ntgCurrentWindowTime.getValue();
-       Long newSelectedWindowTimeRange = ntgTimeRangeWindow.getValue();
+       long newCurrentTime = ntgCurrentEventTime.getValue();
+       long newSelectedWindowTime = ntgCurrentWindowTime.getValue();
+       long newSelectedWindowTimeRange = ntgTimeRangeWindow.getValue();
        
        // If the user changed the current event time, call the notification
        if ( newCurrentTime != currentEventTime ) {
                currentEventChangeNotification( newCurrentTime );
+               // Send a broadcast to the framework about the window change
+               sendTmfTimeSynchSignalBroadcast();
        }
        
        // If the user changed the selected window time, recenter the window and call the notification
        if ( newSelectedWindowTime != selectedWindowTime ) {
                selectedWindowTime = newSelectedWindowTime;
-               fullExperimentCanvas.centerWindow( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(selectedWindowTime) );
+               fullExperimentCanvas.setWindowCenterPosition( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(selectedWindowTime) );
                windowChangedNotification();
+               // Send a broadcast to the framework about the window change
+               sendTmfRangeSynchSignalBroadcast();
        }
        
        // If the user changed the selected window size, resize the window and call the notification
@@ -682,6 +753,8 @@ public class HistogramView extends TmfView implements ControlListener {
                selectedWindowTimerange = newSelectedWindowTimeRange;
                fullExperimentCanvas.resizeWindowByAbsoluteTime(selectedWindowTimerange);
                windowChangedNotification();
+               // Send a broadcast to the framework about the window change
+               sendTmfRangeSynchSignalBroadcast();
        }
        
     }
@@ -704,7 +777,7 @@ public class HistogramView extends TmfView implements ControlListener {
         * 
         * @return      if the time is inside the selection window or not
         */
-       public boolean isGivenTimestampInSelectedWindow(Long timestamp) {
+       public boolean isGivenTimestampInSelectedWindow(long timestamp) {
                boolean returnedValue = true;
                
                // If the content is not set correctly, this will return weird (or even null) result
@@ -781,8 +854,8 @@ public class HistogramView extends TmfView implements ControlListener {
                // Update the timestamp as well
                updateSelectedWindowTimestamp();
                
-               txtWindowMaxNbEvents.setText( selectedWindowCanvas.getHistogramContent().getHeighestEventCount().toString() );
-               txtWindowMinNbEvents.setText("0");
+               txtWindowMaxNbEvents.setText( Long.toString(selectedWindowCanvas.getHistogramContent().getHeighestEventCount()) );
+               txtWindowMinNbEvents.setText(Long.toString(0));
                
                // Refresh the layout
                txtWindowMaxNbEvents.getParent().layout();
@@ -846,10 +919,9 @@ public class HistogramView extends TmfView implements ControlListener {
        public void controlResized(ControlEvent event) {
                
                // Ouch! The screen enlarged (screen resolution changed?) so far that we miss content to fill the space.
-               // Perform a new full request... this is quite heavy.
                if ( parent.getDisplay().getBounds().width > fullExperimentCanvas.getHistogramContent().getNbElement() ) {
                        if ( lastUsedExperiment != null ) {
-                               performAllTraceEventsRequest(lastUsedExperiment);
+                               createCanvasAndRequests(lastUsedExperiment);
                        }
                }
                
index 4344c1c7f05e250b8fc8115f1482ef4230b22616..cb2ce61ddcf698d96868bc710fe5b4f504b3a664 100644 (file)
@@ -31,7 +31,7 @@ public class ParentHistogramCanvas extends HistogramCanvas {
         * @param parent                Composite control which will be the parent of the new instance (cannot be null)
         * @param                               Style the style of control to construct
         */
-       public ParentHistogramCanvas(HistogramView newParentWindow, Composite parent, Integer style) {
+       public ParentHistogramCanvas(HistogramView newParentWindow, Composite parent, int style) {
                super(parent, style);
                
                parentHistogramWindow = newParentWindow;
@@ -51,7 +51,7 @@ public class ParentHistogramCanvas extends HistogramCanvas {
         * @param maxBarsDifferenceToAverage    Factor used to "chop" bars that are too tall. Set to something big (100.0?) if not needed.
         */
        @Override
-       public void createNewHistogramContent(Integer canvasSize, Integer widthPerBar, Integer barsHeight, Double maxBarsDifferenceToAverage) {
+       public void createNewHistogramContent(int canvasSize, int widthPerBar, int barsHeight, double maxBarsDifferenceToAverage) {
                
                // *** FIXME ***
                // Note there MIGHT be some unhandled case, like if the resolution of the screen change 
@@ -101,10 +101,10 @@ public class ParentHistogramCanvas extends HistogramCanvas {
         * @param newRelativeXPosition  New position relative to the last known absolute position.
         */
        @Override
-       public void moveWindow(Integer newRelativeXPosition) {
+       public void moveWindow(int newRelativeXPosition) {
                int absolutePosition = currentWindow.getWindowXPositionCenter() + newRelativeXPosition;
                
-               centerWindow(absolutePosition);
+               setWindowCenterPosition(absolutePosition);
                notifyParentSelectionWindowChangedAsynchronously();
        }
        
@@ -117,7 +117,7 @@ public class ParentHistogramCanvas extends HistogramCanvas {
         * @param newRelativeXPosition  New absolute position.
         */
        @Override
-       public void centerWindow(Integer newAbsoluteXPosition) {
+       public void setWindowCenterPosition(int newAbsoluteXPosition) {
                
                if ( newAbsoluteXPosition < 0 ) {
                        newAbsoluteXPosition = 0;
@@ -141,7 +141,7 @@ public class ParentHistogramCanvas extends HistogramCanvas {
         * @param newTime        New absoulte time (in nanoseconds) to apply to the window.
         */
        @Override
-       public void resizeWindowByAbsoluteTime(Long newTime) {
+       public void resizeWindowByAbsoluteTime(long newTime) {
                if ( newTime != getSelectedWindowSize() ) {
                        setSelectedWindowSize(newTime);
                        
@@ -167,5 +167,7 @@ public class ParentHistogramCanvas extends HistogramCanvas {
        public void notifyParentSelectionWindowChanged() {
                // Notify the parent view that something changed
                parentHistogramWindow.windowChangedNotification();
+               // Send a broadcast to the framework about the window change
+               parentHistogramWindow.sendTmfRangeSynchSignalBroadcast();
        }
 }
index 1ea696401d462df71a612f6597af3cd2b4214ea5..ab9eb6910b8b93a0d85c8edd3546d34dda0de537 100644 (file)
@@ -129,7 +129,7 @@ public class ParentHistogramCanvasPaintListener extends HistogramCanvasPaintList
                //      here because the window might have been resized!
                int exp = (int)Math.floor( Math.log( (double)tmpContent.getCanvasWindowSize() ) / Math.log(2.0) );
                int contentSize = (int)Math.pow(2, exp);
-               Double maxBarsDiffFactor = ((double)tmpContent.getNbElement() / (double)contentSize );
+               double maxBarsDiffFactor = ((double)tmpContent.getNbElement() / (double)contentSize );
                
                if ( maxBarsDiffFactor != tmpContent.getMaxDifferenceToAverageFactor() ) {
                        // The factor changed! That's unfortunate because it will take a while to recalculate.
index ae03c64e0435021e5a4376bc46573e01c9decbe9..1c887aa6623db15f9cbc2db2a1fa6837981b4356 100644 (file)
@@ -38,14 +38,14 @@ public class TimeTextGroup implements FocusListener, KeyListener {
        
        protected static final String   NANOSEC_LABEL = "sec";
        protected static final String   LONGEST_STRING_VALUE = "." + Long.MAX_VALUE;
-       protected static final Integer  MAX_CHAR_IN_TEXTBOX = LONGEST_STRING_VALUE.length();
+       protected static final int      MAX_CHAR_IN_TEXTBOX = LONGEST_STRING_VALUE.length();
     
     // The "small font" height used to display time will be "default font" minus this constant
-       protected static final Integer VERY_SMALL_FONT_MODIFIER = 2;
-    protected static final Integer SMALL_FONT_MODIFIER = 1;
+       protected static final int VERY_SMALL_FONT_MODIFIER = 2;
+    protected static final int SMALL_FONT_MODIFIER = 1;
     
     // Indentation size 
-    protected static final Integer DEFAULT_INDENT_SIZE = 10;
+    protected static final int DEFAULT_INDENT_SIZE = 10;
     
     protected HistogramView parentView = null;
     protected AsyncTimeTextGroupRedrawer asyncRedrawer = null;
@@ -54,7 +54,7 @@ public class TimeTextGroup implements FocusListener, KeyListener {
     protected Text     txtNanosec      = null;
     protected Label lblNanosec         = null;
     
-    protected Long     timeValue       = 0L; 
+    protected long     timeValue       = 0L; 
     
     /**
      * Default Constructor.<p>
@@ -225,19 +225,19 @@ public class TimeTextGroup implements FocusListener, KeyListener {
      * 
      * @return The nanoseconds time value
      */
-    public Long getValue() {
+    public long getValue() {
        return timeValue;
     }
     
     /**
      * Set a new String value to the control.<p>
-     * Note : The String value will be converted in Long before being applied;
+     * Note : The String value will be converted in long before being applied;
      *                         if any conversion error occur, 0 will be used. <p>
      * 
      * @param newTimeAsString  The value to convert and set.
      */
     public void setValue(String newTimeAsString) {
-       Long timeAsLong = HistogramConstant.convertStringToNanoseconds(newTimeAsString);
+       long timeAsLong = HistogramConstant.convertStringToNanoseconds(newTimeAsString);
        setValue( timeAsLong );
     }
     
@@ -248,7 +248,7 @@ public class TimeTextGroup implements FocusListener, KeyListener {
      * 
      * @param newTime  The value to set.
      */
-    public void setValue(Long newTime) {
+    public void setValue(long newTime) {
        timeValue = newTime;
        txtNanosec.setText( HistogramConstant.formatNanoSecondsTime(newTime) );
     }
@@ -260,17 +260,17 @@ public class TimeTextGroup implements FocusListener, KeyListener {
      * @param newTimeAsString  The value to convert and set.
      */
     public void setValueAsynchronously(String newTimeAsString) {
-       Long timeAsLong = HistogramConstant.convertStringToNanoseconds(newTimeAsString);
+       long timeAsLong = HistogramConstant.convertStringToNanoseconds(newTimeAsString);
        setValueAsynchronously( timeAsLong );
     }
     
     /**
      * Set a new String value, asynchronously.<p>
-     * This will call setValue(Long) in async.Exec to avoid Thread Access problem to UI.<p>
+     * This will call setValue(long) in async.Exec to avoid Thread Access problem to UI.<p>
      * 
      * @param newTimeAsString  The value to set.
      */
-    public void setValueAsynchronously(Long newTime) {
+    public void setValueAsynchronously(long newTime) {
        // Set the correct value ASAP
        timeValue = newTime;
        
@@ -293,7 +293,7 @@ public class TimeTextGroup implements FocusListener, KeyListener {
     
     /**
      * Set a new group name (label) for this control, asynchronously.<p>
-     * This will call setValue(Long) in async.Exec to avoid Thread Access problem to UI.<p>
+     * This will call setValue(long) in async.Exec to avoid Thread Access problem to UI.<p>
      * 
      * @param newName  The new name to set.
      */
@@ -335,7 +335,7 @@ public class TimeTextGroup implements FocusListener, KeyListener {
      */
        protected void handleNewStringValue() {
        String valueInText = txtNanosec.getText();
-               Long valueAsLong = HistogramConstant.convertStringToNanoseconds(valueInText);
+               long valueAsLong = HistogramConstant.convertStringToNanoseconds(valueInText);
                
                if ( getValue() != valueAsLong ) {
                        setValue(valueAsLong);
@@ -430,7 +430,7 @@ class AsyncTimeTextGroupRedrawer {
         * 
         * @param newTime       The new time to set
         */
-       public void asynchronousSetValue(Long newTime) {
+       public void asynchronousSetValue(long newTime) {
                final long tmpTime = newTime;
                
                Display display =  parentTimeTextGroup.getParent().getDisplay();
This page took 0.056891 seconds and 5 git commands to generate.