Timeline: Remove Magic number and Hard coding 84/21684/1
authorjungwook.ryu <jungwook.ryu@samsung.com>
Mon, 26 May 2014 11:31:30 +0000 (20:31 +0900)
committerjungwook.ryu <jungwook.ryu@samsung.com>
Mon, 26 May 2014 11:36:31 +0000 (20:36 +0900)
Translate Magic number in Timeline DB to ENUM
Handling Get CPU Core count

Change-Id: Iacae939ea74fd70c8a3eca0f17c0ed8c70c9b4ac
Signed-off-by: jungwook.ryu <jungwook.ryu@samsung.com>
org.tizen.dynamicanalyzer.appearance/src/org/tizen/dynamicanalyzer/resources/ColorResources.java
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chart/DAChartRenderer.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/CPUDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/CustomDataDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/EnergyDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/ProcessLoadDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/ScreenShotDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/SystemDataDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/UIEventDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/CPUCoreChart.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/CPUFrequencyChart.java

index f930fda..d8833a2 100755 (executable)
@@ -365,7 +365,6 @@ public class ColorResources {
        public static Color SERIES_COLOR_CPU_SYSTEM = getColor("seriesColorCPUSystem"); //$NON-NLS-1$\r
        public static Color SERIES_COLOR_CPU_APP = getColor("seriesColorCPUApp"); //$NON-NLS-1$\r
 \r
-       public final static int MAX_SERIES_COLOR_COUNT = 4;\r
        public static Color SERIES_COLOR_CPUCORE_CORE0 = getColor("seriesColorCPUCoreCore0"); //$NON-NLS-1$\r
        public static Color SERIES_COLOR_CPUCORE_CORE1 = getColor("seriesColorCPUCoreCore1"); //$NON-NLS-1$\r
        public static Color SERIES_COLOR_CPUCORE_CORE2 = getColor("seriesColorCPUCoreCore2"); //$NON-NLS-1$\r
index b53fc66..b91a53d 100644 (file)
@@ -1027,6 +1027,11 @@ public class DAChartRenderer {
                gc.setAlpha(255);
        }
        
+       /*
+        * This method is one of Chart renderer. Real chart using this method is File Analysis chart.
+        * This renderer draws Rectangle and bar in multi line and need specific seriesItem type.
+        * Type is possible SERIES_AREA_START, SERIES_AREA_END, SERIES_AREA_BAR.
+        */
        private void drawStateAreaSeries(GC gc, DAChartSeries series, int seriesIndex, 
                        int seriesSize) {
                List<DAChartSeriesItem> seriesItems = series.getSeriesItemList();
index e3a26dd..c3430b6 100644 (file)
@@ -70,10 +70,10 @@ public class CPUDBTable extends DBTable {
                        isPrepared = false;
                } else {
                        try {
-                               prep.setLong(1, (Long) (rowData.get(0)));
-                               prep.setInt(2, (Integer) (rowData.get(1)));
-                               prep.setFloat(3, (Float) (rowData.get(2)));
-                               prep.setFloat(4, (Float) (rowData.get(3)));     
+                               prep.setLong(1, (Long) (rowData.get(COLUMN.TIME.ordinal())));
+                               prep.setInt(2, (Integer) (rowData.get(COLUMN.CORE_NUM.ordinal())));
+                               prep.setFloat(3, (Float) (rowData.get(COLUMN.CPU_LOAD.ordinal())));
+                               prep.setFloat(4, (Float) (rowData.get(COLUMN.CPU_FREQUENCY.ordinal())));        
                        } catch (SQLException e) {
                                e.printStackTrace();
                                isPrepared = false;
index a137060..6e067f0 100644 (file)
@@ -67,9 +67,9 @@ public class CustomDataDBTable extends DBTable {
                        isPrepared = false;
                } else {
                        try {
-                               prep.setLong(1, (Long) (rowData.get(0)));
-                               prep.setInt(2, (Integer) (rowData.get(1)));
-                               prep.setFloat(3, (Float) (rowData.get(2)));
+                               prep.setLong(1, (Long) (rowData.get(COLUMN.TIME.ordinal())));
+                               prep.setInt(2, (Integer) (rowData.get(COLUMN.CHART_HANDLE.ordinal())));
+                               prep.setFloat(3, (Float) (rowData.get(COLUMN.CHART_VALUE.ordinal())));
                        } catch (SQLException e) {
                                e.printStackTrace();
                                isPrepared = false;
index edbec16..6093819 100644 (file)
@@ -70,10 +70,10 @@ public class EnergyDBTable extends DBTable {
                        isPrepared = false;
                } else {
                        try {
-                               prep.setLong(1, (Long) (rowData.get(0)));
-                               prep.setInt(2, (Integer) (rowData.get(1)));
-                               prep.setInt(3, (Integer) (rowData.get(2)));
-                               prep.setInt(4, (Integer) (rowData.get(3)));
+                               prep.setLong(1, (Long) (rowData.get(COLUMN.TIME.ordinal())));
+                               prep.setInt(2, (Integer) (rowData.get(COLUMN.DEVICE_NUM.ordinal())));
+                               prep.setInt(3, (Integer) (rowData.get(COLUMN.ENERGY_USAGE_DEVICE.ordinal())));
+                               prep.setInt(4, (Integer) (rowData.get(COLUMN.ENERGY_USAGE_APP.ordinal())));
                        } catch (SQLException e) {
                                e.printStackTrace();
                                isPrepared = false;
index 5c03f86..313aa7b 100644 (file)
@@ -67,9 +67,9 @@ public class ProcessLoadDBTable extends DBTable {
                        isPrepared = false;
                } else {
                        try {
-                               prep.setLong(1, (Long) (rowData.get(0)));
-                               prep.setInt(2, (Integer) (rowData.get(1)));
-                               prep.setFloat(3, (Float) (rowData.get(2)));
+                               prep.setLong(1, (Long) (rowData.get(COLUMN.TIME.ordinal())));
+                               prep.setInt(2, (Integer) (rowData.get(COLUMN.PID.ordinal())));
+                               prep.setFloat(3, (Float) (rowData.get(COLUMN.CPU_LOAD.ordinal())));
                        } catch (SQLException e) {
                                e.printStackTrace();
                                isPrepared = false;
index cdf115b..debcf6a 100644 (file)
@@ -69,9 +69,9 @@ public class ScreenShotDBTable extends DBTable {
                        isPrepared = false;
                } else {
                        try {
-                               prep.setLong(1, (Long) (rowData.get(0)));
-                               prep.setString(2, (String) (rowData.get(1)));
-                               prep.setInt(3, (Integer) (rowData.get(2)));
+                               prep.setLong(1, (Long) (rowData.get(COLUMN.TIME.ordinal())));
+                               prep.setString(2, (String) (rowData.get(COLUMN.IMAGE_FILE_PATH.ordinal())));
+                               prep.setInt(3, (Integer) (rowData.get(COLUMN.IMAGE_ORIENTATION.ordinal())));
                        } catch (SQLException e) {
                                e.printStackTrace();
                                isPrepared = false;
index 55aa0d4..ca44b4a 100644 (file)
@@ -163,39 +163,39 @@ public class SystemDataDBTable extends DBTable {
                        isPrepared = false;
                } else {
                        try {
-                               prep.setLong(1, (Long) (rowData.get(0)));
-                               prep.setFloat(2, (Float) (rowData.get(1)));
-                               prep.setFloat(3, (Float) (rowData.get(2)));
-                               prep.setInt(4, (Integer) (rowData.get(3)));     
-                               prep.setLong(5, (Long) (rowData.get(4)));
-                               prep.setLong(6, (Long) (rowData.get(5)));
-                               prep.setInt(7, (Integer) (rowData.get(6)));
-                               prep.setInt(8, (Integer) (rowData.get(7)));
-                               prep.setInt(9, (Integer) (rowData.get(8)));
-                               prep.setInt(10, (Integer) (rowData.get(9)));
-                               prep.setLong(11, (Long) (rowData.get(10)));
-                               prep.setLong(12, (Long) (rowData.get(11)));
-                               prep.setInt(13, (Integer) (rowData.get(12)));
-                               prep.setInt(14, (Integer) (rowData.get(13)));
-                               prep.setInt(15, (Integer) (rowData.get(14)));
-                               prep.setInt(16, (Integer) (rowData.get(15)));
-                               prep.setInt(17, (Integer) (rowData.get(16)));
-                               prep.setInt(18, (Integer) (rowData.get(17)));
-                               prep.setInt(19, (Integer) (rowData.get(18)));
-                               prep.setInt(20, (Integer) (rowData.get(19)));
-                               prep.setInt(21, (Integer) (rowData.get(20)));
-                               prep.setInt(22, (Integer) (rowData.get(21)));
-                               prep.setInt(23, (Integer) (rowData.get(22)));
-                               prep.setInt(24, (Integer) (rowData.get(23)));
-                               prep.setInt(25, (Integer) (rowData.get(24)));
-                               prep.setInt(26, (Integer) (rowData.get(25)));
-                               prep.setInt(27, (Integer) (rowData.get(26)));
-                               prep.setInt(28, (Integer) (rowData.get(27)));
-                               prep.setInt(29, (Integer) (rowData.get(28)));
-                               prep.setInt(30, (Integer) (rowData.get(29)));
-                               prep.setInt(31, (Integer) (rowData.get(30)));
-                               prep.setInt(32, (Integer) (rowData.get(31)));
-                               prep.setInt(33, (Integer) (rowData.get(32)));
+                               prep.setLong(1, (Long) (rowData.get(COLUMN.TIME.ordinal())));
+                               prep.setFloat(2, (Float) (rowData.get(COLUMN.CPU_LOAD_APP.ordinal())));
+                               prep.setFloat(3, (Float) (rowData.get(COLUMN.CPU_LOAD_TOTAL.ordinal())));
+                               prep.setInt(4, (Integer) (rowData.get(COLUMN.PROCESS_COUNT.ordinal())));        
+                               prep.setLong(5, (Long) (rowData.get(COLUMN.HEAP_ALLOCATION_TOTAL.ordinal())));
+                               prep.setLong(6, (Long) (rowData.get(COLUMN.HEAP_ALLOCATION_APP.ordinal())));
+                               prep.setInt(7, (Integer) (rowData.get(COLUMN.MEMORY_VIRTUAL.ordinal())));
+                               prep.setInt(8, (Integer) (rowData.get(COLUMN.MEMORY_RESIDENT.ordinal())));
+                               prep.setInt(9, (Integer) (rowData.get(COLUMN.MEMORY_SHARED.ordinal())));
+                               prep.setInt(10, (Integer) (rowData.get(COLUMN.MEMORY_PSS.ordinal())));
+                               prep.setLong(11, (Long) (rowData.get(COLUMN.MEMORY_TOTAL_SYSTEM.ordinal())));
+                               prep.setLong(12, (Long) (rowData.get(COLUMN.MEMORY_USAGE_SYSTEM.ordinal())));
+                               prep.setInt(13, (Integer) (rowData.get(COLUMN.NETWORK_SIZE_SEND.ordinal())));
+                               prep.setInt(14, (Integer) (rowData.get(COLUMN.NETWORK_SIZE_RECEIVE.ordinal())));
+                               prep.setInt(15, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_WIFI.ordinal())));
+                               prep.setInt(16, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_BLUETOOTH.ordinal())));
+                               prep.setInt(17, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_GPS.ordinal())));
+                               prep.setInt(18, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_BRIGHTNESS.ordinal())));
+                               prep.setInt(19, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_DNET.ordinal())));
+                               prep.setInt(20, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_CAMERA.ordinal())));
+                               prep.setInt(21, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_SOUND.ordinal())));
+                               prep.setInt(22, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_AUDIO.ordinal())));
+                               prep.setInt(23, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_VIBRATION.ordinal())));
+                               prep.setInt(24, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_VOLTAGE.ordinal())));
+                               prep.setInt(25, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_RSSI.ordinal())));
+                               prep.setInt(26, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_VIDEO.ordinal())));
+                               prep.setInt(27, (Integer) (rowData.get(COLUMN.DEVICE_STATUS_CALL.ordinal())));
+                               prep.setInt(28, (Integer) (rowData.get(COLUMN.DISK_TOTAL_USAGE.ordinal())));
+                               prep.setInt(29, (Integer) (rowData.get(COLUMN.DISK_IO_READ_SIZE.ordinal())));
+                               prep.setInt(30, (Integer) (rowData.get(COLUMN.DISK_IO_READ_SECTOR.ordinal())));
+                               prep.setInt(31, (Integer) (rowData.get(COLUMN.DISK_IO_WRITE_SIZE.ordinal())));
+                               prep.setInt(32, (Integer) (rowData.get(COLUMN.DISK_IO_WRITE_SECTOR.ordinal())));
+                               prep.setInt(33, (Integer) (rowData.get(COLUMN.ENERGY_USAGE.ordinal())));
                        } catch (SQLException e) {
                                e.printStackTrace();
                                isPrepared = false;
index 6fe846c..5e7ce3c 100644 (file)
@@ -81,13 +81,13 @@ public class UIEventDBTable extends DBTable {
                        isPrepared = false;
                } else {
                        try {
-                               prep.setLong(1, (Long) (rowData.get(0)));
-                               prep.setInt(2, (Integer) (rowData.get(1)));
-                               prep.setInt(3, (Integer) (rowData.get(2)));
-                               prep.setInt(4, (Integer) (rowData.get(3)));
-                               prep.setInt(5, (Integer) (rowData.get(4)));
-                               prep.setString(6, (String) (rowData.get(5)));
-                               prep.setInt(7, (Integer) (rowData.get(6)));
+                               prep.setLong(1, (Long) (rowData.get(COLUMN.TIME.ordinal())));
+                               prep.setInt(2, (Integer) (rowData.get(COLUMN.EVENT_TYPE.ordinal())));
+                               prep.setInt(3, (Integer) (rowData.get(COLUMN.DETAIL_TYPE.ordinal())));
+                               prep.setInt(4, (Integer) (rowData.get(COLUMN.POINT_X.ordinal())));
+                               prep.setInt(5, (Integer) (rowData.get(COLUMN.POINT_Y.ordinal())));
+                               prep.setString(6, (String) (rowData.get(COLUMN.INFO_INTEGER.ordinal())));
+                               prep.setInt(7, (Integer) (rowData.get(COLUMN.INFO_INTEGER.ordinal())));
                        } catch (SQLException e) {
                                e.printStackTrace();
                                isPrepared = false;
index 347d687..175b615 100644 (file)
@@ -95,7 +95,7 @@ public class CPUCoreChart extends TimelineChart {
                                DAChartSeries chartSeries = new DAChartSeries(
                                                TimelineChartLabels.CPU_CORE_CHART_SERIES_NAME_CORE + i,
                                                DAChartSeries.SERIES_STYLE_LINE,
-                                               coreChartSeriesColors[i % ColorResources.MAX_SERIES_COLOR_COUNT]);
+                                               coreChartSeriesColors[i % coreSize]);
                                chart.addSeries(chartSeries);
                                coreChartSeriesList.add(chartSeries);
                        }
index 9a8b124..316748b 100644 (file)
@@ -90,7 +90,7 @@ public class CPUFrequencyChart extends TimelineChart {
                 DAChartSeries chartSeries =
                         new DAChartSeries(TimelineChartLabels.CPU_CORE_CHART_SERIES_NAME_CORE + i,
                                           DAChartSeries.SERIES_STYLE_LINE,
-                                          coreChartSeriesColors[i % ColorResources.MAX_SERIES_COLOR_COUNT]);
+                                          coreChartSeriesColors[i % coreSize]);
                 chart.addSeries(chartSeries);
                 coreFrequencyChartSeriesList.add(chartSeries);
             }