[Title]custom chart regular chart
authorsanghyunnim.lee <sanghyunnim.lee@samsung.com>
Mon, 20 Aug 2012 13:25:59 +0000 (22:25 +0900)
committersanghyunnim.lee <sanghyunnim.lee@samsung.com>
Mon, 20 Aug 2012 13:25:59 +0000 (22:25 +0900)
[Type]
[Module]
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/constants/LogCenterConstants.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/timeline/CustomLogParser.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/timeline/TimelineChartManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/timeline/TimelineComposite.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/timeline/TimelineEditItemsDialog.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/timeline/chart/UserCustomChart.java

index 7781308..59cea21 100644 (file)
@@ -122,7 +122,10 @@ public class LogCenterConstants {
        
        /* custom log */
        public static final int CUSTOM_HANDLE = 11;
-       public static final int CUSTOM_TEXT = 12;
+       public static final int CUSTOM_TYPE = 12;
+       public static final int CUSTOM_TEXT = 13;
+       public static final int CUSTOM_COLOR = 14;
+       public static final int CUSTOM_VALUE = 15;
        
        
        /* Common Column Size */
index b80a7c3..2122b21 100644 (file)
 
 package org.tizen.dynamicanalyzer.timeline;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+import org.eclipse.swt.graphics.Color;
+import org.tizen.dynamicanalyzer.ColorResources;
 import org.tizen.dynamicanalyzer.constants.LogCenterConstants;
 import org.tizen.dynamicanalyzer.model.LogPackage;
 import org.tizen.dynamicanalyzer.model.Logs;
 import org.tizen.dynamicanalyzer.timeline.chart.UserCustomChart;
+import org.tizen.dynamicanalyzer.widgets.chart.DACustomChartSeries;
+import org.tizen.dynamicanalyzer.widgets.chart.DACustomChartSeriesItem;
 
 public class CustomLogParser {
        private static final String API_NAME_CREATE_CHART = "da_create_chart";  //$NON-NLS-1$
@@ -34,6 +40,7 @@ public class CustomLogParser {
        private static final String API_NAME_TIMER_THREAD = "timerThread";  //$NON-NLS-1$
        
        private static TimelineChartManager chartManager = TimelineChartManager.getInstance();
+       private static Map<Integer, DACustomChartSeries> customChartSeriesMap = new HashMap<Integer, DACustomChartSeries>();
        
        public static void parsingLogPackage(LogPackage logPack) {
                if(!isAbleToParse(logPack, LogCenterConstants.LOG_CUSTOM)) {
@@ -51,11 +58,32 @@ public class CustomLogParser {
                String apiName = log.get(LogCenterConstants.APINAME_INDEX);
                
                if(apiName.equals(API_NAME_CREATE_CHART)) {
-                       int chartHandle = Integer.parseInt(log.get(LogCenterConstants.CUSTOM_HANDLE));
+                       int chartHandle = Integer.parseInt(log.get(LogCenterConstants.RETURN_INDEX));
                        String chartName = log.get(LogCenterConstants.CUSTOM_TEXT);
                        chartManager.addCustomChart(new UserCustomChart(chartHandle, chartName));
+               } else if(apiName.equals(API_NAME_CREATE_SERIES)) {
+                       int chartType = Integer.parseInt(log.get(LogCenterConstants.CUSTOM_HANDLE));
+                       UserCustomChart chart = (UserCustomChart)chartManager.getChartInstance(chartType);
+                       if(chart.getSeriesNum() >= 4) {
+                               return;
                        }
-               } 
+
+                       int seriesHandle = Integer.parseInt(log.get(LogCenterConstants.RETURN_INDEX));
+                       int seriesType = Integer.parseInt(log.get(LogCenterConstants.CUSTOM_TYPE));
+                       String seriesName = log.get(LogCenterConstants.CUSTOM_TEXT);
+                       Color seriesColor = getCustomColor(Integer.parseInt(log.get(LogCenterConstants.CUSTOM_COLOR)));
+                       DACustomChartSeries series = new DACustomChartSeries(seriesName, seriesType, seriesColor);
+                       
+                       chart.addSeries(series);
+                       customChartSeriesMap.put(seriesHandle, series);
+               } else if(apiName.equals(API_NAME_DA_LOG)) {
+                       int seriesHandle = Integer.parseInt(log.get(LogCenterConstants.CUSTOM_HANDLE));
+                       long time = Integer.parseInt(log.get(LogCenterConstants.TIME_INDEX));
+                       double value = Integer.parseInt(log.get(LogCenterConstants.CUSTOM_VALUE));
+                       DACustomChartSeries series = customChartSeriesMap.get(seriesHandle);
+                       series.addSeriesItem(new DACustomChartSeriesItem(time, value, series.getName() + " : " + value));
+               }
+       }
        
        private static boolean isAbleToParse(LogPackage logPack, int probeType) {
                Logs logList = logPack.getLogs(probeType);
@@ -74,4 +102,35 @@ public class CustomLogParser {
                
                return true;
        }
+       
+       public static void clear() {
+               customChartSeriesMap.clear();
+       }
+       
+       private static Color getCustomColor(int colorType) {
+               switch(colorType) {
+               case 1:
+                       return ColorResources.GOLDENROD;
+               case 2:
+                       return ColorResources.TURQUOISE;
+               case 3:
+                       return ColorResources.VIOLET;
+               case 4:
+                       return ColorResources.SLATEBLUE;
+               case 5:
+                       return ColorResources.ORANGE;
+               case 6:
+                       return ColorResources.YELLOWGREEN;
+               case 7:
+                       return ColorResources.SKYBLUE;
+               case 8:
+                       return ColorResources.ORCHID;
+               case 9:
+                       return ColorResources.SANDYBROWN;
+               case 10:
+                       return ColorResources.MEDIUMPURPLE;
+               default:
+                       return ColorResources.RED;
+               }
+       }
 }
index 9743424..cf4d620 100644 (file)
@@ -45,6 +45,7 @@ import org.tizen.dynamicanalyzer.timeline.chart.ProcessMemoryChart;
 import org.tizen.dynamicanalyzer.timeline.chart.SystemMemoryChart;
 import org.tizen.dynamicanalyzer.timeline.chart.TimelineChart;
 import org.tizen.dynamicanalyzer.timeline.chart.UserCustomChart;
+import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
 import org.tizen.dynamicanalyzer.widgets.chart.DACustomChart;
 
 
@@ -157,7 +158,6 @@ public class TimelineChartManager {
                return chart;
        }
        
-       // FIXME this must be removed
        public int getChartType(String string) {
                if (string.equals(getChartName(TimelineConstants.CHART_TYPE_CPU))) {
                        return TimelineConstants.CHART_TYPE_CPU;
@@ -175,7 +175,7 @@ public class TimelineChartManager {
                        return TimelineConstants.CHART_TYPE_FILE;
                }
                else {
-                       return NOT_DEFAULT_CHART; // FIXME custom?
+                       return NOT_DEFAULT_CHART;
                }
        }
        
@@ -242,6 +242,28 @@ public class TimelineChartManager {
                if(!customChartMap.containsKey(chartType)) {
                        customChartMap.put(chartType, customChart);
                        chartList.add(customChart);
+                       selectedChartList.add(customChart);
+                       
+
+                       StringBuffer strSaveChartNameList = new StringBuffer(""); //$NON-NLS-1$
+                       StringBuffer strSaveSelectedChartNameList = new StringBuffer(""); //$NON-NLS-1$
+
+                       for (int i = 0; i < chartList.size(); i++) {
+                               strSaveChartNameList.append(chartList.get(i).getChartName());
+                               strSaveChartNameList.append(","); //$NON-NLS-1$
+                       }
+
+                       for(int i = 0; i < selectedChartList.size(); i++) {
+                               strSaveSelectedChartNameList.append(selectedChartList.get(i).getChartName());
+                               strSaveSelectedChartNameList.append(","); //$NON-NLS-1$
+                       }
+
+                       TimelineComposite timelineComposite = AnalyzerUtil.getTimelineComposite();
+                       timelineComposite.resetItems();
+                       TimelineMaster.getInstance().redrawTimeTickCanvas();
+
+                       ConfigureManager.getInstance().setValue(ConfigureManager.CONFIGUREMANAGER_CHART_AVAILABLE_ITEM_LIST, strSaveChartNameList.toString());
+                       ConfigureManager.getInstance().setValue(ConfigureManager.CONFIGUREMANAGER_CHART_SELECTED_ITEM_LIST, strSaveSelectedChartNameList.toString());
                }
        }
 
index 106af2e..b689e87 100644 (file)
@@ -283,16 +283,28 @@ public class TimelineComposite extends DAView {
                
                //FIXME chart manager
                for (int i = 0; i < chartList.size(); i++) {
-                       updateChartDataSet(logPack, chartList.get(i).getChartType());
+                       int probeType = TimelineUtils.getProbeID(chartList.get(i).getChartType());
+                       
+                       DATimelineChart timelineChart = (DATimelineChart)chartList.get(i);
+                       timelineChart.parsingLogPackage(logPack, probeType);
+                       
                }
+               
+               logList = logPack.getLogs(LogCenterConstants.LOG_CUSTOM);
+               if(logList == null || logList.getLogs() == null || logList.getLogs().size() <= 0) {
+                       return;
+               } else {
+                       List<List<String>> customLogs = logList.getLogs();
+                       for (List<String> customLog : customLogs) {
+                               if (null == customLog || 0 >= customLog.size()) {
+                                       return;
+                               }
+                       }
+               }
+               
+               System.out.println("logs : " + logPack.getLogs(LogCenterConstants.LOG_CUSTOM).getLogs());
                CustomLogParser.parsingLogPackage(logPack);
-       }
-
-       private void updateChartDataSet(LogPackage logPack, int chartType) {
-               int probeType = TimelineUtils.getProbeID(chartType);
                
-               DATimelineChart timelineChart = (DATimelineChart)TimelineChartManager.getInstance().getChartInstance(chartType);
-               timelineChart.parsingLogPackage(logPack, probeType);
        }
 
        @Override
@@ -304,5 +316,6 @@ public class TimelineComposite extends DAView {
                timelineMaster.clearSelectionMarker();
                timelineMaster.clearSnapshot();
                SnapshotData.getInstance().clear();
+               CustomLogParser.clear();
        }
 }
index 9101718..394b833 100644 (file)
@@ -131,7 +131,8 @@ public class TimelineEditItemsDialog extends Dialog {
 
                @Override
                public void handleClickEvent(DACustomButton button) {
-                       chartManager.addCustomChart(new UserCustomChart(55, "This is message from H.O.T"));
+                       //FIXME test
+                       chartManager.addCustomChart(new UserCustomChart(55, "This is a message from H.O.T."));
                        shell.dispose();
                }
        };
index 8db89f9..fd9e2f1 100644 (file)
@@ -30,11 +30,6 @@ import org.tizen.dynamicanalyzer.widgets.chart.DACustomChart;
 import org.tizen.dynamicanalyzer.widgets.chart.DACustomChartSeries;
 
 public class UserCustomChart extends DATimelineChart {
-       private DACustomChartSeries userSeries0 = null;
-       private DACustomChartSeries userSeries1 = null;
-       private DACustomChartSeries userSeries2 = null;
-       private DACustomChartSeries userSeries3 = null;
-       
        public UserCustomChart(int chartType, String chartName) {
                this.chartType = chartType;
                this.chartName = chartName;
@@ -52,7 +47,6 @@ public class UserCustomChart extends DATimelineChart {
 
        @Override
        public List<XYSeries> getBaseSeriesList() {
-               // TODO Auto-generated method stub
                return null;
        }
 
@@ -91,4 +85,12 @@ public class UserCustomChart extends DATimelineChart {
                // TODO Auto-generated method stub
 
        }
+       
+       public void addSeries(DACustomChartSeries series) {
+               chart.addSeries(series);
+       }
+       
+       public int getSeriesNum() {
+               return chart.getSeriesList().size();
+       }
 }