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:ColorCreate.java

public static void main(String[] args) {
    Display display = new Display();

    RGB rgb = new RGB(255, 0, 0); // pure red
    Color color = new Color(display, rgb);

    System.out.println(color.getBlue());

    display.dispose();//from   www.  j a  v  a2  s. c om
}

From source file:SWTUtils.java

/**
 * Creates an awt color instance to match the rgb values
 * of the specified swt color./*from  w  w w .ja va  2 s  .  c o  m*/
 *
 * @param color The swt color to match.
 * @return an awt color abject.
 */
public static java.awt.Color toAwtColor(Color color) {
    return new java.awt.Color(color.getRed(), color.getGreen(), color.getBlue());
}

From source file:SWTUtils.java

/**
 * Creates a swt color instance to match the rgb values
 * of the specified awt color. alpha channel is not supported.
 * Note that the dispose method will need to be called on the
 * returned object./*from  w ww.ja  v  a2s  . c om*/
 *
 * @param device The swt device to draw on (display or gc device).
 * @param color The awt color to match.
 * @return a swt color object.
 */
public static Color toSwtColor(Device device, java.awt.Color color) {
    return new org.eclipse.swt.graphics.Color(device, color.getRed(), color.getGreen(), color.getBlue());
}

From source file:SWTUtils.java

/**
 * Creates a swt color instance to match the rgb values
 * of the specified awt paint. For now, this method test
 * if the paint is a color and then return the adequate
 * swt color. Otherwise plain black is assumed.
 *
 * @param device The swt device to draw on (display or gc device).
 * @param paint The awt color to match./*from   ww w  .j a v a  2  s  . co m*/
 * @return a swt color object.
 */
public static Color toSwtColor(Device device, java.awt.Paint paint) {
    java.awt.Color color;
    if (paint instanceof java.awt.Color) {
        color = (java.awt.Color) paint;
    } else {
        try {
            throw new Exception(
                    "only color is supported at present... " + "setting paint to uniform black color");
        } catch (Exception e) {
            e.printStackTrace();
            color = new java.awt.Color(0, 0, 0);
        }
    }
    return new org.eclipse.swt.graphics.Color(device, color.getRed(), color.getGreen(), color.getBlue());
}

From source file:org.qsos.radar.GenerateRadar.java

/**
 * This class creates a composite in which the radar char will be
 * implemented//w w  w  .ja  va2 s.  c  o m
 * 
 * @param parent
 *             Composite where the chart will be seen
 * @param Categories
 *             String[] that contains the name of the elements [4 min and 7 max] the user has chosen to visualize
 * @param Scores
 *             Double[] that contains the average score of each category
 * @return Control
 * 
 */
public static Control createChart(Composite parent, String[] Categories, double[] Scores) {

    Composite Charcomposite = new Composite(parent, SWT.EMBEDDED);
    Charcomposite.setLayout(new FillLayout());
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    //
    for (int i = 0; i < CatNumber; i++) {
        dataset.addValue(Scores[i], getTitle(), Categories[i]);
    }

    String BackGroundMire = null;

    //Configuration of the spiderwebplot
    SpiderWebPlot plot = new SpiderWebPlot();
    plot.setDataset(dataset);
    plot.setMaxValue(JQConst.RADAR_MAX_VALUE);
    plot.setSeriesPaint(JQConst.RADAR_SERIES_PAINT);
    plot.setAxisLabelGap(JQConst.RADAR_AXIS_LABEL_GAP);
    plot.setHeadPercent(JQConst.RADAR_HEAD_PERCENT);
    plot.setInteriorGap(JQConst.RADAR_INTERIOR_GAP);
    plot.setWebFilled(true);

    //The backgroundpicture used as a spiderweb is chosen according to the 
    //number of categories selected
    switch (CatNumber) {
    case 4:
        BackGroundMire = JQConst.RADAR_SPIDERWEB_4;
        break;
    case 5:
        BackGroundMire = JQConst.RADAR_SPIDERWEB_5;
        break;
    case 6:
        BackGroundMire = JQConst.RADAR_SPIDERWEB_6;
        break;
    case 7:
        BackGroundMire = JQConst.RADAR_SPIDERWEB_7;
        break;
    }
    javax.swing.ImageIcon icon = new javax.swing.ImageIcon(BackGroundMire);
    plot.setBackgroundImage(icon.getImage());

    //chart creation
    JFreeChart chart = new JFreeChart(plot);

    //Here the background color from the shell is taken in order to match AWT and SWT backgrounds
    Color backgroundColor = parent.getBackground();

    //JFreechart doesn't support SWT so we create an AWT Frame that will depend on Charcomposite
    java.awt.Frame chartPanel = SWT_AWT.new_Frame(Charcomposite);
    chartPanel.setLayout(new java.awt.GridLayout());
    ChartPanel jfreeChartPanel = new ChartPanel(chart);

    chartPanel.setBackground(new java.awt.Color(backgroundColor.getRed(), backgroundColor.getGreen(),
            backgroundColor.getBlue()));

    chartPanel.add(jfreeChartPanel);
    chartPanel.pack();

    return parent;

}

From source file:org.eclipse.swt.examples.controlexample.ColorTab.java

String getRGBcolor(int id) {
    Color color = display.getSystemColor(id);
    return String.format("(%d,%d,%d,%d)", color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
}

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

private ChartComposite createCPUChart(InstanceVisualizationData instanceVisualizationData,
        Color backgroundColor) {

    final JFreeChart chart = ChartFactory.createStackedXYAreaChart(null, "Time [sec.]", "CPU",
            instanceVisualizationData.getCpuDataSet(), PlotOrientation.VERTICAL, true, true, 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(false);
    xyPlot.getRangeAxis().setRange(0, 100);

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

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

private ChartComposite createMemoryChart(InstanceVisualizationData instanceVisualizationData,
        Color backgroundColor) {

    final JFreeChart chart = ChartFactory.createStackedXYAreaChart(null, "Time [sec.]", "Memory",
            instanceVisualizationData.getMemoryDataSet(), PlotOrientation.VERTICAL, true, true, 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(false);
    xyPlot.getRangeAxis().setRange(0, instanceVisualizationData.getUpperBoundForMemoryChart());

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

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

private ChartComposite createNetworkChart(InstanceVisualizationData instanceVisualizationData,
        Color backgroundColor) {

    final JFreeChart chart = ChartFactory.createStackedXYAreaChart(null, "Time [sec.]", "Network",
            instanceVisualizationData.getNetworkDataSet(), PlotOrientation.VERTICAL, true, true, 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);

    // TODO: Repair auto range for range axis
    xyPlot.getRangeAxis().setAutoRange(false);
    xyPlot.getRangeAxis().setRange(0, 4096);

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

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

private ChartComposite createThreadChart(VertexVisualizationData visualizationData, Color backgroundColor) {

    final JFreeChart chart = ChartFactory.createStackedXYAreaChart(null, "Time [sec.]",
            "Thread Utilization [%]", visualizationData.getThreadDataSet(), PlotOrientation.VERTICAL, true,
            true, false);/*w ww . j av a2s. co m*/

    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);
}