[Title]improve ui event chart tooltip
authorsanghyunnim.lee <sanghyunnim.lee@samsung.com>
Wed, 21 Nov 2012 02:00:59 +0000 (11:00 +0900)
committersanghyunnim.lee <sanghyunnim.lee@samsung.com>
Wed, 21 Nov 2012 02:00:59 +0000 (11:00 +0900)
[Desc.]
[Issue]

org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chart/DACustomChartRenderer.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogCenterConstants.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/UIEventChart.java

index f2d81cf..d135cbb 100644 (file)
@@ -31,6 +31,7 @@ import java.util.List;
 
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Rectangle;
@@ -201,24 +202,25 @@ public class DACustomChartRenderer {
                        }
                        DACustomChartSeries series = seriesList.get(i);
                        int index = series.getPrevIndexByXvalue(realXVal);
-                       String text;
+                       String text = "";
                        if (index >= 0) {
                                double yVal = series.getSeriesItemList().get(index).getY();
                                double xVal = series.getSeriesItemList().get(index).getX();
 
-                               text = series.getName()
-                                               + " : "
-                                               + series.getSeriesItemList().get(index)
-                                                               .getTooltipText();
+                               if(!(plot instanceof DACustomUIEventChartPlot)) {
+                                       text += series.getName() + " : ";
+                               }
+                                       text +=  series.getSeriesItemList().get(index).getTooltipText();
 
                                gc.setForeground(tooltip.getLineColor());
                                gc.setLineStyle(SWT.LINE_DOT);
                                gc.setLineWidth(1);
-                               if (!(plot instanceof DACustomUIEventChartPlot)) {
+
+                               if(!(plot instanceof DACustomUIEventChartPlot)) {
                                        gc.drawLine(0, plot.getYPixcelFromY(series, yVal, r),
                                                        r.width, plot.getYPixcelFromY(series, yVal, r));
                                }
-
+                               
                                gc.drawLine(plot.getXPixcelFromX(xVal), 0,
                                                plot.getXPixcelFromX(xVal), r.height);
                                gc.setLineStyle(SWT.LINE_CUSTOM);
@@ -260,38 +262,50 @@ public class DACustomChartRenderer {
 
                gc.setBackground(tooltip.getBackgroundColor());
                gc.setForeground(tooltip.getTextColor());
-               gc.fillRectangle(startX, ((r.y + r.height) / 2) - (totalHeight / 2),
+               
+               int startY;
+               if(plot instanceof DACustomUIEventChartPlot) {
+                       startY = (int)(r.height * (int)(tooltip.getYPosRatio() * seriesList.size()) / seriesList.size());
+                       if(r.height - startY - totalHeight < 0) {
+                               startY = r.height - totalHeight - 1;
+                               if(startY < 0) {
+                                       startY = 0;
+                               }
+                       }
+                       
+               } else {
+                       startY = (r.y + r.height / 2) - (totalHeight / 2);
+               }
+               
+               gc.fillRectangle(startX, startY,
                                preTextWidthMargin + textWidthMax
                                                + DACustomChartPlotTooltip.TOOLTIP_MARGIN, totalHeight);
-               gc.drawRectangle(startX, ((r.y + r.height) / 2) - (totalHeight / 2),
+               gc.drawRectangle(startX, startY,
                                preTextWidthMargin + textWidthMax
                                                + DACustomChartPlotTooltip.TOOLTIP_MARGIN, totalHeight);
                gc.setFont(tooltip.getFont());
                for (int i = 0; i < seriesList.size(); i++) {
-                       DACustomChartSeries series = seriesList.get(i);
-                       int y = ((r.y + r.height) / 2) - (totalHeight / 2)
+                       int y = startY
                                        + (textHeightMax * i)
                                        + DACustomChartPlotTooltip.TOOLTIP_MARGIN;
-                       if (series.getStyle() != DACustomChartSeries.SERIES_STYLE_IMAGE) {
-                               gc.setBackground(series.getColor());
+                       DACustomChartSeries series;
+                       if (plot instanceof DACustomUIEventChartPlot) {
+                               series = seriesList.get((int) (seriesList.size() * tooltip.getYPosRatio()));
+                       } else {
+                               series = seriesList.get(i);
                        }
+                       gc.setBackground(series.getColor());
 
                        gc.fillRectangle(
                                        startX + DACustomChartPlotTooltip.TOOLTIP_MARGIN,
-                                       y
-                                                       + textHeightMax
-                                                       / 2
-                                                       - DACustomChartPlotTooltip.TOOLTIP_SERIES_RECT_LENGTH
-                                                       / 2,
+                                       y + textHeightMax / 2 - DACustomChartPlotTooltip.TOOLTIP_SERIES_RECT_LENGTH / 2,
                                        DACustomChartPlotTooltip.TOOLTIP_SERIES_RECT_LENGTH,
                                        DACustomChartPlotTooltip.TOOLTIP_SERIES_RECT_LENGTH);
                        gc.setBackground(tooltip.getBackgroundColor());
                        gc.drawText(tooltipTexts.get(i), startX
                                        + DACustomChartPlotTooltip.TOOLTIP_MARGIN
                                        + DACustomChartPlotTooltip.TOOLTIP_SERIES_RECT_LENGTH
-//                                     + DACustomChartPlotTooltip.TOOLTIP_MARGIN, y, SWT.DRAW_DELIMITER);
-//                     if(plot instanceof DACustomUIEventChartPlot) {
-                                       + DACustomChartPlotTooltip.TOOLTIP_MARGIN, y);
+                                       + DACustomChartPlotTooltip.TOOLTIP_MARGIN, y, SWT.DRAW_DELIMITER);
                        if (plot instanceof DACustomUIEventChartPlot) {
                                break;
                        }
@@ -369,8 +383,10 @@ public class DACustomChartRenderer {
                int seriesItemSize = seriesItems.size();
                Rectangle rect = new Rectangle(r.x, r.y + (r.height/seriesSize * seriesIndex), r.width, r.height/seriesSize);
                gc.setForeground(ColorResources.UI_EVENT_CHART_TEXT);
+               Font tempFont = gc.getFont();
                gc.setFont(FontResources.TIMELINE_TICK_FONT);
                gc.drawText(series.getName(), rect.x + 3, rect.y + 3, true);
+               gc.setFont(tempFont);
                if(seriesIndex != 0) {
                        gc.setForeground(ColorResources.UI_EVENT_CHART_SEPERATE_LINE);
                        gc.drawLine(rect.x, rect.y, rect.width, rect.y);
index 02b5a56..6132ec3 100644 (file)
@@ -73,6 +73,14 @@ public class LogCenterConstants {
        public static final int USER_INTERFACE_CONTROL_LIST_CHILD_NAME_INDEX = 16;
        public static final int USER_INTERFACE_CONTROL_LIST_CHILD_POINTER_INDEX = 17;
 
+       /* Log UI Event : 3 */
+       public static final int UI_EVENT_EVENT_TYPE = 12;
+       public static final int UI_EVENT_DETAIL_TYPE = 13;
+       public static final int UI_EVENT_X = 14;
+       public static final int UI_EVENT_Y = 15;
+       public static final int UI_EVENT_INFO1 = 16;
+       public static final int UI_EVENT_INFO2 = 17;
+       
        /* log user function : 4 */
        public static final int USER_FUNCTION_BINARY_RANGE_START_INDEX = 12;
        public static final int USER_FUNCTION_BINARY_RANGE_END_INDEX = 13;
index 1302978..49e77aa 100644 (file)
@@ -51,13 +51,6 @@ public class UIEventChart extends TimelineChart {
        private DACustomChartSeries orientationEventSeries;
        private DACustomChartSeries frameworkEventSeries;
 
-       private final int EVENT_TYPE = 12;
-       private final int DETAIL_TYPE = 13;
-       private final int X = 14;
-       private final int Y = 15;
-       private final int INFO1 = 16;
-       private final int INFO2 = 17;
-
        private final int TYPE_KEY = 1;
        private final int TYPE_TOUCH = 2;
        private final int TYPE_GESTURE = 3;
@@ -98,9 +91,10 @@ public class UIEventChart extends TimelineChart {
                keyEventSeries.addSeriesItem(new DACustomChartSeriesItem(10, 10, "key1"));
                gestureEventSeries.addSeriesItem(new DACustomChartSeriesItem(10, 100, "gesture1"));
                gestureEventSeries.addSeriesItem(new DACustomChartSeriesItem(15, 100, "gesture2"));
-               gestureEventSeries.addSeriesItem(new DACustomChartSeriesItem(30, 100, "gesture2"));
+               gestureEventSeries.addSeriesItem(new DACustomChartSeriesItem(30, 100, "gesture2\nn\nn\nn\nn\nn\nn"));
                keyEventSeries.addSeriesItem(new DACustomChartSeriesItem(20, 100, "key2"));
                keyEventSeries.addSeriesItem(new DACustomChartSeriesItem(25, 100, "key3"));
+               frameworkEventSeries.addSeriesItem(new DACustomChartSeriesItem(40, 30, "framework\nframework"));
        }
 
        @Override
@@ -145,11 +139,11 @@ public class UIEventChart extends TimelineChart {
        private void parsingLog(List<String> log) {
                double time = Double.parseDouble(log.get(LogCenterConstants.TIME_INDEX)) /  TimelineConstants.MEGA;
 
-               int type = Integer.parseInt(log.get(EVENT_TYPE));
-               int detailType = Integer.parseInt(log.get(DETAIL_TYPE));
+               int type = Integer.parseInt(log.get(LogCenterConstants.UI_EVENT_EVENT_TYPE));
+               int detailType = Integer.parseInt(log.get(LogCenterConstants.UI_EVENT_DETAIL_TYPE));
                switch (type) {
                case TYPE_KEY:
-                       String keyName = log.get(INFO1);
+                       String keyName = log.get(LogCenterConstants.UI_EVENT_INFO1);
                        String keyStatus;
                        if(detailType == 0) {
                                keyStatus = KEY_DOWN;
@@ -159,9 +153,9 @@ public class UIEventChart extends TimelineChart {
                        keyEventSeries.addSeriesItem(new DACustomChartSeriesItem(time, 0, keyName + SPACE + keyStatus));
                        break;
                case TYPE_TOUCH:
-                       String info = EnumTouchStatus.values()[Integer.parseInt(log.get(DETAIL_TYPE))].getStatus() + NEW_LINE 
-                                                       + log.get(X) + NEW_LINE
-                                                       + log.get(Y) + NEW_LINE;
+                       String info = EnumTouchStatus.values()[Integer.parseInt(log.get(LogCenterConstants.UI_EVENT_DETAIL_TYPE))].getStatus() + NEW_LINE 
+                                                       + log.get(LogCenterConstants.UI_EVENT_X) + NEW_LINE
+                                                       + log.get(LogCenterConstants.UI_EVENT_Y);
 //                                                     + log.get(INFO2);
                        touchEventSeries.addSeriesItem(new DACustomChartSeriesItem(time, 0, info));
                        break;
@@ -170,7 +164,7 @@ public class UIEventChart extends TimelineChart {
                        gestureEventSeries.addSeriesItem(new DACustomChartSeriesItem(time, 0));
                        break;
                case TYPE_ORIENTATION:
-                       orientationEventSeries.addSeriesItem(new DACustomChartSeriesItem(time, 0, log.get(INFO1)));
+                       orientationEventSeries.addSeriesItem(new DACustomChartSeriesItem(time, 0, log.get(LogCenterConstants.UI_EVENT_INFO1)));
                        break;
                case TYPE_FRAMEWORK:
                        // FIXME argument