Search in sources :

Example 1 with IDisposeListener

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

the class AxisTickPage method apply.

/*
	 * @see AbstractPreferencePage#apply()
	 */
@Override
public void apply() {
    for (int i = 0; i < axes.length; i++) {
        axes[i].getTick().setVisible(visibilityStates[i]);
        FontData fontData = axes[i].getTick().getFont().getFontData()[0];
        fontData.setHeight(fontSizes[i]);
        Font font = new Font(Display.getDefault(), fontData);
        axes[i].getTick().setFont(font);
        final String fontKey = AXIS_TICK_FONT + axes[i].getDirection() + axes[i].getId();
        if (resources.getFont(fontKey) == null) {
            axes[i].addDisposeListener(new IDisposeListener() {

                public void disposed(Event e) {
                    resources.removeFont(fontKey);
                }
            });
        }
        resources.put(fontKey, font);
        Color color = new Color(Display.getDefault(), foregroundColors[i]);
        axes[i].getTick().setForeground(color);
        final String colorKey = AXIS_TICK_FOREGROUND + axes[i].getDirection() + axes[i].getId();
        if (resources.getColor(colorKey) == null) {
            axes[i].addDisposeListener(new IDisposeListener() {

                public void disposed(Event e) {
                    resources.removeColor(colorKey);
                }
            });
        }
        resources.put(colorKey, color);
    }
}
Also used : IDisposeListener(org.eclipse.swtchart.IDisposeListener) FontData(org.eclipse.swt.graphics.FontData) Color(org.eclipse.swt.graphics.Color) Event(org.eclipse.swt.widgets.Event) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Font(org.eclipse.swt.graphics.Font)

Example 2 with IDisposeListener

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

the class SeriesLabelPage method apply.

/*
	 * @see AbstractPreferencePage#apply()
	 */
@Override
public void apply() {
    for (int i = 0; i < series.length; i++) {
        series[i].getLabel().setVisible(visibleStates[i]);
        Color color = new Color(Display.getDefault(), colors[i]);
        series[i].getLabel().setForeground(color);
        final String colorKey = SERIES_LABEL_FOREGROUND + series[i].getId();
        if (resources.getColor(colorKey) == null) {
            series[i].addDisposeListener(new IDisposeListener() {

                public void disposed(Event e) {
                    resources.removeColor(colorKey);
                }
            });
        }
        resources.put(colorKey, color);
        FontData fontData = series[i].getLabel().getFont().getFontData()[0];
        fontData.setHeight(fontSizes[i]);
        Font font = new Font(Display.getDefault(), fontData);
        series[i].getLabel().setFont(font);
        final String fontKey = SERIES_LABEL_FONT + series[i].getId();
        if (resources.getFont(fontKey) == null) {
            series[i].addDisposeListener(new IDisposeListener() {

                public void disposed(Event e) {
                    resources.removeFont(fontKey);
                }
            });
        }
        resources.put(fontKey, font);
    }
}
Also used : IDisposeListener(org.eclipse.swtchart.IDisposeListener) Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Font(org.eclipse.swt.graphics.Font)

Example 3 with IDisposeListener

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

the class SeriesPage method apply.

/*
	 * @see AbstractPreferencePage#apply()
	 */
@Override
public void apply() {
    for (int i = 0; i < series.length; i++) {
        series[i].setVisible(visibleStates[i]);
        if (series[i] instanceof ILineSeries) {
            Color lineColor = new Color(Display.getDefault(), lineColors[i]);
            ((ILineSeries) series[i]).setLineColor(lineColor);
            final String lineColorKey = SERIES_LINE_COLOR + series[i].getId();
            if (resources.getColor(lineColorKey) == null) {
                series[i].addDisposeListener(new IDisposeListener() {

                    public void disposed(Event e) {
                        resources.removeColor(lineColorKey);
                    }
                });
            }
            resources.put(lineColorKey, lineColor);
            Color symbolColor = new Color(Display.getDefault(), symbolColors[i]);
            ((ILineSeries) series[i]).setSymbolColor(symbolColor);
            final String symbolColorKey = SERIES_SYMBOL_COLOR + series[i].getId();
            if (resources.getColor(symbolColorKey) == null) {
                series[i].addDisposeListener(new IDisposeListener() {

                    public void disposed(Event e) {
                        resources.removeColor(symbolColorKey);
                    }
                });
            }
            resources.put(symbolColorKey, symbolColor);
            ((ILineSeries) series[i]).setLineStyle(lineStyles[i]);
            ((ILineSeries) series[i]).setSymbolType(symbolTypes[i]);
            ((ILineSeries) series[i]).setSymbolSize(symbolSizes[i]);
        } else if (series[i] instanceof IBarSeries) {
            Color barColor = new Color(Display.getDefault(), barColors[i]);
            ((IBarSeries) series[i]).setBarColor(barColor);
            final String barColorKey = SERIES_BAR_COLOR + series[i].getId();
            if (resources.getColor(barColorKey) == null) {
                series[i].addDisposeListener(new IDisposeListener() {

                    public void disposed(Event e) {
                        resources.removeColor(barColorKey);
                    }
                });
            }
            resources.put(barColorKey, barColor);
            ((IBarSeries) series[i]).setBarPadding(paddings[i]);
        }
        try {
            series[i].enableStack(stackedStates[i]);
        } catch (IllegalArgumentException e) {
            stackedStates[i] = false;
            stackedButton.setSelection(false);
        }
        series[i].setXAxisId(xAxisIds[i]);
        series[i].setYAxisId(yAxisIds[i]);
    }
}
Also used : IDisposeListener(org.eclipse.swtchart.IDisposeListener) IBarSeries(org.eclipse.swtchart.IBarSeries) ILineSeries(org.eclipse.swtchart.ILineSeries) Color(org.eclipse.swt.graphics.Color) Event(org.eclipse.swt.widgets.Event) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 4 with IDisposeListener

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

the class Axis method dispose.

/**
 * Disposes the resources.
 */
protected void dispose() {
    tick.getAxisTickLabels().dispose();
    tick.getAxisTickMarks().dispose();
    title.dispose();
    for (IDisposeListener listener : listeners) {
        listener.disposed(new Event());
    }
}
Also used : IDisposeListener(org.eclipse.swtchart.IDisposeListener) Event(org.eclipse.swt.widgets.Event)

Example 5 with IDisposeListener

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

the class AxisPage method apply.

/*
	 * @see AbstractPreferencePage#apply()
	 */
@Override
public void apply() {
    for (int i = 0; i < axes.length; i++) {
        axes[i].getTitle().setVisible(titleVisibleStates[i]);
        axes[i].getTitle().setText(titleTexts[i]);
        FontData fontData = axes[i].getTitle().getFont().getFontData()[0];
        fontData.setHeight(titleFontSizes[i]);
        Font font = new Font(Display.getDefault(), fontData);
        axes[i].getTitle().setFont(font);
        final String fontKey = AXIS_TITLE_FONT + axes[i].getDirection() + axes[i].getId();
        if (resources.getFont(fontKey) == null) {
            axes[i].addDisposeListener(new IDisposeListener() {

                public void disposed(Event e) {
                    resources.removeFont(fontKey);
                }
            });
        }
        resources.put(fontKey, font);
        Color color = new Color(Display.getDefault(), titleColors[i]);
        axes[i].getTitle().setForeground(color);
        final String colorKey = AXIS_TITLE_FOREGROUND + axes[i].getDirection() + axes[i].getId();
        if (resources.getColor(colorKey) == null) {
            axes[i].addDisposeListener(new IDisposeListener() {

                public void disposed(Event e) {
                    resources.removeColor(colorKey);
                }
            });
        }
        resources.put(colorKey, color);
        axes[i].setRange(new Range(minRanges[i], maxRanges[i]));
        axes[i].setPosition(positions[i]);
        try {
            axes[i].enableLogScale(logScaleStates[i]);
        } catch (IllegalStateException e) {
            axes[i].enableLogScale(false);
            logScaleButton.setSelection(false);
        }
        if (direction == Direction.X) {
            axes[i].enableCategory(categoryStates[i]);
        }
    }
}
Also used : IDisposeListener(org.eclipse.swtchart.IDisposeListener) FontData(org.eclipse.swt.graphics.FontData) Color(org.eclipse.swt.graphics.Color) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Range(org.eclipse.swtchart.Range) Font(org.eclipse.swt.graphics.Font)

Aggregations

Event (org.eclipse.swt.widgets.Event)5 IDisposeListener (org.eclipse.swtchart.IDisposeListener)5 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Color (org.eclipse.swt.graphics.Color)4 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3 Font (org.eclipse.swt.graphics.Font)3 FontData (org.eclipse.swt.graphics.FontData)3 FocusEvent (org.eclipse.swt.events.FocusEvent)1 IBarSeries (org.eclipse.swtchart.IBarSeries)1 ILineSeries (org.eclipse.swtchart.ILineSeries)1 Range (org.eclipse.swtchart.Range)1