+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Sanghyun Lee <sanghyunnim.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.timeline.common;
-
-import java.awt.Color;
-
-
-public class TempConstants {
- public static final int NOT_INITED = -1;
- public static final int DEFAULT_SCALE = 0;
- public static final int MAX_SCALE = 2;
- public static final int MIN_SELECTION_HALF_WIDTH_PX = 1;
-
- public static int currentScaleValue = DEFAULT_SCALE;
- public static int oriScaleValue = DEFAULT_SCALE;
-
- public static final int oneTickPx = 5;
- public static int timetickWidthPx = NOT_INITED;
-
- public static int startPx = 0;
- public static int endPx = NOT_INITED;
-
- public static int originalEndPx = NOT_INITED;
- public static int chartRunningSec = NOT_INITED;
-
- public static boolean scaleChanged = false;
- public static boolean allowRedrawTimeTickCanvas = true;
-
- public enum EnumScaleSec {
- SCALE_0(10), SCALE_1(5), SCALE_2(1);
- private int scaleSec;
- private EnumScaleSec(int scaleValue) {
- this.scaleSec = scaleValue;
- }
-
- public int getScaleSec() {
- return scaleSec;
- }
- }
-
- public static final double WIFI_SET_VALUE = 0.97;
- public static final double BT_SET_VALUE = 0.92;
- public static final double GPS_SET_VALUE = 0.87;
- public static final double DNET_SET_VALUE = 0.82;
- public static final double CALL_SET_VALUE = 0.77;
- public static final double CLEAR_VALUE = Double.NaN;
-
- public static final int JFREE_MIN_SIZE = 300;
-
- public static boolean isSnapshotChartDisposed = false;
-
- public static final String LIFECYCLE_API_NAME_CREATE = "usercallback_app_create"; //$NON-NLS-1$
- public static final String LIFECYCLE_API_NAME_TERMINATE = "usercallback_app_terminate"; //$NON-NLS-1$
- public static final String LIFECYCLE_API_NAME_PAUSE = "usercallback_app_pause"; //$NON-NLS-1$
- public static final String LIFECYCLE_API_NAME_RESUME = "usercallback_app_resume"; //$NON-NLS-1$
- public static final String LIFECYCLE_API_NAME_SERVICE = "usercallback_app_service"; //$NON-NLS-1$
-
- public static final int LIFECYCLE_CREATE = 0;
- public static final int LIFECYCLE_TERMINATE = 1;
- public static final int LIFECYCLE_PAUSE = 2;
- public static final int LIFECYCLE_RESUME = 3;
- public static final int LIFECYCLE_SERVICE = 4;
-
- public static final Color LIFECYCLE_COLOR_CREATE = new Color(48, 69, 50);
- public static final Color LIFECYCLE_COLOR_TERMINATE = new Color(57, 48, 76);
- public static final Color LIFECYCLE_COLOR_PAUSE = new Color(86, 56, 57);
- public static final Color LIFECYCLE_COLOR_RESUME = new Color(47, 64, 77);
- public static final Color LIFECYCLE_COLOR_SERVICE = new Color(66, 67, 68);
-
- public static long TOTAL_MEMORY = 90;
- public static boolean SUPPORT_WIFI = false;
- public static boolean SUPPORT_BLUETOOTH = false;
- public static boolean SUPPORT_GPS = false;
-
- public static double chartRangeRatio = 0.85;
-}
graphComposite.setLayoutData(graphCompLayoutData);
graphComposite.setBackground(ColorResources.WHITE);
- timeTickCanvas = new Canvas(graphComposite, SWT.DOUBLE_BUFFERED
- | SWT.TRANSPARENT);
+ timeTickCanvas = new Canvas(graphComposite, SWT.DOUBLE_BUFFERED | SWT.TRANSPARENT);
timelineMaster.setTimeTickCanvas(timeTickCanvas);
timeTickCanvas.setLayoutData(layoutData);
@Override
public void paintControl(PaintEvent e) {
gc = e.gc;
- int x, y, w, h;
+ final int x, y, w, h;
Rectangle timeTickRect = timeTickCanvas.getClientArea();
x = timeTickRect.x;
y = timeTickRect.y;
- TimelineGlobalVriable.timetickWidthPx = w = timeTickRect.width;
+ TimelineGlobalVariable.timetickWidthPx = w = timeTickRect.width;
h = timeTickRect.height;
gc.setBackground(ColorResources.TABLE_HEADER_BG);
gc.fillRectangle(x, y, w, h);
gc.setFont(FontResources.TIMELINE_TICK_FONT);
- int timeStringWidthPx = (gc.getCharWidth('0') * 4
- + gc.getCharWidth(':') + 1);
+ int timeStringWidthPx = (gc.getCharWidth('0') * 4 + gc.getCharWidth(':') + 1);
int halfStringWidth = (int) Math.round(timeStringWidthPx / 2.0);
gc.drawLine(x, y + h - 1, x + w, y + h - 1);
}
int oneTickPx = TimelineConstants.ONE_TICK_PIXEL;
- int scaleSec = TimelineGlobalVriable.EnumScaleSec.values()[TimelineGlobalVriable.currentScaleValue]
- .getScaleSec();
-
- int originalScaleSec = TimelineGlobalVriable.EnumScaleSec.values()[TimelineGlobalVriable.oriScaleValue]
- .getScaleSec();
- int chartRunningPx = timelineMaster
- .getPxBySec(TimelineGlobalVriable.chartRunningSec);
-
- TimelineGlobalVriable.oriScaleValue = TimelineGlobalVriable.currentScaleValue;
- TimelineGlobalVriable.originalEndPx = (int) Math
- .round((double) TimelineGlobalVriable.originalEndPx
- * originalScaleSec / scaleSec);
- if (TimelineGlobalVriable.scaleChanged) {
- TimelineGlobalVriable.scaleChanged = false;
- int tempEndPx = (int) Math
- .round((double) TimelineGlobalVriable.endPx
- * originalScaleSec / scaleSec);
- tempEndPx = tempEndPx < TimelineGlobalVriable.originalEndPx ? tempEndPx
- : TimelineGlobalVriable.originalEndPx;
- TimelineGlobalVriable.startPx = tempEndPx - w;
- if (TimelineGlobalVriable.startPx < 0) {
- TimelineGlobalVriable.startPx = 0;
+ int currentScaleSec = TimelineGlobalVariable.EnumScaleSec.values()[TimelineGlobalVariable.currentScaleValue].getScaleSec();
+
+ int originalScaleSec = TimelineGlobalVariable.EnumScaleSec.values()[TimelineGlobalVariable.oriScaleValue].getScaleSec();
+ int chartRunningPx = timelineMaster.getPxBySec(TimelineGlobalVariable.chartRunningSec);
+
+ TimelineGlobalVariable.oriScaleValue = TimelineGlobalVariable.currentScaleValue;
+ TimelineGlobalVariable.originalEndPx = (int) Math.round((double) TimelineGlobalVariable.originalEndPx * originalScaleSec / currentScaleSec);
+
+ if (TimelineGlobalVariable.scaleChanged) {
+ TimelineGlobalVariable.scaleChanged = false;
+ timelineMaster.setRangeScrollBarStuckState(false);
+
+ int tempMidPx = (int) Math.round((double) (TimelineGlobalVariable.endPx + TimelineGlobalVariable.startPx ) / 2 * originalScaleSec / currentScaleSec);
+ TimelineGlobalVariable.startPx = tempMidPx - w / 2;
+ if (TimelineGlobalVariable.startPx < 0) {
+ TimelineGlobalVariable.startPx = 0;
}
} else {
- TimelineGlobalVriable.startPx = (int) Math
- .round((double) TimelineGlobalVriable.startPx
- * originalScaleSec / scaleSec);
+ TimelineGlobalVariable.startPx = (int) Math.round((double) TimelineGlobalVariable.startPx * originalScaleSec / currentScaleSec);
}
-
- if (timelineMaster.isRangeScrollBarStuck()) {
- if (chartRunningPx > TimelineGlobalVriable.endPx) {
- TimelineGlobalVriable.startPx = chartRunningPx - w;
- }
+
+ if (TimelineGlobalVariable.originalEndPx == TimelineConstants.NOT_INITED) {
+ TimelineGlobalVariable.originalEndPx = w;
+ timelineMaster.setRangeScrollBarMax(w);
+ timelineMaster.setRangeScrollBarSelection(0);
+ timelineMaster.setRangeScrollBarThumb(w);
}
-
- int tempQuotient = TimelineGlobalVriable.startPx / (10 * oneTickPx);
- int tempRemainder = TimelineGlobalVriable.startPx % (10 * oneTickPx);
- int tickOrder = tempRemainder / oneTickPx
- + (tempRemainder % oneTickPx == 0 ? 0 : 1);
- int posXPx = oneTickPx
- - (tempRemainder % oneTickPx == 0 ? oneTickPx
- : tempRemainder % oneTickPx);
-
- long tickLabelValue = scaleSec * tempQuotient
- + (tempRemainder == 0 ? 0 : scaleSec);
- tickLabelValue -= scaleSec;
+
+ TimelineGlobalVariable.endPx = TimelineGlobalVariable.startPx + w;
+ int maxPx = chartRunningPx > TimelineGlobalVariable.originalEndPx ? chartRunningPx : TimelineGlobalVariable.originalEndPx;
+ if(TimelineGlobalVariable.endPx > maxPx) {
+ TimelineGlobalVariable.endPx = maxPx;
+ TimelineGlobalVariable.startPx = maxPx - w;
+ timelineMaster.setRangeScrollBarStuckState(true);
+ }
+
+ if (timelineMaster.isRangeScrollBarStuck() && chartRunningPx > TimelineGlobalVariable.endPx) {
+ TimelineGlobalVariable.startPx = chartRunningPx - w;
+ }
+
+ int tempQuotient = TimelineGlobalVariable.startPx / (10 * oneTickPx);
+ int tempRemainder = TimelineGlobalVariable.startPx % (10 * oneTickPx);
+ int tickOrder = tempRemainder / oneTickPx + (tempRemainder % oneTickPx == 0 ? 0 : 1);
+ int posXPx = oneTickPx - (tempRemainder % oneTickPx == 0 ? oneTickPx : tempRemainder % oneTickPx);
+
+ long tickLabelValue = currentScaleSec * tempQuotient + (tempRemainder == 0 ? 0 : currentScaleSec);
+ tickLabelValue -= currentScaleSec;
while (posXPx < w) {
tickOrder = tickOrder % 10;
int tickLineHeight = 2;
if (tickOrder == 0) {
tickLineHeight = 6;
- tickLabelValue += scaleSec;
+ tickLabelValue += currentScaleSec;
gc.setForeground(ColorResources.TABLE_HEADER_FONT_COLOR);
- gc.drawText(timeFormat(tickLabelValue * MS * US),
- (int) Math.round(posXPx) - halfStringWidth + 1,
- 1);
+ gc.drawText(timeFormat(tickLabelValue * MS * US), (int) Math.round(posXPx) - halfStringWidth + 1, 1);
} else if (tickOrder == 5) {
tickLineHeight = 4;
}
gc.setForeground(ColorResources.TABLE_LINE);
- gc.drawLine((int) Math.round(posXPx), y + h
- - (1 + tickLineHeight), (int) Math.round(posXPx), y
- + h - 1);
+ gc.drawLine((int) Math.round(posXPx), y + h - (1 + tickLineHeight), (int) Math.round(posXPx), y + h - 1);
posXPx += oneTickPx;
tickOrder = tickOrder + 1;
}
- TimelineGlobalVriable.endPx = TimelineGlobalVriable.startPx + w;
-
- if (TimelineGlobalVriable.originalEndPx == TimelineConstants.NOT_INITED) {
- TimelineGlobalVriable.originalEndPx = w;
- timelineMaster.setRangeScrollBarMax(w);
- timelineMaster.setRangeScrollBarSelection(0);
- timelineMaster.setRangeScrollBarThumb(w);
- }
-
- int maxPx = chartRunningPx > TimelineGlobalVriable.originalEndPx ? chartRunningPx
- : TimelineGlobalVriable.originalEndPx;
+
timelineMaster.setRangeScrollBarMax(maxPx);
- timelineMaster.setRangeScrollBarSelection(TimelineGlobalVriable.startPx);
+ timelineMaster.setRangeScrollBarSelection(TimelineGlobalVariable.startPx);
timelineMaster.setRangeScrollBarThumb(w);
- if (maxPx == TimelineGlobalVriable.startPx + w) {
+ if (maxPx == TimelineGlobalVariable.startPx + w) {
timelineMaster.setRangeScrollBarStuckState(true);
}
- TimelineChartManager.getInstance().setAllChartDoaminAxisRange(
- TimelineGlobalVriable.startPx * scaleSec / oneTickPx / 10.0,
- TimelineGlobalVriable.endPx * scaleSec / oneTickPx / 10.0);
- TimelineGlobalVriable.allowRedrawTimeTickCanvas = true;
+ TimelineChartManager.getInstance().setAllChartDoaminAxisRange(TimelineGlobalVariable.startPx * currentScaleSec / oneTickPx / 10.0,
+ TimelineGlobalVariable.endPx * currentScaleSec / oneTickPx / 10.0);
+ TimelineGlobalVariable.allowRedrawTimeTickCanvas = true;
}
});
}
public void clear() {
- TimelineGlobalVriable.startPx = 0;
+ TimelineGlobalVariable.startPx = 0;
timeTickCanvas.redraw();
}
nextTime = minTime % MIN;
}
- format = digitMapping(frontTime) + AnalyzerConstants.COLON
- + digitMapping(nextTime);
+ format = digitMapping(frontTime) + AnalyzerConstants.COLON + digitMapping(nextTime);
return format;
}
timelineItemManager.updateActiveItem(runTimeMs);
- TimelineGlobalVriable.chartRunningSec = (int) (runTimeMs / TimelineConstants.KILO);
+ TimelineGlobalVariable.chartRunningSec = (int) (runTimeMs / TimelineConstants.KILO);
TimelineMaster.getInstance().redrawTimeTickCanvas();
}
}
int middlePx = timelineMaster.getPxBySec(middleTime);
- TimelineGlobalVriable.startPx = middlePx - TimelineGlobalVriable.timetickWidthPx / 2;
- if (TimelineGlobalVriable.startPx < 0) {
- TimelineGlobalVriable.startPx = 0;
+ TimelineGlobalVariable.startPx = middlePx - TimelineGlobalVariable.timetickWidthPx / 2;
+ if (TimelineGlobalVariable.startPx < 0) {
+ TimelineGlobalVariable.startPx = 0;
}
timelineMaster.redrawTimeTickCanvas();
@Override
public void clear() {
chartManager.clear();
- timelineRangeSelector.clear();
timelineTick.clear();
SnapshotData.getInstance().clear();
CustomLogParser.clear();
package org.tizen.dynamicanalyzer.ui.timeline.common;
public class TimelineConstants {
- public static final long CHART_RANGE_DEFAULT = 120000;// 12
-
/* timeline Item type */
public static final int NOT_DEFAULT_CHART = -100;
public static final int CHART_TYPE_CPU = -101;
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Sanghyun Lee <sanghyunnim.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.dynamicanalyzer.ui.timeline.common;
+
+
+
+public class TimelineGlobalVariable {
+ public static int currentScaleValue = 0;
+ public static int oriScaleValue = 0;
+
+ public static int timetickWidthPx = TimelineConstants.NOT_INITED;
+
+ public static int startPx = 0;
+ public static int endPx = TimelineConstants.NOT_INITED;
+
+ public static int originalEndPx = TimelineConstants.NOT_INITED;
+ public static int chartRunningSec = TimelineConstants.NOT_INITED;
+
+ public static boolean scaleChanged = false;
+ public static boolean allowRedrawTimeTickCanvas = true;
+
+ public enum EnumScaleSec {
+ SCALE_0(10), SCALE_1(5), SCALE_2(1);
+ private int scaleSec;
+ private EnumScaleSec(int scaleValue) {
+ this.scaleSec = scaleValue;
+ }
+
+ public int getScaleSec() {
+ return scaleSec;
+ }
+ }
+
+ public static long TOTAL_MEMORY = 90;
+ public static boolean SUPPORT_WIFI = false;
+ public static boolean SUPPORT_BLUETOOTH = false;
+ public static boolean SUPPORT_GPS = false;
+}
if (thumb != -1) {
rangeScrollBar.setThumb(thumb);
rangeScrollBar.setPageIncrement(thumb);
- rangeScrollBar.setIncrement(thumb / 5);
+ if(thumb < 5) {
+ rangeScrollBar.setIncrement(1);
+ } else {
+ rangeScrollBar.setIncrement(thumb / 5);
+ }
}
}
public int getPxBySec(double sec) {
int scaleSec =
- TimelineGlobalVriable.EnumScaleSec.values()[TimelineGlobalVriable.currentScaleValue].getScaleSec();
+ TimelineGlobalVariable.EnumScaleSec.values()[TimelineGlobalVariable.currentScaleValue].getScaleSec();
return (int) Math.round(sec * TimelineConstants.ONE_TICK_PIXEL * 10.0 / scaleSec);
}
public double getSecByPx(int px) {
int scaleSec =
- TimelineGlobalVriable.EnumScaleSec.values()[TimelineGlobalVriable.currentScaleValue].getScaleSec();
+ TimelineGlobalVariable.EnumScaleSec.values()[TimelineGlobalVariable.currentScaleValue].getScaleSec();
return px * scaleSec / 10.0 / TimelineConstants.ONE_TICK_PIXEL;
}
public void initAppInfo(String[] datas) {
setTotalMemory(Integer.parseInt(datas[AnalyzerConstants.APP_INFO_SYSTEM_MEMORY_SIZE]));
- TimelineGlobalVriable.SUPPORT_WIFI =
+ TimelineGlobalVariable.SUPPORT_WIFI =
datas[AnalyzerConstants.APP_INFO_WIFI_SUPPORT].equals("1") ? true : false; //$NON-NLS-1$
- TimelineGlobalVriable.SUPPORT_BLUETOOTH =
+ TimelineGlobalVariable.SUPPORT_BLUETOOTH =
datas[AnalyzerConstants.APP_INFO_BLUETOOTH_SUPPORT].equals("1") ? true : false; //$NON-NLS-1$
- TimelineGlobalVriable.SUPPORT_GPS =
+ TimelineGlobalVariable.SUPPORT_GPS =
datas[AnalyzerConstants.APP_INFO_GPS_SUPPORT].equals("1") ? true : false; //$NON-NLS-1$
}
private void setTotalMemory(final int totalMemory) {
- TimelineGlobalVriable.TOTAL_MEMORY = totalMemory;
+ TimelineGlobalVariable.TOTAL_MEMORY = totalMemory;
}
}
\ No newline at end of file
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.tizen.dynamicanalyzer.widgets.scale.DAScaleSelectionListener;
public class TimelineRangeSelector {
- private final int RANGE_SCALE_LEVEL_3 = 120;
private final int MAX_SCALE = 2;
private Composite scaleAndRangeComp;
private Composite rangeScaleComp;
private Composite rangeSelectorComp;
- private Canvas rangeCanvas;
private DAScale rangeScale;
private ScrollBar rangeScrollBar;
- private final int MARGIN_HORIZONTAL = 0;
-
- private double chartRunningSec;
- private double rangeScaleSec;
-
- private boolean isEndSticky = false;
- private boolean isTotalRange = false;
-
- RangeRectInfo rangeRectInfo;
-
- class RangeRectInfo {
- public Rectangle rangeRect;
- public int startSec;
- public int endSec;
- public int preStartSec;
-
- /* pixel */
- public int firstStartXP;
- public int downXP;
-
- public Rectangle selectorRect;
- protected int downLeftMarginP;
- }
-
- public TimelineRangeSelector() {
- rangeRectInfo = new RangeRectInfo();
- chartRunningSec = (double) (TimelineConstants.CHART_RANGE_DEFAULT / TimelineConstants.KILO);
- isEndSticky = true;
- }
-
public Composite createScaleAndRangeComp(Composite baseComp) {
scaleAndRangeComp = new Composite(baseComp, SWT.NONE);
scaleAndRangeComp.setBackground(ColorResources.VIEW_BG_COLOR);
return scaleAndRangeComp;
}
- public void updateRuntime(long runTime) {
- if (0 >= runTime) {
- return;
- }
- double runningTime = (double) (runTime / TimelineConstants.KILO);
-
- if (chartRunningSec >= runningTime) {
- return;
- }
-
- chartRunningSec = runningTime;
-
- resetRangeRectSec();
-
- // if (isEndSticky) {
- // setRangeSelection(rangeRectInfo.startSec, rangeScaleSec.intValue());
- // }
- }
-
- public void clear() {
- /* Init value */
- rangeRectInfo = null;
- rangeRectInfo = new RangeRectInfo();
- chartRunningSec = (double) (TimelineConstants.CHART_RANGE_DEFAULT / TimelineConstants.KILO);
- isEndSticky = true;
-
- /* Scale init */
- resetRangeRectSec();
- rangeScrollBar.setThumb(120);
- rangeScrollBar.setPageIncrement(60);
- rangeScrollBar.setIncrement(12);
- rangeScrollBar.setSelection(0);
- }
-
private Composite createRangeScaleComp(Composite selectorComp, int style) {
Composite rangeScaleComp = new Composite(selectorComp, SWT.None);
rangeScaleComp.setLayout(new FillLayout());
@Override
public void widgetSelected() {
- if (!TimelineGlobalVriable.allowRedrawTimeTickCanvas) {
+ if (!TimelineGlobalVariable.allowRedrawTimeTickCanvas) {
return;
}
- int oriScaleValue = TimelineGlobalVriable.currentScaleValue;
- TimelineGlobalVriable.currentScaleValue = rangeScale.getSelection();
- if (oriScaleValue == TimelineGlobalVriable.currentScaleValue) {
+ int oriScaleValue = TimelineGlobalVariable.currentScaleValue;
+ TimelineGlobalVariable.currentScaleValue = rangeScale.getSelection();
+ if (oriScaleValue == TimelineGlobalVariable.currentScaleValue) {
return;
}
- TimelineGlobalVriable.oriScaleValue = oriScaleValue;
- TimelineGlobalVriable.scaleChanged = true;
- isTotalRange = (TimelineGlobalVriable.currentScaleValue == MAX_SCALE ? true
- : false);
- TimelineGlobalVriable.allowRedrawTimeTickCanvas = false;
+ TimelineGlobalVariable.oriScaleValue = oriScaleValue;
+ TimelineGlobalVariable.scaleChanged = true;
+ TimelineGlobalVariable.allowRedrawTimeTickCanvas = false;
TimelineMaster.getInstance().redrawTimeTickCanvas();
}
});
- initRangeMagScale();
-
+
return rangeScaleComp;
}
- private void initRangeMagScale() {
- rangeScaleSec = RANGE_SCALE_LEVEL_3;
- }
-
private Composite createRangeComp(Composite parent) {
ScrolledComposite rangeSelectorComp = new ScrolledComposite(parent, SWT.H_SCROLL);
rangeSelectorComp.setAlwaysShowScrollBars(true);
rangeScrollBar.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
- if (TimelineGlobalVriable.startPx == rangeScrollBar.getSelection()) {
+ if (TimelineGlobalVariable.startPx == rangeScrollBar.getSelection()) {
return;
}
TimelineMaster.getInstance()
.setRangeScrollBarStuckState(false);
}
- TimelineGlobalVriable.startPx = rangeScrollBar.getSelection();
+ TimelineGlobalVariable.startPx = rangeScrollBar.getSelection();
TimelineMaster.getInstance().redrawTimeTickCanvas();
}
return rangeSelectorComp;
}
- private void setRangeRect(double startTime) {
- /* Calculate start X */
- Rectangle rangeCanvasRect = rangeCanvas.getBounds();
- int rangeCanvasRectWidth = rangeCanvasRect.width - MARGIN_HORIZONTAL
- - MARGIN_HORIZONTAL;
-
- double pixPerSec = rangeCanvasRectWidth / chartRunningSec;
- double startX = pixPerSec * startTime + MARGIN_HORIZONTAL;
-
- /* Calculate rectWidth */
- double rangeScaleRatio = rangeScaleSec / chartRunningSec;
- double rangeRectWidth = rangeCanvasRectWidth * rangeScaleRatio;
-
- Rectangle rect = new Rectangle((int)startX, 0,
- (int)rangeRectWidth, rangeCanvasRect.height);
-
- rangeRectInfo.rangeRect = null;
- rangeRectInfo.rangeRect = rect;
-
- if (rangeRectInfo.endSec == chartRunningSec) {
- isEndSticky = true;
- }
-
- redrawRangeSelector(rangeCanvas);
- }
-
- private void setRangeRectTotal() {
- /* Get Time */
- double endTime = chartRunningSec;
- double startTime = 0.0;
- rangeRectInfo.endSec = (int)endTime;
- rangeRectInfo.startSec = (int)startTime;
-
- rangeScaleSec = chartRunningSec;
-
- setRangeRect(startTime);
- }
-
- private void resetRangeRectSec() {
- if (null == rangeCanvas) {
- return;
- }
-
- if (isTotalRange) {
- setRangeRectTotal();
- return;
- }
-
- /* Get Time */
- double endTime;
- double startTime;
-
- if (isEndSticky) {
- endTime = chartRunningSec;
- rangeRectInfo.endSec = (int)endTime;
- startTime = endTime - rangeScaleSec;
- rangeRectInfo.startSec = (int)startTime;
- setRangeRect(startTime);
- } else {
- setRangeRect((double) rangeRectInfo.startSec);
- }
- }
-
/*
* draw background gradient
*/
composite.setBackgroundImage(newImage);
}
-
- private void redrawRangeSelector(Canvas canvas) {
- if (null == canvas) {
- return;
- }
- canvas.redraw();
- }
}
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
private DACustomButton addItems;
private DACustomButton minimizeItems;
- private Double chartRunningSec;// 60;
-
- RangeRectInfo rangeRectInfo;
-
- class RangeRectInfo {
- public Rectangle rangeRect;
- public int startSec;
- public int endSec;
- public int preStartSec;
-
- /* pixel */
- public int firstStartXP;
- public int downXP;
-
- public Rectangle selectorRect;
- protected int downLeftMarginP;
- }
-
private DACustomButtonClickEventListener addItemListButtonListener = new DACustomButtonClickEventListener() {
@Override
}
};
- public TimelineTick() {
- rangeRectInfo = new RangeRectInfo();
- chartRunningSec = (double) (TimelineConstants.CHART_RANGE_DEFAULT / TimelineConstants.KILO);
- }
-
public Composite createTimetickAndMenuComp(Composite baseComp) {
timeAndMenuComp = new Composite(baseComp, SWT.NONE);
timeAndMenuComp.setBackground(ColorResources.VIEW_BG_COLOR);
ColorResources.DEFAULT_FONT_COLOR);
addItems.setFont(FontResources.ADDITEM_BUTTON_FONT);
- // Label addItems = new Label(addItemComp, SWT.NONE);
GridData gDataAddBtn = new GridData();
gDataAddBtn.horizontalAlignment = GridData.FILL;
gDataAddBtn.grabExcessHorizontalSpace = true;
gDataAddBtn.verticalAlignment = GridData.FILL;
gDataAddBtn.grabExcessVerticalSpace = true;
addItems.setLayoutData(gDataAddBtn);
- // addItems.setImage(ImageResources.ADD_ITEMS_BAR);
addItems.addClickListener(addItemListButtonListener);
- // addItems.addMouseListener(addItemListListener);
minimizeItems = new DACustomButton(addItemComp,
ImageResources.TIMLINE_SIZE_MIN_NORMAL,
return addItemComp;
}
- public void updateRuntime(long runTime) {
- if (0 >= runTime) {
- return;
- }
- double runningTime = (double) (runTime / TimelineConstants.KILO);
-
- if (chartRunningSec >= runningTime) {
- return;
- }
-
- chartRunningSec = runningTime;
- }
-
public void clear() {
timeTickComp.clear();
}