[Title]apply screenshot chart orientation
authorsanghyunnim.lee <sanghyunnim.lee@samsung.com>
Mon, 3 Dec 2012 07:35:08 +0000 (16:35 +0900)
committersanghyunnim.lee <sanghyunnim.lee@samsung.com>
Mon, 3 Dec 2012 07:35:08 +0000 (16:35 +0900)
[Desc.]
[Issue]

org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chart/DACustomChartRenderer.java
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chart/DACustomChartSeriesItem.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/ScreenshotChart.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/UIEventChart.java

index 36fbba1..0f127b7 100644 (file)
@@ -51,11 +51,8 @@ public class DACustomChartRenderer {
        private DACustomChartPlot plot = null;
        private Rectangle r = null;
 
-       private final int SCREENSHOT_WIDTH = 40;
-       private final int SCREENSHOT_HEIGHT = 66;
-       private final int SCREENSHOT_TOP_MARGIN = 10;
 //     private final int SCREENSHOT_HORIZONTAL_TOP_MARGIN = 13;
-       private final int SCREENSHOT_SELECTED_MOVE_SIZE = 6;
+       private final int SCREENSHOT_SELECTED_Y_POSITION = 4;
 //     private final int SCREENSHOT_HORIZONTAL_SELECTED_MOVE_SIZE = 19;
        private final int SCREENSHOT_SELECTED_LINE_WIDTH = 2;
        private final int SCREENSHOT_BORDER_LINE_WIDTH = 1;
@@ -662,31 +659,29 @@ public class DACustomChartRenderer {
                        return;
                }
 
-               DACustomChartSeriesItem seriesItem;
 
                int index = series.getPrevIndexByXvalue(plot.getVisibleStartX());
                if (index < 0) {
                        index = 0;
                }
-               Image image;
-
                int highlightedImageIndex = ((DACustomScreenshotChartPlot) plot)
                                .getHighlightedImageIndex();
                int selectedImageIndex = ((DACustomScreenshotChartPlot) plot)
                                .getSelectedImageIndex();
                for (int i = index; i < seriesItemSize; i++) {
-                       seriesItem = seriesItems.get(i);
+                       DACustomChartSeriesItem seriesItem = seriesItems.get(i);
                        double currentX = seriesItem.getX();
-
                        int pixcelStartX = plot.getXPixcelFromX(currentX, r);
-                       image = seriesItem.getImage();
+                       int yPostion = (int)seriesItem.getY();
+                       Image image = seriesItem.getImage();
+                       int screenshotWidth = image.getBounds().width;
+                       int screenshotHeight = image.getBounds().height;
 
                        if (i != highlightedImageIndex && i != selectedImageIndex) {
-                               gc.drawImage(image, pixcelStartX, SCREENSHOT_TOP_MARGIN);
+                               gc.drawImage(image, pixcelStartX, yPostion);
                                gc.setLineWidth(SCREENSHOT_BORDER_LINE_WIDTH);
                                gc.setForeground(ColorResources.SCREENSHOT_CHART_BORDER_LINE);
-                               gc.drawRectangle(pixcelStartX, SCREENSHOT_TOP_MARGIN,
-                                               SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT);
+                               gc.drawRectangle(pixcelStartX, yPostion, screenshotWidth, screenshotHeight);
                        }
 
                        if (currentX > plot.getVisibleEndX()) {
@@ -697,36 +692,38 @@ public class DACustomChartRenderer {
                if (selectedImageIndex >= 0) {
                        gc.setForeground(ColorResources.SCREENSHOT_CHART_SELECTED_LINE);
                        gc.setLineWidth(SCREENSHOT_SELECTED_LINE_WIDTH);
-                       Image selectedImage = seriesItems.get(selectedImageIndex)
-                                       .getImage();
-                       double currentX = seriesItems.get(selectedImageIndex).getX();
+                       
+                       DACustomChartSeriesItem seriesItem = seriesItems.get(selectedImageIndex);
+                       Image selectedImage = seriesItem.getImage();
+                       double currentX = seriesItem.getX();
                        int pixcelStartX = plot.getXPixcelFromX(currentX, r);
+                       int yPosition = (int)seriesItem.getY();
+                       int screenshotWidth = selectedImage.getBounds().width;
+                       int screenshotHeight = selectedImage.getBounds().height;
+                       
                        if (selectedImageIndex == highlightedImageIndex) {
-                               gc.drawRectangle(pixcelStartX, r.y + SCREENSHOT_TOP_MARGIN
-                                               - SCREENSHOT_SELECTED_MOVE_SIZE,
-                                               selectedImage.getBounds().width + 1,
-                                               selectedImage.getBounds().height + 1);
+                               gc.drawRectangle(pixcelStartX, SCREENSHOT_SELECTED_Y_POSITION,
+                                               screenshotWidth + 1, screenshotHeight + 1);
                        } else {
-                               gc.drawRectangle(pixcelStartX - 1, r.y + SCREENSHOT_TOP_MARGIN
-                                               - 1, selectedImage.getBounds().width + 1,
-                                               selectedImage.getBounds().height + 1);
-                               gc.drawImage(selectedImage, pixcelStartX, SCREENSHOT_TOP_MARGIN);
+                               gc.drawRectangle(pixcelStartX - 1, r.y + yPosition
+                                               - 1, screenshotWidth + 1, screenshotHeight + 1);
+                               gc.drawImage(selectedImage, pixcelStartX, yPosition);
                        }
                }
 
                if (highlightedImageIndex >= 0) {
-                       Image highlightedImage = seriesItems.get(highlightedImageIndex)
-                                       .getImage();
+                       DACustomChartSeriesItem seriesItem = seriesItems.get(highlightedImageIndex);
+                       Image highlightedImage = seriesItem.getImage();
                        double currentX = seriesItems.get(highlightedImageIndex).getX();
                        int pixcelStartX = plot.getXPixcelFromX(currentX, r);
+                       int screenshotWidth = highlightedImage.getBounds().width;
+                       int screenshotHeight = highlightedImage.getBounds().height;
 
-                       gc.drawImage(highlightedImage, pixcelStartX, SCREENSHOT_TOP_MARGIN
-                                       - SCREENSHOT_SELECTED_MOVE_SIZE);
+                       gc.drawImage(highlightedImage, pixcelStartX, SCREENSHOT_SELECTED_Y_POSITION);
                        gc.setLineWidth(SCREENSHOT_BORDER_LINE_WIDTH);
                        gc.setForeground(ColorResources.SCREENSHOT_CHART_BORDER_LINE);
-                       gc.drawRectangle(pixcelStartX, SCREENSHOT_TOP_MARGIN
-                                       - SCREENSHOT_SELECTED_MOVE_SIZE, SCREENSHOT_WIDTH,
-                                       SCREENSHOT_HEIGHT);
+                       gc.drawRectangle(pixcelStartX, SCREENSHOT_SELECTED_Y_POSITION, screenshotWidth,
+                                       screenshotHeight);
                }
        }
 
index 31e8868..3009697 100644 (file)
@@ -71,6 +71,12 @@ public class DACustomChartSeriesItem {
                this.setImage(image);
        }
        
+       public DACustomChartSeriesItem(double x, double y, Image image) {
+               this.x = x;
+               this.y = y;
+               this.setImage(image);
+       }
+       
        public DACustomChartSeriesItem(double x, Image image, String tooltipText) {
                this.x = x;
                this.setImage(image);
index 6b5557e..764e516 100644 (file)
@@ -106,6 +106,8 @@ public class ScreenshotChart extends TimelineChart {
        }
        
        private void parsingLog(List<String> log) {
+               double time = Double.parseDouble(log.get(LogCenterConstants.TIME_INDEX)) /  TimelineConstants.MEGA;
+               
                String imagePath = AnalyzerManager.getProject().getSavePath() + File.separator
                                + AnalyzerConstants.IMAGE_FOLDER_NAME + File.separator
                                + AnalyzerConstants.SMALL_IMAGE_FOLDER_NAME;
@@ -114,9 +116,15 @@ public class ScreenshotChart extends TimelineChart {
                String fileName = splitedImagePathLog[splitedImagePathLog.length - 1];
                imagePath += File.separator + fileName;
                
-               double time = Double.parseDouble(log.get(LogCenterConstants.TIME_INDEX)) /  TimelineConstants.MEGA;
+               String orientation = log.get(LogCenterConstants.SNAPSHOT_ROTATE_INDEX);
+               int yPostion;
+               if(orientation.equals("0") || orientation.equals("180")) {
+                       yPostion = 10;
+               } else {
+                       yPostion = 23;
+               }
                
-               new CreateImageThread(imagePath, time).run();
+               new CreateImageThread(imagePath, time, yPostion).run();
        }
 
        @Override
@@ -130,10 +138,12 @@ public class ScreenshotChart extends TimelineChart {
        private class CreateImageThread extends Thread{
                private String imagePath;
                private double time;
+               private int yPosition;
                
-               private CreateImageThread(String imagePath, double time) {
+               private CreateImageThread(String imagePath, double time, int yPostion) {
                        this.imagePath = imagePath;
                        this.time = time;
+                       this.yPosition = yPostion;
                }
                
                public void run() {
@@ -154,7 +164,7 @@ public class ScreenshotChart extends TimelineChart {
                                break;
                        }
                        
-                       screenshotSeries.addSeriesItem(new DACustomChartSeriesItem(time, image));
+                       screenshotSeries.addSeriesItem(new DACustomChartSeriesItem(time, yPosition, image));
                }
        }
 }
index caeddae..1141d52 100644 (file)
@@ -165,6 +165,7 @@ public class UIEventChart extends TimelineChart {
                        break;
                case TYPE_ORIENTATION:
                        int status = Integer.parseInt(log.get(LogCenterConstants.UI_EVENT_INFO1));
+                       System.out.println("status : " + status);
                        orientationEventSeries.addSeriesItem(new DACustomChartSeriesItem(time, 0, "Orientation   " + EnumOrientationStatus.values()[status].getStatus()));
                        break;
                case TYPE_FRAMEWORK: