Example usage for java.awt Color getRed

List of usage examples for java.awt Color getRed

Introduction

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

Prototype

public int getRed() 

Source Link

Document

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

Usage

From source file:org.jtrfp.trcl.SkySystem.java

/**
 * @return the suggestedFogColor//  ww  w  .j  ava2s.c o  m
 */
public Color getSuggestedFogColor() {
    if (suggestedFogColor == null) {
        if (!hasClouds()) {
            return Color.black;
        } else {
            Color l = getHorizonGradientBottom();
            Color r = cloudTexture.getAverageColor();
            return new Color((l.getRed() + r.getRed()) / 2, (l.getGreen() + r.getGreen()) / 2,
                    (l.getBlue() + r.getBlue()) / 2, (l.getAlpha() + r.getAlpha()) / 2);
        }
    } //end if(suggestedFogColor==null)
    return suggestedFogColor;
}

From source file:net.wastl.rdfdot.base.GraphvizSerializerBase.java

protected String graphvizColor(Color c) {
    return String.format("\"#%02x%02x%02x\"", c.getRed(), c.getGreen(), c.getBlue());
}

From source file:task5.deneme.java

private void getRGBs() {
    for (int i = 0; i < img.getWidth(); i++) {
        for (int j = 0; j < img.getHeight(); j++) {
            Color c = new Color(img.getRGB(i, j));
            red.add(c.getRed());
            green.add(c.getGreen());/*  w w w  .ja  v  a 2 s . c  om*/
            blue.add(c.getBlue());
        }
    }
}

From source file:com.peadargrant.filecheck.web.controllers.CheckController.java

@RequestMapping(method = RequestMethod.POST)
public String performCheck(@RequestParam(value = "assignment", required = true) String assignmentCode,
        @RequestParam("file") MultipartFile file, ModelMap model) throws Exception {

    String assignmentsUrl = serverEnvironment.getPropertyAsString("assignmentsUrl");
    model.addAttribute("assignmentsUrl", assignmentsUrl);

    // bail out if the file is empty
    if (file.isEmpty()) {
        model.addAttribute("message", "file.was.empty");
        return "error";
    }/*from   ww w. j a v a2 s  .  co m*/

    // input stream from file 
    byte[] bytes = file.getBytes();
    String name = file.getOriginalFilename();

    // write to temp dir
    String filePath = System.getProperty("java.io.tmpdir") + "/" + name;
    BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(new File(filePath)));
    stream.write(bytes);
    stream.close();

    // load file
    File inputFile = new File(filePath);

    // get assignment
    Assignment assignment = this.getAssignmentForCode(assignmentCode);
    if (assignment == null) {
        return "assignmentNotFound";
    }
    model.addAttribute(assignment);

    // GUI report table model
    SummaryTableModel summaryTableModel = new SummaryTableModel();
    ReportTableModel reportTableModel = new ReportTableModel(summaryTableModel);

    // checker
    Checker checker = new Checker();
    checker.setReport(reportTableModel);
    checker.runChecks(inputFile, assignment);

    // details for output
    model.addAttribute("fileName", name);
    model.addAttribute("startTime", new java.util.Date());
    String ipAddress = request.getHeader("X-FORWARDED-FOR");
    if (ipAddress == null) {
        ipAddress = request.getRemoteAddr();
    }
    model.addAttribute("remoteIP", ipAddress);

    // final outcome
    model.addAttribute("outcome", summaryTableModel.getFinalOutcome());
    Color finalOutcomeColor = summaryTableModel.getFinalOutcome().getSaturatedColor();
    model.addAttribute("colourr", finalOutcomeColor.getRed());
    model.addAttribute("colourg", finalOutcomeColor.getGreen());
    model.addAttribute("colourb", finalOutcomeColor.getBlue());

    // transformer for parsing tables
    FileCheckWebTableTransformer transformer = new FileCheckWebTableTransformer();

    // summary table headings
    List<String> summaryColumns = transformer.getColumnHeaders(summaryTableModel);
    model.addAttribute("summaryColumns", summaryColumns);

    // summary table
    List summaryContents = transformer.getTableContents(summaryTableModel);
    model.addAttribute("summary", summaryContents);

    // detail table headings
    List<String> detailColumns = transformer.getColumnHeaders(reportTableModel);
    model.addAttribute("detailColumns", detailColumns);

    // detail report table
    List detailContents = transformer.getTableContents(reportTableModel);
    model.addAttribute("detail", detailContents);

    // delete the uploaded file
    inputFile.delete();

    // Return results display
    return "check";
}

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

private Color transp(Color c, double alpha) {
    return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255 * alpha));
}

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);
        }//from w  w  w  .j av a 2 s.  c  o  m
    }
    return outputMap;
}

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

public void render() {
    if (!isVisible()) {
        return;/* w w  w  . j av a2 s. c om*/
    }

    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:org.pentaho.ui.xul.swt.tags.SwtGrid.java

public void setBgcolor(String bgcolor) {
    this.bgcolor = bgcolor;
    Color c = Color.decode(bgcolor);
    grid.setBackground(/* w  w  w  .j ava  2s . com*/
            new org.eclipse.swt.graphics.Color(grid.getDisplay(), c.getRed(), c.getGreen(), c.getBlue()));
    grid.setBackgroundMode(SWT.INHERIT_DEFAULT);
}

From source file:org.jfree.eastwood.GXYPlot.java

/**
 * Draws the gridlines for the plot's primary range axis, if they are
 * visible./*from  w  w w  .ja  va  2s.  c  om*/
 *
 * @param g2  the graphics device.
 * @param area  the data area.
 * @param ticks  the ticks.
 *
 * @see #drawDomainGridlines(Graphics2D, Rectangle2D, List)
 */
protected void drawRangeGridlines(Graphics2D g2, Rectangle2D area, List ticks) {

    // no renderer, no gridlines...
    if (getRenderer() == null) {
        return;
    }

    // draw the range grid lines, if any...
    if (isRangeGridlinesVisible() && this.yAxisStepSize > 0) {
        Stroke gridStroke = getRangeGridlineStroke();
        Paint gridPaint = getRangeGridlinePaint();
        ValueAxis axis = getRangeAxis();
        if (axis != null) {
            double lower = axis.getRange().getLowerBound();
            double upper = axis.getRange().getUpperBound();
            double y = lower;
            while (y <= upper) {
                Paint paint = gridPaint;
                if ((y == lower || y == upper) && gridPaint instanceof Color) {
                    Color c = (Color) gridPaint;
                    paint = new Color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha() / 3);
                }
                getRenderer().drawRangeLine(g2, this, getRangeAxis(), area, y, paint, gridStroke);
                y += this.yAxisStepSize;
            }
        }
    }
}

From source file:org.geotools.renderer.chart.GeometryRenderer.java

void drawGeometry(Geometry g, Graphics2D g2, int series, int item, Rectangle2D dataArea, XYPlot plot,
        ValueAxis domainAxis, ValueAxis rangeAxis) {

    if (g instanceof GeometryCollection) {
        GeometryCollection gc = (GeometryCollection) g;
        for (int i = 0; i < gc.getNumGeometries(); i++) {
            drawGeometry(gc.getGeometryN(i), g2, series, item, dataArea, plot, domainAxis, rangeAxis);
        }//from   w  ww.j a v a2s .c  o  m
    } else if (g instanceof Point) {
        drawCoordinate(((Point) g).getCoordinate(), g2, series, item, dataArea, plot, domainAxis, rangeAxis);
    } else if (g instanceof LineString) {
        g2.draw(new TranslatedLiteShape(g, dataArea, plot, domainAxis, rangeAxis));
    } else {

        if (fillPolygons) {
            Paint p = getSeriesPaint(series);
            if (p instanceof Color) {
                Color c = (Color) p;
                p = new Color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, polygonFillOpacity);
            }
            g2.setPaint(p);
            g2.fill(new TranslatedLiteShape(g, dataArea, plot, domainAxis, rangeAxis));

        }
        g2.setPaint(getSeriesPaint(series));
        g2.draw(new TranslatedLiteShape(g, dataArea, plot, domainAxis, rangeAxis));
    }
}