Search in sources :

Example 6 with GraphItemStyle

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);
}
Also used : ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) ArrayList(java.util.ArrayList) GraphItemStyle(org.netxms.client.datacollection.GraphItemStyle) GraphItem(org.netxms.client.datacollection.GraphItem) Date(java.util.Date)

Aggregations

GraphItemStyle (org.netxms.client.datacollection.GraphItemStyle)6 GraphItem (org.netxms.client.datacollection.GraphItem)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 ProgressDialog (android.app.ProgressDialog)1 TextView (android.widget.TextView)1 LineGraphView (com.jjoe64.graphview.LineGraphView)1 GC (org.eclipse.swt.graphics.GC)1 Point (org.eclipse.swt.graphics.Point)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 ChartDciConfig (org.netxms.client.datacollection.ChartDciConfig)1 CustomLabel (org.netxms.ui.android.helpers.CustomLabel)1 DataPoint (org.netxms.ui.eclipse.charts.api.DataPoint)1