Search in sources :

Example 21 with ChartDciConfig

use of org.netxms.client.datacollection.ChartDciConfig 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

ChartDciConfig (org.netxms.client.datacollection.ChartDciConfig)21 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 ArrayList (java.util.ArrayList)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 GraphSettings (org.netxms.client.datacollection.GraphSettings)4 DataSourceEditDlg (org.netxms.ui.eclipse.datacollection.dialogs.DataSourceEditDlg)4 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)4 Date (java.util.Date)3 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)3 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)3 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 SelectionListener (org.eclipse.swt.events.SelectionListener)3 Color (org.eclipse.swt.graphics.Color)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 RowData (org.eclipse.swt.layout.RowData)3