package com.samsung.dynamicanalyzer.timeline.chart;
import java.awt.BasicStroke;
+import java.awt.Color;
import java.util.HashSet;
import java.util.List;
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.chart.renderer.xy.XYStepAreaRenderer;
import org.jfree.data.time.FixedMillisecond;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
chart = ChartFactory.createTimeSeriesChart("FD Usage chart", "Time",
"Number", dataset, true, true, false);
- /* Rendering */
+ if (null == chart) {
+ return null;
+ }
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);
+ setChartStyle("FD Usage");
+
+ setSeriesRendering(xyplot);
+
+ setPlotRange(xyplot);
+
+ return chart;
+ }
+
+ private void setPlotRange(XYPlot xyplot) {
xyplot.getDomainAxis().setRange(
TimelineConstants.MS_TO_FIXED_MS - 1,
TimelineConstants.MS_TO_FIXED_MS
+ TimelineConstants.CHART_RANGE_DEFAULT);
- return chart;
+ }
+
+ private void setSeriesRendering(XYPlot xyplot) {
+ if (null == chart) {
+ return;
+ }
+
+ /* Rendering */
+
+ // XYStepRenderer renderer = new XYStepRenderer();
+ XYStepAreaRenderer renderer = new XYStepAreaRenderer(2);
+
+ // renderer.setSeriesStroke(0, new BasicStroke(2.0F));
+ // renderer.setSeriesStroke(1, new BasicStroke(2.0F));
+
+ renderer.setSeriesPaint(1, new Color(0, 255, 0, 80));
+ renderer.setSeriesPaint(0, new Color(0, 0, 255, 80));
+
+ renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
+ renderer.setDefaultEntityRadius(6);
+ xyplot.setRenderer(renderer);
+
}
@Override
package com.samsung.dynamicanalyzer.timeline.chart;
+import java.awt.BasicStroke;
+import java.awt.Color;
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.SeriesRenderingOrder;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYBarRenderer;
import org.jfree.data.time.FixedMillisecond;
chart = ChartFactory.createXYBarChart("Read write chart", "Time", true,
"Size", dataset, PlotOrientation.VERTICAL, true, true, false);
- /* Rendering */
+ if (null == chart) {
+ return null;
+ }
+
+ setChartStyle("Read / Write");
XYPlot xyplot = (XYPlot) chart.getPlot();
- XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer();
- renderer.setShadowVisible(false);
- renderer.setDrawBarOutline(false);
- xyplot.setRenderer(renderer);
+ setSeriesRendering(xyplot);
+
+ setPlotRange(xyplot);
+
+ return chart;
+
+ }
+
+ private void setPlotRange(XYPlot xyplot) {
+
+ if (null == xyplot) {
+ return;
+ }
xyplot.getDomainAxis().setRange(
TimelineConstants.MS_TO_FIXED_MS - 1,
TimelineConstants.MS_TO_FIXED_MS
+ TimelineConstants.CHART_RANGE_DEFAULT);
+ }
- return chart;
+ private void setSeriesRendering(XYPlot xyplot) {
+
+ if (null == xyplot) {
+ return;
+ }
+
+ XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer();
+
+ renderer.clearSeriesPaints(true);
+
+ renderer.setSeriesPaint(0, new Color(0, 255, 255, 80));
+ renderer.setSeriesPaint(1, new Color(255, 255, 0, 80));
+
+ renderer.setShadowVisible(false);
+ renderer.setDrawBarOutline(false);
+
+ xyplot.setRenderer(renderer);
}
@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,
package com.samsung.dynamicanalyzer.timeline.chart;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Font;
import java.text.NumberFormat;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.title.TextTitle;
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 org.jfree.ui.HorizontalAlignment;
import com.samsung.dynamicanalyzer.constants.TimelineConstants;
import com.samsung.dynamicanalyzer.model.Logs;
return sec;
}
+
+ protected void setChartStyle(String chartName) {
+
+ if (null == chart) {
+ return;
+ }
+
+ // chart.setAntiAlias(true);
+ // chart.getLegend().setPosition(RectangleEdge.RIGHT);
+
+ chart.setBackgroundPaint(new Color(151, 151, 151));
+
+ chart.getLegend().setVisible(false);
+
+ TextTitle texttitle = new TextTitle(chartName);
+ texttitle.setHorizontalAlignment(HorizontalAlignment.LEFT);
+ // texttitle.setBackgroundPaint(Color.red);
+ texttitle.setFont(new Font("SansSerif", Font.BOLD, 20));
+ texttitle.setPaint(Color.LIGHT_GRAY);
+ chart.setTitle(texttitle);
+
+ XYPlot xyplot = (XYPlot) chart.getPlot();
+ xyplot.setBackgroundPaint(new Color(151, 151, 151));
+ xyplot.setOutlineVisible(false);
+
+ xyplot.setDomainGridlinesVisible(false);
+ xyplot.setRangeGridlineStroke(new BasicStroke(1.0F));
+ xyplot.setRangeGridlinesVisible(false);
+
+ xyplot.getRangeAxis().setLabel(null);
+ xyplot.getDomainAxis().setLabel(null);
+
+
+ }
}