class="com.samsung.dynamicanalyzer.ui.views.lifecycle.LifeCycleSubject">
</updateLog>
</extension>
+ <extension
+ point="com.samsung.dynamicanalyzer.updateLog">
+ <updateLog
+ class="com.samsung.dynamicanalyzer.extensions.TimelineUpdateTest">
+ </updateLog>
+ </extension>
</plugin>
--- /dev/null
+package com.samsung.dynamicanalyzer.constants;
+
+public class TimelineConstants {
+
+ public static final int CHART_TYPE_DEFAULT = 0;
+ public static final int CHART_TYPE_AREA_PERCENT = 1;
+ public static final int CHART_TYPE_FDUSAGE = 2;
+ public static final int CHART_TYPE_READ_WRITE = 3;
+
+ public static final int COLUMN_TIME = 3;
+ public static final int COLUMN_API_NAME = 2;
+ public static final int COLUMN_FD_VALUE = 9;
+ public static final int COLUMN_FD_TYPE = 10;
+ public static final int COLUMN_FD_API_TYPE = 11;
+
+ public static final long MS_TO_FIXED_MS = 54000000;
+
+ public static final int FD_TYPE_FILE = 0;
+ public static final int FD_TYPE_SOCKET = 1;
+
+ public static final int FD_API_TYPE_OPEN = 0;
+ public static final int FD_API_TYPE_CLOSE = 1;
+ public static final int FD_API_TYPE_READ = 2;
+ public static final int FD_API_TYPE_WRITE = 3;
+
+ public static final long CHART_RANGE_DEFAULT = 60000;
+ public static final int COLUMN_SIZE = 8;
+
+}
--- /dev/null
+package com.samsung.dynamicanalyzer.extensions;
+
+import com.samsung.dynamicanalyzer.extensionPoints.IUpdateLog;
+import com.samsung.dynamicanalyzer.model.LogPackage;
+import com.samsung.dynamicanalyzer.ui.views.AdditionalTimelineView;
+import com.samsung.dynamicanalyzer.ui.views.TimelineView;
+import com.samsung.dynamicanalyzer.utils.TimelineUtils;
+
+public class TimelineUpdateTest implements IUpdateLog {
+
+ @Override
+ public void postUpdateLog(LogPackage logPack) {
+
+ TimelineView timelineView = TimelineUtils.getTimelineView();
+ timelineView.updateData(logPack);
+
+ AdditionalTimelineView timelineViewSub = TimelineUtils
+ .getTimelineViewSub();
+ timelineViewSub.updateData(logPack);
+
+ }
+
+}
public class TestInputHandler extends AbstractHandler {
+ static int times = 0;
+ boolean TimelineTest = true;
+ boolean ApiTest = false;
+
public static final String ID = "com.samsung.dynamicanalyzer.commands.testInput"; //$NON-NLS-1$
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Project old = AnalyzerManager.getProject();
Project neo = new Project();
- old.setName("testApp");
- old.setDevice("testEmul");
neo.init(old);
+
+ List<String> input = new ArrayList<String>();
+
+ if (TimelineTest) {
+ input = makeTimelineTestLog();
+ } else if (ApiTest) {
+ input = makeApiTestLog();
+ } else {
+ input = makeTestLog();
+ }
+
+ LogSpliter.logSlicing(input);
+ return null;
+ }
+
+ private List<String> makeTestLog() {
List<String> input = new ArrayList<String>();
+
input.add("5`,0`,open`,390`,/dev/log_main,1`,5`,0`,0`,`,5`,0`,0`,");
input.add("5`,1`,open`,523`,/dev/log_radio,1`,7`,0`,0`,`,7`,0`,0`,");
input.add("5`,2`,open`,589`,/dev/log_system,1`,8`,0`,0`,`,8`,0`,0`,");
input.add("5`,8`,close`,58741`,19`,0`,0`,0`,`,0`,0`,0`,");
input.add("5`,9`,close`,59342`,19`,0`,0`,2`,`,0`,0`,0`,");
input.add("5`,10`,open`,59904`,/opt/var/kdb/db/menu_widget/language,0`,19`,0`,2`,`,19`,0`,0`,");
- LogSpliter.logSlicing(input);
- return null;
+ return input;
+ }
+
+ private List<String> makeApiTestLog() {
+ List<String> input = new ArrayList<String>();
+
+ input.add("5`,9`,open`,157`,input`,return`,pcaddr`,error`,size`,15`,fdtype`,fdapitype`,");
+ input.add("5`,9`,write`,180`,input`,failed`,pcaddr`,error`,size`,15`,fdtype`,fdapitype`,");
+ input.add("5`,9`,write`,220`,input`,return`,pcaddr`,error`,size`,15`,fdtype`,fdapitype`,");
+ input.add("5`,9`,close`,250`,input`,return`,pcaddr`,error`,size`,15`,fdtype`,fdapitype`,");
+
+ input.add("5`,9`,open`,300`,input`,return`,pcaddr`,error`,size`,17`,fdtype`,fdapitype`,");
+
+ input.add("5`,9`,open`,450`,input`,return`,pcaddr`,error`,size`,18`,fdtype`,fdapitype`,");
+
+ input.add("5`,9`,open`,521`,input`,return`,pcaddr`,error`,size`,13`,fdtype`,fdapitype`,");
+
+ input.add("5`,9`,write`,535`,input`,return`,pcaddr`,error`,size`,18`,fdtype`,fdapitype`,");
+
+ input.add("5`,9`,write`,545`,input`,return`,pcaddr`,error`,size`,13`,fdtype`,fdapitype`,");
+ input.add("5`,9`,close`,589`,input`,return`,pcaddr`,error`,size`,13`,fdtype`,fdapitype`,");
+
+ input.add("5`,9`,write`,600`,input`,return`,pcaddr`,error`,size`,17`,fdtype`,fdapitype`,");
+
+ input.add("5`,9`,open`,632`,input`,return`,pcaddr`,error`,size`,11`,fdtype`,fdapitype`,");
+ input.add("5`,9`,write`,637`,input`,return`,pcaddr`,error`,size`,11`,fdtype`,fdapitype`,");
+
+ input.add("5`,9`,write`,650`,input`,return`,pcaddr`,error`,size`,17`,fdtype`,fdapitype`,");
+ input.add("5`,9`,close`,670`,input`,return`,pcaddr`,error`,size`,18`,fdtype`,fdapitype`,");
+
+ input.add("5`,9`,close`,689`,input`,return`,pcaddr`,error`,size`,11`,fdtype`,fdapitype`,");
+
+ input.add("5`,9`,close`,702`,input`,return`,pcaddr`,error`,size`,17`,fdtype`,fdapitype`,");
+
+ return input;
+ }
+
+ private List<String> makeTimelineTestLog() {
+ List<String> input = new ArrayList<String>();
+
+ String DumStr = "/dev/log_radio`,1`,7`,0`,1000`,";
+ String timeStr = times++ * 1000 + "`,";
+
+ // File FD Log
+ input.add("5`," + times + "`,open`," + timeStr + DumStr + "7`,0`,0`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,fopen`," + timeStr + DumStr + "8`,0`,0`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,freopen`," + timeStr + DumStr
+ + "9`,0`,0`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,openat`," + timeStr + DumStr
+ + "10`,0`,0`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,openat`," + timeStr + DumStr + "6`,0`,0`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,fclose`," + timeStr + DumStr + "6`,0`,1`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,close`," + timeStr + DumStr + "7`,0`,1`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,close`," + timeStr + DumStr + "8`,0`,1`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,close`," + timeStr + DumStr + "9`,0`,1`,");
+
+ if (0 == times % 2) {
+ // Socket FD Log
+ input.add("5`," + times + "`,open`," + timeStr + DumStr
+ + "11`,1`,0`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,open`," + timeStr + DumStr
+ + "12`,1`,0`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,close`," + timeStr + DumStr
+ + "11`,1`,1`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,close`," + timeStr + DumStr
+ + "12`,1`,1`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,close`," + timeStr + DumStr
+ + "12`,1`,1`,");
+ }
+
+ input.add("5`," + times + "`,read`," + timeStr + DumStr + "11`,1`,2`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,read`," + timeStr + DumStr + "12`,1`,2`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,write`," + timeStr + DumStr + "11`,1`,3`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,write`," + timeStr + DumStr + "12`,1`,3`,");
+ timeStr = times++ * 1000 + "`,";
+ input.add("5`," + times + "`,write`," + timeStr + DumStr + "12`,1`,3`,");
+
+ return input;
+
}
-}
+}
\ No newline at end of file
--- /dev/null
+package com.samsung.dynamicanalyzer.timeline.chart;
+
+import java.awt.BasicStroke;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Display;
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.labels.StandardXYToolTipGenerator;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.renderer.xy.XYStepRenderer;
+import org.jfree.data.time.FixedMillisecond;
+import org.jfree.data.time.TimeSeries;
+import org.jfree.data.time.TimeSeriesCollection;
+
+import com.samsung.dynamicanalyzer.constants.TimelineConstants;
+import com.samsung.dynamicanalyzer.model.Logs;
+
+public class FDUsageChart extends TimelineChart {
+
+ class FDSeriesInfo {
+ String FDType;
+ TimeSeries baseSeries;
+ TimeSeries newSeries;
+
+ HashSet<Integer> fdValueSet;
+ }
+
+ private FDSeriesInfo fileFDinfo;
+ private FDSeriesInfo socketFDinfo;
+
+ long currentTime;
+
+ public FDUsageChart() {
+
+ fileFDinfo = new FDSeriesInfo();
+ fileFDinfo.FDType = "File";
+ fileFDinfo.baseSeries = new TimeSeries("File");
+ fileFDinfo.newSeries = new TimeSeries("File");
+ fileFDinfo.fdValueSet = new HashSet<Integer>();
+
+ socketFDinfo = new FDSeriesInfo();
+ socketFDinfo.FDType = "Socket";
+ socketFDinfo.baseSeries = new TimeSeries("Socket");
+ socketFDinfo.newSeries = new TimeSeries("Socket");
+ socketFDinfo.fdValueSet = new HashSet<Integer>();
+
+ }
+
+ @Override
+ public JFreeChart createChart() {
+
+ /* Data */
+
+ TimeSeriesCollection dataset = createFDDataset();
+
+ /* Create */
+
+ chart = ChartFactory.createTimeSeriesChart("FD Usage chart", "Time",
+ "Number", dataset, true, true, false);
+
+ /* Rendering */
+
+ XYPlot xyplot = (XYPlot) chart.getPlot();
+ XYStepRenderer renderer = new XYStepRenderer();
+ renderer.setBaseShapesVisible(true);
+ renderer.setSeriesStroke(0, new BasicStroke(2.0F));
+ renderer.setSeriesStroke(1, new BasicStroke(2.0F));
+ renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
+ renderer.setDefaultEntityRadius(6);
+
+ xyplot.setRenderer(renderer);
+
+ xyplot.getDomainAxis().setRange(
+ TimelineConstants.MS_TO_FIXED_MS - 1,
+ TimelineConstants.MS_TO_FIXED_MS
+ + TimelineConstants.CHART_RANGE_DEFAULT);
+
+ return chart;
+ }
+
+ @Override
+ public boolean updateDataSet(Logs logList) {
+
+ if (null == logList || null == logList.getLogs()) {
+ return false;
+ }
+
+ if (0 > logList.getLogs().size()) {
+ return false;
+ }
+
+ List<List<String>> logs = logList.getLogs();
+
+ for (List<String> log : logs) {
+ parsingElement(log);
+ }
+
+ /* TODO : Use Thread */
+ update();
+
+ return false;
+ }
+
+ @Override
+ public void update() {
+
+ if (null == fileFDinfo.newSeries || null == socketFDinfo.newSeries) {
+ return;
+ }
+
+ if (0 == fileFDinfo.newSeries.getItemCount()
+ && 0 == socketFDinfo.newSeries.getItemCount()) {
+ return;
+ }
+
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ fileFDinfo.baseSeries.addAndOrUpdate(fileFDinfo.newSeries);
+ socketFDinfo.baseSeries.addAndOrUpdate(socketFDinfo.newSeries);
+
+ fileFDinfo.newSeries.clear();
+ socketFDinfo.newSeries.clear();
+
+ if (TimelineConstants.CHART_RANGE_DEFAULT < currentTime) {
+
+ setChartRange(TimelineConstants.MS_TO_FIXED_MS
+ + currentTime
+ - TimelineConstants.CHART_RANGE_DEFAULT,
+ TimelineConstants.MS_TO_FIXED_MS + currentTime);
+ }
+ }
+ });
+ }
+
+ private TimeSeriesCollection createFDDataset() {
+
+ TimeSeriesCollection timeDataSet = new TimeSeriesCollection(
+ fileFDinfo.baseSeries);
+ timeDataSet.addSeries(socketFDinfo.baseSeries);
+
+ return timeDataSet;
+
+ }
+
+ private void parsingElement(List<String> log) {
+
+ if (null == log || 0 > log.size()) {
+ return;
+ }
+
+ /* API check */
+ int fdApiType = 0;
+
+ try {
+ fdApiType = Integer.parseInt(log
+ .get(TimelineConstants.COLUMN_FD_API_TYPE));
+ } catch (NumberFormatException ne) {
+ ne.printStackTrace();
+ }
+
+ if (TimelineConstants.FD_API_TYPE_OPEN != fdApiType
+ && TimelineConstants.FD_API_TYPE_CLOSE != fdApiType) {
+ return;
+ }
+
+ long time = 0;
+ int fdValue = 0;
+ int fdType = 0;
+
+ try {
+ time = Long.parseLong(log.get(TimelineConstants.COLUMN_TIME));
+ fdValue = Integer.parseInt(log
+ .get(TimelineConstants.COLUMN_FD_VALUE));
+ fdType = Integer
+ .parseInt(log.get(TimelineConstants.COLUMN_FD_TYPE));
+ } catch (NumberFormatException ne) {
+ ne.printStackTrace();
+ } catch (NullPointerException ne) {
+ ne.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ addNewSeriesData(time, fdValue, fdType, fdApiType);
+
+ }
+
+ private void addNewSeriesData(long time, int fdValue, int fdType,
+ int fdApiType) {
+
+ if (TimelineConstants.FD_TYPE_FILE == fdType) {
+ addNewSeriesFileData(time, fdValue, fdApiType);
+ } else if (TimelineConstants.FD_TYPE_SOCKET == fdType) {
+ addNewSeriesSocketData(time, fdValue, fdApiType);
+ } else {
+ return;
+ }
+
+ /* FIXME : Temp code */
+ currentTime = time;
+ }
+
+ private void addNewSeriesFileData(long time, int fdValue, int fdApiType) {
+
+ if (TimelineConstants.FD_API_TYPE_OPEN == fdApiType) {
+ fileFDinfo.fdValueSet.add(fdValue);
+ } else if (TimelineConstants.FD_API_TYPE_CLOSE == fdApiType) {
+ fileFDinfo.fdValueSet.remove(fdValue);
+ } else {
+ return;
+ }
+
+ FixedMillisecond fmSec = convertToFixedMs(time);
+ fileFDinfo.newSeries.addOrUpdate(fmSec, fileFDinfo.fdValueSet.size());
+
+ return;
+ }
+
+ private void addNewSeriesSocketData(long time, int fdValue, int fdApiType) {
+ if (TimelineConstants.FD_API_TYPE_OPEN == fdApiType) {
+ socketFDinfo.fdValueSet.add(fdValue);
+ } else if (TimelineConstants.FD_API_TYPE_CLOSE == fdApiType) {
+ socketFDinfo.fdValueSet.remove(fdValue);
+ } else {
+ return;
+ }
+
+ FixedMillisecond fmSec = convertToFixedMs(time);
+ socketFDinfo.newSeries.addOrUpdate(fmSec,
+ socketFDinfo.fdValueSet.size());
+
+ return;
+ }
+
+}
--- /dev/null
+package com.samsung.dynamicanalyzer.timeline.chart;
+
+import java.util.List;
+
+import org.eclipse.swt.widgets.Display;
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.renderer.xy.XYBarRenderer;
+import org.jfree.data.time.FixedMillisecond;
+import org.jfree.data.time.TimeSeries;
+import org.jfree.data.time.TimeSeriesCollection;
+
+import com.samsung.dynamicanalyzer.constants.TimelineConstants;
+import com.samsung.dynamicanalyzer.model.Logs;
+
+public class ReadWriteChart extends TimelineChart {
+
+ class RWSeriesInfo {
+ TimeSeries baseSeries;
+ TimeSeries newSeries;
+ }
+
+ RWSeriesInfo readInfo;
+ RWSeriesInfo writeInfo;
+
+ long currentTime;
+
+ public ReadWriteChart() {
+
+ readInfo = new RWSeriesInfo();
+ readInfo.baseSeries = new TimeSeries("Read");
+ readInfo.newSeries = new TimeSeries("Read");
+
+ writeInfo = new RWSeriesInfo();
+ writeInfo.baseSeries = new TimeSeries("Read");
+ writeInfo.newSeries = new TimeSeries("Read");
+
+ }
+
+ @Override
+ public JFreeChart createChart() {
+
+ /* Data */
+
+ TimeSeriesCollection dataset = createRWDataset();
+
+ /* Create */
+
+ chart = ChartFactory.createXYBarChart("Read write chart", "Time", true,
+ "Size", dataset, PlotOrientation.VERTICAL, true, true, false);
+
+ /* Rendering */
+
+ XYPlot xyplot = (XYPlot) chart.getPlot();
+ XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer();
+ renderer.setShadowVisible(false);
+ renderer.setDrawBarOutline(false);
+
+ xyplot.setRenderer(renderer);
+
+ xyplot.getDomainAxis().setRange(
+ TimelineConstants.MS_TO_FIXED_MS - 1,
+ TimelineConstants.MS_TO_FIXED_MS
+ + TimelineConstants.CHART_RANGE_DEFAULT);
+
+ return chart;
+
+ }
+
+ @Override
+ public boolean updateDataSet(Logs logList) {
+ if (null == logList || null == logList.getLogs()) {
+ return false;
+ }
+
+ if (0 > logList.getLogs().size()) {
+ return false;
+ }
+
+ List<List<String>> logs = logList.getLogs();
+
+ for (List<String> log : logs) {
+ parsingElement(log);
+ }
+
+ /* TODO : Use Thread */
+ update();
+
+ return false;
+ }
+
+ @Override
+ public void update() {
+
+ if (null == readInfo.newSeries || null == writeInfo.newSeries) {
+ return;
+ }
+
+ if (0 == readInfo.newSeries.getItemCount()
+ && 0 == writeInfo.newSeries.getItemCount()) {
+ return;
+ }
+
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ readInfo.baseSeries.addAndOrUpdate(readInfo.newSeries);
+ writeInfo.baseSeries.addAndOrUpdate(writeInfo.newSeries);
+
+ readInfo.newSeries.clear();
+ writeInfo.newSeries.clear();
+
+ if (TimelineConstants.CHART_RANGE_DEFAULT < currentTime) {
+
+ setChartRange(TimelineConstants.MS_TO_FIXED_MS
+ + currentTime
+ - TimelineConstants.CHART_RANGE_DEFAULT,
+ TimelineConstants.MS_TO_FIXED_MS + currentTime);
+ }
+ }
+ });
+ }
+
+ private void parsingElement(List<String> log) {
+ if (null == log || 0 > log.size()) {
+ return;
+ }
+
+ /* API check */
+ int fdApiType = 0;
+
+ try {
+ fdApiType = Integer.parseInt(log
+ .get(TimelineConstants.COLUMN_FD_API_TYPE));
+ } catch (NumberFormatException ne) {
+ ne.printStackTrace();
+ }
+
+ if (TimelineConstants.FD_API_TYPE_READ != fdApiType
+ && TimelineConstants.FD_API_TYPE_WRITE != fdApiType) {
+ return;
+ }
+
+ long time = 0;
+ int size = 0;
+ try {
+ time = Long.parseLong(log.get(TimelineConstants.COLUMN_TIME));
+ size = Integer.parseInt(log.get(TimelineConstants.COLUMN_SIZE));
+ } catch (NumberFormatException ne) {
+ ne.printStackTrace();
+ } catch (NullPointerException ne) {
+ ne.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ addNewSeriesData(time, size, fdApiType);
+ }
+
+ private void addNewSeriesData(long time, int size, int fdApiType) {
+
+ FixedMillisecond fmSec = convertToFixedMs(time);
+ if (TimelineConstants.FD_API_TYPE_READ == fdApiType) {
+ readInfo.newSeries.addOrUpdate(fmSec, size);
+ } else if (TimelineConstants.FD_API_TYPE_WRITE == fdApiType) {
+ writeInfo.newSeries.addOrUpdate(fmSec, size);
+ } else {
+ return;
+ }
+ /* FIXME : Temp code */
+ currentTime = time;
+ }
+
+ private TimeSeriesCollection createRWDataset() {
+
+ TimeSeriesCollection timeDataSet = new TimeSeriesCollection(
+ readInfo.baseSeries);
+ timeDataSet.addSeries(writeInfo.baseSeries);
+
+ return timeDataSet;
+
+ }
+
+}
--- /dev/null
+package com.samsung.dynamicanalyzer.timeline.chart;
+
+import java.text.NumberFormat;
+
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.ValueAxis;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.data.time.FixedMillisecond;
+import org.jfree.data.time.Millisecond;
+import org.jfree.data.time.TimeSeries;
+import org.jfree.data.time.TimeSeriesCollection;
+import org.jfree.data.xy.XYDataset;
+
+import com.samsung.dynamicanalyzer.constants.TimelineConstants;
+import com.samsung.dynamicanalyzer.model.Logs;
+
+public abstract class TimelineChart {
+
+ public abstract JFreeChart createChart();
+
+ public abstract boolean updateDataSet(Logs logs);
+
+ public abstract void update();
+
+ protected JFreeChart chart;
+
+ public JFreeChart createDefaultChart() {
+
+ XYDataset dataSet = createDefaultDataset();
+
+ JFreeChart chart = ChartFactory.createTimeSeriesChart("Default",
+ "Time", "Usage", dataSet, true, false, false);
+
+ final XYPlot plot = chart.getXYPlot();
+
+ /* Axis set */
+ ValueAxis axis = plot.getDomainAxis();
+
+ axis.setAutoRange(true);
+ axis.setFixedAutoRange(60000.0);
+
+ NumberAxis numAxis = (NumberAxis) plot.getRangeAxis();
+ numAxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
+ numAxis.setUpperMargin(0.10000000000000001D);
+
+ return chart;
+
+ }
+
+ public XYDataset createDefaultDataset() {
+
+ TimeSeries timeSeries = new TimeSeries("Time data");
+
+ TimeSeriesCollection TimeDataSet = new TimeSeriesCollection(timeSeries);
+
+ Millisecond ms = new Millisecond(0, 0, 0, 0, 1, 1, 2010);
+
+ for (int i = 0; i < 60; i++) {
+
+ double percent = i;
+ timeSeries.addOrUpdate(ms, percent / 100);
+ ms = null;
+ ms = new Millisecond(0, i, 0, 0, 1, 1, 2010);
+ }
+
+ return TimeDataSet;
+ }
+
+ protected void setChartRange(long startMs, long endMs) {
+
+ if (null == chart) {
+ return;
+ }
+
+ XYPlot plot = (XYPlot) chart.getPlot();
+ plot.getDomainAxis().setRange(startMs, endMs);
+ }
+
+ protected FixedMillisecond convertToFixedMs(long timeMs) {
+
+ timeMs = timeMs + TimelineConstants.MS_TO_FIXED_MS;
+ FixedMillisecond sec = new FixedMillisecond(timeMs);
+
+ return sec;
+ }
+}
--- /dev/null
+package com.samsung.dynamicanalyzer.timeline.chart;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jfree.chart.JFreeChart;
+
+import com.samsung.dynamicanalyzer.AnalyzerConstants;
+import com.samsung.dynamicanalyzer.constants.TimelineConstants;
+import com.samsung.dynamicanalyzer.model.LogPackage;
+import com.samsung.dynamicanalyzer.model.Logs;
+
+public class TimelineChartManager {
+
+ // TimelineChart chartCreator;
+ List<TimelineChart> timelineChartList;
+
+ FDUsageChart fdUsageChart;
+ ReadWriteChart rwChart;
+
+ public TimelineChartManager() {
+ timelineChartList = new ArrayList<TimelineChart>();
+
+ fdUsageChart = new FDUsageChart();
+ rwChart = new ReadWriteChart();
+
+ timelineChartList.add(fdUsageChart);
+ timelineChartList.add(rwChart);
+ }
+
+ public JFreeChart createTimelineChart(int chartType) {
+
+ JFreeChart chart = null;
+
+ switch (chartType) {
+ case TimelineConstants.CHART_TYPE_FDUSAGE:
+ chart = fdUsageChart.createChart();
+ break;
+ case TimelineConstants.CHART_TYPE_READ_WRITE:
+ chart = rwChart.createChart();
+ break;
+ case TimelineConstants.CHART_TYPE_DEFAULT:
+ chart = fdUsageChart.createDefaultChart();
+ break;
+ default:
+ break;
+ }
+
+ return chart;
+ }
+
+ public void updateTimelineChartData(LogPackage logPack) {
+ // TODO Auto-generated method stub
+
+ Logs logList = logPack.getLogs(AnalyzerConstants.PROBE_RESOURCE);
+ if (null == logList) {
+ return;
+ }
+
+ int chartListSize = timelineChartList.size();
+ for (int i = 0; i < chartListSize; i++) {
+ timelineChartList.get(i).updateDataSet(logList);
+ }
+ // fdUsageChart.updateChartDataSet(logList);
+ // rwChart.updateChartDataSet(logList);
+
+ }
+
+ public void updateTimelineChart() {
+ //
+ int chartListSize = timelineChartList.size();
+ for (int i = 0; i < chartListSize; i++) {
+ timelineChartList.get(i).update();
+ }
+ }
+}
package com.samsung.dynamicanalyzer.ui.views;\r
\r
+import org.eclipse.swt.SWT;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.part.ViewPart;\r
+import org.jfree.chart.JFreeChart;\r
+import org.jfree.experimental.chart.swt.ChartComposite;\r
+\r
+import com.samsung.dynamicanalyzer.AnalyzerConstants;\r
+import com.samsung.dynamicanalyzer.constants.TimelineConstants;\r
+import com.samsung.dynamicanalyzer.model.LogPackage;\r
+import com.samsung.dynamicanalyzer.model.Logs;\r
+import com.samsung.dynamicanalyzer.timeline.chart.TimelineChartManager;\r
\r
public class AdditionalTimelineView extends ViewPart {\r
\r
+ public static final String ID = "com.samsung.dynamicanalyzer.ui.views.AdditionalTimelineView";//$NON-NLS-1$\r
+\r
+ JFreeChart activeChart;\r
+ ChartComposite chartComp;\r
+ TimelineChartManager subChartManager;\r
+\r
public AdditionalTimelineView() {\r
+ subChartManager = new TimelineChartManager();\r
+\r
}\r
\r
@Override\r
public void createPartControl(Composite parent) {\r
+\r
+ // activeChart = subChartManager\r
+ // .createTimelineChart(TimelineConstants.CHART_TYPE_FDUSAGE);\r
+\r
+ activeChart = subChartManager\r
+ .createTimelineChart(TimelineConstants.CHART_TYPE_READ_WRITE);\r
+ \r
+ chartComp = new ChartComposite(parent, SWT.NONE, activeChart, true);\r
}\r
\r
@Override\r
public void setFocus() {\r
+\r
}\r
\r
+ public void updateData(LogPackage logPack) {\r
+\r
+ Logs logs = logPack.getLogs(AnalyzerConstants.PROBE_RESOURCE);\r
+\r
+ if (null == logs) {\r
+ return;\r
+ }\r
+\r
+ subChartManager.updateTimelineChartData(logPack);\r
+ }\r
+ \r
+ public void updateView() {\r
+ subChartManager.updateTimelineChart();\r
+ }\r
}\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.ui.part.ViewPart;\r
-import org.jfree.chart.ChartFactory;\r
import org.jfree.chart.JFreeChart;\r
-import org.jfree.chart.axis.CategoryAxis;\r
-import org.jfree.chart.axis.CategoryLabelPositions;\r
-import org.jfree.chart.plot.CategoryPlot;\r
-import org.jfree.chart.plot.PlotOrientation;\r
-import org.jfree.chart.renderer.category.BarRenderer3D;\r
-import org.jfree.data.category.CategoryDataset;\r
-import org.jfree.data.category.DefaultCategoryDataset;\r
import org.jfree.experimental.chart.swt.ChartComposite;\r
\r
+import com.samsung.dynamicanalyzer.constants.TimelineConstants;\r
+import com.samsung.dynamicanalyzer.model.LogPackage;\r
+import com.samsung.dynamicanalyzer.timeline.chart.TimelineChartManager;\r
+\r
public class TimelineView extends ViewPart {\r
\r
- public TimelineView() {\r
+ public static final String ID = "com.samsung.dynamicanalyzer.ui.views.TimelineView";\r
\r
+ JFreeChart activeChart;\r
+ ChartComposite chartComp;\r
+ TimelineChartManager chartManager;\r
+\r
+ public TimelineView() {\r
+ chartManager = new TimelineChartManager();\r
}\r
\r
@Override\r
public void createPartControl(Composite parent) {\r
- JFreeChart chart = createChart(createDataset());\r
- new ChartComposite(parent, SWT.NONE, chart, true);\r
- }\r
\r
- @Override\r
- public void setFocus() {\r
+ // FIXME : Test\r
\r
- }\r
+ activeChart = chartManager\r
+ .createTimelineChart(TimelineConstants.CHART_TYPE_DEFAULT);\r
\r
- /**\r
- * Creates the Dataset for the Pie chart\r
- */\r
+ if (null == activeChart) {\r
+ return;\r
+ }\r
\r
- private static CategoryDataset createDataset() {\r
- DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();\r
- defaultcategorydataset.addValue(10D, "Series 1", "Category 1");\r
- defaultcategorydataset.addValue(4D, "Series 1", "Category 2");\r
- defaultcategorydataset.addValue(15D, "Series 1", "Category 3");\r
- defaultcategorydataset.addValue(14D, "Series 1", "Category 4");\r
- defaultcategorydataset.addValue(-5D, "Series 2", "Category 1");\r
- defaultcategorydataset.addValue(-7D, "Series 2", "Category 2");\r
- defaultcategorydataset.addValue(14D, "Series 2", "Category 3");\r
- defaultcategorydataset.addValue(-3D, "Series 2", "Category 4");\r
- defaultcategorydataset.addValue(6D, "Series 3", "Category 1");\r
- defaultcategorydataset.addValue(17D, "Series 3", "Category 2");\r
- defaultcategorydataset.addValue(-12D, "Series 3", "Category 3");\r
- defaultcategorydataset.addValue(7D, "Series 3", "Category 4");\r
- defaultcategorydataset.addValue(7D, "Series 4", "Category 1");\r
- defaultcategorydataset.addValue(15D, "Series 4", "Category 2");\r
- defaultcategorydataset.addValue(11D, "Series 4", "Category 3");\r
- defaultcategorydataset.addValue(0.0D, "Series 4", "Category 4");\r
- defaultcategorydataset.addValue(-8D, "Series 5", "Category 1");\r
- defaultcategorydataset.addValue(-6D, "Series 5", "Category 2");\r
- defaultcategorydataset.addValue(10D, "Series 5", "Category 3");\r
- defaultcategorydataset.addValue(-9D, "Series 5", "Category 4");\r
- defaultcategorydataset.addValue(9D, "Series 6", "Category 1");\r
- defaultcategorydataset.addValue(8D, "Series 6", "Category 2");\r
- defaultcategorydataset.addValue(0.0D, "Series 6", "Category 3");\r
- defaultcategorydataset.addValue(6D, "Series 6", "Category 4");\r
- defaultcategorydataset.addValue(-10D, "Series 7", "Category 1");\r
- defaultcategorydataset.addValue(9D, "Series 7", "Category 2");\r
- defaultcategorydataset.addValue(7D, "Series 7", "Category 3");\r
- defaultcategorydataset.addValue(7D, "Series 7", "Category 4");\r
- defaultcategorydataset.addValue(11D, "Series 8", "Category 1");\r
- defaultcategorydataset.addValue(13D, "Series 8", "Category 2");\r
- defaultcategorydataset.addValue(9D, "Series 8", "Category 3");\r
- defaultcategorydataset.addValue(9D, "Series 8", "Category 4");\r
- defaultcategorydataset.addValue(-3D, "Series 9", "Category 1");\r
- defaultcategorydataset.addValue(7D, "Series 9", "Category 2");\r
- defaultcategorydataset.addValue(11D, "Series 9", "Category 3");\r
- defaultcategorydataset.addValue(-10D, "Series 9", "Category 4");\r
- return defaultcategorydataset;\r
+ chartComp = new ChartComposite(parent, SWT.NONE, activeChart, true);\r
}\r
\r
- /**\r
- * Creates the Chart based on a dataset\r
- */\r
-\r
- private JFreeChart createChart(CategoryDataset categorydataset) {\r
-\r
- // JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 1", //\r
- // chart\r
- // // title\r
- // dataset, // data\r
- // true, // include legend\r
- // true, false);\r
- //\r
- // PiePlot plot = (PiePlot) chart.getPlot();\r
- // plot.setSectionOutlinesVisible(false);\r
- // // plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));\r
- // plot.setNoDataMessage("No data available");\r
- // plot.setCircular(false);\r
- // plot.setLabelGap(0.02);\r
-\r
- JFreeChart jfreechart = ChartFactory.createBarChart3D(\r
- "3D Bar Chart Demo", "Category", "Value", categorydataset,\r
- PlotOrientation.VERTICAL, true, true, false);\r
- CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();\r
- categoryplot.setDomainGridlinesVisible(true);\r
- CategoryAxis categoryaxis = categoryplot.getDomainAxis();\r
- categoryaxis.setCategoryLabelPositions(CategoryLabelPositions\r
- .createUpRotationLabelPositions(0.39269908169872414D));\r
- categoryaxis.setCategoryMargin(0.0D);\r
- BarRenderer3D barrenderer3d = (BarRenderer3D) categoryplot\r
- .getRenderer();\r
- barrenderer3d.setDrawBarOutline(false);\r
-\r
- return jfreechart;\r
+ @Override\r
+ public void setFocus() {\r
\r
}\r
\r
+ public void updateData(LogPackage logPack) {\r
+ }\r
}
\ No newline at end of file
--- /dev/null
+package com.samsung.dynamicanalyzer.utils;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import com.samsung.dynamicanalyzer.ui.views.AdditionalTimelineView;
+import com.samsung.dynamicanalyzer.ui.views.TimelineView;
+
+public class TimelineUtils {
+
+ private static IWorkbenchWindow window = null;
+
+ public static TimelineView getTimelineView() {
+ TimelineView tv = (TimelineView) getWorkbenchWindow().getActivePage()
+ .findView(TimelineView.ID);
+
+ return tv;
+ }
+
+ public static AdditionalTimelineView getTimelineViewSub() {
+ AdditionalTimelineView tvs = (AdditionalTimelineView) getWorkbenchWindow()
+ .getActivePage().findView(AdditionalTimelineView.ID);
+
+ return tvs;
+ }
+
+ public static IWorkbenchWindow getWorkbenchWindow() {
+ if (null == window) {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ window = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow();
+ }
+ });
+ }
+
+ return window;
+ }
+}