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 FourBarGraph extends Composite {
+ public static int TYPE_BYTE = 1;
+ public static int TYPE_PERCENT = 0;
+
+ private String measure = Formatter.toByteFormatMeasure(0);
+ private String labelText = "";
private final int INNER_MARGIN = 3;
private final int LABEL_MARGIN = 15;
private int graphCount = 4;
+ private int graphType = TYPE_PERCENT;
private List<SingleBar> graphs;
private Label label;
private Font labelFont;
private FourBarGraph me;
private Color bgColor = ColorResources.BLACK;
- public FourBarGraph(Composite parent, int style) {
+ public FourBarGraph(Composite parent, int style, int type) {
super(parent, style);
+ graphType = type;
me = this;
graphs = new ArrayList<SingleBar>();
labelFont = new Font(getDisplay(), new FontData[] { new FontData(
- "Arial", 10, SWT.NORMAL) });
+ "Arial", 8, SWT.NORMAL) });
this.setLayout(new FormLayout());
this.setBackground(bgColor);
this.addControlListener(controlListener);
for (int i = 0; i < graphCount; i++) {
- SingleBar bar = new SingleBar(me, SWT.NONE);
+ SingleBar bar = new SingleBar(me, SWT.NONE, graphType);
FormData data = new FormData();
data.top = new FormAttachment(0, 0);
if (i == 0) {
public void setCurrentValue(List<Long> currentValues) {
for (int i = 0; i < currentValues.size() && i < graphCount; i++) {
+ if (graphType == TYPE_BYTE) {
+ long value = currentValues.get(i);
+ measure = Formatter.toByteFormatMeasure(value);
+ System.out.println(value + " " + measure);
+ setText(labelText);
+ }
graphs.get(i).setCurrentSize(currentValues.get(i));
graphs.get(i).redraw();
}
}
public void setText(String text) {
+ labelText = text;
label.setForeground(fontColor);
+ if (graphType == TYPE_BYTE) {
+ text += " (" + measure + ")";
+ } else {
+ text += " (%)";
+ }
+
label.setText(text);
}
graphs.add(bar);
}
- // label = new Label(me, SWT.TRANSPARENT);
FormData data = new FormData();
data.top = new FormAttachment(graphs.get(0), 0);
data.height = 15;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
+import org.tizen.dynamicanalyzer.widgets.helper.Formatter;
public class SingleBar extends Canvas {
+ public static int TYPE_PERCENT = 0;
+ public static int TYPE_BYTE = 1;
+
private final int TOP_MARGIN = 5;
private final int BOTTOM_MARGIN = 4;
private final int BOTTOM_FULL_MARGIN = 15;
+ private int graphType = TYPE_PERCENT;
+
private long maxSize;
private long currentSize;
private Color graphColor;
SWT.NORMAL) });
}
+ public SingleBar(Composite parent, int style, int type) {
+ this(parent, style);
+ graphType = type;
+ }
+
private PaintListener barPaintListener = new PaintListener() {
@Override
int textY = endY + BOTTOM_MARGIN;
e.gc.setForeground(fontColor);
e.gc.setFont(font);
- e.gc.drawText(Long.toString(currentSize), rect.x + 1, textY);
+ String value = null;
+ if (graphType == TYPE_BYTE) {
+ value = Formatter.toByteFormatValue(currentSize);
+ System.out.println(value);
+ } else {
+ value = Long.toString(currentSize);
+ }
+ e.gc.drawText(value, rect.x + 1, textY);
}
};
return "Byte"; //$NON-NLS-1$
}
}
+
+ // only return value
+ public static String toByteFormatValue(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;
+ }
+
+ // only return measure
+ public static String toByteFormatMeasure(long input) {
+ long quotient = input;
+ int count = 0;
+ String value = null;
+
+ while (true) {
+ if (quotient >= 1024) {
+ quotient = quotient / 1024;
+ count++;
+ continue;
+ } else {
+ value = getMeasure(count); //$NON-NLS-1$
+ break;
+ }
+ }
+ return value;
+ }
}
bar.setMaxSize(100);
bar.setCurrentSize(45);
- FourBarGraph fbar = new FourBarGraph(shell, SWT.NONE);
+ FourBarGraph fbar = new FourBarGraph(shell, SWT.NONE, FourBarGraph.TYPE_PERCENT);
data = new FormData();
data.top = new FormAttachment(bar, 10);
data.left = new FormAttachment(10, 0);
public static final String PERCENT = "%"; //$NON-NLS-1$\r
\r
/* paths */\r
- public static final String DYNAMICANALYZER_FOLDER_NAME = "DynamicAnalyzer"; //$NON-NLS-1$\r
+ public static final String DYNAMICANALYZER_FOLDER_NAME = "dynamic_analyzer"; //$NON-NLS-1$\r
public static final String DYNAMICANALYZER_DIR_PATH = AnalyzerManager\r
.getDefaultDynamicAnalyzerRoot();\r
public static final String SAVE_FOLDER_NAME = "save"; //$NON-NLS-1$\r
/** device and application combo specific colors start **/
setColor("device_application_enable_font", new RGB(255, 255, 255)); //$NON-NLS-1$
-
setColor("device_application_disable_font", new RGB(128, 128, 128)); //$NON-NLS-1$
-
setColor("device_application_popup_outer_1", new RGB(31, 31, 31)); //$NON-NLS-1$
-
setColor("device_application_popup_outer_2", new RGB(31, 137, 163)); //$NON-NLS-1$
-
setColor("device_application_item_normal_top", new RGB(76, 76, 77)); //$NON-NLS-1$
-
setColor("device_application_item_normal_inner", new RGB(66, 66, 67)); //$NON-NLS-1$
-
setColor("device_application_item_normal_bottom", new RGB(56, 56, 60)); //$NON-NLS-1$
-
setColor("device_application_item_select_top", new RGB(76, 76, 77)); //$NON-NLS-1$
-
setColor("device_application_item_select_inner", new RGB(0, 151, 201)); //$NON-NLS-1$
-
setColor("device_application_item_select_bottom", new RGB(56, 56, 60)); //$NON-NLS-1$
/** device and application combo specific colors end **/
setColor("device_application_button_hover_end", new RGB(0, 151, 201)); //$NON-NLS-1$
setColor("device_application_button_disable_start", new RGB(51, 52, 53)); //$NON-NLS-1$
setColor("device_application_button_disable_end", new RGB(0, 0, 0)); //$NON-NLS-1$
-
setColor("device_application_button_outline", new RGB(0, 0, 0));
+
/** normal view layout colors start **/
-
setColor("normal_view_layout_outer", new RGB(160, 160, 160)); //$NON-NLS-1$
-
setColor("normal_view_layout_middle", new RGB(74, 74, 74)); //$NON-NLS-1$
-
setColor("normal_view_layout_inner", new RGB(66, 66, 68)); //$NON-NLS-1$
-
/** normal view layout colors end **/
/** current view colors start **/
setColor("current_view_cpu_text", new RGB(2, 171, 208)); //$NON-NLS-1$
setColor("current_view_process_text", new RGB(114, 203, 8)); //$NON-NLS-1$
setColor("current_view_graph_bg", new RGB(79, 79, 81)); //$NON-NLS-1$
-
setColor("current_view_graph_outline", new RGB(43, 44, 45)); //$NON-NLS-1$
-
setColor("current_view_snapshot_outline", new RGB(49, 104, 127)); //$NON-NLS-1$
/** current view colors end **/
setColor("tab_hover_color", new RGB(63, 72, 78));
setColor("tab_push_color", new RGB(36, 41, 45));
setColor("tab_outline_color", new RGB(104, 104, 104));
-
+
setColor("tab_normal_font_color", new RGB(140, 140, 140));
setColor("tab_other_font_color", new RGB(255, 255, 255));
setColor("defaultBackground", new RGB(255, 255, 255)); //$NON-NLS-1$
setColor("defaultRed", new RGB(173, 13, 1)); //$NON-NLS-1$
- // circular graph
+ // bar graph
setColor("cpu_bar_graph_color", new RGB(2, 171, 208)); //$NON-NLS-1$
setColor("cpu_bar_graph_gray_color", new RGB(79, 79, 81));
setColor("cpu_bar_graph_bg_color", new RGB(43, 44, 45));
-
+
setColor("process_bar_graph_color", new RGB(114, 203, 8)); //$NON-NLS-1$
setColor("process_bar_graph_gray_color", new RGB(79, 79, 81)); //$NON-NLS-1$
setColor("process_bar_graph_bg_color", new RGB(43, 44, 45)); //$NON-NLS-1$
// shell window background color
setColor("window_bg_color", new RGB(255, 255, 255)); //$NON-NLS-1$
setColor("coolbar_bg_color", new RGB(255, 255, 255)); //$NON-NLS-1$
+
/** title bar colors **/
setColor("titlebar_text_color", new RGB(64, 208, 255)); //$NON-NLS-1$
/** device and application combo specific colors start **/
setColor("device_application_enable_font", new RGB(0, 0, 0)); //$NON-NLS-1$
-
setColor("device_application_disable_font", new RGB(160, 160, 160)); //$NON-NLS-1$
-
setColor("device_application_popup_outer_1", new RGB(120, 120, 120)); //$NON-NLS-1$
-
setColor("device_application_popup_outer_2", new RGB(50, 185, 231)); //$NON-NLS-1$
-
setColor("device_application_item_normal_top", new RGB(255, 255, 255)); //$NON-NLS-1$
-
setColor("device_application_item_normal_inner", new RGB(230, 230, 230)); //$NON-NLS-1$
-
- setColor(
- "device_application_item_normal_bottom", new RGB(189, 189, 189)); //$NON-NLS-1$
-
+ setColor("device_application_item_normal_bottom", new RGB(189, 189, 189)); //$NON-NLS-1$
setColor("device_application_item_select_top", new RGB(255, 255, 255)); //$NON-NLS-1$
-
setColor("device_application_item_select_inner", new RGB(50, 185, 231)); //$NON-NLS-1$
-
- setColor(
- "device_application_item_select_bottom", new RGB(189, 189, 189)); //$NON-NLS-1$
+ setColor("device_application_item_select_bottom", new RGB(189, 189, 189)); //$NON-NLS-1$
/** device and application combo specific colors end **/
/*** combo button gradation ***/
- setColor(
- "device_application_button_normal_start", new RGB(221, 221, 221)); //$NON-NLS-1$
+ setColor("device_application_button_normal_start", new RGB(221, 221, 221)); //$NON-NLS-1$
setColor("device_application_button_normal_end", new RGB(157, 157, 157)); //$NON-NLS-1$
setColor("device_application_button_push_start", new RGB(24, 147, 189)); //$NON-NLS-1$
setColor("device_application_button_push_end", new RGB(24, 147, 189)); //$NON-NLS-1$
setColor("device_application_button_hover_end", new RGB(50, 185, 231)); //$NON-NLS-1$
setColor("device_application_button_disable_start", new RGB(78, 79, 81)); //$NON-NLS-1$
setColor("device_application_button_disable_end", new RGB(78, 79, 81)); //$NON-NLS-1$
-
setColor("device_application_button_outline", new RGB(31, 31, 31));
/** normal view layout colors start **/
-
setColor("normal_view_layout_outer", new RGB(160, 160, 160)); //$NON-NLS-1$
-
setColor("normal_view_layout_middle", new RGB(74, 74, 74)); //$NON-NLS-1$
-
setColor("normal_view_layout_inner", new RGB(66, 66, 68)); //$NON-NLS-1$
-
/** normal view layout colors end **/
/** current view colors start **/
setColor("current_view_cpu_text", new RGB(2, 171, 208)); //$NON-NLS-1$
setColor("current_view_process_text", new RGB(114, 203, 8)); //$NON-NLS-1$
setColor("current_view_graph_bg", new RGB(79, 79, 81)); //$NON-NLS-1$
-
setColor("current_view_graph_outline", new RGB(43, 44, 45)); //$NON-NLS-1$
-
setColor("current_view_snapshot_outline", new RGB(49, 104, 127)); //$NON-NLS-1$
/** current view colors end **/
setColor("defaultBackground", new RGB(255, 255, 255)); //$NON-NLS-1$
setColor("defaultRed", new RGB(173, 13, 1)); //$NON-NLS-1$
- // circular graph
- setColor("cpu_circular_graph_color", new RGB(2, 171, 208)); //$NON-NLS-1$
- setColor("process_circular_graph_color", new RGB(114, 203, 8)); //$NON-NLS-1$
+ // bar graph
+ setColor("cpu_bar_graph_color", new RGB(2, 171, 208)); //$NON-NLS-1$
+ setColor("cpu_bar_graph_gray_color", new RGB(79, 79, 81));
+ setColor("cpu_bar_graph_bg_color", new RGB(43, 44, 45));
+
+ setColor("process_bar_graph_color", new RGB(114, 203, 8)); //$NON-NLS-1$
+ setColor("process_bar_graph_gray_color", new RGB(79, 79, 81)); //$NON-NLS-1$
+ setColor("process_bar_graph_bg_color", new RGB(43, 44, 45)); //$NON-NLS-1$
setColor("profiling_graph_color_start", new RGB(145, 190, 3)); //$NON-NLS-1$
setColor("profiling_graph_color_end", new RGB(114, 149, 1)); //$NON-NLS-1$
return colorRegistry.get(colorName);
}
- // @Override
- // public String getThemePath() {
- // // TODO Auto-generated method stub
- // // return THEME_PATH;
- // return "theme" + File.separator + name + File.separator;
- // }
- //
- // @Override
- // public String getImagePath() {
- // // TODO Auto-generated method stub
- // return IMAGE_PATH;
- // }
- //
- // @Override
- // public String getIconPath() {
- // // TODO Auto-generated method stub
- // return ICON_PATH;
- // }
-
}
// cpu graph
// cpuGrp = new CircularGraph(graphComp, SWT.NONE,
// CircularGraph.TYPE_PERCENT);
- cpuGrp = new FourBarGraph(graphComp, SWT.NONE);
+ cpuGrp = new FourBarGraph(graphComp, SWT.NONE, FourBarGraph.TYPE_PERCENT);
data = new FormData();
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(0, 0);
// process graph
// processGraph = new CircularGraph(graphComp, SWT.NONE,
// CircularGraph.TYPE_CUSTOM);
- processGraph = new FourBarGraph(graphComp, SWT.NONE);
+ processGraph = new FourBarGraph(graphComp, SWT.NONE, FourBarGraph.TYPE_BYTE);
data = new FormData();
- data.top = new FormAttachment(cpuGrp, 15);
+ data.top = new FormAttachment(cpuGrp, 5);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
// data.bottom = new FormAttachment(100, 0);
private void computeData() {
if (startTime % 1000000 != 0)
- startTime += 1000000;
- String query = "select * from system where time = (select max(time) from system where time < " //$NON-NLS-1$
+ startTime += 500000;
+ String query = "select * from system where time = (select max(time) from system where time <= " //$NON-NLS-1$
+ startTime + ");"; //$NON-NLS-1$
+ // FIXME : debug log
+ System.out.println(startTime);
List<String> input = SqlManager
.executeSelectQuery(query, AnalyzerManager
.getLogCenterById(LogCenterConstants.LOG_DEVICE));
}
}
- 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;
return ret;
}
+ // 1000 to 1,000
public static String toNumberFormat(long input) {
int reminder = 0;
long quotient = input;
}
return output;
}
-
- public static String toNumberFormat(double input){
- return toNumberFormat((long)input);
+
+ public static String toNumberFormat(double input) {
+ return toNumberFormat((long) input);
}
public static String toByteFormat(long input) {
}
return value;
}
+
public static String toByteFormat(double input) {
- return toByteFormat((long)input);
+ return toByteFormat((long) input);
}
-
+
public static String toHzFormat(long input) {
int reminder = 0;
long quotient = input;
}
return value;
}
+
public static String toHzFormat(double input) {
- return toHzFormat((long)input);
+ return toHzFormat((long) input);
}
-
- public static String toBpsFormat(long nByte, long startTime, long endTime){
+
+ 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)));
+ 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);
+
+ public static String toBpsFormat(double nByte, long startTime, long endTime) {
+ return toBpsFormat((long) nByte, startTime, endTime);
}
private static String getMeasure(int count) {
return "Byte"; //$NON-NLS-1$
}
}
-
+
private static String getHzMeasure(int count) {
if (count == 4) {
return "THz"; //$NON-NLS-1$
return "Hz"; //$NON-NLS-1$
}
}
+
+ // only return value
+ public static String toByteFormatValue(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;
+ }
+
+ // only return measure
+ public static String toByteFormatMeasure(long input) {
+ long quotient = input;
+ int count = 0;
+ String value = null;
+
+ while (true) {
+ if (quotient >= 1024) {
+ quotient = quotient / 1024;
+ count++;
+ continue;
+ } else {
+ value = getMeasure(count); //$NON-NLS-1$
+ break;
+ }
+ }
+ return value;
+ }
}