Example usage for java.awt Color getGreen

List of usage examples for java.awt Color getGreen

Introduction

In this page you can find the example usage for java.awt Color getGreen.

Prototype

public int getGreen() 

Source Link

Document

Returns the green component in the range 0-255 in the default sRGB space.

Usage

From source file:guineu.modules.dataanalysis.PCA.ProjectionPlotPanel.java

public ProjectionPlotPanel(ProjectionPlotWindow masterFrame, ProjectionPlotDataset dataset,
        ParameterSet parameters) {// www . j  a  v  a 2  s  .co  m
    super(null);

    boolean createLegend = true;
    if (dataset.getNumberOfGroups() > 20) {
        createLegend = false;
    }

    chart = ChartFactory.createXYAreaChart("", dataset.getXLabel(), dataset.getYLabel(), dataset,
            PlotOrientation.VERTICAL, createLegend, false, false);
    chart.setBackgroundPaint(Color.white);

    setChart(chart);

    // title

    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);
    chart.removeSubtitle(chartTitle);

    // disable maximum size (we don't want scaling)
    setMaximumDrawWidth(Integer.MAX_VALUE);
    setMaximumDrawHeight(Integer.MAX_VALUE);

    // set the plot properties
    plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    // set grid properties
    plot.setDomainGridlinePaint(gridColor);
    plot.setRangeGridlinePaint(gridColor);

    // set crosshair (selection) properties
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    plot.setForegroundAlpha(dataPointAlpha);

    NumberFormat numberFormat = NumberFormat.getNumberInstance();

    // set the X axis (component 1) properties
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setNumberFormatOverride(numberFormat);

    // set the Y axis (component 2) properties
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setNumberFormatOverride(numberFormat);

    plot.setDataset(dataset);

    spotRenderer = new ProjectionPlotRenderer(plot, dataset);
    itemLabelGenerator = new ProjectionPlotItemLabelGenerator(parameters);
    spotRenderer.setBaseItemLabelGenerator(itemLabelGenerator);
    spotRenderer.setBaseItemLabelsVisible(true);
    spotRenderer.setBaseToolTipGenerator(new ProjectionPlotToolTipGenerator(parameters));
    plot.setRenderer(spotRenderer);

    // Setup legend
    if (createLegend) {
        LegendItemCollection legendItemsCollection = new LegendItemCollection();
        for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) {
            Object paramValue = dataset.getGroupParameterValue(groupNumber);
            if (paramValue == null) {
                // No parameter value available: search for raw data files
                // within this group, and use their names as group's name
                String fileNames = new String();
                for (int itemNumber = 0; itemNumber < dataset.getItemCount(0); itemNumber++) {
                    String rawDataFile = dataset.getRawDataFile(itemNumber);
                    if (dataset.getGroupNumber(itemNumber) == groupNumber) {
                        fileNames = fileNames.concat(rawDataFile);
                    }
                }
                if (fileNames.length() == 0) {
                    fileNames = "Empty group";
                }

                paramValue = fileNames;
            }
            Color nextColor = (Color) spotRenderer.getGroupPaint(groupNumber);
            Color groupColor = new Color(nextColor.getRed(), nextColor.getGreen(), nextColor.getBlue(),
                    (int) Math.round(255 * dataPointAlpha));
            legendItemsCollection.add(new LegendItem(paramValue.toString(), "-", null, null,
                    spotRenderer.getDataPointsShape(), groupColor));
        }
        plot.setFixedLegendItems(legendItemsCollection);
    } else {

        Dataset legends = new SimpleBasicDataset("Legends");
        legends.addColumnName("Samples");

        for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) {
            Object paramValue = dataset.getGroupParameterValue(groupNumber);
            if (paramValue == null) {
                // No parameter value available: search for raw data files
                // within this group, and use their names as group's name
                String fileNames = new String();
                for (int itemNumber = 0; itemNumber < dataset.getItemCount(0); itemNumber++) {
                    String rawDataFile = dataset.getRawDataFile(itemNumber);
                    if (dataset.getGroupNumber(itemNumber) == groupNumber) {
                        fileNames = fileNames.concat(rawDataFile.toString());
                    }
                }
                if (fileNames.length() == 0) {
                    fileNames = "Empty group";
                }

                paramValue = fileNames;
            }

            Color nextColor = (Color) spotRenderer.getGroupPaint(groupNumber);
            Color groupColor = new Color(nextColor.getRed(), nextColor.getGreen(), nextColor.getBlue(),
                    (int) Math.round(255 * dataPointAlpha));

            PeakListRow row = new SimplePeakListRowOther();
            row.setPeak("Samples", paramValue.toString());
            legends.addRow(row);
            legends.addRowColor(groupColor);
        }

        GuineuCore.getDesktop().AddNewFile(legends);
    }

}

From source file:ro.nextreports.server.web.dashboard.indicator.IndicatorWidgetView.java

@SuppressWarnings("unchecked")
public IndicatorWidgetView(String id, WidgetModel model, boolean zoom, Map<String, Object> urlQueryParameters) {
    super(id, model, zoom);

    final String widgetId = model.getWidgetId();

    final IndicatorModel indicatorModel = new IndicatorModel(widgetId, urlQueryParameters);

    setModel(new CompoundPropertyModel(indicatorModel));

    add(new Label("error", new Model<String>()) {

        private static final long serialVersionUID = 1L;

        @Override/*from w  w w .  j av  a2  s . com*/
        protected void onInitialize() {
            super.onInitialize();

            if (indicatorModel.getObject() == null) {
                if (indicatorModel.getError() instanceof NoDataFoundException) {
                    setDefaultModelObject("No Data Found");
                } else {
                    setDefaultModelObject(ExceptionUtils.getRootCauseMessage(indicatorModel.getError()));
                }
            }
        }

        @Override
        public boolean isVisible() {
            return indicatorModel.hasError();
        }

    });

    container = new WebMarkupContainer("indicator") {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !indicatorModel.hasError();
        }

    };
    container.setOutputMarkupId(true);
    // indicator background color is set to the entire container
    Color background = indicatorModel.getObject().getBackground();
    String s = "background-color: rgb(" + background.getRed() + "," + background.getGreen() + ","
            + background.getBlue() + ");";
    container.add(new AttributeAppender("style", s));
    add(container);

    add(new HTML5Behavior(zoom, indicatorModel));

    container.add(new EmptyPanel("image"));

    //IndicatorHTML5Panel panel = new IndicatorHTML5Panel("image", width, height, indicatorModel);
    //IndicatorImagePanel panel = new IndicatorImagePanel("image", width, height, indicatorModel);
    //container.add(panel);
}

From source file:net.sf.maltcms.chromaui.foldChangeViewer.tasks.FoldChangeViewLoaderWorker.java

@Override
public void run() {
    ProgressHandle handle = ProgressHandleFactory.createHandle("Creating fold change plot");
    try {//from w  ww .  j a  va  2s. c om
        handle.setDisplayName("Loading fold change elements");//+new File(this.files.getResourceLocation()).getName());
        handle.start(5);
        handle.progress("Reading settings", 1);
        RTUnit rtAxisUnit = RTUnit.valueOf(sp.getProperty("rtAxisUnit", "SECONDS"));
        handle.progress("Retrieving data", 2);
        XYShapeRenderer renderer = new XYShapeRenderer() {

            @Override
            protected Paint getPaint(XYDataset dataset, int series, int item) {
                double x = dataset.getXValue(series, item);
                double y = dataset.getYValue(series, item);
                if (Math.abs(x) < 1.0) {
                    Paint p = super.getPaint(dataset, series, item);
                    if (p instanceof Color) {
                        Color color = (Color) p;
                        float[] values = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(),
                                new float[3]);
                        Color hsb = new Color(
                                Color.HSBtoRGB(values[0], (float) Math.max(0.1, values[1] - 0.9), values[2]));
                        return new Color(hsb.getRed(), hsb.getGreen(), hsb.getBlue(), 64);
                    }
                }
                return super.getPaint(dataset, series, item);
            }

        };
        renderer.setAutoPopulateSeriesFillPaint(true);
        renderer.setAutoPopulateSeriesOutlinePaint(true);
        renderer.setBaseCreateEntities(true);
        handle.progress("Building plot", 3);
        XYPlot plot = new XYPlot(dataset, new NumberAxis("log2 fold change"), new NumberAxis("-log10 p-value"),
                renderer);
        BasicStroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f,
                new float[] { 5.0f }, 0.0f);
        ValueMarker marker = new ValueMarker(-Math.log10(0.05), Color.RED, dashed);
        marker.setLabel("p-value=0.05");
        marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
        marker.setLabelOffset(new RectangleInsets(UnitType.ABSOLUTE, 0, 50, 10, 0));
        marker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
        marker.setLabelPaint(Color.LIGHT_GRAY);
        plot.addRangeMarker(marker);

        Font font1 = new Font("SansSerif", Font.PLAIN, 12);
        SelectionAwareXYTooltipGenerator tooltipGenerator = cvtc.getLookup()
                .lookup(SelectionAwareXYTooltipGenerator.class);
        if (tooltipGenerator == null) {
            tooltipGenerator = new SelectionAwareXYTooltipGenerator(tooltipGenerator) {
                @Override
                public String createSelectionAwareTooltip(XYDataset xyd, int i, int i1) {
                    FoldChangeDataset dataset = (FoldChangeDataset) xyd;
                    FoldChangeElement fce = dataset.getNamedElementProvider().get(i).get(i1);
                    StringBuilder sb = new StringBuilder();
                    sb.append("<html>");
                    sb.append(fce.getPeakGroup().getMajorityDisplayName());
                    sb.append("<br>");
                    sb.append("log2 fold change=");
                    sb.append(fce.getFoldChange());
                    sb.append("<br>");
                    sb.append("p-value=");
                    sb.append(Math.pow(10, -fce.getPvalue()));
                    sb.append("</html>");
                    return sb.toString();
                }
            };
        }
        tooltipGenerator.setXYToolTipGenerator(new XYToolTipGenerator() {
            @Override
            public String generateToolTip(XYDataset xyd, int i, int i1) {
                Comparable comp = xyd.getSeriesKey(i);
                double x = xyd.getXValue(i, i1);
                double y = xyd.getYValue(i, i1);
                StringBuilder sb = new StringBuilder();
                sb.append("<html>");
                sb.append(comp);
                sb.append("<br>");
                sb.append("log2 fold change=");
                sb.append(x);
                sb.append("<br>");
                sb.append("p-value=");
                sb.append(sb.append(Math.pow(10, -y)));
                sb.append("</html>");
                return sb.toString();
            }
        });
        plot.getRenderer().setBaseToolTipGenerator(tooltipGenerator);
        handle.progress("Configuring plot", 4);
        configurePlot(plot, rtAxisUnit);
        final FoldChangeViewPanel cmhp = cvtc.getLookup().lookup(FoldChangeViewPanel.class);
        Range domainRange = null;
        Range valueRange = null;
        if (cmhp != null) {
            XYPlot xyplot = cmhp.getPlot();
            if (xyplot != null) {
                ValueAxis domain = xyplot.getDomainAxis();
                domainRange = domain.getRange();
                ValueAxis range = xyplot.getRangeAxis();
                valueRange = range.getRange();
            }
        }

        if (domainRange != null) {
            plot.getDomainAxis().setRange(domainRange);
        }
        if (valueRange != null) {
            Logger.getLogger(getClass().getName()).info("Setting previous value range!");
        }
        handle.progress("Adding plot to panel", 5);
        final XYPlot targetPlot = plot;
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                final FoldChangeViewPanel cmhp = cvtc.getLookup().lookup(FoldChangeViewPanel.class);
                cmhp.setPlot(targetPlot);
                cvtc.requestActive();
            }
        });
    } finally {
        handle.finish();
    }
}

From source file:net.sourceforge.processdash.ev.ui.chart.RangeXYItemRenderer.java

private double calcAlpha(Color c) {
    // convert the color to a black-and-white value.  0=black, 1=white
    double gray = (0.30 * c.getRed() + 0.59 * c.getGreen() + 0.11 * c.getBlue()) / 255;
    // the brighter the color, the higher an alpha value we need.
    // (keep bright colors from disappearing into the white background)
    // the darker the color, the lower an alpha value we need.
    // (keep dark colors from hiding the trend line)
    double result = 0.85 * 0.123 / (1 - gray);
    if (result < 0.3)
        return 0.3;
    if (result > 0.8)
        return 0.8;
    return result;
}

From source file:io.github.minecraftgui.models.network.packets.PacketInitClient.java

@Override
public JSONObject toJSON() {
    JSONObject jsonObject = new JSONObject();
    JSONArray fonts = new JSONArray();
    JSONArray images = new JSONArray();
    JSONArray fontsToGenerate = new JSONArray();

    for (String font : this.fonts)
        fonts.put(font);/*ww  w  .ja  v a  2s . co  m*/

    for (Map.Entry pairs : this.images.entrySet())
        images.put(new JSONObject().put(NetworkController.URL, pairs.getKey()).put(NetworkController.NAME,
                pairs.getValue()));

    for (Map.Entry pairs : this.fontsGenerate.entrySet()) {
        JSONObject font = new JSONObject();
        JSONArray colorList = new JSONArray();

        for (Map.Entry pairs1 : ((HashMap<Color, Integer>) pairs.getValue()).entrySet()) {
            JSONObject colorObj = new JSONObject();
            JSONArray sizeList = new JSONArray();
            Color color = (Color) pairs1.getKey();
            ArrayList<Integer> sizes = (ArrayList) pairs1.getValue();

            for (Integer size : sizes)
                sizeList.put(size);

            colorObj.put(NetworkController.R, color.getRed());
            colorObj.put(NetworkController.G, color.getGreen());
            colorObj.put(NetworkController.B, color.getBlue());
            colorObj.put(NetworkController.A, color.getAlpha());
            colorObj.put(NetworkController.LIST, sizeList);
            colorList.put(colorObj);
        }

        font.put(NetworkController.NAME, pairs.getKey());
        font.put(NetworkController.LIST, colorList);
        fontsToGenerate.put(font);
    }

    jsonObject.put(NetworkController.FONTS, fonts);
    jsonObject.put(NetworkController.IMAGES, images);
    jsonObject.put(NetworkController.FONTS_TO_GENERATE, fontsToGenerate);

    return jsonObject;
}

From source file:org.kalypso.model.wspm.pdb.wspm.CheckoutRoughnessUpdater.java

private void updateColor() {
    final String colorAsString = m_roughness.getColor();
    if (StringUtils.isEmpty(colorAsString))
        return;/*from w  w  w  .  ja v  a 2  s.  c om*/
    final Color color = Color.decode(colorAsString);
    final RGB oldRGB = m_roughnessClass.getColor();
    final Color oldColor = new Color(oldRGB.red, oldRGB.green, oldRGB.blue);
    if (ObjectUtils.equals(color, oldColor))
        return;

    final RGB newRGB = new RGB(color.getRed(), color.getGreen(), color.getBlue());
    m_roughnessClass.setColor(newRGB);
    m_changed = true;
}

From source file:nz.ac.massey.cs.gql4jung.browser.queryviews.GraphBasedQueryView.java

private Color makeTransparent(Color c, int alpha) {
    return new Color(c.getRed(), c.getGreen(), c.getBlue(), alpha);
}

From source file:de.brendamour.jpasskit.PKPass.java

protected String convertColorToString(final Color color) {
    if (color != null) {
        return "rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")";
    }/*from  ww w  .j ava  2 s  .  com*/
    return null;
}

From source file:jmemorize.gui.swing.panels.CardCounterPanel.java

private ExtentProgressBar buildExtentProgressBar() {
    ExtentProgressBar bar = new ExtentProgressBar();

    bar.setForeground(Color.BLUE);
    Color grn = Color.GREEN.darker();
    Color transparentGreen = new Color(grn.getRed(), grn.getGreen(), grn.getBlue(), 128);
    bar.setExtentForeground(transparentGreen);
    bar.setExtent(0);//from  ww  w .  ja  v a 2 s  .c o  m

    return bar;
}

From source file:org.kalypso.model.wspm.pdb.wspm.CheckoutVegetationUpdater.java

private void updateColor() {

    final String colorAsString = m_vegetation.getColor();
    if (StringUtils.isEmpty(colorAsString))
        return;//from  www . j av a  2  s.c  om
    final Color color = Color.decode(colorAsString);
    final RGB oldRGB = m_vegetationClass.getColor();
    final Color oldColor = new Color(oldRGB.red, oldRGB.green, oldRGB.blue);
    if (ObjectUtils.equals(color, oldColor))
        return;

    final RGB newRGB = new RGB(color.getRed(), color.getGreen(), color.getBlue());
    m_vegetationClass.setColor(newRGB);
    m_changed = true;
}