Timeline UI Coloring
authorpyeongsoo.kim <pyeongsoo.kim@samsung.com>
Tue, 8 Nov 2011 13:36:25 +0000 (22:36 +0900)
committerpyeongsoo.kim <pyeongsoo.kim@samsung.com>
Tue, 8 Nov 2011 13:36:25 +0000 (22:36 +0900)
com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/timeline/chart/FDUsageChart.java
com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/timeline/chart/ReadWriteChart.java
com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/timeline/chart/TimelineChart.java

index 46b02d5..67cd034 100644 (file)
@@ -1,6 +1,7 @@
 package com.samsung.dynamicanalyzer.timeline.chart;
 
 import java.awt.BasicStroke;
+import java.awt.Color;
 import java.util.HashSet;
 import java.util.List;
 
@@ -9,7 +10,7 @@ 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.chart.renderer.xy.XYStepAreaRenderer;
 import org.jfree.data.time.FixedMillisecond;
 import org.jfree.data.time.TimeSeries;
 import org.jfree.data.time.TimeSeriesCollection;
@@ -60,24 +61,50 @@ public class FDUsageChart extends TimelineChart {
                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
index 3f8113e..4033e70 100644 (file)
@@ -1,11 +1,14 @@
 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;
@@ -51,21 +54,51 @@ public class ReadWriteChart extends TimelineChart {
                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);
 
        }
 
@@ -93,27 +126,27 @@ public class ReadWriteChart extends TimelineChart {
 
        @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,
index 5ee1855..569a642 100644 (file)
@@ -1,17 +1,23 @@
 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;
@@ -85,4 +91,38 @@ public abstract class TimelineChart {
 
                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);
+               
+
+       }
 }