Example usage for org.eclipse.swt.graphics Color getBlue

List of usage examples for org.eclipse.swt.graphics Color getBlue

Introduction

In this page you can find the example usage for org.eclipse.swt.graphics Color getBlue.

Prototype

public int getBlue() 

Source Link

Usage

From source file:eu.stratosphere.addons.visualization.swt.SWTGateToolTip.java

private ChartComposite createChart(GateVisualizationData visualizationData, Color backgroundColor) {

    final String yAxisLabel = this.managementGate.isInputGate() ? "No data available/sec."
            : "Capacity limit reached/sec.";

    final JFreeChart chart = ChartFactory.createXYLineChart(null, "Time [sec.]", yAxisLabel,
            visualizationData.getChartCollection(), PlotOrientation.VERTICAL, false, false, false);

    chart.setBackgroundPaint(new java.awt.Color(backgroundColor.getRed(), backgroundColor.getGreen(),
            backgroundColor.getBlue()));

    // Set axis properly
    final XYPlot xyPlot = chart.getXYPlot();
    xyPlot.getDomainAxis().setAutoRange(true);
    xyPlot.getDomainAxis().setAutoRangeMinimumSize(60);

    xyPlot.getRangeAxis().setAutoRange(true);
    // xyPlot.getRangeAxis().setRange(0, 100);

    return new ChartComposite(getShell(), SWT.NONE, chart, true);
}

From source file:at.ac.tuwien.inso.subcat.ui.widgets.TrendView.java

public TrendView(Composite parent, int style) {
    super(parent, style);
    initCharts();//from w  ww  . j  a  v  a 2 s.co m

    setLayout(new FillLayout());

    SashForm sashForm = new SashForm(this, SWT.VERTICAL);

    timeChart = new TimeChartControlPanel<SelectedChart>(sashForm, SWT.BORDER);
    timeChart.addChartSelectionEntry("Trend View", SelectedChart.LINE);
    timeChart.addChartSelectionEntry("Bar View", SelectedChart.BAR);
    timeChart.addChartSelectionEntry("Both", SelectedChart.BOTH);

    JFreeChart chart = createChart(SelectedChart.LINE);
    setChart(chart);

    scrolledComposite = new ScrolledComposite(sashForm, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    scrolledComposite.setLayout(new FillLayout());

    optionComposite = new Composite(scrolledComposite, SWT.NONE);
    optionComposite.setLayout(new GridLayout(3, false));

    scrolledComposite.setContent(optionComposite);
    scrolledComposite.setMinSize(optionComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setAlwaysShowScrollBars(false);

    // Signals:
    boxListener = new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Button button = (Button) e.getSource();
            ChartIdentifier boxData = (ChartIdentifier) button.getData();
            assert (boxData != null);

            boolean checked = button.getSelection();

            if (boxData.paint == null) {
                boxData.paint = drawingSupplier.getNextPaint();
            }

            if (checked) {
                java.awt.Color paintColor = (java.awt.Color) boxData.paint;
                Color color = new Color(null, paintColor.getRed(), paintColor.getGreen(), paintColor.getBlue());
                button.setBackground(color);
            } else {
                button.setBackground(null);
            }

            for (TrendViewListener listener : listeners) {
                listener.optionSelected(boxData, checked);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    };

    comboListener = new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Combo combo = (Combo) e.getSource();
            DropDownData data = (DropDownData) combo.getData();
            assert (data != null);
            DropDownConfig config = data.getConfig();

            for (TrendViewListener listener : listeners) {
                listener.comboChanged(config);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    };
}

From source file:at.ac.tuwien.inso.subcat.ui.widgets.TrendChart.java

public TrendChart(Composite parent, int style) {
    super(parent, style);
    initCharts();//w ww.j  a va2s  .  c  om

    setLayout(new FillLayout());

    SashForm sashForm = new SashForm(this, SWT.VERTICAL);

    timeChart = new TimeChartControlPanel<SelectedChart>(sashForm, SWT.BORDER);
    timeChart.addChartSelectionEntry("Trend View", SelectedChart.LINE);
    timeChart.addChartSelectionEntry("Bar View", SelectedChart.BAR);
    timeChart.addChartSelectionEntry("Both", SelectedChart.BOTH);

    JFreeChart chart = createChart(SelectedChart.LINE);
    setChart(chart);

    scrolledComposite = new ScrolledComposite(sashForm, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    scrolledComposite.setLayout(new FillLayout());

    optionComposite = new Composite(scrolledComposite, SWT.NONE);
    optionComposite.setLayout(new GridLayout(3, false));

    scrolledComposite.setContent(optionComposite);
    scrolledComposite.setMinSize(optionComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setAlwaysShowScrollBars(false);

    // Signals:
    boxListener = new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Button button = (Button) e.getSource();
            ChartIdentifier boxData = (ChartIdentifier) button.getData();
            assert (boxData != null);

            boolean checked = button.getSelection();

            if (boxData.paint == null) {
                boxData.paint = drawingSupplier.getNextPaint();
            }

            if (checked) {
                java.awt.Color paintColor = (java.awt.Color) boxData.paint;
                Color color = new Color(null, paintColor.getRed(), paintColor.getGreen(), paintColor.getBlue());
                button.setBackground(color);
            } else {
                button.setBackground(null);
            }

            for (TrendChartListener listener : listeners) {
                listener.optionSelected(boxData, checked);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    };

    comboListener = new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Combo combo = (Combo) e.getSource();
            DropDownData data = (DropDownData) combo.getData();
            assert (data != null);
            DropDownConfig config = data.getConfig();

            for (TrendChartListener listener : listeners) {
                listener.comboChanged(config);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    };
}

From source file:com.planetmayo.debrief.satc_rcp.views.MaintainContributionsView.java

private Color colorFor(BaseContribution contribution) {

    if (assignedColors == null) {
        assignedColors = new HashMap<BaseContribution, Color>();
    }//  w ww  .  j  av a2  s .  c  om

    // have we already assigned this one?
    Color res = assignedColors.get(contribution);

    if (res == null) {
        int index = assignedColors.size() % defaultColors.length;
        java.awt.Color newCol = defaultColors[index];
        res = new Color(Display.getDefault(), newCol.getRed(), newCol.getGreen(), newCol.getBlue());
        assignedColors.put(contribution, res);
    }

    return res;

}