Example usage for java.awt Color getBlue

List of usage examples for java.awt Color getBlue

Introduction

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

Prototype

public int getBlue() 

Source Link

Document

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

Usage

From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java

private Color getSideDark(Color primary) {
    float hsbVals[] = new float[3];
    Color.RGBtoHSB(primary.getRed(), primary.getGreen(), primary.getBlue(), hsbVals);
    hsbVals[1] = 1.0f;/*from  w w w. j  av a 2 s . c om*/
    hsbVals[2] = 0.3f;
    return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]);
}

From source file:edu.csun.ecs.cs.multitouchj.ui.control.TexturedControl.java

public void render() {
    if (!isVisible()) {
        return;/*from  w  ww.  j  a  va2 s . c o m*/
    }

    Size controlSize = getSize();
    Size imageSize = null;
    if (texture != null) {
        imageSize = texture.getImage().getSize();
    }

    Color color = getColor();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(((float) color.getRed() / 255.0f), ((float) color.getGreen() / 255.0f),
            ((float) color.getBlue() / 255.0f), getOpacity());

    Point position = getOpenGlPosition();
    float halfWidth = (controlSize.getWidth() / 2.0f);
    float halfHeight = (controlSize.getHeight() / 2.0f);
    GL11.glTranslatef(position.getX(), position.getY(), 0.0f);

    float rotation = OpenGlUtility.getOpenGlRotation(getRotation());
    GL11.glRotatef(rotation, 0.0f, 0.0f, 1.0f);

    if (texture != null) {
        GL11.glEnable(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT);
        GL11.glBindTexture(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, texture.getId().intValue());
    } else {
        GL11.glDisable(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT);
    }

    // bl -> br -> tr -> tl
    GL11.glBegin(GL11.GL_QUADS);
    if (texture != null) {
        GL11.glTexCoord2f(0.0f, 0.0f);
    }
    GL11.glVertex3f((-1 * halfWidth), (-1 * halfHeight), 0.0f);

    if (texture != null) {
        GL11.glTexCoord2f(imageSize.getWidth(), 0.0f);
    }
    GL11.glVertex3f(halfWidth, (-1 * halfHeight), 0.0f);

    if (texture != null) {
        GL11.glTexCoord2f(imageSize.getWidth(), imageSize.getHeight());
    }
    GL11.glVertex3f(halfWidth, halfHeight, 0.0f);

    if (texture != null) {
        GL11.glTexCoord2f(0.0f, imageSize.getHeight());
    }
    GL11.glVertex3f((-1 * halfWidth), halfHeight, 0.0f);
    GL11.glEnd();
}

From source file:com.cedarsoft.serialization.serializers.jackson.ColorSerializer.java

@Override
public void serialize(@Nonnull JsonGenerator serializeTo, @Nonnull Color object, @Nonnull Version formatVersion)
        throws IOException, VersionException, JsonProcessingException {
    serializeTo.writeNumberField(PROPERTY_RED, object.getRed());
    serializeTo.writeNumberField(PROPERTY_GREEN, object.getGreen());
    serializeTo.writeNumberField(PROPERTY_BLUE, object.getBlue());
}

From source file:app.springapp.ImageConverter.java

public int getBlockValue(int x1, int y1, int n, boolean flag) {

    BufferedImage im;/*from w w w  .  j a va  2 s .co m*/
    if (flag) {
        im = new_image;

    } else {
        im = org_image;
    }

    int x2 = getX(x1, y1, n);
    int y2 = getY(x1, y1, n);

    int sum = 0;
    int i = x1, j = y1;

    while (i != x2 || j != y2) {

        int rgb = im.getRGB(i, j);
        Color c = new Color(rgb);
        sum += c.getRed() % 2;
        sum += c.getBlue() % 2;
        sum += c.getGreen() % 2;

        if (i + 1 < org_image.getWidth()) {
            i = i + 1;

        } else {
            j++;
            i = 0;
        }

    }

    int rgb = im.getRGB(x2, y2);
    Color c = new Color(rgb);
    sum += c.getRed() % 2;
    sum += c.getBlue() % 2;
    sum += c.getGreen() % 2;

    return sum;

}

From source file:omeis.providers.re.HSBStrategy.java

/**
 * Retrieves the color for each active channels.
 * //from w w  w.  j av  a 2 s  .  c o  m
 * @return the active channel color data.
 */
private List<int[]> getColors() {
    ChannelBinding[] channelBindings = renderer.getChannelBindings();
    List<int[]> colors = new ArrayList<int[]>();

    for (int w = 0; w < channelBindings.length; w++) {
        ChannelBinding cb = channelBindings[w];
        if (cb.getActive()) {
            int[] theNewColor = new int[] { cb.getRed(), cb.getGreen(), cb.getBlue(), cb.getAlpha() };
            colors.add(theNewColor);
        }
    }
    Map<byte[], Integer> overlays = renderer.getOverlays();
    if (overlays != null) {
        for (byte[] overlay : overlays.keySet()) {
            Integer packedColor = overlays.get(overlay);
            Color color = new Color(packedColor);
            colors.add(new int[] { color.getRed(), color.getBlue(), color.getGreen(), color.getAlpha() });
        }
    }
    return colors;
}

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

public ProjectionPlotPanel(ProjectionPlotWindow masterFrame, ProjectionPlotDataset dataset,
        ParameterSet parameters) {/*from   w  w  w.  j av a  2s. c  o  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:com.alkacon.opencms.survey.CmsFormReportingBean.java

/**
 * Returns a lazy initialized map that provides the color of the label for each background color used as a key in the Map.<p> 
 * //from  w w w  . ja va 2 s  .c o  m
 * Dark background color returns white.<p>
 * Light background color returns black.<p>
 * 
 * @return a lazy initialized map
 */
public Map getTextColor() {

    if (m_color == null) {
        m_color = LazyMap.decorate(new HashMap(), new Transformer() {

            /**
             * @see org.apache.commons.collections.Transformer#transform(java.lang.Object)
             */
            public Object transform(Object input) {

                try {
                    // get the color from the given value
                    String value = String.valueOf(input);
                    Color color = Color.decode(value);

                    // look if its a dark color or a light
                    int dezColor = color.getBlue() + color.getGreen() + color.getRed();
                    if (dezColor < SEP_DARK_LIGHT) {
                        return "#FFF";
                    }

                } catch (Exception e) {
                    // NOOP
                }
                return "#000";
            }
        });
    }
    return m_color;
}

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  v  a2s  . c  o m*/
        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:org.niord.web.wms.WmsProxyServlet.java

/**
 * Masks out white colour/*  w w  w .j a  v a2  s .  co m*/
 * @param image the image to mask out
 * @return the resulting image
 */
@SuppressWarnings("unused")
private BufferedImage transformWhiteToTransparent(BufferedImage image) {

    BufferedImage dest = image;
    if (image.getType() != BufferedImage.TYPE_INT_ARGB) {
        dest = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = dest.createGraphics();
        g2.drawImage(image, 0, 0, null);
        g2.dispose();

        image.flush();
    }

    // Mask out the white pixels
    final int width = image.getWidth();
    int[] imgData = new int[width];

    for (int y = 0; y < dest.getHeight(); y++) {
        // fetch a line of data from each image
        dest.getRGB(0, y, width, 1, imgData, 0, 1);
        // apply the mask
        for (int x = 0; x < width; x++) {
            for (Color col : MASKED_COLORS) {
                int colDist = Math.abs(col.getRed() - (imgData[x] >> 16 & 0x000000FF))
                        + Math.abs(col.getGreen() - (imgData[x] >> 8 & 0x000000FF))
                        + Math.abs(col.getBlue() - (imgData[x] & 0x000000FF));
                if (colDist <= COLOR_DIST) {
                    imgData[x] = 0x00FFFFFF & imgData[x];
                }
            }
        }
        // replace the data
        dest.setRGB(0, y, width, 1, imgData, 0, 1);
    }
    return dest;
}

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