use of org.netxms.client.datacollection.GraphItemStyle in project netxms by netxms.
the class HistoricalGraphView method configureGraphFromSettings.
/**
* Configure graph from graph settings
*/
private void configureGraphFromSettings() {
if (chart != null)
((Widget) chart).dispose();
chart = ChartFactory.createLineChart(chartParent, SWT.NONE);
createPopupMenu();
// General settings
setPartName(settings.getTitle());
chart.setChartTitle(settings.getTitle());
// Chart visual settings
chart.setLogScaleEnabled(settings.isLogScale());
chart.setGridVisible(settings.isShowGrid());
chart.setLegendVisible(settings.isShowLegend());
chart.setLegendPosition(settings.getLegendPosition());
chart.setExtendedLegend(settings.isExtendedLegend());
chart.setStacked(settings.isStacked());
chart.setTranslucent(settings.isTranslucent());
chart.setLineWidth(settings.getLineWidth());
chart.setUseMultipliers(settings.isUseMultipliers());
if (!settings.isAutoScale())
chart.setYAxisRange(settings.getMinYScaleValue(), settings.getMaxYScaleValue());
else
chart.modifyYBase(settings.modifyYBase());
// Data
final List<GraphItemStyle> styles = new ArrayList<GraphItemStyle>(settings.getDciList().length);
int index = 0;
int nodeId = 0;
for (ChartDciConfig dci : settings.getDciList()) {
// Check that all DCI's are form one node
nodeId |= dci.nodeId;
// $NON-NLS-1$
final String name = settings.isShowHostNames() ? (session.getObjectName(dci.nodeId) + " - " + dci.getName()) : dci.getName();
chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, DataType.INT32, Long.toString(dci.dciId), name, dci.getDisplayFormat()));
int color = dci.getColorAsInt();
if (color == -1)
color = ChartColor.getDefaultColor(index).getRGB();
styles.add(new GraphItemStyle(getDisplayType(dci), color, 2, dci.invertValues ? GraphItemStyle.INVERTED : 0));
index++;
}
// Check that all DCI's are form one node
if (index > 0)
useMoreThanOneShoucrNode = (nodeId != settings.getDciList()[0].nodeId);
chart.setItemStyles(styles);
if (settings.getTimeFrameType() == GraphSettings.TIME_FRAME_BACK_FROM_NOW) {
settings.setTimeFrom(new Date(System.currentTimeMillis() - settings.getTimeRangeMillis()));
settings.setTimeTo(new Date(System.currentTimeMillis()));
}
getDataFromServer();
// Automatic refresh
actionAutoRefresh.setChecked(settings.isAutoRefresh());
refreshMenuSelection();
refreshController.setInterval(settings.isAutoRefresh() ? settings.getRefreshRate() : -1);
}
Aggregations