UI : Add default title composition render to DAChartBoard 69/23069/1
authorjungwook.ryu <jungwook.ryu@samsung.com>
Tue, 17 Jun 2014 06:13:58 +0000 (15:13 +0900)
committerjungwook.ryu <jungwook.ryu@samsung.com>
Tue, 17 Jun 2014 06:14:28 +0000 (15:14 +0900)
FileChartView and NetworkChartView use this default render.

Change-Id: Id6fd4431b5badf4d4abe32dcc1a12243d00a47f8
Signed-off-by: jungwook.ryu <jungwook.ryu@samsung.com>
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoard.java
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/timeline/DATimeline.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/FileChartView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileChartView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkChartView.java

index eb68590..cf53dc7 100644 (file)
@@ -41,6 +41,7 @@ import org.eclipse.swt.events.PaintEvent;
 import org.eclipse.swt.events.PaintListener;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
@@ -800,6 +801,56 @@ public class DAChartBoard extends Composite {
                return selectItem;
        }
 
+       /**
+        * this method makes default title composition for user of DAChartBoard.
+        * default format is a simple label. user of DAChartBoard can make own 
+        * renderer to draw title composition not use this method.
+        * 
+        * @param title                 text to draw
+        * @param titleFont             text font
+        * @param titleColor    text color
+        * @param bgColorStart  for gradient
+        * @param bgColorEnd    for gradient
+        * @param borderColor   border color
+        */
+       public void makeDefaultTitleComposite(final String title, final Font titleFont, 
+                       final Color titleColor, final Color bgColorStart, 
+                       final Color bgColorEnd, final Color borderColor) {
+               if (this.titleComp == null) {
+                       return;
+               }
+               Composite textBoxLabel = new Composite(titleComp, SWT.NONE);
+               textBoxLabel.addPaintListener(new PaintListener() {
+                       @Override
+                       public void paintControl(PaintEvent e) {
+                               Composite composite = (Composite) e.widget;
+                               Rectangle rect = composite.getClientArea();
+                               
+                               /*
+                                * draw background color
+                                */
+                               e.gc.setForeground(bgColorStart);
+                               e.gc.setBackground(bgColorEnd);
+                               e.gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, true);
+
+                               /*
+                                * draw border
+                                */
+                               e.gc.setForeground(borderColor);
+                               e.gc.drawRectangle(rect.x, rect.y, rect.width, rect.height - 1);
+                               
+                               /*
+                                * draw text
+                                */
+                               e.gc.setFont(titleFont);
+                               e.gc.setForeground(titleColor);
+                               int startX = (rect.width / 2) - (e.gc.textExtent(title).x / 2);
+                               int startY = (rect.height / 2) - (e.gc.textExtent(title).y / 2);
+                               e.gc.drawString(title, startX, startY, true);
+                       }
+               });
+       }
+       
        protected int getInterval() {
                return interval;
        }
index bdf6fa7..6658654 100644 (file)
@@ -315,7 +315,10 @@ public class DATimeline extends Canvas {
                        startRangeMarker.setStatus(status);
                        DATimeline.this.redraw();
                } else {
-                       /* Do not handle else case. above 2 case is means catching mouse pointer is in maker image.*/
+                       /*
+                        * Do not handle else case. because mouse pointer in other space on timeline is not
+                        * need to handle.
+                        */
                }
        }
 }
index d9f1ee4..6452a1d 100644 (file)
 
 package org.tizen.dynamicanalyzer.ui.file;
 
-import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
@@ -40,7 +36,6 @@ import org.tizen.dynamicanalyzer.common.DASelectionData;
 import org.tizen.dynamicanalyzer.nl.FilePageLabels;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.resources.ImageResources;
 import org.tizen.dynamicanalyzer.swap.model.data.LogData;
 import org.tizen.dynamicanalyzer.ui.common.SetRangeMarkerMouseMoveListener;
 import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
@@ -102,23 +97,15 @@ public class FileChartView extends DAViewComposite {
                initIntervalMarkers(fileChart);
 
                stackLayout.topControl = fileChart;
-               Composite textBoxLabel = new Composite(fileChart.getTitleComp(),
-                               SWT.NONE);
-               textBoxLabel.addPaintListener(new PaintListener() {
-                       @Override
-                       public void paintControl(PaintEvent e) {
-                               Composite composite = (Composite) e.widget;
-                               Rectangle rect = composite.getClientArea();
-
-                               e.gc.drawImage(ImageResources.TIMELINE_DROPDOWN_NORMAL, rect.x,
-                                               rect.y);
-                               e.gc.setFont(FontResources.COMBO);
-                               e.gc.setForeground(ColorResources.BLACK);
-                               e.gc.drawString(FilePageLabels.FILE_CHART_FILE, rect.x + 30,
-                                               rect.y + 2, true);
-                       }
-               });
-
+               
+               // Making title composition using resource of timeline pages.
+               fileChart.makeDefaultTitleComposite(FilePageLabels.FILE_CHART_FILE, 
+                               FontResources.ADDITEM_BUTTON_FONT,
+                               ColorResources.ADD_CHART_FONT_COLOR,
+                               ColorResources.ADD_CHART_NORMAL_START,
+                               ColorResources.ADD_CHART_NORMAL_END,
+                               ColorResources.ADD_CHART_NORMAL_STROKE);
+               
                DATimeline timeline = fileChart.getTimeline();
 
                timeline.setTimeTickFont(FontResources.TIMELINE_TICK_FONT);
index 6883f7d..becc7c5 100644 (file)
@@ -28,11 +28,7 @@ package org.tizen.dynamicanalyzer.ui.file.view;
 
 import java.util.List;
 
-import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
@@ -41,13 +37,12 @@ import org.tizen.dynamicanalyzer.common.DASelectionData;
 import org.tizen.dynamicanalyzer.nl.FilePageLabels;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.resources.ImageResources;
 import org.tizen.dynamicanalyzer.swap.model.data.LogData;
 import org.tizen.dynamicanalyzer.ui.common.SetRangeMarkerMouseMoveListener;
 import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
 import org.tizen.dynamicanalyzer.ui.file.FilePage;
-import org.tizen.dynamicanalyzer.ui.file.model.FileEvent;
 import org.tizen.dynamicanalyzer.ui.file.manager.FileChartManager;
+import org.tizen.dynamicanalyzer.ui.file.model.FileEvent;
 import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
 import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
 import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
@@ -110,23 +105,14 @@ public class FileChartView extends DAViewComposite {
                initIntervalMarkers(fileChartBoard);
 
                stackLayout.topControl = fileChartBoard;
-               // comment : textBoxLabel
-               Composite textBoxLabel = new Composite(fileChartBoard.getTitleComp(),
-                               SWT.NONE);
-               textBoxLabel.addPaintListener(new PaintListener() {
-                       @Override
-                       public void paintControl(PaintEvent e) {
-                               Composite composite = (Composite) e.widget;
-                               Rectangle rect = composite.getClientArea();
-
-                               e.gc.drawImage(ImageResources.TIMELINE_DROPDOWN_NORMAL, rect.x,
-                                               rect.y);
-                               e.gc.setFont(FontResources.COMBO);
-                               e.gc.setForeground(ColorResources.BLACK);
-                               e.gc.drawString(FilePageLabels.FILE_CHART_FILE, rect.x + 30,
-                                               rect.y + 2, true);
-                       }
-               });
+
+               // Making title composition using resource of timeline pages.
+               fileChartBoard.makeDefaultTitleComposite(FilePageLabels.FILE_CHART_FILE, 
+                               FontResources.ADDITEM_BUTTON_FONT,
+                               ColorResources.ADD_CHART_FONT_COLOR,
+                               ColorResources.ADD_CHART_NORMAL_START,
+                               ColorResources.ADD_CHART_NORMAL_END,
+                               ColorResources.ADD_CHART_NORMAL_STROKE);
 
                DATimeline timeline = fileChartBoard.getTimeline();
 
index d65c0cf..335d644 100644 (file)
 
 package org.tizen.dynamicanalyzer.ui.network;
 
-import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
@@ -40,7 +36,6 @@ import org.tizen.dynamicanalyzer.common.DASelectionData;
 import org.tizen.dynamicanalyzer.nl.NetworkPageLabels;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.resources.ImageResources;
 import org.tizen.dynamicanalyzer.swap.model.data.LogData;
 import org.tizen.dynamicanalyzer.ui.common.SetRangeMarkerMouseMoveListener;
 import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
@@ -101,23 +96,15 @@ public class NetworkChartView extends DAViewComposite {
                                });
 
                stackLayout.topControl = networkChartBoard;
-               Composite textBoxLabel = new Composite(
-                               networkChartBoard.getTitleComp(), SWT.NONE);
-               textBoxLabel.addPaintListener(new PaintListener() {
-                       @Override
-                       public void paintControl(PaintEvent e) {
-                               Composite composite = (Composite) e.widget;
-                               Rectangle rect = composite.getClientArea();
-
-                               e.gc.drawImage(ImageResources.TIMELINE_DROPDOWN_NORMAL, rect.x,
-                                               rect.y);
-                               e.gc.setFont(FontResources.COMBO);
-                               e.gc.setForeground(ColorResources.BLACK);
-                               e.gc.drawString(NetworkPageLabels.NETWORK_CHART, rect.x + 15,
-                                               rect.y + 2, true);
-                       }
-               });
-
+               
+               // Making title composition using resource of timeline pages.
+               networkChartBoard.makeDefaultTitleComposite(NetworkPageLabels.NETWORK_CHART,
+                               FontResources.ADDITEM_BUTTON_FONT,
+                               ColorResources.ADD_CHART_FONT_COLOR,
+                               ColorResources.ADD_CHART_NORMAL_START,
+                               ColorResources.ADD_CHART_NORMAL_END,
+                               ColorResources.ADD_CHART_NORMAL_STROKE);
+               
                DATimeline timeline = networkChartBoard.getTimeline();
 
                timeline.setTimeTickFont(FontResources.TIMELINE_TICK_FONT);