implemented bar charts and pie charts
authorVictor Kirhenshtein <victor@netxms.org>
Wed, 13 Jun 2012 13:10:58 +0000 (13:10 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Wed, 13 Jun 2012 13:10:58 +0000 (13:10 +0000)
13 files changed:
.gitattributes
android/src/console/.classpath
android/src/console/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
android/src/console/AndroidManifest.xml
android/src/console/libs/achartengine-1.0.0.jar [new file with mode: 0644]
android/src/console/res/menu/last_values_actions.xml
android/src/console/res/values/strings.xml
android/src/console/src/org/netxms/ui/android/main/activities/AbstractComparisonChart.java [new file with mode: 0644]
android/src/console/src/org/netxms/ui/android/main/activities/DrawBarChart.java [new file with mode: 0644]
android/src/console/src/org/netxms/ui/android/main/activities/DrawPieChart.java [new file with mode: 0644]
android/src/console/src/org/netxms/ui/android/main/activities/NodeInfo.java
android/src/console/src/org/netxms/ui/android/main/adapters/LastValuesAdapter.java
android/src/console/src/org/netxms/ui/android/main/views/CheckableLinearLayout.java

index 70e3b8f..52fdc98 100644 (file)
@@ -4,8 +4,10 @@ android/src/console/.externalToolBuilders/Generate[!!-~]build_number.xml[!!-~]fr
 android/src/console/.externalToolBuilders/build_number.xml -text
 android/src/console/.externalToolBuilders/generate_build_number.xml -text
 android/src/console/.externalToolBuilders/run.exe -text
+android/src/console/.settings/org.eclipse.jdt.core.prefs -text
 android/src/console/AndroidManifest.xml -text
 android/src/console/default.properties -text
+android/src/console/libs/achartengine-1.0.0.jar -text
 android/src/console/libs/simple-xml-2.6.4.jar -text
 android/src/console/lint.xml -text
 android/src/console/project.properties -text
@@ -118,10 +120,13 @@ android/src/console/src/com/jjoe64/graphview/GraphViewDemo.java -text
 android/src/console/src/com/jjoe64/graphview/LineGraphView.java -text
 android/src/console/src/com/jjoe64/graphview/compatible/RealScaleGestureDetector.java -text
 android/src/console/src/com/jjoe64/graphview/compatible/ScaleGestureDetector.java -text
+android/src/console/src/org/netxms/ui/android/main/activities/AbstractComparisonChart.java -text
 android/src/console/src/org/netxms/ui/android/main/activities/AlarmBrowser.java -text
 android/src/console/src/org/netxms/ui/android/main/activities/ConnectionPointBrowser.java -text
 android/src/console/src/org/netxms/ui/android/main/activities/ConsolePreferences.java -text
+android/src/console/src/org/netxms/ui/android/main/activities/DrawBarChart.java -text
 android/src/console/src/org/netxms/ui/android/main/activities/DrawGraph.java -text
+android/src/console/src/org/netxms/ui/android/main/activities/DrawPieChart.java -text
 android/src/console/src/org/netxms/ui/android/main/activities/GraphBrowser.java -text
 android/src/console/src/org/netxms/ui/android/main/activities/HomeScreen.java -text
 android/src/console/src/org/netxms/ui/android/main/activities/LastValues.java -text
index d012aa7..6085f7a 100644 (file)
@@ -8,5 +8,6 @@
        <classpathentry exported="true" kind="lib" path="libs/netxms-client-api-1.2.1.jar"/>
        <classpathentry exported="true" kind="lib" path="libs/netxms-client-1.2.1.jar"/>
        <classpathentry exported="true" kind="lib" path="libs/simple-xml-2.6.4.jar"/>
+       <classpathentry exported="true" kind="lib" path="libs/achartengine-1.0.0.jar"/>
        <classpathentry kind="output" path="bin/classes"/>
 </classpath>
diff --git a/android/src/console/.settings/org.eclipse.jdt.core.prefs b/android/src/console/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..54e493c
--- /dev/null
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate\r
+org.eclipse.jdt.core.compiler.debug.localVariable=generate\r
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.6\r
index e61fd96..b79de53 100644 (file)
         <activity android:label="@string/app_name" 
                   android:name=".main.activities.DrawGraph">
         </activity>        
+        <activity android:label="@string/app_name" 
+                  android:name=".main.activities.DrawBarChart">
+        </activity>        
+        <activity android:label="@string/app_name" 
+                  android:name=".main.activities.DrawPieChart">
+        </activity>        
        </application>
 </manifest>
diff --git a/android/src/console/libs/achartengine-1.0.0.jar b/android/src/console/libs/achartengine-1.0.0.jar
new file mode 100644 (file)
index 0000000..fe75dc3
Binary files /dev/null and b/android/src/console/libs/achartengine-1.0.0.jar differ
index 794d251..f75261d 100644 (file)
@@ -6,4 +6,6 @@
         <item android:id="@+id/graph_four_hours" android:visible="true" android:checkable="false" android:enabled="true" android:checked="false" android:title="@string/last_values_graph_four_hours"></item>
         <item android:id="@+id/graph_one_day" android:visible="true" android:checkable="false" android:enabled="true" android:checked="false" android:title="@string/last_values_graph_one_day"></item>
         <item android:id="@+id/graph_one_week" android:visible="true" android:checkable="false" android:enabled="true" android:checked="false" android:title="@string/last_values_graph_one_week"></item>
+        <item android:id="@+id/bar_chart" android:title="@string/last_values_bar_chart" android:enabled="true" android:visible="true" android:checkable="false" android:checked="false"></item>
+        <item android:id="@+id/pie_chart" android:enabled="true" android:visible="true" android:checkable="false" android:checked="false" android:title="@string/last_values_pie_chart"></item>
     </menu>
index 038e581..483a90e 100644 (file)
        <string name="ts_ok">OK</string>
        <string name="home">Home</string>
        <string name="line_chart">Line Chart</string>
+       <string name="last_values_pie_chart">Pie Chart</string>
+       <string name="last_values_bar_chart">Bar Chart</string>
 </resources>
diff --git a/android/src/console/src/org/netxms/ui/android/main/activities/AbstractComparisonChart.java b/android/src/console/src/org/netxms/ui/android/main/activities/AbstractComparisonChart.java
new file mode 100644 (file)
index 0000000..ea1b5c4
--- /dev/null
@@ -0,0 +1,184 @@
+package org.netxms.ui.android.main.activities;\r
+\r
+import java.util.ArrayList;\r
+import org.achartengine.GraphicalView;\r
+import org.netxms.client.datacollection.DciData;\r
+import org.netxms.client.datacollection.DciDataRow;\r
+import org.netxms.client.datacollection.GraphItem;\r
+import org.netxms.ui.android.R;\r
+import android.app.ProgressDialog;\r
+import android.content.ComponentName;\r
+import android.os.AsyncTask;\r
+import android.os.Bundle;\r
+import android.os.IBinder;\r
+import android.util.Log;\r
+import android.widget.LinearLayout;\r
+import android.widget.TextView;\r
+\r
+public abstract class AbstractComparisonChart extends AbstractClientActivity\r
+{\r
+       protected ArrayList<Integer> colorList = null;\r
+       protected GraphItem[] items = null;\r
+       protected double[] values = null;\r
+       protected String graphTitle = "";\r
+\r
+       private GraphicalView graphView = null;\r
+       private ProgressDialog dialog;\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.netxms.ui.android.main.activities.AbstractClientActivity#onCreateStep2(android.os.Bundle)\r
+        */\r
+       @Override\r
+       protected void onCreateStep2(Bundle savedInstanceState)\r
+       {\r
+               dialog = new ProgressDialog(this); \r
+               setContentView(R.layout.graphics);\r
+               int numItems = getIntent().getIntExtra("numItems", 0);\r
+               if (numItems > 0)\r
+               {\r
+                       items = new GraphItem[numItems];\r
+                       values = new double[numItems];\r
+                       ArrayList<Integer> nodeIdList = getIntent().getIntegerArrayListExtra("nodeIdList");\r
+                       ArrayList<Integer> dciIdList = getIntent().getIntegerArrayListExtra("dciIdList");\r
+                       ArrayList<String> nameList = getIntent().getStringArrayListExtra("nameList");\r
+                       colorList = getIntent().getIntegerArrayListExtra("colorList");\r
+                       for (int i = 0; i < numItems; i++)\r
+                       {\r
+                               items[i] = new GraphItem();\r
+                               items[i].setNodeId(nodeIdList.get(i));\r
+                               items[i].setDciId(dciIdList.get(i));\r
+                               items[i].setDescription(nameList.get(i));\r
+                       }\r
+                       graphTitle = getIntent().getStringExtra("graphTitle");\r
+               }\r
+               TextView title = (TextView)findViewById(R.id.ScreenTitlePrimary);\r
+               title.setText(R.string.graph_title);\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.netxms.ui.android.main.activities.AbstractClientActivity#onServiceConnected(android.content.ComponentName, android.os.IBinder)\r
+        */\r
+       @Override\r
+       public void onServiceConnected(ComponentName name, IBinder binder)\r
+       {\r
+               super.onServiceConnected(name, binder);\r
+               refreshGraph();\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.netxms.ui.android.main.activities.AbstractClientActivity#onServiceDisconnected(android.content.ComponentName)\r
+        */\r
+       @Override\r
+       public void onServiceDisconnected(ComponentName name)\r
+       {\r
+               super.onServiceDisconnected(name);\r
+       }\r
+\r
+       /**\r
+        * Refresh node graph\r
+        */\r
+       public void refreshGraph()\r
+       {\r
+               if (graphTitle != null)\r
+               {\r
+                       TextView title = (TextView)findViewById(R.id.ScreenTitlePrimary);\r
+                       title.setText(graphTitle);\r
+               }\r
+               new LoadDataTask().execute();\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see android.app.Activity#onDestroy()\r
+        */\r
+       @Override\r
+       protected void onDestroy()\r
+       {\r
+               service.registerNodeBrowser(null);\r
+               unbindService(this);\r
+               super.onDestroy();\r
+       }\r
+\r
+       /**\r
+        * Convert to Android color format (swap RGB and add alpha)\r
+        */\r
+       protected int toAndroidColor(int color)\r
+       {\r
+               return 0xFF000000 | ((color & 0x0000FF) << 16) | (color & 0x00FF00) | ((color & 0xFF0000) >> 16);       // Alpha | R | G | B\r
+       }\r
+       \r
+       /**\r
+        * @return\r
+        */\r
+       protected abstract GraphicalView buildGraphView();\r
+       \r
+       /**\r
+        * Internal task for loading DCI data\r
+        */\r
+       class LoadDataTask extends AsyncTask<Object, Void, DciData[]>\r
+       {\r
+               /* (non-Javadoc)\r
+                * @see android.os.AsyncTask#onPreExecute()\r
+                */\r
+               @Override\r
+               protected void onPreExecute()\r
+               {\r
+                       dialog.setMessage(getString(R.string.progress_gathering_data)); \r
+                       dialog.setIndeterminate(true); \r
+                       dialog.setCancelable(false);\r
+                       dialog.show();\r
+               }\r
+               \r
+               /* (non-Javadoc)\r
+                * @see android.os.AsyncTask#doInBackground(Params[])\r
+                */\r
+               @Override\r
+               protected DciData[] doInBackground(Object... params)\r
+               {\r
+                       DciData[] dciData = null;\r
+                       try\r
+                       {\r
+                               if (items.length > 0)\r
+                               {\r
+                                       dciData = new DciData[items.length];\r
+                                       for (int i = 0; i < dciData.length; i++)\r
+                                       {\r
+                                               dciData[i] = new DciData(0, 0);\r
+                                               dciData[i] = service.getSession().getCollectedData(items[i].getNodeId(), items[i].getDciId(), null, null, 1);\r
+                                       }\r
+                               }\r
+                       }\r
+                       catch(Exception e)\r
+                       {\r
+                               Log.d("nxclient/AbstractComparisonChart", "Exception while executing LoadDataTask.doInBackground", e);\r
+                               dciData = null;\r
+                       }\r
+                       return dciData;\r
+               }\r
+\r
+               /* (non-Javadoc)\r
+                * @see android.os.AsyncTask#onPostExecute(java.lang.Object)\r
+                */\r
+               @Override\r
+               protected void onPostExecute(DciData[] result)\r
+               {\r
+                       if (result != null)\r
+                       {\r
+                               for (int i = 0; (i < result.length) && (i < values.length); i++)\r
+                               {\r
+                                       DciDataRow value = result[i].getLastValue();\r
+                                       values[i] = (value != null) ? value.getValueAsDouble() : 0.0;\r
+                               }\r
+\r
+                               LinearLayout layout = (LinearLayout)findViewById(R.id.graphics);   \r
+                               if (layout != null)\r
+                               {\r
+                                       if (graphView != null)\r
+                                               layout.removeView(graphView);\r
+                                       graphView = buildGraphView();\r
+                                       layout.addView(graphView);\r
+                               }\r
+                       }\r
+                       dialog.cancel();\r
+               }\r
+       }\r
+}\r
diff --git a/android/src/console/src/org/netxms/ui/android/main/activities/DrawBarChart.java b/android/src/console/src/org/netxms/ui/android/main/activities/DrawBarChart.java
new file mode 100644 (file)
index 0000000..216ed39
--- /dev/null
@@ -0,0 +1,85 @@
+/**\r
+ * \r
+ */\r
+package org.netxms.ui.android.main.activities;\r
+\r
+import org.achartengine.ChartFactory;\r
+import org.achartengine.GraphicalView;\r
+import org.achartengine.chart.BarChart.Type;\r
+import org.achartengine.model.XYMultipleSeriesDataset;\r
+import org.achartengine.model.XYSeries;\r
+import org.achartengine.renderer.SimpleSeriesRenderer;\r
+import org.achartengine.renderer.XYMultipleSeriesRenderer;\r
+import android.graphics.Paint.Align;\r
+\r
+\r
+/**\r
+ * Draw pie chart activity\r
+ */\r
+public class DrawBarChart extends AbstractComparisonChart\r
+{\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.netxms.ui.android.main.activities.AbstractComparisonChart#buildGraphView()\r
+        */\r
+       @Override\r
+       protected GraphicalView buildGraphView()\r
+       {\r
+               return ChartFactory.getBarChartView(this, buildDataset(), buildRenderer(), Type.STACKED);\r
+       }\r
+       \r
+       /**\r
+        * @return\r
+        */\r
+       private XYMultipleSeriesDataset buildDataset()\r
+       {\r
+               XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();\r
+\r
+               for(int i = 0; i < items.length; i++)\r
+               {\r
+                       XYSeries series = new XYSeries(items[i].getDescription());\r
+                       for(int j = 0; j < items.length; j++)\r
+                       {\r
+                               series.add(j + 1, (i == j) ? values[i] : 0);\r
+                       }\r
+                       dataset.addSeries(series);\r
+               }\r
+               \r
+               return dataset;\r
+       }\r
+       \r
+       /**\r
+        * @return\r
+        */\r
+       private XYMultipleSeriesRenderer buildRenderer()\r
+       {\r
+               XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();\r
+               renderer.setAxisTitleTextSize(16);\r
+               renderer.setChartTitleTextSize(20);\r
+               renderer.setLabelsTextSize(15);\r
+               renderer.setLegendTextSize(15);\r
+               renderer.setFitLegend(true);\r
+               renderer.setBarSpacing(0.4f);\r
+               renderer.setShowGrid(true);\r
+               renderer.setPanEnabled(false);\r
+               renderer.setZoomEnabled(false);\r
+               \r
+               for(int color : colorList)\r
+               {\r
+                       SimpleSeriesRenderer r = new SimpleSeriesRenderer();\r
+                       r.setColor(color | 0xFF000000);\r
+                       renderer.addSeriesRenderer(r);\r
+                       r.setDisplayChartValues(false);\r
+               }\r
+\r
+               renderer.setXAxisMin(0.5);\r
+               renderer.setXAxisMax(items.length + 0.5);\r
+               renderer.setXLabels(1);\r
+               renderer.setYLabelsAlign(Align.RIGHT);\r
+               renderer.clearXTextLabels();\r
+               for(int i = 0; i < items.length; i++)\r
+                       renderer.addXTextLabel(i + 1, items[i].getDescription());\r
+               \r
+               return renderer;\r
+       }\r
+}\r
diff --git a/android/src/console/src/org/netxms/ui/android/main/activities/DrawPieChart.java b/android/src/console/src/org/netxms/ui/android/main/activities/DrawPieChart.java
new file mode 100644 (file)
index 0000000..cf1b582
--- /dev/null
@@ -0,0 +1,60 @@
+/**\r
+ * \r
+ */\r
+package org.netxms.ui.android.main.activities;\r
+\r
+import org.achartengine.ChartFactory;\r
+import org.achartengine.GraphicalView;\r
+import org.achartengine.model.CategorySeries;\r
+import org.achartengine.renderer.DefaultRenderer;\r
+import org.achartengine.renderer.SimpleSeriesRenderer;\r
+\r
+\r
+/**\r
+ * Draw pie chart activity\r
+ */\r
+public class DrawPieChart extends AbstractComparisonChart\r
+{\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.netxms.ui.android.main.activities.AbstractComparisonChart#buildGraphView()\r
+        */\r
+       @Override\r
+       protected GraphicalView buildGraphView()\r
+       {\r
+               return ChartFactory.getPieChartView(this, buildDataset(), buildRenderer());\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        */\r
+       private DefaultRenderer buildRenderer()\r
+       {\r
+               DefaultRenderer renderer = new DefaultRenderer();\r
+               renderer.setLabelsTextSize(15);\r
+               renderer.setLegendTextSize(15);\r
+               renderer.setMargins(new int[] { 20, 30, 15, 0 });\r
+               renderer.setPanEnabled(false);\r
+               renderer.setZoomEnabled(false);\r
+               for(int color : colorList)\r
+               {\r
+                       SimpleSeriesRenderer r = new SimpleSeriesRenderer();\r
+                       r.setColor(color | 0xFF000000);\r
+                       renderer.addSeriesRenderer(r);\r
+               }\r
+               return renderer;\r
+       }\r
+       \r
+       /**\r
+        * @return\r
+        */\r
+       private CategorySeries buildDataset()\r
+       {\r
+               CategorySeries series = new CategorySeries(graphTitle);\r
+               for(int i = 0; i < items.length; i++)\r
+               {\r
+                       series.add(items[i].getDescription(), values[i]);\r
+               }\r
+               return series;\r
+       }\r
+}\r
index 5821ffb..42b0c3b 100644 (file)
@@ -13,7 +13,6 @@ import android.app.TabActivity;
 import android.content.ComponentName;\r
 import android.content.Intent;\r
 import android.content.ServiceConnection;\r
-import android.graphics.Color;\r
 import android.os.AsyncTask;\r
 import android.os.Bundle;\r
 import android.os.IBinder;\r
@@ -169,6 +168,8 @@ public class NodeInfo extends TabActivity implements OnTabChangeListener, Servic
                        menu.add(Menu.NONE, R.id.graph_four_hours, Menu.NONE, getString(R.string.last_values_graph_four_hours));\r
                        menu.add(Menu.NONE, R.id.graph_one_day, Menu.NONE, getString(R.string.last_values_graph_one_day));\r
                        menu.add(Menu.NONE, R.id.graph_one_week, Menu.NONE, getString(R.string.last_values_graph_one_week));\r
+                       menu.add(Menu.NONE, R.id.bar_chart, Menu.NONE, getString(R.string.last_values_bar_chart));\r
+                       menu.add(Menu.NONE, R.id.pie_chart, Menu.NONE, getString(R.string.last_values_pie_chart));\r
                }\r
                else\r
                {\r
@@ -178,6 +179,8 @@ public class NodeInfo extends TabActivity implements OnTabChangeListener, Servic
                        menu.removeItem(R.id.graph_four_hours);\r
                        menu.removeItem(R.id.graph_one_day);\r
                        menu.removeItem(R.id.graph_one_week);\r
+                       menu.removeItem(R.id.bar_chart);\r
+                       menu.removeItem(R.id.pie_chart);\r
                }\r
                \r
                recreateOptionsMenu = false;\r
@@ -292,6 +295,10 @@ public class NodeInfo extends TabActivity implements OnTabChangeListener, Servic
                                return drawGraph(86400, info.position);\r
                        case R.id.graph_one_week:\r
                                return drawGraph(604800, info.position);\r
+                       case R.id.bar_chart:\r
+                               return drawComparisonChart(DrawBarChart.class);\r
+                       case R.id.pie_chart:\r
+                               return drawComparisonChart(DrawPieChart.class);\r
                        // Alarms\r
                        case R.id.acknowledge:\r
                                alarmsAdapter.acknowledgeItem(((Alarm)alarmsAdapter.getItem(info.position)).getId());\r
@@ -334,6 +341,10 @@ public class NodeInfo extends TabActivity implements OnTabChangeListener, Servic
                                return drawGraph(86400, lastValuesListView.getSelectedItemPosition());\r
                        case R.id.graph_one_week:\r
                                return drawGraph(604800, lastValuesListView.getSelectedItemPosition());\r
+                       case R.id.bar_chart:\r
+                               return drawComparisonChart(DrawBarChart.class);\r
+                       case R.id.pie_chart:\r
+                               return drawComparisonChart(DrawPieChart.class);\r
                        default:\r
                                return super.onOptionsItemSelected(item);\r
                }\r
@@ -373,7 +384,8 @@ public class NodeInfo extends TabActivity implements OnTabChangeListener, Servic
                                count++;\r
                        }\r
                }\r
-               else\r
+               \r
+               if ((count == 0) && (position != ListView.INVALID_POSITION))\r
                {\r
                        DciValue value = (DciValue)lastValuesAdapter.getItem(position);\r
                        nodeIdList.add((int)nodeId);\r
@@ -386,15 +398,64 @@ public class NodeInfo extends TabActivity implements OnTabChangeListener, Servic
                }\r
 \r
                // Pass them to activity\r
-               newIntent.putExtra("numGraphs", count);\r
-               newIntent.putIntegerArrayListExtra("nodeIdList", nodeIdList);\r
-               newIntent.putIntegerArrayListExtra("dciIdList", dciIdList);\r
-               newIntent.putIntegerArrayListExtra("colorList", colorList);\r
-               newIntent.putIntegerArrayListExtra("lineWidthList", lineWidthList);\r
-               newIntent.putStringArrayListExtra("nameList", nameList);\r
-               newIntent.putExtra("timeFrom", System.currentTimeMillis() - secsBack * 1000);\r
-               newIntent.putExtra("timeTo", System.currentTimeMillis());\r
-               startActivity(newIntent);\r
+               if (count > 0)\r
+               {\r
+                       newIntent.putExtra("numGraphs", count);\r
+                       newIntent.putIntegerArrayListExtra("nodeIdList", nodeIdList);\r
+                       newIntent.putIntegerArrayListExtra("dciIdList", dciIdList);\r
+                       newIntent.putIntegerArrayListExtra("colorList", colorList);\r
+                       newIntent.putIntegerArrayListExtra("lineWidthList", lineWidthList);\r
+                       newIntent.putStringArrayListExtra("nameList", nameList);\r
+                       newIntent.putExtra("timeFrom", System.currentTimeMillis() - secsBack * 1000);\r
+                       newIntent.putExtra("timeTo", System.currentTimeMillis());\r
+                       startActivity(newIntent);\r
+               }\r
+               return true;\r
+       }\r
+       \r
+       /**\r
+        * Draw pie chart for selected DCIs\r
+        * \r
+        * @return\r
+        */\r
+       private boolean drawComparisonChart(Class<?> chartClass)\r
+       {\r
+               Intent newIntent = new Intent(this, chartClass);\r
+               \r
+               ArrayList<Integer> nodeIdList = new ArrayList<Integer>();\r
+               ArrayList<Integer> dciIdList = new ArrayList<Integer>();\r
+               ArrayList<Integer> colorList = new ArrayList<Integer>();\r
+               ArrayList<String> nameList = new ArrayList<String>();\r
+\r
+               // Set values\r
+               int count = 0;\r
+               final SparseBooleanArray positions = lastValuesListView.getCheckedItemPositions();\r
+               if (positions.size() > 0)\r
+               {\r
+                       for(int i = 0; (i < lastValuesAdapter.getCount()) && (count < 16); i++)\r
+                       {\r
+                               if (!positions.get(i))\r
+                                       continue;\r
+                               \r
+                               DciValue value = (DciValue)lastValuesAdapter.getItem(i);\r
+                               nodeIdList.add((int)nodeId);\r
+                               dciIdList.add((int)value.getId());\r
+                               colorList.add(DEFAULT_COLORS[count]);\r
+                               nameList.add(value.getDescription());\r
+                               count++;\r
+                       }\r
+               }\r
+\r
+               // Pass them to activity\r
+               if (count > 0)\r
+               {\r
+                       newIntent.putExtra("numItems", count);\r
+                       newIntent.putIntegerArrayListExtra("nodeIdList", nodeIdList);\r
+                       newIntent.putIntegerArrayListExtra("dciIdList", dciIdList);\r
+                       newIntent.putIntegerArrayListExtra("colorList", colorList);\r
+                       newIntent.putStringArrayListExtra("nameList", nameList);\r
+                       startActivity(newIntent);\r
+               }\r
                return true;\r
        }\r
 \r
index 7465ec6..4507925 100644 (file)
@@ -200,12 +200,20 @@ public class LastValuesAdapter extends BaseAdapter
                return view;\r
        }\r
        \r
+       /**\r
+        * @param t\r
+        * @return\r
+        */\r
        private int getThresholdIcon(Threshold t)\r
        {\r
                int s = t != null ? t.getCurrentSeverity() : 0;\r
                return severityImageId[s < severityImageId.length ? s : 0];\r
        }\r
        \r
+       /**\r
+        * @param t\r
+        * @return\r
+        */\r
        private String getThresholdText(Threshold t)\r
        {\r
                final int[] fns = { R.string.ts_fn_last, R.string.ts_fn_average, R.string.ts_fn_deviation, \r
index aca2edd..309532b 100644 (file)
@@ -22,15 +22,12 @@ public class CheckableLinearLayout extends LinearLayout implements Checkable
        public CheckableLinearLayout(Context context)\r
        {\r
                super(context);\r
-               checkBox = new CheckBox(context);\r
+               checkBox = new CheckBox(context) {\r
+                       \r
+               };\r
                checkBox.setFocusable(false);\r
+               checkBox.setClickable(false);\r
                addView(checkBox);\r
-               checkBox.setOnClickListener(new OnClickListener() {\r
-                       @Override\r
-                       public void onClick(View v)\r
-                       {\r
-                       }\r
-               });\r
        }\r
        \r
        /*\r