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: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 ww . ja  v  a2s  . c  o m*/
        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:gr.iti.mklab.reveal.forensics.util.Util.java

public static double[][][] getImageDifferenceD(BufferedImage image1, BufferedImage image2) {
    Color tmpColor1, tmpColor2;
    int width = image1.getWidth();
    int height = image1.getHeight();
    double red_temp, green_temp, blue_temp;

    double[][][] outputMap = new double[3][width][height];
    for (int ii = 0; ii < width; ii++) {
        for (int jj = 0; jj < height; jj++) {
            tmpColor1 = new Color(image1.getRGB(ii, jj));
            tmpColor2 = new Color(image2.getRGB(ii, jj));
            red_temp = tmpColor1.getRed() - tmpColor2.getRed();
            green_temp = tmpColor1.getGreen() - tmpColor2.getGreen();
            blue_temp = tmpColor1.getBlue() - tmpColor2.getBlue();
            outputMap[0][ii][jj] = (double) (red_temp) * (red_temp);
            outputMap[1][ii][jj] = (double) (green_temp) * (green_temp);
            outputMap[2][ii][jj] = (double) (blue_temp) * (blue_temp);
        }/*w w w. j  a  v a 2  s.c  o  m*/
    }
    return outputMap;
}

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

public PacketSetAttribute(Component component, Shape shape, State state, double percentage, long time,
        Color value) {
    this.component = component;
    this.shape = shape;
    this.state = state;
    this.percentage = percentage;
    this.time = time;
    this.value = new JSONObject().put(NetworkController.R, value.getRed())
            .put(NetworkController.G, value.getGreen()).put(NetworkController.B, value.getBlue())
            .put(NetworkController.A, value.getAlpha());
}

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

public PacketSetAttribute(Component component, State state, Color value) {
    this.component = component;
    this.shape = component.getShape();
    this.state = state;
    this.percentage = 1;
    this.time = 0;
    this.value = new JSONObject().put(NetworkController.R, value.getRed())
            .put(NetworkController.G, value.getGreen()).put(NetworkController.B, value.getBlue())
            .put(NetworkController.A, value.getAlpha());
}

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);/*from   ww w . j  a va2  s .c o 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:net.sf.maltcms.chromaui.charts.GradientPaintScale.java

/**
 *
 * @param f/*from  ww w  . j a v a2s  . co m*/
 */
public void saveGradientPaintScale(File f) {
    try (BufferedWriter bw = new BufferedWriter(new FileWriter(f))) {
        double lowerBound = getLowerBound();
        double upperBound = getUpperBound();
        double incr = (upperBound - lowerBound) / 256.0d;
        double value = lowerBound;
        for (int i = 0; i < 256; i++) {
            Paint p = getPaint(value);
            if (p instanceof Color) {
                Color c = (Color) p;
                bw.write(c.getRed() + "\t" + c.getGreen() + "\t" + c.getBlue());
                bw.newLine();
            }
            lowerBound += incr;
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}

From source file:pdi.HistogramaRGB.java

public int[] pegaPixels(File file) {
    BufferedImage img = pegaImagem();
    int[] rgb = new int[w * h];

    for (int i = 0; i < w; i++)
        for (int j = 0; j < h; j++) {
            rgb[i * j] = img.getRGB(i, j);
        }/*from  w  w w. jav  a  2  s .  com*/

    for (int i = 0; i < rgb.length; i++) {
        Color c = new Color(rgb[i]);
        System.out.println("Vermelho: " + c.getRed());
    }
    for (int i = 0; i < rgb.length; i++) {
        Color c = new Color(rgb[i]);
        System.out.println("Vermelho: " + c.getGreen());
    }
    for (int i = 0; i < rgb.length; i++) {
        Color c = new Color(rgb[i]);
        System.out.println("Vermelho: " + c.getBlue());
    }

    return rgb;
}

From source file:gr.iti.mklab.reveal.forensics.maps.dwnoisevar.DWNoiseVarExtractor.java

public void getNoiseMap() throws IOException {

    BufferedImage img = inputImage;

    int imWidth, imHeight;
    if (img.getWidth() % 2 == 0) {
        imWidth = img.getWidth();/*from  www  .  java 2 s  . c  om*/
    } else {
        imWidth = (img.getWidth() - 1);
    }
    if (img.getHeight() % 2 == 0) {
        imHeight = img.getHeight();
    } else {
        imHeight = (img.getHeight() - 1);
    }

    int columnFilterScale = (int) (Math.log(imHeight) / Math.log(2)) - 1;
    int rowFilterScale = (int) (Math.log(imWidth) / Math.log(2)) - 1;

    double[][] imgYAsArray = new double[imWidth][imHeight];
    double[][] filteredImgYAsArray = new double[imWidth][imHeight / 2];
    double[][] doubleFilteredImgYAsArray = new double[imWidth / 2][imHeight / 2];
    double[] imgColumn, imgRow;
    Color tmpcolor;
    double R, G, B;

    for (int ii = 0; ii < imWidth; ii++) {
        for (int jj = 0; jj < imHeight; jj++) {
            tmpcolor = new Color(img.getRGB(ii, jj));
            R = tmpcolor.getRed();
            G = tmpcolor.getGreen();
            B = tmpcolor.getBlue();
            imgYAsArray[ii][jj] = 0.2989 * R + 0.5870 * G + 0.1140 * B;
        }
    }

    double[] waveletColumn;
    RealMatrix rm = new Array2DRowRealMatrix(imgYAsArray);
    for (int ii = 0; ii < imWidth; ii++) {
        try {
            imgColumn = new double[imHeight];
            imgColumn = rm.getRow(ii);
            //Long startTime1 = System.currentTimeMillis();  
            waveletColumn = DWT.transform(imgColumn, Wavelet.Daubechies, 8, columnFilterScale,
                    DWT.Direction.forward);
            System.arraycopy(waveletColumn, imHeight / 2, filteredImgYAsArray[ii], 0, imHeight / 2);
        } catch (Exception ex) {
            Logger.getLogger(DWNoiseVarExtractor.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    double[] waveletRow;
    RealMatrix rm2 = new Array2DRowRealMatrix(filteredImgYAsArray);
    for (int jj = 0; jj < imHeight / 2; jj++) {
        try {
            imgRow = new double[imWidth];
            imgRow = rm2.getColumn(jj);
            waveletRow = DWT.transform(imgRow, Wavelet.Daubechies, 8, rowFilterScale, DWT.Direction.forward);
            for (int ii = 0; ii < imWidth / 2; ii++) {
                doubleFilteredImgYAsArray[ii][jj] = waveletRow[ii + imWidth / 2];
            }
        } catch (Exception ex) {
            Logger.getLogger(DWNoiseVarExtractor.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    int blockSize = 8;
    double[][] blockNoiseVar = Util.blockNoiseVar(doubleFilteredImgYAsArray, blockSize);

    int medianFilterSize = 7;
    if (medianFilterSize > blockNoiseVar.length) {
        medianFilterSize = blockNoiseVar.length - 1;
    }
    if (medianFilterSize > blockNoiseVar[0].length) {
        medianFilterSize = blockNoiseVar[0].length - 1;
    }
    if (medianFilterSize < 5) {
        minNoiseValue = 0;
        maxNoiseValue = 0;
        noiseMap = new float[1][1];
        noiseMap[0][0] = 0;
        double[][] artificialOutput = new double[1][1];
        artificialOutput[0][0] = 0;
        BufferedImage outputImage = Util.visualizeWithJet(artificialOutput);
        displaySurface = outputImage;
        return;
    }

    float[][] outBlockMap = Util.medianFilterSingleChannelImage(blockNoiseVar, medianFilterSize);

    minNoiseValue = Util.minDouble2DArray(outBlockMap);
    maxNoiseValue = Util.maxDouble2DArray(outBlockMap);
    noiseMap = outBlockMap;
    double[][] normalizedMap = Util.normalizeIm(outBlockMap);
    BufferedImage outputImage = Util.visualizeWithJet(normalizedMap);
    // output
    displaySurface = outputImage;
}

From source file:com.hygenics.imaging.ImageCleanup.java

public byte[] reaverage(double factor, byte[] ibytes) {
    // tone red coloring
    BufferedImage color = BufferImage(ibytes);

    if (color != null) {
        BufferedImage averaged = new BufferedImage(color.getWidth(), color.getHeight(),
                BufferedImage.TYPE_INT_RGB);

        for (int i = 0; i < color.getWidth(); i++) {
            for (int j = 0; j < color.getHeight(); j++) {
                Color c = new Color(color.getRGB(i, j));

                averaged.setRGB(i, j,/*ww w  .  j  a v  a2 s  .  co  m*/
                        new Color((int) Math.round(c.getRed() / factor), c.getGreen(), c.getBlue()).getRGB());
            }
        }

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        // convert to jpeg for compression
        try {
            // use apache to read to a buffered image with certain metadata
            // and then convert to a jpg
            ImageIO.write(averaged, "jpg", bos);
            return ibytes = bos.toByteArray();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return ibytes;

}

From source file:org.polymap.core.data.image.WmsRenderProcessor.java

protected void getMap(GetMapRequest request, ProcessorContext context) throws Exception {
    int width = request.getWidth();
    int height = request.getHeight();
    BoundingBox bbox = request.getBoundingBox();
    log.debug("bbox=" + bbox + ", imageSize=" + width + "x" + height);

    Set<ILayer> layers = context.getLayers();
    IService service = context.getService();

    // skip if no layers are visible
    if (layers.isEmpty()) {
        log.debug("no layers.");
    }/* www.  j  a v  a 2  s  .com*/

    WebMapServer wms = service.resolve(WebMapServer.class, null);
    org.geotools.data.wms.request.GetMapRequest getMap = wms.createGetMapRequest();

    getMap.setFormat(request.getFormat());
    getMap.setDimensions(width, height);
    getMap.setTransparent(true);
    Color color = request.getBgColor();
    if (color != null) {
        getMap.setBGColour(String.format("#%02X%02X%02X", color.getRed(), color.getGreen(), color.getBlue()));
    }
    //getMap.setBGColour( "0xFFFFFF" );

    //CRSEnvelope envelop = calculateRequestBBox( )
    // CRSEnvelope envelop = new CRSEnvelope( "EPSG:31468", 4621529.925,5657790.683333333,4623149.175,5659484.016666667 );
    BoundingBox requestBBox = bbox;
    getMap.setBBox(requestBBox.getMinX() + "," + requestBBox.getMinY() //$NON-NLS-1$
            + "," + requestBBox.getMaxX() //$NON-NLS-1$
            + "," + requestBBox.getMaxY()); //$NON-NLS-1$
    // FIXME hack for LRA to support EPSG3857, see GeoServerWms
    // check to see if backend wms supports 900913 or not
    String srs = request.getCRS();
    //String srs = request.getCRS().equals( "EPSG:900913" )
    //        ? "EPSG:3857" : request.getCRS(); 
    getMap.setSRS(srs);

    //getMap.setBBox(  );

    //request.setSRS( "EPSG:4326" );
    //request.setBBox( "-131.13151509433965,46.60532747661736,-117.61620566037737,56.34191403281659" );
    // Note: you can look at the layer metadata to determine a layer's bounding box for a SRS

    //        Map sortedLayersMap = MultiValueMap.decorate( new TreeMap() );
    //        for (Iterator it=visibleLayers.referencedLayers(); it.hasNext();) {
    //            Layer layer = (Layer)availableLayers.get( it.next() );
    //            Integer layerOrder = (Integer)layerOrderMap.get( layer.getName() );
    //            // reverse order; request.addLayer() works that way
    //            Integer key = Integer.valueOf( Integer.MAX_VALUE - layerOrder.intValue() );
    //            sortedLayersMap.put( key, layer );
    //        }
    for (ILayer layer : layers) {
        IGeoResource geores = layer.getGeoResource();
        Layer wmsLayer = geores.resolve(org.geotools.data.ows.Layer.class, null);
        getMap.addLayer(wmsLayer);
        log.debug("    request: layer: " + layer.getLabel());
    }
    log.debug("    WMS URL:" + getMap.getFinalURL());

    InputStream in = null;
    try {
        long start = System.currentTimeMillis();
        GetMapResponse wmsResponse = wms.issueRequest(getMap);
        log.debug("Got repsonse (" + (System.currentTimeMillis() - start) + "ms). providing data: "
                + wmsResponse.getContentType());

        in = wmsResponse.getInputStream();
        int count = 0;
        byte[] buf = new byte[8 * 1024];
        for (int c = in.read(buf); c != -1; c = in.read(buf)) {
            context.sendResponse(new EncodedImageResponse(buf, c));
            buf = new byte[8 * 2048];
            //log.debug( "    --->data sent: " + c );
            count += c;
        }
        if (count == 0) {
            throw new IOException("WMSResponse is empty.");
        }
        context.sendResponse(ProcessorResponse.EOP);
        log.debug("...all data send.");
    } finally {
        IOUtils.closeQuietly(in);
    }
}