Search in sources :

Example 1 with LineStyle

use of org.eclipse.swtchart.LineStyle in project swtchart by eclipse.

the class GridPage method addGridPanel.

/**
 * Adds the grid panel.
 *
 * @param parent
 *            the parent to add the grid panel
 */
private void addGridPanel(Composite parent) {
    Composite group = new Composite(parent, SWT.NONE);
    GridData gridData = new GridData();
    gridData.horizontalSpan = 2;
    group.setLayoutData(gridData);
    group.setLayout(new GridLayout(2, false));
    createLabelControl(group, "Line style:");
    LineStyle[] values = LineStyle.values();
    String[] labels = new String[values.length];
    for (int i = 0; i < values.length; i++) {
        labels[i] = values[i].label;
    }
    styleCombo = createComboControl(group, labels);
    styleCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String value = styleCombo.getText();
            LineStyle selectedStyle = LineStyle.NONE;
            for (LineStyle style : LineStyle.values()) {
                if (style.label.equals(value)) {
                    selectedStyle = style;
                }
            }
            styles[selectedIndex] = selectedStyle;
        }
    });
    createLabelControl(group, "Color:");
    foregroundButton = createColorButtonControl(group);
    foregroundButton.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            foregroundColors[selectedIndex] = foregroundButton.getColorValue();
        }
    });
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) LineStyle(org.eclipse.swtchart.LineStyle) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 2 with LineStyle

use of org.eclipse.swtchart.LineStyle in project netxms by netxms.

the class LineChart method setGridVisible.

/**
 * Set grid visible
 *
 * @param visible true to set grid visible
 */
private void setGridVisible(boolean visible) {
    final LineStyle ls = visible ? LineStyle.DOT : LineStyle.NONE;
    getAxisSet().getXAxis(0).getGrid().setStyle(ls);
    getAxisSet().getYAxis(0).getGrid().setStyle(ls);
}
Also used : LineStyle(org.eclipse.swtchart.LineStyle)

Example 3 with LineStyle

use of org.eclipse.swtchart.LineStyle in project swtchart by eclipse.

the class SeriesPage method addLineSeriesGroup.

/**
 * Adds the line series group.
 *
 * @param parent
 *            the parent to add the line series group
 */
private void addLineSeriesGroup(Composite parent) {
    lineSeriesGroup = createGroupControl(parent, "Line series:", true);
    stackLayout.topControl = lineSeriesGroup;
    createLabelControl(lineSeriesGroup, "Line color:");
    lineColorButton = createColorButtonControl(lineSeriesGroup);
    lineColorButton.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            lineColors[selectedIndex] = lineColorButton.getColorValue();
        }
    });
    createLabelControl(lineSeriesGroup, "Line style:");
    LineStyle[] styles = LineStyle.values();
    String[] labels = new String[styles.length];
    for (int i = 0; i < styles.length; i++) {
        labels[i] = styles[i].label;
    }
    lineStyleCombo = createComboControl(lineSeriesGroup, labels);
    lineStyleCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String value = lineStyleCombo.getText();
            LineStyle selectedStyle = LineStyle.NONE;
            for (LineStyle style : LineStyle.values()) {
                if (style.label.equals(value)) {
                    selectedStyle = style;
                }
            }
            lineStyles[selectedIndex] = selectedStyle;
        }
    });
    createLabelControl(lineSeriesGroup, "Symbol color:");
    symbolColorButton = createColorButtonControl(lineSeriesGroup);
    symbolColorButton.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            symbolColors[selectedIndex] = symbolColorButton.getColorValue();
        }
    });
    createLabelControl(lineSeriesGroup, "Symbol type:");
    PlotSymbolType[] types = PlotSymbolType.values();
    labels = new String[types.length];
    for (int i = 0; i < types.length; i++) {
        labels[i] = types[i].label;
    }
    symbolTypeCombo = createComboControl(lineSeriesGroup, labels);
    symbolTypeCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String value = symbolTypeCombo.getText();
            PlotSymbolType selectedType = PlotSymbolType.CIRCLE;
            for (PlotSymbolType type : PlotSymbolType.values()) {
                if (type.label.equals(value)) {
                    selectedType = type;
                }
            }
            symbolTypes[selectedIndex] = selectedType;
        }
    });
    createLabelControl(lineSeriesGroup, "Symbol size:");
    symbolSizeSpinner = createSpinnerControl(lineSeriesGroup, 1, 10);
    symbolSizeSpinner.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            symbolSizes[selectedIndex] = symbolSizeSpinner.getSelection();
        }
    });
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) LineStyle(org.eclipse.swtchart.LineStyle) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PlotSymbolType(org.eclipse.swtchart.ILineSeries.PlotSymbolType)

Example 4 with LineStyle

use of org.eclipse.swtchart.LineStyle in project tracecompass by tracecompass.

the class XYChartLegendImageProvider method drawStyleLine.

private void drawStyleLine(GC gc, Color lineColor, int imageWidth, int imageHeight, @NonNull OutputElementStyle appearance) {
    Color prev = gc.getForeground();
    BaseXYPresentationProvider presProvider = fChartViewer.getPresentationProvider();
    LineStyle lineStyle = LineStyle.valueOf((String) presProvider.getStyleOrDefault(appearance, StyleProperties.SERIES_STYLE, StyleProperties.SeriesStyle.SOLID));
    if (lineStyle != LineStyle.NONE) {
        gc.setForeground(lineColor);
        gc.setLineWidth(((Number) presProvider.getFloatStyleOrDefault(appearance, StyleProperties.WIDTH, 1.0f)).intValue());
        gc.setLineStyle(lineStyle.ordinal());
        gc.drawLine(0, imageHeight / 2, imageWidth, imageHeight / 2);
        gc.setForeground(prev);
    }
}
Also used : LineStyle(org.eclipse.swtchart.LineStyle) Color(org.eclipse.swt.graphics.Color) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) BaseXYPresentationProvider(org.eclipse.tracecompass.internal.provisional.tmf.ui.viewers.xychart.BaseXYPresentationProvider)

Aggregations

LineStyle (org.eclipse.swtchart.LineStyle)4 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)2 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 Color (org.eclipse.swt.graphics.Color)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 PlotSymbolType (org.eclipse.swtchart.ILineSeries.PlotSymbolType)1 BaseXYPresentationProvider (org.eclipse.tracecompass.internal.provisional.tmf.ui.viewers.xychart.BaseXYPresentationProvider)1 RGBAColor (org.eclipse.tracecompass.tmf.core.presentation.RGBAColor)1