--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.tizen.dynamicanalyzer.widgets</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+#Thu Jul 05 13:02:20 KST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Widgets
+Bundle-SymbolicName: org.tizen.dynamicanalyzer.widgets
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.tizen.dynamicanalyzer.widgets.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.tizen.dynamicanalyzer.widgets,
+ org.tizen.dynamicanalyzer.widgets.button,
+ org.tizen.dynamicanalyzer.widgets.button.toggle,
+ org.tizen.dynamicanalyzer.widgets.combo,
+ org.tizen.dynamicanalyzer.widgets.helper
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.tizen.dynamicanalyzer.widgets"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.button;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
+
+public class TizenButton extends Canvas {
+ public static final int MAX_SIZE = 100;
+
+ public static final int STATE_NORMAL = 0;
+ public static final int STATE_PUSH = 1;
+ public static final int STATE_HOVER = 2;
+ public static final int STATE_DISABLE = 3;
+
+ public static final int TYPE_IMAGE = 0;
+ public static final int TYPE_COLOR = 1;
+ public static final int TYPE_GRADATION = 2;
+
+ Composite parent;
+ protected boolean enabled = true;
+
+ protected int state = STATE_NORMAL;
+ protected TizenWidgetAttribute attr;
+ protected TizenDefaultButtonRenderer buttonRenderer = null;
+
+ public void addListeners() {
+ this.addListener(SWT.MouseEnter, buttonMouseListener);
+ this.addListener(SWT.MouseExit, buttonMouseListener);
+ this.addListener(SWT.MouseDown, buttonMouseListener);
+ this.addListener(SWT.MouseUp, buttonMouseListener);
+ }
+
+ public TizenButton(Composite parent, int style) {
+ super(parent, style);
+
+ this.parent = parent;
+ FillLayout layout = new FillLayout(SWT.HORIZONTAL);
+ this.setLayout(layout);
+
+ this.setForeground(ColorResources.WHITE);
+ this.addPaintListener(buttonPaintListener);
+ addListeners();
+ buttonRenderer = new TizenButtonRenderer();
+ attr = new TizenWidgetAttribute();
+ setDefaultColors();
+ }
+
+ public TizenButton(Composite parent, int style, String titleText) {
+ this(parent, style);
+ attr.setTitle(titleText);
+ }
+
+ public TizenButton(Composite parent, Image normal, Image mouseDown,
+ Image hover, Image disable) {
+ this(parent, SWT.TRANSPARENT);
+ setImages(normal, mouseDown, hover, disable);
+ attr.setDrawType(TYPE_IMAGE);
+ }
+
+ protected void changeButtonState(int s) {
+ state = s;
+ this.redraw();
+ }
+
+ protected Listener buttonMouseListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ if (state == STATE_DISABLE) {
+ return;
+ }
+
+ if (event.type == SWT.MouseEnter) {
+ changeButtonState(STATE_HOVER);
+ }
+
+ if (event.type == SWT.MouseExit) {
+ changeButtonState(STATE_NORMAL);
+ }
+
+ if (event.type == SWT.MouseDown) {
+ changeButtonState(STATE_PUSH);
+ }
+
+ if (event.type == SWT.MouseUp) { // FIXME
+ changeButtonState(STATE_HOVER);
+ }
+ }
+ };
+
+ private void setDefaultColors() {
+ attr.setColor(STATE_DISABLE,
+ new Color(Display.getCurrent(), 48, 48, 48));
+ attr.setColor(STATE_PUSH, new Color(Display.getCurrent(), 29, 109, 140));
+ attr.setColor(STATE_HOVER, new Color(Display.getCurrent(), 0, 134, 185));
+ attr.setColor(STATE_NORMAL, new Color(Display.getCurrent(), 67, 67, 67));
+ }
+
+ private PaintListener buttonPaintListener = new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ buttonRenderer.draw(e.gc, (Canvas) e.widget, state, attr);
+ }
+ };
+
+ public void setTitle(String newTitle) {
+ attr.setTitle(newTitle);
+ }
+
+ public void setText(String newTitle) {
+ attr.setTitle(newTitle);
+ }
+
+ public void setRenderer(TizenDefaultButtonRenderer newRenderer) {
+ buttonRenderer = newRenderer;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ if (enabled) {
+ changeButtonState(STATE_NORMAL);
+ } else {
+ changeButtonState(STATE_DISABLE);
+ }
+ }
+
+ public boolean getEnabled() {
+ return this.enabled;
+ }
+
+ public void setHoverImage(Image image) {
+ attr.setImage(STATE_HOVER, image);
+ }
+
+ public void setNormalImage(Image image) {
+ attr.setImage(STATE_NORMAL, image);
+ }
+
+ public void setPushImage(Image image) {
+ attr.setImage(STATE_PUSH, image);
+ }
+
+ public void setDisableImage(Image image) {
+ attr.setImage(STATE_DISABLE, image);
+ }
+
+ public Image getHoverImage() {
+ return attr.getImage(STATE_HOVER);
+ }
+
+ public Image getNormalImage() {
+ return attr.getImage(STATE_NORMAL);
+ }
+
+ public Image getPushImage() {
+ return attr.getImage(STATE_PUSH);
+ }
+
+ public Image getDisableImage(Image image) {
+ return attr.getImage(STATE_DISABLE);
+ }
+
+ public void setHoverColor(Color color) {
+ attr.setColor(STATE_HOVER, color);
+ }
+
+ public void setNormalColor(Color color) {
+ attr.setColor(STATE_NORMAL, color);
+ }
+
+ public void setPushColor(Color color) {
+ attr.setColor(STATE_PUSH, color);
+ }
+
+ public void setDisableColor(Color color) {
+ attr.setColor(STATE_DISABLE, color);
+ }
+
+ public void setVisible(boolean visible) {
+ setVisible(visible);
+ }
+
+ public void setFont(Font font) {
+ attr.setFont(font);
+ }
+
+ public void setFontPoint(Point p) {
+ attr.setFontPoint(p);
+ }
+
+ public void setImages(Image normal, Image push, Image hover, Image disable) {
+ attr.setImage(STATE_NORMAL, normal);
+ attr.setImage(STATE_PUSH, push);
+ attr.setImage(STATE_HOVER, hover);
+ attr.setImage(STATE_DISABLE, disable);
+ }
+
+ public void addClickListener(TizenButtonClickEventListener listener) {
+ addListener(SWT.MouseUp, listener);
+ }
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.button;\r
+\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
+\r
+public abstract class TizenButtonClickEventListener implements Listener {\r
+\r
+ @Override\r
+ public void handleEvent(Event event) {\r
+ TizenButton button = (TizenButton) event.widget;\r
+ if (null != button) {\r
+ Rectangle rectangle = button.getBounds();\r
+ int x = event.x;\r
+ int y = event.y;\r
+\r
+ if (x < 0 || x > rectangle.width || y < 0 || y > rectangle.height) {\r
+ return;\r
+ }\r
+ }\r
+\r
+ handleClickEvent(event);\r
+ }\r
+\r
+ public abstract void handleClickEvent(Event event);\r
+}\r
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.button;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Display;
+import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
+
+public class TizenButtonRenderer extends TizenDefaultButtonRenderer {
+
+ @Override
+ public void draw(GC gc, Canvas canvas, int state, TizenWidgetAttribute attr) {
+ Rectangle rect = canvas.getClientArea();
+
+ if (attr.getDrawType() == TizenButton.TYPE_IMAGE) {
+ Image image = attr.getImage(state);
+ if (null == image) {
+ return;
+ }
+
+ gc.drawImage(image, rect.x, rect.y);
+ drawButtonText(gc, rect, attr);
+ } else if (attr.getDrawType() == TizenButton.TYPE_COLOR) {
+ Color color = attr.getColor(state);
+ drawButton(gc, rect, color, attr);
+ } else if (attr.getDrawType() == TizenButton.TYPE_GRADATION) {
+ // TODO: implement..
+ }
+ }
+
+ public int computeFontSize(Rectangle rect) {
+ if (rect.height > 20)
+ return 10;
+ else
+ return 8;
+ }
+
+ public void drawButton(GC gc, Rectangle rect, Color c,
+ TizenWidgetAttribute attr) {
+ gc.setBackground(c);
+ gc.fillRectangle(rect);
+ Rectangle r = new Rectangle(0, 0, rect.width - 1, rect.height - 1);
+ drawButtonText(gc, r, attr);
+ c = gc.getForeground();
+ gc.setForeground(ColorResources.BLACK);
+ gc.drawRectangle(r);
+ gc.setForeground(c);
+ }
+
+ protected void drawButtonText(GC gc, Rectangle rect, TizenWidgetAttribute attr) {
+ String s = null;
+ Font f = null;
+ Point p = null;
+ if (null != (s = attr.getTitle())) {
+ if (null == (f = attr.getFont())) {
+ f = new Font(Display.getCurrent(), "Arial",
+ computeFontSize(rect), SWT.BOLD);
+ attr.setFont(f);
+ }
+ gc.setFont(f);
+
+ int x = 0, y = 0;
+ int offset = 0;
+ if (null == (p = attr.getFontPoint())) {
+ p = gc.textExtent(s, SWT.DRAW_MNEMONIC);
+ x = (rect.width - p.x) / 2;
+ y = (rect.height - p.y) / 2;
+ x = (x < 0) ? 0 : x;
+ // rect size < text length -> insert offset
+ offset = ((x - rect.x) < 4) ? 4 : 0;
+ } else {
+ x = p.x;
+ y = p.y;
+ }
+ gc.drawString(s, x + offset, y, true);
+ }
+ }
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.button;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Canvas;
+
+public abstract class TizenDefaultButtonRenderer {
+ public abstract void draw(GC gc, Canvas canvas, int state,
+ TizenWidgetAttribute attr);
+
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.button;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+public class TizenWidgetAttribute {
+ private final int MAX_SIZE = 10;
+ private String title;
+ private Font font;
+ private Point fontPoint;
+ private int drawType = TizenButton.TYPE_COLOR;
+
+ private List<Image> images = new ArrayList<Image>();
+ private List<Color> colors = new ArrayList<Color>();
+ private boolean enabled;
+
+ public TizenWidgetAttribute() {
+ enabled = true;
+
+ // init array
+ for (int i = 0; i < MAX_SIZE; i++) {
+ images.add(null);
+ colors.add(null);
+ }
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public Font getFont() {
+ return font;
+ }
+
+ public void setFont(Font font) {
+ this.font = font;
+ }
+
+ public Point getFontPoint() {
+ return fontPoint;
+ }
+
+ public void setFontPoint(Point fontPoint) {
+ this.fontPoint = fontPoint;
+ }
+
+ public int getDrawType() {
+ return drawType;
+ }
+
+ public void setDrawType(int type) {
+ drawType = type;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Image getImage(int state) {
+ if (!images.isEmpty()) {
+ return images.get(state);
+ }
+ return null;
+ }
+
+ public void setImage(int state, Image img) {
+ images.set(state, img);
+ }
+
+ public Color getColor(int state) {
+ if (!colors.isEmpty()) {
+ return colors.get(state);
+ }
+ return null;
+ }
+
+ public void setColor(int state, Color color) {
+ colors.set(state, color);
+ }
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.button.toggle;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.Image;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
+import org.tizen.dynamicanalyzer.widgets.button.TizenButton;\r
+import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;\r
+\r
+public class TizenToggleButton extends TizenButton {\r
+\r
+ public static final int STATE_TOGGLE = 4;\r
+ private boolean toggle = false;\r
+\r
+ public TizenToggleButton(Composite parent, Image normal, Image mouseDown,\r
+ Image hover, Image disable, Image toggle) {\r
+ super(parent, normal, mouseDown, hover, disable);\r
+ buttonRenderer = new TizenToggleButtonRenderer();\r
+\r
+ attr.setImage(STATE_TOGGLE, toggle);\r
+ addListeners();\r
+ }\r
+\r
+ public TizenToggleButton(Composite parent, int style) {\r
+ super(parent, style);\r
+ buttonRenderer = new TizenToggleButtonRenderer();\r
+ attr.setColor(STATE_TOGGLE, ColorResources.BLUE);\r
+ addListeners();\r
+ }\r
+\r
+ public void setToggled(boolean toggled) {\r
+ toggle = toggled;\r
+ }\r
+\r
+ public boolean isToggled() {\r
+ return toggle;\r
+ }\r
+\r
+ @Override\r
+ public void addListeners() {\r
+ if (null != toggleButtonMouseListener) {\r
+ this.addListener(SWT.MouseEnter, toggleButtonMouseListener);\r
+ this.addListener(SWT.MouseExit, toggleButtonMouseListener);\r
+ this.addListener(SWT.MouseDown, toggleButtonMouseListener);\r
+ this.addListener(SWT.MouseUp, toggleButtonMouseListener);\r
+ }\r
+ }\r
+\r
+ private Listener toggleButtonMouseListener = new Listener() {\r
+\r
+ @Override\r
+ public void handleEvent(Event event) {\r
+ if (state == STATE_DISABLE) {\r
+ return;\r
+ }\r
+\r
+ if (event.type == SWT.MouseEnter) {\r
+ changeButtonState(STATE_HOVER);\r
+ }\r
+\r
+ if (event.type == SWT.MouseExit) {\r
+ if (toggle) {\r
+ changeButtonState(STATE_TOGGLE);\r
+ } else {\r
+ changeButtonState(STATE_NORMAL);\r
+ }\r
+ }\r
+\r
+ if (event.type == SWT.MouseDown) {\r
+ changeButtonState(STATE_PUSH);\r
+ }\r
+\r
+ if (event.type == SWT.MouseUp) { // FIXME\r
+ toggle = !toggle;\r
+ changeButtonState(STATE_HOVER);\r
+ }\r
+ }\r
+ };\r
+}\r
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.button.toggle;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.tizen.dynamicanalyzer.widgets.button.TizenButton;
+import org.tizen.dynamicanalyzer.widgets.button.TizenButtonRenderer;
+import org.tizen.dynamicanalyzer.widgets.button.TizenWidgetAttribute;
+
+public class TizenToggleButtonRenderer extends TizenButtonRenderer {
+
+ @Override
+ public void draw(GC gc, Canvas canvas, int state, TizenWidgetAttribute attr) {
+ Rectangle rect = canvas.getClientArea();
+ if (attr.getDrawType() == TizenButton.TYPE_IMAGE) {
+ Image image = attr.getImage(state);
+ if (null == image) {
+ return;
+ }
+
+ gc.drawImage(image, rect.x, rect.y);
+ drawButtonText(gc, rect, attr);
+ } else if (attr.getDrawType() == TizenButton.TYPE_COLOR) {
+ Color color = attr.getColor(state);
+ drawButton(gc, rect, color, attr);
+ } else if (attr.getDrawType() == TizenButton.TYPE_GRADATION) {
+ // TODO: implement..
+ }
+ }
+
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.combo;
+
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
+
+
+public class DefaultTizenComboPopupRenderer extends TizenComboPopupRenderer {
+
+ @Override
+ public void draw(GC gc, Canvas canvas, int state, List<Rectangle> rects,
+ int selection, List<String> items) {
+ int size = rects.size();
+ for (int i = 0; i < size; i++) {
+ Rectangle r = rects.get(i);
+ gc.setBackground(ColorResources.WINDOW_BG_COLOR);
+ if (selection == i) {
+ gc.setBackground(ColorResources.RED);
+ gc.fillRectangle(r);
+ gc.setBackground(ColorResources.WINDOW_BG_COLOR);
+ }
+ gc.setForeground(ColorResources.WHITE);
+ gc.drawRectangle(r.x, r.y, r.width - 1, r.height - 1);
+ Point p = gc.textExtent(items.get(i), SWT.DRAW_MNEMONIC);
+ gc.drawString(items.get(i), 5, (r.height - p.y) / 2 + i * r.height,
+ true);
+ }
+ }
+
+ @Override
+ public void drawPattern(GC gc, Canvas canvas, Image patternImage,
+ int state, List<Rectangle> rects, int selection, List<String> items) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void drawImage(GC gc, Canvas canvas, Image image, int state,
+ List<Rectangle> rects, int selection, List<String> items) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.combo;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
+
+
+public class DefaultTizenComboRenderer extends TizenComboRenderer {
+
+ @Override
+ public void draw(GC gc, Canvas canvas, String text, int state) {
+ Rectangle rect = canvas.getClientArea();
+ if (state == TizenCombo.STATE_NORMAL) {
+ gc.setBackground(ColorResources.WINDOW_BG_COLOR);
+ } else if (state == TizenCombo.STATE_HOVER) {
+ gc.setBackground(ColorResources.ITEM_BLUE_DARK);
+ } else if (state == TizenCombo.STATE_PUSH) {
+ gc.setBackground(ColorResources.BLUE);
+ } else if (state == TizenCombo.STATE_DISABLE) {
+ gc.setBackground(ColorResources.BAR_GRAY1);
+ }
+ gc.fillRectangle(rect);
+ gc.drawRectangle(rect.x, rect.y, rect.width - 20, rect.height - 1);
+
+ if (null == text) {
+ text = ""; //$NON-NLS-1$
+ }
+ Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ gc.drawString(text, 5, (rect.height - p.y)/2, true);
+ gc.fillRectangle(rect.x + rect.width - 20, rect.y, 19, rect.height - 1);
+ gc.drawRectangle(rect.x + rect.width - 20, rect.y, 19, rect.height - 1);
+ }
+
+ @Override
+ public void drawPattern(GC gc, Canvas canvas, Image patternImage,
+ String text, int state) {
+
+ }
+
+ @Override
+ public void drawImage(GC gc, Canvas canvas, Image image, String text,
+ int state) {
+
+ }
+
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.combo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.widgets.button.TizenButton;
+import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
+
+public class TizenCombo extends Canvas {
+ public static final int MAX_SIZE = 10;
+ public static final int STATE_NORMAL = 0;
+ public static final int STATE_HOVER = 1;
+ public static final int STATE_PUSH = 2;
+ public static final int STATE_DISABLE = 3;
+
+ private static final int pageSize = 5;
+
+ Composite parent;
+ private Canvas combo = null;
+ private Canvas popup = null;
+ private int itemHeight = 0;
+ private TizenButton upArrowButton = null;
+ private TizenButton downArrowButton = null;
+ private int itemIndex = 0;
+
+ private List<String> items;
+ private List<Rectangle> rects = null;
+
+ private List<Image> images = null;
+ private boolean enabled = true;
+ private Shell childShell = null;
+ private int selection = 0;
+ private String text = ""; //$NON-NLS-1$
+ private boolean imgCombo = false;
+ private int state = STATE_NORMAL; // 0 normal 1 hover 2 push 3 disable
+ private TizenComboRenderer comboRenderer = new DefaultTizenComboRenderer();;
+ private TizenComboPopupRenderer popupRenderer = new DefaultTizenComboPopupRenderer();
+
+ public TizenCombo(Composite parent, int style) {
+ super(parent, style);
+ combo = this;
+
+ this.parent = parent;
+ addPaintListener(comboPaintListener);
+ setForeground(ColorResources.WHITE);
+ addListeners();
+ }
+
+ public void addListeners() {
+ addListener(SWT.MouseEnter, comboMouseListener);
+ addListener(SWT.MouseHover, comboMouseListener);
+ addListener(SWT.MouseExit, comboMouseListener);
+ addListener(SWT.MouseDown, comboMouseListener);
+ addListener(SWT.MouseMove, comboMouseListener);
+ addListener(SWT.MouseUp, comboMouseListener);
+ }
+
+ public String getText() {
+ if (getItems().size() > 0) {
+ return getItems().get(itemIndex + selection);
+ }
+ return null;
+ }
+
+ public List<String> getItems() {
+ if (null == items) {
+ items = new ArrayList<String>();
+ }
+ return items;
+ }
+
+ private List<Rectangle> getRects() {
+ if (null == rects) {
+ rects = new ArrayList<Rectangle>();
+ }
+ return rects;
+ }
+
+ private void changeComboState(int s) {
+ state = s;
+ redraw();
+ }
+
+ private Listener popupSelectionListener = new TizenComboSelectionListener() {
+
+ @Override
+ public void selectionEvent(TizenCombo combo) {
+ System.out.println("default selection" + combo.getText());
+ }
+ };
+
+ public void addSelectionListener(TizenComboSelectionListener listener) {
+ popupSelectionListener = listener;
+ }
+
+ private Listener comboMouseListener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (enabled) {
+ if (event.type == SWT.MouseEnter) {
+ changeComboState(STATE_HOVER);
+ }
+
+ if (event.type == SWT.MouseHover) {
+ if (!isOutOfBounds(event.x, event.y)) {
+ if (0 != (event.stateMask & SWT.BUTTON1)) {
+ changeComboState(STATE_PUSH);
+ } else if (0 == (event.stateMask & SWT.BUTTON1)) {
+ changeComboState(STATE_HOVER);
+ }
+ }
+ }
+
+ if (event.type == SWT.MouseDown) {
+ changeComboState(STATE_PUSH);
+ }
+
+ if (event.type == SWT.MouseUp) {
+ changeComboState(STATE_HOVER);
+ if (childShell == null || childShell.isDisposed()) {
+ openChildShell();
+ } else {
+ childShell.close();
+ childShell = null;
+ }
+ }
+
+ if (event.type == SWT.MouseMove) {
+ if (isOutOfBounds(event.x, event.y)) {
+ changeComboState(STATE_NORMAL);
+ } else if (isOutOfBounds(event.x, event.y)) {
+ if (0 != (event.stateMask & SWT.BUTTON1)) {
+ changeComboState(STATE_PUSH);
+ } else if (0 == (event.stateMask & SWT.BUTTON1)) {
+ changeComboState(STATE_HOVER);
+ }
+ }
+ }
+
+ if (event.type == SWT.MouseExit) {
+ changeComboState(STATE_NORMAL);
+ }
+ }
+ }
+ };
+
+ protected boolean isOutOfBounds(int x, int y) {
+ Rectangle rectangle = combo.getBounds();
+
+ if (x < 0 || x > rectangle.width || y < 0 || y > rectangle.height) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private int getShellWidth() {
+ if (getItems().isEmpty()) {
+ return 0;
+ }
+ int max = 0;
+ int size = items.size();
+ GC gc = new GC(parent.getDisplay(), SWT.NONE);
+ for (int i = 0; i < size; i++) {
+ Point p = gc.textExtent(items.get(i), SWT.DRAW_MNEMONIC);
+ if (p.x > max) {
+ max = p.x;
+ }
+ }
+ max += 10;
+ gc.dispose();
+ return max;
+ }
+
+ public int getItemHeight() {
+ return itemHeight;
+ }
+
+ public void setItemHeight(int height) {
+ itemHeight = height;
+ }
+
+ private void openChildShell() {
+ childShell = new Shell(parent.getShell(), SWT.ON_TOP);
+ childShell.setLayout(new FormLayout());
+
+ Point p = combo.toDisplay(0, 0);
+ Rectangle rect = combo.getBounds();
+ int size = getItems().size();
+
+ int boundSize = (size > MAX_SIZE) ? MAX_SIZE : (size > 0) ? size : 1;
+
+ int textSize = getShellWidth() + 4;
+ int shellWidth = (textSize > rect.width) ? textSize : rect.width + 4;
+ int height = 0;
+
+ if (getItemHeight() == 0) {
+ height = rect.height;
+ } else {
+ height = getItemHeight();
+ }
+ int shellHeight = height * boundSize + 5;
+
+ childShell.setSize(shellWidth, shellHeight);
+ childShell.setLocation(p.x, p.y + rect.height);
+
+ popup = new Canvas(childShell, SWT.DOUBLE_BUFFERED);
+ popup.setData(this);
+ popup.setBackground(ColorResources.WINDOW_BG_COLOR);
+ popup.addPaintListener(popupPaintListener);
+ popup.addListener(SWT.MouseUp, popupMouseEventListener);
+ popup.addListener(SWT.MouseMove, popupMouseEventListener);
+ popup.addListener(SWT.FocusOut, popupMouseEventListener);
+ popup.addListener(SWT.MouseUp, popupSelectionListener);
+ popup.addListener(SWT.MouseWheel, popupMouseEventListener);
+
+ if (size > MAX_SIZE) {
+ upArrowButton = new TizenButton(childShell, SWT.NONE);
+ upArrowButton.setText("up"); //$NON-NLS-1$
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.height = height;
+ upArrowButton.setLayoutData(data);
+ upArrowButton.addMouseListener(upArrowListener);
+ upArrowButton.addListener(SWT.MouseExit, upButtonMouseExitListener);
+ shellHeight += height;
+ upArrowButton.setEnabled(false);
+
+ data = new FormData();
+ data.top = new FormAttachment(upArrowButton, 0);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.height = height * boundSize + 5 - 2;
+ popup.setLayoutData(data);
+
+ downArrowButton = new TizenButton(childShell, SWT.NONE);
+ downArrowButton.setText("down"); //$NON-NLS-1$
+ data = new FormData();
+ data.top = new FormAttachment(popup, 0);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.height = height;
+ downArrowButton.setLayoutData(data);
+ downArrowButton.addMouseListener(downArrowListener);
+ downArrowButton.addListener(SWT.MouseExit,
+ downButtonMouseExitListener);
+ shellHeight += height;
+
+ childShell.setSize(shellWidth, shellHeight);
+ } else {
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.height = shellHeight - 2;
+ popup.setLayoutData(data);
+ }
+
+ size = (size > MAX_SIZE) ? MAX_SIZE : size;
+ getRects().clear();
+ for (int i = 0; i < size; i++) {
+ Rectangle r = new Rectangle(2, 2 + i * height, shellWidth - 2,
+ height);
+ getRects().add(r);
+ }
+ childShell.open();
+ }
+
+ private MouseListener upArrowListener = new MouseListener() {
+
+ @Override
+ public void mouseUp(MouseEvent event) {
+ if (!upArrowButton.isEnabled()) {
+ return;
+ }
+
+ if (null != upArrowButton) {
+ Rectangle rectangle = upArrowButton.getBounds();
+ int x = event.x;
+ int y = event.y;
+
+ if (x < 0 || x > rectangle.width || y < 0
+ || y > rectangle.height) {
+ return;
+ }
+ }
+
+ int size = getItems().size();
+ if (itemIndex - pageSize < 0) {
+ itemIndex = 0;
+ upArrowButton.setEnabled(false);
+ } else {
+ itemIndex -= pageSize;
+ }
+
+ if (itemIndex + pageSize < size - 1) {
+ downArrowButton.setEnabled(true);
+ }
+ popup.redraw();
+ }
+
+ @Override
+ public void mouseDown(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+ };
+
+ private MouseListener downArrowListener = new MouseListener() {
+
+ @Override
+ public void mouseUp(MouseEvent event) {
+
+ if (!downArrowButton.isEnabled()) {
+ return;
+ }
+
+ if (null != downArrowButton) {
+ Rectangle rectangle = downArrowButton.getBounds();
+ int x = event.x;
+ int y = event.y;
+
+ if (x < 0 || x > rectangle.width || y < 0
+ || y > rectangle.height) {
+ return;
+ }
+ }
+
+ int size = getItems().size();
+ if (itemIndex + pageSize + MAX_SIZE >= size - 1) {
+ itemIndex = size - MAX_SIZE;
+ downArrowButton.setEnabled(false);
+ } else {
+ itemIndex += pageSize;
+ }
+
+ if (itemIndex - pageSize > 0) {
+ upArrowButton.setEnabled(true);
+ }
+ popup.redraw();
+ }
+
+ @Override
+ public void mouseDown(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+ }
+ };
+
+ private PaintListener popupPaintListener = new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ List<String> items = getItems();
+ List<String> input = new ArrayList<String>();
+ int size = (items.size() > MAX_SIZE) ? MAX_SIZE : items.size();
+ for (int i = 0; i < size; i++) {
+ input.add(items.get(itemIndex + i));
+ }
+ popupRenderer
+ .draw(e.gc, popup, state, getRects(), selection, input);
+ }
+ };
+
+ public void setText(String text) {
+ if (!setSelect(text)) {
+ this.text = text;
+ redraw();
+ }
+ }
+
+ private boolean setSelect(String text) {
+ if (getItems().isEmpty()) {
+ return false;
+ }
+
+ int index = items.indexOf(text);
+ if (index < 0) {
+ return false;
+ }
+ int size = items.size();
+ if (index + MAX_SIZE >= size) {
+ int lower = size - index;
+ selection = MAX_SIZE - lower;
+ itemIndex = size - MAX_SIZE;
+ select(selection);
+ } else {
+ selection = index - itemIndex;
+ select(selection);
+ }
+ return true;
+ }
+
+ public void upEvent() {
+ if (getItems().size() > 0) {
+ setText(getItems().get(itemIndex + selection));
+ } else {
+ setText(""); //$NON-NLS-1$
+ }
+ childShell.close();
+ childShell = null;
+ }
+
+ private Listener popupMouseEventListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.type == SWT.MouseMove) {
+ List<Rectangle> rs = getRects();
+ int size = rs.size();
+ for (int i = 0; i < size; i++) {
+ if (rs.get(i).contains(event.x, event.y)) {
+ selection = i;
+ popup.redraw();
+ break;
+ }
+ }
+ }
+
+ if (event.type == SWT.FocusOut) {
+ childShell.close();
+ childShell = null;
+ }
+
+ if (event.type == SWT.MouseWheel) {
+ int size = getItems().size();
+ if (null != downArrowButton && null != upArrowButton) {
+ if (event.count < 0) {
+ if (itemIndex - event.count + MAX_SIZE >= size - 1) {
+ itemIndex = size - MAX_SIZE;
+ downArrowButton.setEnabled(false);
+ } else {
+ itemIndex -= event.count;
+ }
+
+ if (itemIndex - pageSize > 0) {
+ upArrowButton.setEnabled(true);
+ }
+ } else {
+
+ if (itemIndex - event.count < 0) {
+ itemIndex = 0;
+ upArrowButton.setEnabled(false);
+ } else {
+ itemIndex -= event.count;
+ }
+
+ if (itemIndex + event.count < size - 1) {
+ downArrowButton.setEnabled(true);
+ }
+ }
+ popup.redraw();
+ }
+ }
+ }
+ };
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ if (enabled) {
+ changeComboState(STATE_NORMAL);
+ if (isImageCombo()) {
+ setBackgroundImage(images.get(STATE_NORMAL));
+ }
+ } else {
+ changeComboState(STATE_DISABLE);
+ if (isImageCombo()) {
+ setBackgroundImage(images.get(STATE_DISABLE));
+ }
+ }
+ }
+
+ private PaintListener comboPaintListener = new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ if (!isImageCombo()) {
+ comboRenderer.draw(e.gc, combo, text, state);
+ } else {
+ comboRenderer.drawImage(e.gc, combo, images.get(state), text,
+ state);
+ }
+ }
+ };
+
+ public void setComboRender(TizenComboRenderer newRenderer) {
+ comboRenderer = newRenderer;
+ }
+
+ public void setComboPopupRender(TizenComboPopupRenderer newRenderer) {
+ popupRenderer = newRenderer;
+ }
+
+ public void removeAll() {
+ getItems().clear();
+ }
+
+ public void add(String item) {
+ getItems().add(item);
+ }
+
+ public void select(int index) {
+ selection = index;
+ this.text = items.get(itemIndex + selection);
+ redraw();
+ }
+
+ public String getItem(int index) {
+ if (getItems().size() > 0) {
+ return getItems().get(index);
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ public void setImages(Image normal, Image hover, Image push, Image disable) {
+ if (null == normal || null == hover || null == push || null == disable) {
+ return;
+ }
+ List<Image> imgs = getImages();
+
+ imgs.add(normal);
+ imgs.add(hover);
+ imgs.add(push);
+ imgs.add(disable);
+ setImageCombo(true);
+ }
+
+ private List<Image> getImages() {
+ if (null == images) {
+ images = new ArrayList<Image>();
+ }
+ return images;
+ }
+
+ private void setImageCombo(boolean b) {
+ this.imgCombo = b;
+ }
+
+ public boolean isImageCombo() {
+ return imgCombo;
+ }
+
+ private Listener upButtonMouseExitListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ }
+ };
+
+ private Listener downButtonMouseExitListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+
+ }
+ };
+
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.combo;
+
+import java.util.List;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+
+public abstract class TizenComboPopupRenderer {
+ public abstract void draw(GC gc, Canvas canvas, int state,
+ List<Rectangle> rects, int selection, List<String> items);
+
+ public abstract void drawPattern(GC gc, Canvas canvas, Image patternImage,
+ int state, List<Rectangle> rects, int selection, List<String> items);
+
+ public abstract void drawImage(GC gc, Canvas canvas, Image image,
+ int state, List<Rectangle> rects, int selection, List<String> items);
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.combo;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Canvas;
+
+public abstract class TizenComboRenderer {
+ public abstract void draw(GC gc, Canvas canvas, String text, int state);
+ public abstract void drawPattern(GC gc, Canvas canvas, Image patternImage, String text, int state);
+ public abstract void drawImage(GC gc, Canvas canvas, Image image, String text, int state);
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.combo;
+
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+
+public abstract class TizenComboSelectionListener implements Listener {
+
+ @Override
+ public void handleEvent(Event event) {
+ Canvas popup = (Canvas) event.widget;
+ TizenCombo combo = (TizenCombo) popup.getData();
+ if (null != combo) {
+ selectionEvent(combo);
+ combo.upEvent();
+ }
+ }
+
+ public abstract void selectionEvent(TizenCombo combo);
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.graph.circular;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
+import org.tizen.dynamicanalyzer.widgets.helper.Formatter;
+
+public class CircularGraph extends Composite {
+
+ private final int DEFAULT_ANGLE = 90;
+ private Color defaultGraphColor = ColorResources.ITEM_BLUE_BRIGHT;
+ private Color defaultGraphBgcolor = ColorResources.TITLEBAR_BG_COLOR;
+ public static final int TYPE_PERCENT = 0;
+ public static final int TYPE_CUSTOM = 1;
+
+ private Canvas canvas;
+ private Label label;
+ private Font font;
+ private long max = 100;
+ private long value = 0;
+ private Color graphColor = defaultGraphColor;
+ private Color bgColor = defaultGraphBgcolor;
+ private String measure;
+ private int type = TYPE_PERCENT;
+ private Color textColor = defaultGraphColor;
+
+ public CircularGraph(Composite parent, int style, int type) {
+ super(parent, style);
+ this.setLayout(new FormLayout());
+ this.type = type;
+
+ if (type == TYPE_PERCENT) {
+ measure = "%"; //$NON-NLS-1$
+ } else {
+ measure = ""; //$NON-NLS-1$
+ }
+
+ canvas = new Canvas(this, SWT.DOUBLE_BUFFERED);
+ canvas.addPaintListener(paintListener);
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(0, 0);
+ data.width = 74;
+ data.height = 74;
+ canvas.setLayoutData(data);
+
+ label = new Label(this, SWT.TRANSPARENT);
+ label.setForeground(textColor);
+ font = getShell().getDisplay().getSystemFont();
+ label.setFont(font);
+ label.setAlignment(SWT.CENTER);
+ data = new FormData();
+ data.top = new FormAttachment(canvas, 1);
+ data.left = new FormAttachment(0, 0);
+ data.height = 25;
+ data.width = 76;
+ label.setLayoutData(data);
+ }
+
+ private PaintListener paintListener = new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ Rectangle rect = canvas.getBounds();
+ int x = rect.x;
+ int y = rect.y;
+ int width = rect.width;
+ int height = rect.height;
+ if (width > height) {
+ x += (rect.width - rect.height) / 2;
+ width = height;
+ } else if (width < height) {
+ y += (rect.height - rect.width) / 2;
+ height = width;
+ }
+
+ e.gc.setAntialias(SWT.ON);
+ e.gc.setBackground(bgColor);
+ e.gc.fillOval(x, y, width, height);
+ e.gc.setBackground(graphColor);
+ e.gc.fillArc(x, y, width, height, DEFAULT_ANGLE, calculateAngle());
+ e.gc.setBackground(ColorResources.BLACK);
+ e.gc.fillOval(x + 9, y + 9, 56, 56);
+
+ // Draws text.
+ String center = getCenterText();
+
+ e.gc.setFont(font);
+ e.gc.setForeground(graphColor);
+ Point textSize = e.gc.textExtent(center, SWT.DRAW_MNEMONIC);
+ e.gc.drawText(center, (rect.width - textSize.x) / 2, 28 - 6, true);
+ // (rect.height - textSize.y) / 2 - 5, true);
+
+ e.gc.setFont(font);
+ e.gc.setForeground(graphColor);
+ Point measureSize = e.gc.textExtent(measure, SWT.DRAW_MNEMONIC);
+ e.gc.drawText(measure, (rect.width - measureSize.x) / 2, 46 - 4,
+ true);
+ // (rect.height - measureSize.y) / 2 - 5 + textSize.y, true);
+ }
+ };
+
+ public void setMax(long max) {
+ this.max = max;
+ canvas.redraw();
+ }
+
+ public void update(long max, long value) {
+ this.max = max;
+ this.value = value;
+ canvas.redraw();
+ }
+
+ public void update(long value) {
+ this.value = value;
+ canvas.redraw();
+ }
+
+ private int calculateAngle() {
+ int angle = (int) (360 * ((float) value / max)) * (-1);
+ return angle;
+ }
+
+ public void setText(String text) {
+ label.setForeground(textColor);
+ label.setText(text);
+ }
+
+ public void setFont(Font font) {
+ label.setFont(font);
+ this.font = font;
+ }
+
+ public void setTextColor(Color color) {
+ textColor = color;
+ }
+
+ private String getCenterText() {
+ String str = null;
+ if (type == TYPE_PERCENT) {
+ int percent = (int) (((float) value / max) * 100);
+ str = Integer.toString(percent);
+ } else {
+ // type : memory size
+ if (value >= 1024) {
+ double dValue = (value) / 1024.;
+ if (dValue >= 1024. * 1024) {
+ dValue = (dValue) / 1024. * 1024;
+ setMeasure("GB"); //$NON-NLS-1$
+ } else if (dValue >= 1024.) {
+ dValue = (dValue) / 1024.0;
+ setMeasure("MB"); //$NON-NLS-1$
+ } else {
+ setMeasure("KB"); //$NON-NLS-1$
+ }
+ str = Formatter.toDoubleFormat1(Double.toString(dValue));
+ } else {
+ str = Long.toString(value);
+ }
+ }
+ return str;
+ }
+
+ public void setMeasure(String m) {
+ measure = m;
+ }
+
+ public void setGraphColor(Color color) {
+ graphColor = color;
+ }
+
+ public void setGraphBgColor(Color color) {
+ bgColor = color;
+ }
+}
--- /dev/null
+/*\r
+ * Dynamic Analyzer\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Jooyoul Lee <jy.exe.lee@samsung.com>\r
+ * Juyoung Kim <j0.kim@samsung.com>\r
+ *\r
+ * This program and the accompanying materials are made available\r
+ * under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ * \r
+ */\r
+package org.tizen.dynamicanalyzer.widgets.helper;\r
+\r
+import org.eclipse.jface.resource.ColorRegistry;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.RGB;\r
+\r
+public class ColorResources {\r
+\r
+ private static ColorRegistry colorRegistry = new ColorRegistry();\r
+\r
+ public static final Color WHITE = getColor("white", new RGB(255, 255, 255)); //$NON-NLS-1$\r
+ public static final Color BLACK = getColor("black", new RGB(0, 0, 0)); //$NON-NLS-1$\r
+ public static final Color BLUE = getColor("blue", new RGB(0, 0, 255)); //$NON-NLS-1$\r
+ public static final Color RED = getColor("red", new RGB(255, 0, 0)); //$NON-NLS-1$\r
+ public static final Color PURPLE = getColor("PUPLE", new RGB(226, 101, 225)); //$NON-NLS-1$\r
+\r
+ // shell window background color\r
+ public static final Color WINDOW_BG_COLOR = getColor(\r
+ "window_bg_color", new RGB(51, 52, 53)); //$NON-NLS-1$\r
+ //\r
+ // /** title bar colors **/\r
+ // public static final Color TITLEBAR_TEXT_COLOR = getColor(\r
+ // "titlebar_text_color", new RGB(64, 208, 255)); //$NON-NLS-1$\r
+ //\r
+ public static final Color TITLEBAR_BG_COLOR = getColor(\r
+ "titlebar_bg", new RGB(78, 79, 81)); //$NON-NLS-1$\r
+ //\r
+ // /** device and application combo specific colors start **/\r
+ // public static final Color DEVICE_APPLICATION_ENABLE = WHITE;\r
+ //\r
+ // public static final Color DEVICE_APPLICATION_DISABLE = getColor(\r
+ // "device_application_disable", new RGB(128, 128, 128)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color DEVICE_APPLICATION_POPUP_OUTER_1 = getColor(\r
+ // "device_application_popup_outer_1", new RGB(31, 31, 31)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color DEVICE_APPLICATION_POPUP_OUTER_2 = getColor(\r
+ // "device_application_popup_outer_2", new RGB(31, 137, 163)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color DEVICE_APPLICATION_DROPDOWN_TEXT = WHITE;\r
+ //\r
+ // public static final Color DEVICE_APPLICATION_ITEM_NORMAL_TOP = getColor(\r
+ // "device_application_item_normal_top", new RGB(76, 76, 77)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color DEVICE_APPLICATION_ITEM_NORMAL_INNER =\r
+ // getColor(\r
+ // "device_application_item_normal_inner", new RGB(66, 66, 67)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color DEVICE_APPLICATION_ITEM_NORMAL_BOTTOM =\r
+ // getColor(\r
+ // "device_application_item_normal_bottom", new RGB(56, 56, 60)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color DEVICE_APPLICATION_ITEM_SELECT_TOP = getColor(\r
+ // "device_application_item_select_top", new RGB(76, 76, 77)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color DEVICE_APPLICATION_ITEM_SELECT_INNER =\r
+ // getColor(\r
+ // "device_application_item_select_inner", new RGB(0, 151, 201)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color DEVICE_APPLICATION_ITEM_SELECT_BOTTOM =\r
+ // getColor(\r
+ // "device_application_item_select_bottom", new RGB(56, 56, 60)); //$NON-NLS-1$\r
+ //\r
+ // /** device and application combo specific colors end **/\r
+ //\r
+ // /** normal view layout colors start **/\r
+ //\r
+ // public static final Color NORMAL_VIEW_LAYOUT_OUTER = getColor(\r
+ // "normal_view_layout_outer", new RGB(160, 160, 160)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color NORMAL_VIEW_LAYOUT_MIDDLE = getColor(\r
+ // "normal_view_layout_middle", new RGB(74, 74, 74)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color NORMAL_VIEW_LAYOUT_INNER = getColor(\r
+ // "normal_view_layout_inner", new RGB(66, 66, 68)); //$NON-NLS-1$\r
+ //\r
+ // /** normal view layout colors end **/\r
+ //\r
+ // /** current view colors start **/\r
+ // public static final Color CURRENT_VIEW_OUTLINE = getColor(\r
+ // "current_view_outline", new RGB(160, 160, 160)); //$NON-NLS-1$\r
+ // public static final Color CURRENT_VIEW_TITLE_TEXT = WHITE;\r
+ // public static final Color CURRENT_VIEW_MIDDLE =\r
+ // NORMAL_VIEW_LAYOUT_MIDDLE;\r
+ // public static final Color CURRENT_VIEW_INNER = NORMAL_VIEW_LAYOUT_INNER;\r
+ //\r
+ // public static final Color CURRENT_VIEW_TABLE_TITLE_BG = getColor(\r
+ // "current_view_table_title_bg", new RGB(59, 59, 60)); //$NON-NLS-1$\r
+ // public static final Color CURRENT_VIEW_TABLE_TITLE_TEXT = getColor(\r
+ // "current_view_table_title_text", new RGB(151, 230, 255)); //$NON-NLS-1$\r
+ // public static final Color CURRENT_VIEW_TABLE_CONTENTS_BG = getColor(\r
+ // "current_view_table_contents_bg", new RGB(84, 85, 86)); //$NON-NLS-1$\r
+ // public static final Color CURRENT_VIEW_TABLE_CONTENTS_TEXT = getColor(\r
+ // "current_view_table_contents_text", new RGB(216, 216, 216)); //$NON-NLS-1$\r
+ // public static final Color CURRENT_VIEW_TABLE_LINE = getColor(\r
+ // "current_view_table_line", new RGB(136, 137, 138)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color CURRENT_VIEW_CPU_TEXT = getColor(\r
+ // "current_view_cpu_text", new RGB(2, 171, 208)); //$NON-NLS-1$\r
+ // public static final Color CURRENT_VIEW_PROCESS_TEXT = getColor(\r
+ // "current_view_process_text", new RGB(114, 203, 8)); //$NON-NLS-1$\r
+ // public static final Color CURRENT_VIEW_GRAPH_BG = getColor(\r
+ // "current_view_graph_bg", new RGB(79, 79, 81)); //$NON-NLS-1$\r
+ // public static final Color CURRENT_VIEW_CPU_GRAPH = CURRENT_VIEW_CPU_TEXT;\r
+ // public static final Color CURRENT_VIEW_PROCESS_GRAPH =\r
+ // CURRENT_VIEW_PROCESS_TEXT;\r
+ // public static final Color CURRENT_VIEW_GRAPH_OUTLINE = getColor(\r
+ // "current_view_graph_outline", new RGB(43, 44, 45)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color CURRENT_VIEW_SNAPSHOT_OUTLINE = getColor(\r
+ // "current_view_snapshot_outline", new RGB(49, 104, 127)); //$NON-NLS-1$\r
+ // /** current view colors end **/\r
+ //\r
+ // /** common table colors start **/\r
+ // public static final Color TABLE_HEADER_BG = getColor(\r
+ // "table_header_bg", new RGB(59, 59, 60)); //$NON-NLS-1$\r
+ // public static final Color TABLE_LINE = getColor(\r
+ // "table_line", new RGB(136, 137, 138)); //$NON-NLS-1$\r
+ // public static final Color TABLE_CONTENTS_NORMAL = getColor(\r
+ // "table_contents_normal", new RGB(84, 85, 86)); //$NON-NLS-1$\r
+ // public static final Color TABLE_CONTENTS_HOVER = getColor(\r
+ // "table_contents_hover", new RGB(72, 98, 108)); //$NON-NLS-1$\r
+ // public static final Color TABLE_CONTENTS_SELECTED_START = getColor(\r
+ // "table_contents_selected_start", new RGB(0, 146, 193)); //$NON-NLS-1$\r
+ // public static final Color TABLE_CONTENTS_SELECTED_END = getColor(\r
+ // "table_contents_selected_end", new RGB(0, 60, 79)); //$NON-NLS-1$\r
+ // public static final Color TABLE_HEADER_FONT_COLOR = getColor(\r
+ // "table_title_font_color", new RGB(151, 230, 255)); //$NON-NLS-1$\r
+ // public static final Color TABLE_CONTENTS_FONT_COLOR = getColor(\r
+ // "table_contents_font_color", new RGB(216, 216, 216)); //$NON-NLS-1$\r
+ // /** common table colors end **/\r
+ //\r
+ // /** open trace popup colors **/\r
+ // public static final Color OPEN_TRACE_POPUP_CONTENTS_BG_COLOR = getColor(\r
+ // "open_trace_popup_contents_bg_color", new RGB(51, 52, 53)); //$NON-NLS-1$\r
+ // public static final Color OPEN_TRACE_POPUP_BOTTOM_BG_COLOR = getColor(\r
+ // "open_trace_popup_bottom_bg_color", new RGB(39, 39, 40)); //$NON-NLS-1$\r
+ // public static final Color OPEN_TRACE_TITLE_TEXT_COLOR =\r
+ // TITLEBAR_TEXT_COLOR;\r
+ // public static final Color OPEN_TRACE_INNERTITLE_TEXT_COLOR = WHITE;\r
+ // public static final Color OPEN_TRACE_BUTTON_TEXT_COLOR = WHITE;\r
+ // public static final Color OPEN_TRACE_TABLE_OUTLINE_COLOR =\r
+ // CURRENT_VIEW_TABLE_LINE;\r
+ // public static final Color OPEN_TRACE_TABLE_LINE1_NORMAL = getColor(\r
+ // "open_trace_table_line1_normal", new RGB(78, 78, 79)); //$NON-NLS-1$\r
+ // public static final Color OPEN_TRACE_TABLE_LINE1_HOVER = getColor(\r
+ // "open_trace_table_line1_hover", new RGB(72, 98, 108)); //$NON-NLS-1$\r
+ // public static final Color OPEN_TRACE_TABLE_LINE_SELECTED_START =\r
+ // getColor(\r
+ // "open_trace_table_line_selected_start", new RGB(0, 146, 193)); //$NON-NLS-1$\r
+ // public static final Color OPEN_TRACE_TABLE_LINE_SELECTED_END = getColor(\r
+ // "open_trace_table_line_selected_end", new RGB(0, 60, 79)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color OPEN_TRACE_TABLE_LINE2_NORMAL = getColor(\r
+ // "open_trace_table_line2_normal", new RGB(84, 85, 86)); //$NON-NLS-1$\r
+ // public static final Color OPEN_TRACE_TABLE_LINE2_HOVER = getColor(\r
+ // "open_trace_table_line2_hover", new RGB(72, 98, 108)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color OPEN_TRACE_TABLE2_FONT_COLOR = getColor(\r
+ // "open_trace_table2_font_color", new RGB(255, 85, 57)); //$NON-NLS-1$\r
+ //\r
+ // /** snapshot viewer colors **/\r
+ // public static final Color SNAPSHOT_VIEWER_BORDER = getColor(\r
+ // "snapshot_viewer_border", new RGB(49, 104, 127)); //$NON-NLS-1$\r
+ //\r
+ // /** File chart colors **/\r
+ // public static final Color FILE_CLOSED_START = getColor(\r
+ // "file_closed_start", new RGB(168, 198, 71)); //$NON-NLS-1$\r
+ // public static final Color FILE_CLOSED_END = getColor(\r
+ // "file_closed_end", new RGB(130, 152, 54)); //$NON-NLS-1$\r
+ // public static final Color FILE_USED_START = getColor(\r
+ // "file_used_start", new RGB(58, 138, 203)); //$NON-NLS-1$\r
+ // public static final Color FILE_USED_END = getColor(\r
+ // "file_used_end", new RGB(44, 104, 153)); //$NON-NLS-1$\r
+ // public static final Color FILE_OPEN_START = getColor(\r
+ // "file_open_start", new RGB(255, 135, 82)); //$NON-NLS-1$\r
+ // public static final Color FILE_OPEN_END = getColor(\r
+ // "file_open_end", new RGB(232, 73, 73)); //$NON-NLS-1$\r
+ // public static final Color FILE_FAILED_START = getColor(\r
+ // "file_failed_start", new RGB(226, 58, 242)); //$NON-NLS-1$\r
+ // public static final Color FILE_FAILED_END = getColor(\r
+ // "file_failed_end", new RGB(164, 40, 176)); //$NON-NLS-1$\r
+ // public static final Color FILE_CHART_SELECTION_BG = getColor(\r
+ // "file_chart_selection_bg", new RGB(0, 151, 201)); //$NON-NLS-1$\r
+ // public static final Color FILE_CHART_PARENT_BG = getColor(\r
+ // "file_chart_parent_bg", new RGB(84, 85, 86)); //$NON-NLS-1$\r
+ // public static final Color FILE_CHART_CHILD_BG = getColor(\r
+ // "file_chart_child_bg", new RGB(59, 59, 60)); //$NON-NLS-1$\r
+ //\r
+ //\r
+ //\r
+ // public static final Color VIEW_BORDER = getColor(\r
+ // "view_border", new RGB(74, 74, 74)); //$NON-NLS-1$\r
+ // public static final Color VIEW_BG_COLOR = getColor(\r
+ // "view_bg_color", new RGB(66, 66, 68)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color TAB_BG_COLOR = VIEW_BG_COLOR; //$NON-NLS-1$\r
+ // public static final Color TABLE_BG_COLOR = getColor(\r
+ // "table_bg_color", new RGB(84, 85, 87)); //$NON-NLS-1$\r
+ // public static final Color TABLE_HEADER_COLOR = getColor(\r
+ // "table_header_color", new RGB(59, 59, 61)); //$NON-NLS-1$\r
+ // // public static final Color TABLE_HEADER_FONT_COLOR = getColor(\r
+ // // "table_header_font_color", new RGB(75, 229, 253)); //$NON-NLS-1$\r
+ // public static final Color TABLE_LINE_COLOR = getColor(\r
+ // "table_line_color", new RGB(96, 97, 99)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color UNSELECTED_TAB_FIRST = getColor(\r
+ // "unselected_tab_first", new RGB(51, 51, 51)); //$NON-NLS-1$\r
+ // public static final Color UNSELECTED_TAB_SECOND = getColor(\r
+ // "unselected_tab_second", new RGB(42, 42, 42)); //$NON-NLS-1$\r
+ // public static final Color SELECTED_TAB_FIRST = getColor(\r
+ // "selected_tab_first", new RGB(74, 74, 74)); //$NON-NLS-1$\r
+ // public static final Color SELECTED_TAB_SECOND = getColor(\r
+ // "selected_tab_second", new RGB(128, 129, 130)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color TOOLTIP = getColor(\r
+ // "tooltip", new RGB(255, 255, 225)); //$NON-NLS-1$\r
+ //\r
+ public static final Color BAR_GRAY1 = getColor(\r
+ "barGRAY1", new RGB(177, 177, 177)); //$NON-NLS-1$\r
+ // public static final Color BAR_GRAY2 = getColor(\r
+ // "barGRAY2", new RGB(153, 153, 153)); //$NON-NLS-1$\r
+ // public static final Color BAR_GRAY3 = getColor(\r
+ // "barGRAY3", new RGB(216, 216, 216)); //$NON-NLS-1$\r
+ //\r
+ // /* Timeline */\r
+ public static final Color ITEM_BLUE_BRIGHT = getColor("item blue right",\r
+ new RGB(131, 196, 218));//$NON-NLS-1$\r
+ public static final Color ITEM_BLUE_DARK = getColor("item blue dark",\r
+ new RGB(38, 104, 138));//$NON-NLS-1$\r
+\r
+ // public static final Color ITEM_BG = getColor("item background", new\r
+ // RGB(50,\r
+ // 50, 50));//$NON-NLS-1$\r
+ // public static final java.awt.Color ITEM_BG_AWT = new java.awt.Color(50,\r
+ // 50,\r
+ // 50);//$NON-NLS-1$\r
+ // public static final java.awt.Color ITEM_BLUE_AWT = new java.awt.Color(38,\r
+ // 104, 138);//$NON-NLS-1$\r
+ // public static final Color TIMELINE_BG = getColor(\r
+ // "timeline_bg", new RGB(50, 50, 50)); //$NON-NLS-1$\r
+ // public static final Color TRANS = getColor(\r
+ // "timeline_bg", new RGB(50, 50, 50)); //$NON-NLS-1$\r
+ // public static final Color SNAPSHOT_CHART_FOREGROUND = BAR_GRAY1;\r
+ // public static final Color SNAPSHOT_CHART_BACKGROUND = getColor(\r
+ // "snapshot_chart_bg", new RGB(50, 50, 50)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color GRAY_80 = getColor("GRAY_80", new RGB(80, 80, 80)); //$NON-NLS-1$\r
+ // public static final Color GRAY_110 = getColor(\r
+ // "GRAY_110", new RGB(110, 110, 110)); //$NON-NLS-1$\r
+ // public static final Color GRAY_130 = getColor(\r
+ // "GRAY_130", new RGB(130, 130, 130)); //$NON-NLS-1$\r
+ // public static final Color GRAY_170 = getColor(\r
+ // "GRAY_170", new RGB(170, 170, 170)); //$NON-NLS-1$\r
+ // public static final Color GRAY_210 = getColor(\r
+ // "GRAY_210", new RGB(210, 210, 210)); //$NON-NLS-1$\r
+ //\r
+ // public static final java.awt.Color DEFAULT_CHART_FOREGROUND =\r
+ // java.awt.Color.LIGHT_GRAY;\r
+ // public static final java.awt.Color DEFAULt_CHART_BACKGROUND = new\r
+ // java.awt.Color(\r
+ // 66, 66, 68);\r
+ // public static final Color DEFAULT_FOREGROUND = getColor(\r
+ // "defaultForeground", new RGB(0, 0, 0)); //$NON-NLS-1$\r
+ // public static final Color DEFAULT_BACKGROUND = getColor(\r
+ // "defaultBackground", new RGB(255, 255, 255)); //$NON-NLS-1$\r
+ // public static final Color DEFAULT_RED = getColor(\r
+ // "defaultRed", new RGB(173, 13, 1)); //$NON-NLS-1$\r
+ //\r
+ // // circular graph\r
+ // public static final Color CPU_CIRCULAR_GRAPH_COLOR = getColor(\r
+ // "cpu_circular_graph_color", new RGB(2, 171, 208)); //$NON-NLS-1$\r
+ // public static final Color PROCESS_CIRCULAR_GRAPH_COLOR = getColor(\r
+ // "process_circular_graph_color", new RGB(114, 203, 8)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color PROFILING_GRAPH_COLOR_START = getColor(\r
+ // "profiling_graph_color_start", new RGB(145, 190, 3)); //$NON-NLS-1$\r
+ // public static final Color PROFILING_GRAPH_COLOR_END = getColor(\r
+ // "profiling_graph_color_end", new RGB(114, 149, 1)); //$NON-NLS-1$\r
+ //\r
+ // public static final Color PROFILING_GRAPH_SELECTION_COLOR_START =\r
+ // getColor(\r
+ // "profiling_graph_selection_color_start", new RGB(255, 135, 82)); //$NON-NLS-1$\r
+ // public static final Color PROFILING_GRAPH_SELECTION_COLOR_END = getColor(\r
+ // "profiling_graph_selection_color_end", new RGB(232, 73, 73)); //$NON-NLS-1$\r
+\r
+ private static Color getColor(String colorName, RGB rgb) {\r
+ if (!colorRegistry.hasValueFor(colorName)) {\r
+ colorRegistry.put(colorName, rgb);\r
+ }\r
+\r
+ return colorRegistry.get(colorName);\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.helper;
+
+import java.text.DecimalFormat;
+
+public class Formatter {
+
+ public static String toHexString(String decimal) {
+ if (null == decimal || decimal.isEmpty()) {
+ return null;
+ }
+
+ try {
+ if (decimal.isEmpty()) {
+ return null;
+ } else {
+ long data = 0;
+ data = Long.parseLong(decimal);
+ return String.format("0x%08X", data); //$NON-NLS-1$
+ }
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ return decimal;
+ }
+ }
+
+ public static String toDoubleFormat1(String value) {
+ if (null == value || value.isEmpty()) {
+ return null;
+ }
+
+ try {
+ double data = Double.parseDouble(value);
+ return String.format("%.1f", data); //$NON-NLS-1$
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ return value;
+ }
+ }
+
+ public static String toByteNumberFormat(String value) {
+ if (null == value || value.isEmpty()) {
+ return null;
+ }
+
+ try {
+ long num = Long.parseLong(value);
+ String str = ""; //$NON-NLS-1$
+ while (num > 0) {
+ long n = num % 1000;
+ if (str.isEmpty()) {
+ str += Long.toString(n);
+ } else {
+ String zero = ""; //$NON-NLS-1$
+ if (str.length() == 1) {
+ zero += "00"; //$NON-NLS-1$
+ } else if (str.length() == 2) {
+ zero += "0"; //$NON-NLS-1$
+ }
+ str = zero + Long.toString(n) + "," + str; //$NON-NLS-1$
+ }
+ num /= 1000;
+ }
+ if (str.isEmpty()) {
+ str += "0"; //$NON-NLS-1$
+ }
+ return str;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return "0"; //$NON-NLS-1$
+ }
+ }
+
+ public static String toByteToMbNumberFormat2(String value) {
+ if (null == value || value.isEmpty()) {
+ return null;
+ }
+ try {
+ long num = Long.parseLong(value);
+ num /= 1024; // KB
+ double kb = num / 1024.;
+
+ String str = Formatter.toDoubleFormat2(Double.toString(kb));
+ return str;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return "0"; //$NON-NLS-1$
+ }
+ }
+
+ public static String toDoubleFormat2(String value) {
+ if (null == value || value.isEmpty()) {
+ return null;
+ }
+
+ try {
+ double data = Double.parseDouble(value);
+ return String.format("%.2f", data); //$NON-NLS-1$
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ return value;
+ }
+ }
+
+ public static String toTimeFormat(String time) {
+ long longTime = Long.parseLong(time);
+ longTime /= 1000;
+ long ms = longTime % 1000;
+ longTime /= 1000;
+ long second = longTime % 60;
+ longTime /= 60;
+ long minute = longTime % 60;
+ String strMinute = Long.toString(minute);
+ if (strMinute.length() < 2) {
+ strMinute = "0" + strMinute; //$NON-NLS-1$
+ }
+
+ String strSecond = Long.toString(second);
+ if (strSecond.length() < 2) {
+ strSecond = "0" + strSecond; //$NON-NLS-1$
+ }
+
+ String strMs = Long.toString(ms);
+ if (strMs.length() == 2) {
+ strMs = "0" + strMs; //$NON-NLS-1$
+ } else if (strMs.length() == 1) {
+ strMs = "00" + strMs; //$NON-NLS-1$
+ }
+
+ String output = strMinute + ":" + strSecond + ":" + strMs; //$NON-NLS-1$ //$NON-NLS-2$
+ return output;
+ }
+
+ public static String toTimeFormat2(String msTime) {
+ long longTime = Long.parseLong(msTime);
+ long ms = longTime % 1000;
+ longTime /= 1000;
+ long second = longTime % 60;
+
+ String strSecond = Long.toString(second);
+ if (strSecond.length() < 2) {
+ strSecond = "0" + strSecond; //$NON-NLS-1$
+ }
+
+ String strMs = Long.toString(ms);
+ if (strMs.length() == 2) {
+ strMs = "0" + strMs; //$NON-NLS-1$
+ } else if (strMs.length() == 1) {
+ strMs = "00" + strMs; //$NON-NLS-1$
+ }
+
+ String output = strSecond + ":" + strMs; //$NON-NLS-1$
+ return output;
+ }
+
+ public static String toPercentageFormat(Double input) {
+ String ret = String.format("%.2f", input); //$NON-NLS-1$
+ ret += " %"; //$NON-NLS-1$
+ return ret;
+ }
+
+ public static String toNumberFormat(long input) {
+ int reminder = 0;
+ long quotient = input;
+ String output = ""; //$NON-NLS-1$
+
+ while (true) {
+ reminder = (int) (quotient % 1000);
+ quotient = quotient / 1000;
+ String value = Integer.toString(reminder);
+ if (quotient > 0) {
+ if (value.length() < 2) {
+ value = "00" + value; //$NON-NLS-1$
+ } else if (value.length() < 3) {
+ value = "0" + value; //$NON-NLS-1$
+ }
+ output = value + output;
+ output = "," + output; //$NON-NLS-1$
+ } else {
+ output = value + output;
+ break;
+ }
+ }
+ return output;
+ }
+
+ public static String toNumberFormat(double input) {
+ return toNumberFormat((long) input);
+ }
+
+ public static String toByteFormat(long input) {
+ int reminder = 0;
+ long quotient = input;
+ int count = 0;
+ String value = ""; //$NON-NLS-1$
+
+ while (true) {
+ if (quotient >= 1024) {
+ reminder = (int) (quotient % 1024);
+ quotient = quotient / 1024;
+ count++;
+ continue;
+ } else {
+ value = Long.toString(quotient);
+ String remStr = Integer.toString(reminder);
+ if (count > 0) {
+ if (remStr.length() < 3) {
+ value += ".0"; //$NON-NLS-1$
+ } else {
+ value += "." + remStr.substring(0, 1); //$NON-NLS-1$
+ }
+ }
+ value += " " + getMeasure(count); //$NON-NLS-1$
+ break;
+ }
+ }
+ return value;
+ }
+
+ public static String toByteFormat(double input) {
+ return toByteFormat((long) input);
+ }
+
+ public static String toBpsFormat(long nByte, long startTime, long endTime) {
+ String value = ""; //$NON-NLS-1$
+ DecimalFormat df1 = new DecimalFormat("#,##0.00"); //$NON-NLS-1$
+ double Bps = nByte;
+
+ if (endTime - startTime >= 1000000) {
+ Bps = ((double) nByte * ((double) 1000000 / (double) (endTime - startTime)));
+ }
+
+ value += df1.format(Bps) + " Bps"; //$NON-NLS-1$
+ return value;
+ }
+
+ public static String toBpsFormat(double nByte, long startTime, long endTime) {
+ return toBpsFormat((long) nByte, startTime, endTime);
+ }
+
+ private static String getMeasure(int count) {
+ if (count == 4) {
+ return "TB"; //$NON-NLS-1$
+ } else if (count == 3) {
+ return "GB"; //$NON-NLS-1$
+ } else if (count == 2) {
+ return "MB"; //$NON-NLS-1$
+ } else if (count == 1) {
+ return "KB"; //$NON-NLS-1$
+ } else {
+ return "Byte"; //$NON-NLS-1$
+ }
+ }
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.helper;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+
+public class ImageResources {
+ private static ImageRegistry imageRegistry = new ImageRegistry();
+
+ // Dialog button
+ public static final Image DIALOG_PUSH = getPngImage("dialog_button_push"); //$NON-NLS-1$
+
+ public static final Image ABOUT = getPngImage("toolbar_about_nor"); //$NON-NLS-1$
+ public static final Image ABOUT_PUSH = getPngImage("toolbar_about_push"); //$NON-NLS-1$
+ public static final Image ABOUT_HOVER = getPngImage("toolbar_about_hover"); //$NON-NLS-1$
+ public static final Image ABOUT_DISABLE = getPngImage("toolbar_about_disable"); //$NON-NLS-1$
+
+ public static final Image VIEW_SOURCE = getPngImage("toolbar_source_view_nor"); //$NON-NLS-1$
+ public static final Image VIEW_SOURCE_PUSH = getPngImage("toolbar_source_view_push"); //$NON-NLS-1$
+ public static final Image VIEW_SOURCE_HOVER = getPngImage("toolbar_source_view_hover"); //$NON-NLS-1$
+ public static final Image VIEW_SOURCE_TOGGLE = getPngImage("toolbar_source_view_tog"); //$NON-NLS-1$
+ public static final Image VIEW_SOURCE_DISABLE = getPngImage("toolbar_source_view_disable"); //$NON-NLS-1$
+
+ /* snapshot */
+ public static final Image SNAPSHOT_LEFT_NORMAL = getPngImage("snapshot_arrow_left_nor"); //$NON-NLS-1$
+ public static final Image SNAPSHOT_LEFT_PUSH = getPngImage("snapshot_arrow_left_push"); //$NON-NLS-1$
+ public static final Image SNAPSHOT_LEFT_HOVER = getPngImage("snapshot_arrow_left_hover"); //$NON-NLS-1$
+ public static final Image SNAPSHOT_LEFT_DISABLE = getPngImage("snapshot_arrow_left_disable"); //$NON-NLS-1$
+ public static final Image SNAPSHOT_RIGHT_NORMAL = getPngImage("snapshot_arrow_right_nor"); //$NON-NLS-1$
+ public static final Image SNAPSHOT_RIGHT_PUSH = getPngImage("snapshot_arrow_right_push"); //$NON-NLS-1$
+ public static final Image SNAPSHOT_RIGHT_HOVER = getPngImage("snapshot_arrow_right_hover"); //$NON-NLS-1$
+ public static final Image SNAPSHOT_RIGHT_DISABLE = getPngImage("snapshot_arrow_right_disable"); //$NON-NLS-1$
+
+ public static final Image NO_IMAGE = getPngImage("noImage"); //$NON-NLS-1$
+
+ private static Image getImage(String folderName, String imageName,
+ String extension) {
+ if (null == imageRegistry.get(imageName)
+ || imageRegistry.get(imageName).isDisposed()) {
+ // ImageDescriptor desc =
+ // AbstractUIPlugin.imageDescriptorFromPlugin(
+ // pluginId, folderName + imageName + extension);
+ String strUrl = "file:" + folderName + imageName + extension;
+ URL url = null;
+ try {
+ url = new URL(strUrl);
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ ImageDescriptor desc = ImageDescriptor.createFromURL(url);
+ imageRegistry.put(imageName, desc);
+ }
+
+ return imageRegistry.get(imageName);
+ }
+
+ private static Image getImage(String imageName, String extension) {
+ return getImage("testImages" + File.separator, imageName, extension);
+ }
+
+ private static Image getPngImage(String imageName) {
+ return getImage(imageName, ".png");
+ }
+}
--- /dev/null
+package test;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.widgets.button.TizenButton;
+import org.tizen.dynamicanalyzer.widgets.button.TizenButtonClickEventListener;
+import org.tizen.dynamicanalyzer.widgets.button.toggle.TizenToggleButton;
+import org.tizen.dynamicanalyzer.widgets.combo.TizenCombo;
+import org.tizen.dynamicanalyzer.widgets.combo.TizenComboSelectionListener;
+import org.tizen.dynamicanalyzer.widgets.graph.circular.CircularGraph;
+import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
+import org.tizen.dynamicanalyzer.widgets.helper.ImageResources;
+
+public class TestClass {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+
+ shell.setSize(new Point(1000, 1000));
+
+ shell.setLayout(new FormLayout());
+ shell.open();
+ TizenButton button = new TizenButton(shell, SWT.NONE);
+ button.setText("test");
+ FormData data = new FormData();
+ data.top = new FormAttachment(5, 0);
+ data.left = new FormAttachment(10, 0);
+ data.width = 200;
+ data.height = 50;
+ button.setLayoutData(data);
+
+ button.addClickListener(new TizenButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(Event event) {
+ System.out.println("button test");
+ }
+ });
+
+ TizenButton imgButton = new TizenButton(shell, ImageResources.ABOUT,
+ ImageResources.ABOUT_PUSH, ImageResources.ABOUT_HOVER,
+ ImageResources.ABOUT_DISABLE);
+ imgButton.setText("test2");
+ data = new FormData();
+ data.top = new FormAttachment(button, 10);
+ data.left = new FormAttachment(10, 0);
+ data.width = 200;
+ data.height = 50;
+ imgButton.setLayoutData(data);
+
+ TizenToggleButton toggle = new TizenToggleButton(shell, SWT.NONE);
+ toggle.setText("toggle");
+ data = new FormData();
+ data.top = new FormAttachment(imgButton, 10);
+ data.left = new FormAttachment(10, 0);
+ data.width = 200;
+ data.height = 50;
+ toggle.setLayoutData(data);
+
+ TizenToggleButton imgToggle = new TizenToggleButton(shell,
+ ImageResources.VIEW_SOURCE, ImageResources.VIEW_SOURCE_PUSH,
+ ImageResources.VIEW_SOURCE_HOVER,
+ ImageResources.VIEW_SOURCE_DISABLE,
+ ImageResources.VIEW_SOURCE_TOGGLE);
+ imgToggle.setText("toggle");
+ data = new FormData();
+ data.top = new FormAttachment(toggle, 10);
+ data.left = new FormAttachment(10, 0);
+ data.width = 200;
+ data.height = 50;
+ imgToggle.setLayoutData(data);
+
+ TizenCombo combo = new TizenCombo(shell, SWT.NONE);
+ for (int i = 0; i < 29; i++) {
+ combo.add("test " + i);
+ }
+ data = new FormData();
+ data.top = new FormAttachment(imgToggle, 10);
+ data.left = new FormAttachment(10, 0);
+ data.width = 200;
+ data.height = 50;
+ combo.setLayoutData(data);
+
+ CircularGraph circle = new CircularGraph(shell, SWT.NONE,
+ CircularGraph.TYPE_PERCENT);
+ data = new FormData();
+ data.top = new FormAttachment(combo, 10);
+ data.left = new FormAttachment(10, 0);
+ data.width = 200;
+ data.height = 100;
+ circle.setLayoutData(data);
+ circle.setMax(100);
+ circle.update(50);
+ circle.setTextColor(ColorResources.BLACK);
+ circle.setText("circlular graph test");
+
+ TizenComboSelectionListener comboSelectionListener = new TizenComboSelectionListener() {
+ @Override
+ public void selectionEvent(TizenCombo combo) {
+ System.out.println("combo selected :" + combo.getText());
+ }
+ };
+
+ combo.addSelectionListener(comboSelectionListener);
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
<classpathentry exported="true" kind="lib" path="lib/jfreechart-1.0.14-experimental.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jfreechart-1.0.14-swt.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jfreechart-1.0.14.jar"/>
- <classpathentry kind="lib" path="lib/org.tizen.widget.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime
+ org.eclipse.core.runtime,
+ org.tizen.dynamicanalyzer.widgets;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Activator: org.tizen.dynamicanalyzer.AnalyzerPlugin
Bundle-ActivationPolicy: lazy
lib/jcommon-1.0.17.jar,
lib/jfreechart-1.0.14-experimental.jar,
lib/jfreechart-1.0.14-swt.jar,
- lib/jfreechart-1.0.14.jar,
- lib/org.tizen.widget.jar
+ lib/jfreechart-1.0.14.jar
Export-Package: org.tizen.dynamicanalyzer.ui.views
import org.tizen.dynamicanalyzer.ui.widgets.combo.TitleComboPopupRenderer;
import org.tizen.dynamicanalyzer.ui.widgets.combo.TitleComboRenderer;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-import org.tizen.widgets.button.TizenButton;
-import org.tizen.widgets.button.TizenButtonClickEventListener;
-import org.tizen.widgets.combo.TizenCombo;
-import org.tizen.widgets.combo.TizenComboSelectionListener;
+import org.tizen.dynamicanalyzer.widgets.button.TizenButton;
+import org.tizen.dynamicanalyzer.widgets.button.TizenButtonClickEventListener;
+import org.tizen.dynamicanalyzer.widgets.combo.TizenCombo;
+import org.tizen.dynamicanalyzer.widgets.combo.TizenComboSelectionListener;
public class CoolbarArea {
import org.eclipse.swt.widgets.Canvas;
import org.tizen.dynamicanalyzer.ColorResources;
import org.tizen.dynamicanalyzer.FontResources;
-import org.tizen.widgets.combo.TizenComboPopupRenderer;
+import org.tizen.dynamicanalyzer.widgets.combo.TizenComboPopupRenderer;
public class TitleComboPopupRenderer extends TizenComboPopupRenderer {
import org.eclipse.swt.widgets.Canvas;
import org.tizen.dynamicanalyzer.ColorResources;
import org.tizen.dynamicanalyzer.FontResources;
-import org.tizen.widgets.combo.TizenComboRenderer;
+import org.tizen.dynamicanalyzer.widgets.combo.TizenComboRenderer;
public class TitleComboRenderer extends TizenComboRenderer {