* @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;
* @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();
* @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);
}
*
* @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);
*
* @return Time width (in nanosecond) of the selection window.
*/
- public Long getSelectedWindowSize() {
+ public long getSelectedWindowSize() {
return currentWindow.getWindowTimeWidth();
}
*
* @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());
}
*
* @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
}
*
* @param newRelativeXPosition New absolute position.
*/
- public void centerWindow(Integer newAbsoluteXPosition) {
+ public void setWindowCenterPosition(int newAbsoluteXPosition) {
// Nothing : function is a place holder
}
*
* @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
}
// 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);
}
}
}
*
* @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 ) {
*/
public void mouseMove(MouseEvent event) {
if ( isWindowMoving == true ) {
- parentCanvas.centerWindow(event.x);
+ parentCanvas.setWindowCenterPosition(event.x);
}
}
public void mouseDown(MouseEvent event) {
if ( event.button == 1) {
isWindowMoving = true;
- parentCanvas.centerWindow(event.x);
+ parentCanvas.setWindowCenterPosition(event.x);
}
}
/**
* 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.
*/
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 ) {
}
/**
- * 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
}
// Conversion into decimal seconds
- Double dblMaxTimerange = Double.parseDouble(timeString);
+ double dblMaxTimerange = Double.parseDouble(timeString);
// Conversion into nanoseconds
returnedNumber = (long)(dblMaxTimerange * 1000000000.0);
}
*
* @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++ ) {
* <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;
* @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);
}
* @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;
*
* @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++) {
startTime = 0L;
endTime = 0L;
- elementsTimeInterval = 0L;
- heightFactor = 0.0;
+ elementsTimeInterval = 1L;
+ heightFactor = 100.0;
heighestEventCount = 0L;
readyUpToPosition = 0;
* @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);
}
* @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;
*
* @return The time of the event.
*/
- public Long getSelectedEventTimeInWindow() {
+ public long getSelectedEventTimeInWindow() {
return selectedEventTimeInWindow;
}
*
* @param newPosition The new event time.
*/
- public void setSelectedEventTimeInWindow(Long newTime) {
+ public void setSelectedEventTimeInWindow(long newTime) {
this.selectedEventTimeInWindow = newTime;
}
*
* @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) ) {
*
* @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) );
*
* @return The <i>closest</i> timestamp found.
*/
- public Long getClosestTimestampFromXPosition(Integer position) {
+ public long getClosestTimestampFromXPosition(int position) {
return getClosestElementFromXPosition(position).firstIntervalTimestamp;
}
*
* @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)
*
* @return The <i>closest</i> position found.
*/
- public Integer getClosestXPositionFromTimestamp(Long timestamp) {
+ public int getClosestXPositionFromTimestamp(long timestamp) {
return getXPositionFromElement(getClosestElementFromTimestamp(timestamp));
}
*
* @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);
*
* @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);
*
* @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);
*
* @return The start time we currently use.
*/
- public Long getStartTime() {
+ public long getStartTime() {
return startTime;
}
*
* @param newStartTime the new start time
*/
- public void setStartTime(Long newStartTime) {
+ public void setStartTime(long newStartTime) {
this.startTime = newStartTime;
}
*
* @return The end time we currently use.
*/
- public Long getEndTime() {
+ public long getEndTime() {
return endTime;
}
*
* @param newStartTime the new end time
*/
- public void setEndTime(Long newEndTime) {
+ public void setEndTime(long newEndTime) {
this.endTime = newEndTime;
}
*
* @return The complete time interval
*/
- public Long getCompleteTimeInterval() {
+ public long getCompleteTimeInterval() {
return ( endTime - startTime );
}
*
* @return The time interval of the position that are ready.
*/
- public Long getReadyTimeInterval() {
+ public long getReadyTimeInterval() {
return ( elementTable[readyUpToPosition].firstIntervalTimestamp - elementTable[0].firstIntervalTimestamp );
}
*
* @return Height factor currently used.
*/
- public Double getHeightFactor() {
+ public double getHeightFactor() {
return heightFactor;
}
// 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 {
* 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;
*
* @return Size of the canvas we currently use.
*/
- public Integer getCanvasWindowSize() {
+ public int getCanvasWindowSize() {
return canvasWindowSize;
}
*
* @param newSize New canvas size;
*/
- public void setCanvasWindowSize(Integer newSize) {
+ public void setCanvasWindowSize(int newSize) {
canvasWindowSize = newSize;
}
*
* @return Current heighestEventCount
*/
- public Long getHeighestEventCount() {
+ public long getHeighestEventCount() {
return heighestEventCount;
}
*
* @param newHeighestEventCount Heighest event count for a single interval.
*/
- public void setHeighestEventCount(Long newHeighestEventCount) {
+ public void setHeighestEventCount(long newHeighestEventCount) {
this.heighestEventCount = newHeighestEventCount;
}
*
* @return maximum height for a bar we currently use.
*/
- public Integer getMaxHeight() {
+ public int getMaxHeight() {
return maxHeight;
}
*
* @param maxHeight The new maximum height for a bar to use.
*/
- public void setMaxHeight(Integer maxHeight) {
+ public void setMaxHeight(int maxHeight) {
this.maxHeight = maxHeight;
}
*
* @return maximum difference to the average we currently use.
*/
- public Double getMaxDifferenceToAverage() {
+ public double getMaxDifferenceToAverage() {
return maxDifferenceToAverage;
}
*
* @param newDiffToAverage The new maximum difference to the average to use.
*/
- public void setMaxDifferenceToAverage(Double newDiffToAverage) {
+ public void setMaxDifferenceToAverage(double newDiffToAverage) {
maxDifferenceToAverage = newDiffToAverage;
}
*
* @return maximum difference to the average we currently use.
*/
- public Double getMaxDifferenceToAverageFactor() {
+ public double getMaxDifferenceToAverageFactor() {
return maxDifferenceFactor;
}
*
* @param newFactor The new factor to use.
*/
- public void setMaxDifferenceToAverageFactor(Double newFactor) {
+ public void setMaxDifferenceToAverageFactor(double newFactor) {
maxDifferenceFactor = newFactor;
}
*
* @return Currently used interval time.
*/
- public Long getElementsTimeInterval() {
+ public long getElementsTimeInterval() {
return elementsTimeInterval;
}
*
* @return New interval time.
*/
- public void setElementsTimeInterval(Long newInterval) {
+ public void setElementsTimeInterval(long newInterval) {
this.elementsTimeInterval = newInterval;
}
*
* @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;
}
*
* @return Last position processed so far.
*/
- public Integer getReadyUpToPosition() {
+ public int getReadyUpToPosition() {
return readyUpToPosition;
}
*
* @return current bars width;
*/
- public Integer getBarsWidth() {
+ public int getBarsWidth() {
return barsWidth;
}
*
* @param newBarsWidth new bars width;
*/
- public void setBarsWidth(Integer newBarsWidth) {
+ public void setBarsWidth(int newBarsWidth) {
this.barsWidth = newBarsWidth;
}
* 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.
}
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;
*
* @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 ***
// 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
// 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;
*/
public class HistogramSelectedWindow {
- protected Integer windowCenterPosition = 0;
- protected Long windowTimeWidth = 0L;
+ protected int windowCenterPosition = 0;
+ protected long windowTimeWidth = 0L;
protected Boolean isSelectedWindowVisible = false;
* @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;
*
* @param newWindowTimeWidth The new time width
*/
- public void setWindowTimeWidth(Long newWindowTimeWidth) {
+ public void setWindowTimeWidth(long newWindowTimeWidth) {
this.windowTimeWidth = newWindowTimeWidth;
}
*
* @param newPosCenter The new central position.
*/
- public void setWindowXPositionCenter(Integer newPosCenter) {
+ public void setWindowXPositionCenter(int newPosCenter) {
this.windowCenterPosition = newPosCenter;
}
*
* @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) );
}
/**
*
* @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) );
}
/**
*
* @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;
}
*
* @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;
}
*
* @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;
}
}
// *** 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;
// 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
//
//
// *** 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!!!
// 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());
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();
// *** 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 );
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);
}
*
* @param newCurrentEventTime
*/
- public void currentEventChangeNotification(Long newCurrentEventTime) {
+ public void currentEventChangeNotification(long newCurrentEventTime) {
+
// Notify other views in the framework
if (currentEventTime != newCurrentEventTime) {
currentEventTime = newCurrentEventTime;
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));
}
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
selectedWindowTimerange = newSelectedWindowTimeRange;
fullExperimentCanvas.resizeWindowByAbsoluteTime(selectedWindowTimerange);
windowChangedNotification();
+ // Send a broadcast to the framework about the window change
+ sendTmfRangeSynchSignalBroadcast();
}
}
*
* @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
// 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();
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);
}
}
* @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;
* @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
* @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();
}
* @param newRelativeXPosition New absolute position.
*/
@Override
- public void centerWindow(Integer newAbsoluteXPosition) {
+ public void setWindowCenterPosition(int newAbsoluteXPosition) {
if ( newAbsoluteXPosition < 0 ) {
newAbsoluteXPosition = 0;
* @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);
public void notifyParentSelectionWindowChanged() {
// Notify the parent view that something changed
parentHistogramWindow.windowChangedNotification();
+ // Send a broadcast to the framework about the window change
+ parentHistogramWindow.sendTmfRangeSynchSignalBroadcast();
}
}
// 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.
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;
protected Text txtNanosec = null;
protected Label lblNanosec = null;
- protected Long timeValue = 0L;
+ protected long timeValue = 0L;
/**
* Default Constructor.<p>
*
* @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 );
}
*
* @param newTime The value to set.
*/
- public void setValue(Long newTime) {
+ public void setValue(long newTime) {
timeValue = newTime;
txtNanosec.setText( HistogramConstant.formatNanoSecondsTime(newTime) );
}
* @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;
/**
* 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.
*/
*/
protected void handleNewStringValue() {
String valueInText = txtNanosec.getText();
- Long valueAsLong = HistogramConstant.convertStringToNanoseconds(valueInText);
+ long valueAsLong = HistogramConstant.convertStringToNanoseconds(valueInText);
if ( getValue() != valueAsLong ) {
setValue(valueAsLong);
*
* @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();