[Title]add custom color constants; add exception handling routine: more 10 chart...
authorsanghyunnim.lee <sanghyunnim.lee@samsung.com>
Thu, 20 Sep 2012 12:04:32 +0000 (21:04 +0900)
committersanghyunnim.lee <sanghyunnim.lee@samsung.com>
Thu, 20 Sep 2012 12:04:32 +0000 (21:04 +0900)
[Type]
[Module]
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/UserCustomChart.java.bak [deleted file]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/CustomLogParser.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/CustomLogParser.java.bak [deleted file]

diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/UserCustomChart.java.bak b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/UserCustomChart.java.bak
deleted file mode 100755 (executable)
index 5ba3b25..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- *  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.chart;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.logparser.LogCenterConstants;
-import org.tizen.dynamicanalyzer.logparser.LogPackage;
-import org.tizen.dynamicanalyzer.logparser.Logs;
-import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
-import org.tizen.dynamicanalyzer.widgets.chart.DACustomChart;
-import org.tizen.dynamicanalyzer.widgets.chart.DACustomChartSeries;
-
-public class UserCustomChart extends TimelineChart {
-       private ArrayList<DACustomChartSeries> tempSeriesList;
-       private boolean[] usedColor;
-       
-       public UserCustomChart(int chartType, String chartName) {
-               this.chartType = chartType;
-               this.chartName = chartName;
-               chartIcon = ImageResources.CHART_CUSTOM;
-               addIcon = ImageResources.ADD_CHART_CUSTOM;
-               
-               tempSeriesList = new ArrayList<DACustomChartSeries>();
-               usedColor = new boolean[11];
-       }
-       
-       @Override
-       public DACustomChart createDAChart(Composite parent) {
-               List<DACustomChartSeries> seriesList = null;
-               if(chart != null) {
-                       seriesList = chart.getSeriesList();
-               }
-               
-               chart = new DACustomChart(parent, chartName);
-               if(seriesList !=null) {
-                       for(DACustomChartSeries series : seriesList) {
-                               chart.addSeries(series);
-                       }
-               }
-               setChartStyle();
-               
-               return chart;
-       }
-
-       @Override
-       public void clear() {
-               // TODO Auto-generated method stub
-       }
-
-       @Override
-       public void dispose() {
-               // TODO Auto-generated method stub
-       }
-       
-       @Override
-       public void parsingLogPackage(LogPackage logPack, int probeType) {
-               // TODO Auto-generated method stub
-               if (!isAbleToParse(logPack, LogCenterConstants.LOG_DEVICE)) {
-                       return;
-               }
-               Logs logList = logPack.getLogs(LogCenterConstants.LOG_DEVICE);
-               List<List<String>> logs = logList.getLogs();
-
-               if(logs.size() <= 0){
-                       return;
-               }
-               parsingLog(logs.get(logs.size()-1));
-       }
-       
-       private void parsingLog(List<String> log) {
-               double time = 0;
-               
-               try {
-                       time = Double
-                                       .parseDouble(log
-                                                       .get(LogCenterConstants.DEVICE_TIME_INDEX))
-                                       / TimelineConstants.MEGA;
-               } catch (NumberFormatException ne) {
-                       ne.printStackTrace();
-               } catch (NullPointerException ne) {
-                       ne.printStackTrace();
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
-               chart.getPlot().setValidEndX(time);
-       }
-       
-       public void addSeries(DACustomChartSeries series) {
-               chart.addSeries(series);
-       }
-       
-       public void addTempSeries(DACustomChartSeries series) {
-               tempSeriesList.add(series);
-       }
-       
-       public ArrayList<DACustomChartSeries> getTempSeries() {
-               return tempSeriesList;
-       }
-       
-       public int getSeriesNum() {
-               return chart.getSeriesList().size();
-       }
-
-       @Override
-       public List<DACustomChartSeries> getBaseDASeriesList() {
-               if(chart != null) {
-                       return chart.getSeriesList();
-               }
-               
-               return null;
-       }
-       
-       public DACustomChart getChart() {
-               return chart;
-       }
-}
index 2874f1a..1d35537 100755 (executable)
@@ -46,6 +46,19 @@ public class CustomLogParser {
        private static final String API_NAME_DA_MARK = "da_mark";  //$NON-NLS-1$
        private static final String API_NAME_TIMER_THREAD = "timerThread";  //$NON-NLS-1$
        
+       private final static int CUSTOM_COLOR_AUTO = 0;
+       private final static int CUSTOM_COLOR_BLUE = 1;
+       private final static int CUSTOM_COLOR_GREEN = 2;
+       private final static int CUSTOM_COLOR_RED = 3;
+       private final static int CUSTOM_COLOR_BROWN = 4;
+       private final static int CUSTOM_COLOR_PURPLE = 5;
+       private final static int CUSTOM_COLOR_NAVY = 6;
+       private final static int CUSTOM_COLOR_CHOCOLATE = 7;
+       private final static int CUSTOM_COLOR_INDIGO = 8;
+       private final static int CUSTOM_COLOR_MAGNETA = 9;
+       private final static int CUSTOM_COLOR_TEAL = 10;
+       
+       
        private static TimelineChartManager chartManager = TimelineChartManager.getInstance();
        private static Map<Integer, DACustomChartSeries> customChartSeriesMap = new HashMap<Integer, DACustomChartSeries>();
        
@@ -74,6 +87,7 @@ public class CustomLogParser {
                        UserCustomChart chart = (UserCustomChart)chartManager.getChartInstance(chartType);
                        
                        if(chart == null) {
+                               System.out.println("unrecognized chart handle");
                                return;
                        }
 
@@ -81,10 +95,14 @@ public class CustomLogParser {
                        int seriesStyle = Integer.parseInt(log.get(LogCenterConstants.CUSTOM_CHART_TYPE));
                        String seriesName = log.get(LogCenterConstants.CUSTOM_CHART_TEXT);
                        int colorIndex = Integer.parseInt(log.get(LogCenterConstants.CUSTOM_CHART_COLOR));
-                       if(colorIndex == 0) {
+                       if(colorIndex == CUSTOM_COLOR_AUTO) {
                                colorIndex = chart.getUnusedColorIndex();
                        }
                        Color seriesColor = getCustomColor(colorIndex);
+                       if(seriesColor == null) {
+                               System.out.println("undefined custom color");
+                               return;
+                       }
                        DACustomChartSeries series = new DACustomChartSeries(seriesName, seriesStyle, seriesColor);
                        chart.addTempSeries(series, colorIndex);
                        customChartSeriesMap.put(seriesHandle, series);
@@ -126,28 +144,28 @@ public class CustomLogParser {
        
        private static Color getCustomColor(int colorType) {
                switch(colorType) {
-               case 1:
+               case CUSTOM_COLOR_BLUE:
                        return ColorResources.BLUE;
-               case 2:
+               case CUSTOM_COLOR_GREEN:
                        return ColorResources.GREEN;
-               case 3:
+               case CUSTOM_COLOR_RED:
                        return ColorResources.RED;
-               case 4:
+               case CUSTOM_COLOR_BROWN:
                        return ColorResources.BROWN;
-               case 5:
+               case CUSTOM_COLOR_PURPLE:
                        return ColorResources.PURPLE;
-               case 6:
+               case CUSTOM_COLOR_NAVY:
                        return ColorResources.NAVY;
-               case 7:
+               case CUSTOM_COLOR_CHOCOLATE:
                        return ColorResources.CHOCOLATE;
-               case 8:
+               case CUSTOM_COLOR_INDIGO:
                        return ColorResources.INDIGO;
-               case 9:
+               case CUSTOM_COLOR_MAGNETA:
                        return ColorResources.MAGNETA;
-               case 10:
+               case CUSTOM_COLOR_TEAL:
                        return ColorResources.TEAL;
                default:
-                       return ColorResources.RED;
+                       return null;
                }
        }
 }
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/CustomLogParser.java.bak b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/CustomLogParser.java.bak
deleted file mode 100755 (executable)
index 56ba7dd..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- *  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.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.swt.graphics.Color;
-import org.tizen.dynamicanalyzer.logparser.LogCenterConstants;
-import org.tizen.dynamicanalyzer.logparser.LogPackage;
-import org.tizen.dynamicanalyzer.logparser.Logs;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.ui.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$
-       private static final String API_NAME_CREATE_SERIES = "da_create_series";  //$NON-NLS-1$
-       private static final String API_NAME_DA_LOG= "da_log";  //$NON-NLS-1$
-       private static final String API_NAME_DA_MARK = "da_mark";  //$NON-NLS-1$
-       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_CHART)) {
-                       return;
-               }
-               
-               Logs logs = logPack.getLogs(LogCenterConstants.LOG_CUSTOM_CHART);
-               List<List<String>> logList = logs.getLogs();
-               for(int i = 0; i< logList.size(); i++) {
-                       parsingLog(logList.get(i));
-               }
-       }
-       
-       private static void parsingLog(List<String> log) {
-               String apiName = log.get(LogCenterConstants.APINAME_INDEX);
-               
-               if(apiName.equals(API_NAME_CREATE_CHART)) {
-                       int chartHandle = Integer.parseInt(log.get(LogCenterConstants.RETURN_INDEX));
-                       String chartName = log.get(LogCenterConstants.CUSTOM_CHART_TEXT);
-                       chartManager.addCustomChart(new UserCustomChart(chartHandle, chartName));
-               } 
-               else if(apiName.equals(API_NAME_CREATE_SERIES)) {
-                       int chartType = Integer.parseInt(log.get(LogCenterConstants.CUSTOM_CHART_HANDLE));
-                       UserCustomChart chart = (UserCustomChart)chartManager.getChartInstance(chartType);
-                       
-                       if(chart == null) {
-                               return;
-                       }
-
-                       int seriesHandle = Integer.parseInt(log.get(LogCenterConstants.RETURN_INDEX));
-                       int seriesStyle = Integer.parseInt(log.get(LogCenterConstants.CUSTOM_CHART_TYPE));
-                       String seriesName = log.get(LogCenterConstants.CUSTOM_CHART_TEXT);
-                       int colorIndex = Integer.parseInt(log.get(LogCenterConstants.CUSTOM_CHART_COLOR));
-                       if(colorIndex == 0) {
-                               colorIndex = chart.getUnusedColorIndex();
-                       }
-                       Color seriesColor = getCustomColor(colorIndex);
-                       DACustomChartSeries series = new DACustomChartSeries(seriesName, seriesStyle, seriesColor);
-                       chart.addTempSeries(series, colorIndex);
-                       customChartSeriesMap.put(seriesHandle, series);
-               } 
-               else if(apiName.equals(API_NAME_DA_LOG) || apiName.equals(API_NAME_TIMER_THREAD)) {
-                       int seriesHandle = Integer.parseInt(log.get(LogCenterConstants.CUSTOM_CHART_HANDLE));
-                       double time = Double.parseDouble(log.get(LogCenterConstants.TIME_INDEX)) 
-                                       / TimelineConstants.MEGA;
-                       double value = Double.parseDouble(log.get(LogCenterConstants.CUSTOM_CHART_VALUE));
-                       DACustomChartSeries series = customChartSeriesMap.get(seriesHandle);
-                       series.addSeriesItem(new DACustomChartSeriesItem(time, value, String.valueOf(value)));
-               } 
-               else if(apiName.equals(API_NAME_DA_MARK)) {
-                       // TODO custom marking
-               }
-       }
-       
-       private static boolean isAbleToParse(LogPackage logPack, int probeType) {
-               Logs logList = logPack.getLogs(probeType);
-
-               if (null == logList) {
-                       return false;
-               }
-
-               if (null == logList.getLogs()) {
-                       return false;
-               }
-
-               if (0 > logList.getLogs().size()) {
-                       return false;
-               }
-               
-               return true;
-       }
-       
-       public static void clear() {
-               customChartSeriesMap.clear();
-       }
-       
-       private static Color getCustomColor(int colorType) {
-               switch(colorType) {
-               case 1:
-                       return ColorResources.BLUE;
-               case 2:
-                       return ColorResources.GREEN;
-               case 3:
-                       return ColorResources.RED;
-               case 4:
-                       return ColorResources.BROWN;
-               case 5:
-                       return ColorResources.PURPLE;
-               case 6:
-                       return ColorResources.NAVY;
-               case 7:
-                       return ColorResources.CHOCOLATE;
-               case 8:
-                       return ColorResources.INDIGO;
-               case 9:
-                       return ColorResources.MAGNETA;
-               case 10:
-                       return ColorResources.TEAL;
-               default:
-                       return ColorResources.RED;
-               }
-       }
-}