use of org.netxms.ui.android.main.activities.helpers.ChartConfig in project netxms by netxms.
the class GraphBrowser method drawGraph.
/**
* Draw graph based on stored settings
*/
public void drawGraph(GraphSettings gs) {
if (gs != null) {
ChartConfig config;
try {
config = ChartConfig.createFromXml(gs.createXml());
} catch (Exception e) {
Log.e(TAG, "ChartConfig.createFromXml", e);
config = new ChartConfig();
}
Intent newIntent = new Intent(this, DrawGraph.class);
ArrayList<Integer> nodeIdList = new ArrayList<Integer>();
ArrayList<Integer> dciIdList = new ArrayList<Integer>();
ArrayList<Integer> colorList = new ArrayList<Integer>();
ArrayList<Integer> lineWidthList = new ArrayList<Integer>();
ArrayList<String> nameList = new ArrayList<String>();
// Set values
ChartDciConfig[] items = config.getDciList();
for (int i = 0; i < items.length && i < Colors.DEFAULT_ITEM_COLORS.length; i++) {
nodeIdList.add((int) items[i].nodeId);
dciIdList.add((int) items[i].dciId);
int color = items[i].getColorAsInt();
colorList.add(color == -1 ? Colors.DEFAULT_ITEM_COLORS[i] : swapRGB(color));
lineWidthList.add(items[i].lineWidth);
nameList.add(items[i].name);
}
// Pass them to activity
newIntent.putExtra("numGraphs", items.length);
newIntent.putIntegerArrayListExtra("nodeIdList", nodeIdList);
newIntent.putIntegerArrayListExtra("dciIdList", dciIdList);
newIntent.putIntegerArrayListExtra("colorList", colorList);
newIntent.putIntegerArrayListExtra("lineWidthList", lineWidthList);
newIntent.putStringArrayListExtra("nameList", nameList);
newIntent.putExtra("graphTitle", adapter.TrimGroup(gs.getName()));
if (config.getTimeFrameType() == GraphSettings.TIME_FRAME_FIXED) {
newIntent.putExtra("timeFrom", config.getTimeFrom().getTime());
newIntent.putExtra("timeTo", config.getTimeTo().getTime());
} else {
// Back from now
newIntent.putExtra("timeFrom", System.currentTimeMillis() - config.getTimeRangeMillis());
newIntent.putExtra("timeTo", System.currentTimeMillis());
}
startActivity(newIntent);
}
}
Aggregations