use of org.netxms.ui.android.helpers.CustomLabel in project netxms by netxms.
the class DrawGraph method onCreateStep2.
/* (non-Javadoc)
* @see org.netxms.ui.android.main.activities.AbstractClientActivity#onCreateStep2(android.os.Bundle)
*/
@Override
protected void onCreateStep2(Bundle savedInstanceState) {
sp = PreferenceManager.getDefaultSharedPreferences(this);
dialog = new ProgressDialog(this);
setContentView(R.layout.graphics);
// boolean showLegend = getIntent().getBooleanExtra("showLegend", true);
numGraphs = getIntent().getIntExtra("numGraphs", 0);
if (numGraphs > 0) {
items = new GraphItem[numGraphs];
itemStyles = new GraphItemStyle[numGraphs];
ArrayList<Integer> nodeIdList = getIntent().getIntegerArrayListExtra("nodeIdList");
ArrayList<Integer> dciIdList = getIntent().getIntegerArrayListExtra("dciIdList");
ArrayList<Integer> colorList = getIntent().getIntegerArrayListExtra("colorList");
ArrayList<Integer> lineWidthList = getIntent().getIntegerArrayListExtra("lineWidthList");
ArrayList<String> nameList = getIntent().getStringArrayListExtra("nameList");
for (int i = 0; i < numGraphs; i++) {
items[i] = new GraphItem();
items[i].setNodeId(nodeIdList.get(i));
items[i].setDciId(dciIdList.get(i));
items[i].setDescription(nameList.get(i));
itemStyles[i] = new GraphItemStyle();
itemStyles[i].setColor(colorList.get(i) | 0xFF000000);
itemStyles[i].setLineWidth(lineWidthList.get(i));
}
timeFrom = getIntent().getLongExtra("timeFrom", 0);
timeTo = getIntent().getLongExtra("timeTo", 0);
graphTitle = getIntent().getStringExtra("graphTitle");
}
graphView = new LineGraphView(this, "");
graphView.getGraphViewStyle().setVerticalLabelsColor(Color.WHITE);
graphView.getGraphViewStyle().setHorizontalLabelsColor(Color.WHITE);
graphView.getGraphViewStyle().setTextSize(Integer.parseInt(sp.getString("global.graph.textsize", "10")));
graphView.getGraphViewStyle().setLegendWidth(240);
graphView.setCustomLabelFormatter(new CustomLabel(Integer.parseInt(sp.getString("global.multipliers", "1")), (timeTo - timeFrom) > 86400 * 1000));
// TOOD: 2014May25 Find a best way to handle this setting
// graphView.setShowLegend(showLegend);
graphView.setShowLegend(sp.getBoolean("global.graph.legend", true));
graphView.setLegendAlign(LegendAlign.TOP);
graphView.setScalable(true);
graphView.setScrollable(true);
TextView title = (TextView) findViewById(R.id.ScreenTitlePrimary);
title.setText(R.string.graph_title);
}
use of org.netxms.ui.android.helpers.CustomLabel in project netxms by netxms.
the class LineChartElement method refresh.
/* (non-Javadoc)
* @see org.netxms.ui.android.main.dashboards.elements.AbstractDashboardElement#refresh()
*/
@Override
public void refresh() {
final ChartDciConfig[] items = config.getDciList();
Log.v(TAG, "refresh(): " + items.length + " items to load");
if (items.length == 0)
return;
final long endTime = System.currentTimeMillis();
final long startTime = endTime - config.getTimeRangeMillis();
graphView.setCustomLabelFormatter(new CustomLabel(Integer.parseInt(sp.getString("global.multipliers", "1")), (endTime - startTime) > 86400 * 1000));
try {
final DciData[] dciData = new DciData[items.length];
for (int i = 0; i < dciData.length; i++) {
dciData[i] = service.getSession().getCollectedData(items[i].nodeId, items[i].dciId, new Date(startTime), new Date(endTime), 0);
}
Log.v(TAG, "refresh(): data retrieved from server");
post(new Runnable() {
@Override
public void run() {
graphView.removeAllSeries();
for (int i = 0; i < dciData.length && i < Colors.DEFAULT_ITEM_COLORS.length; i++) {
DciDataRow[] dciDataRow = dciData[i].getValues();
GraphViewData[] gvData = new GraphViewData[dciDataRow.length];
for (int j = dciDataRow.length - 1, k = 0; j >= 0; j--, k++) // dciData are reversed!
gvData[k] = new GraphViewData(dciDataRow[j].getTimestamp().getTime(), dciDataRow[j].getValueAsDouble());
int color = items[i].getColorAsInt();
color = color == -1 ? Colors.DEFAULT_ITEM_COLORS[i] : swapRGB(color);
GraphViewSeries series = new GraphViewSeries(items[i].getName(), new GraphViewSeriesStyle(color | 0xFF000000, 3), gvData);
graphView.addSeries(series);
}
graphView.setViewPort(startTime, endTime - startTime + 1);
Log.v(TAG, "refresh(): " + dciData.length + " series added; viewport set to " + startTime + "/" + (endTime - startTime + 1));
if (getChildCount() == 0)
addView(graphView);
else
graphView.redrawAll();
}
});
} catch (Exception e) {
Log.e(TAG, "Exception while reading data from server", e);
}
}
Aggregations