+++ /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.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;
- }
-}
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>();
UserCustomChart chart = (UserCustomChart)chartManager.getChartInstance(chartType);
if(chart == null) {
+ System.out.println("unrecognized chart handle");
return;
}
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);
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;
}
}
}
+++ /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.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;
- }
- }
-}