List of usage examples for java.awt Color getGreen
public int getGreen()
From source file:org.jtrfp.trcl.SkySystem.java
/** * @return the suggestedFogColor/*from w w w .ja v a2 s . 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:org.niord.web.wms.WmsProxyServlet.java
/** * Masks out white colour// www . 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:org.jfree.eastwood.GXYPlot.java
/** * Draws the gridlines for the plot, if they are visible. * * @param g2 the graphics device.// w w w .j a v a 2 s. c om * @param dataArea the data area. * @param ticks the ticks. * * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List) */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { // no renderer, no gridlines... if (getRenderer() == null) { return; } // draw the domain grid lines, if any... if (isDomainGridlinesVisible() && this.xAxisStepSize > 0) { Stroke gridStroke = getDomainGridlineStroke(); Paint gridPaint = getDomainGridlinePaint(); if ((gridStroke != null) && (gridPaint != null)) { ValueAxis axis = getDomainAxis(); if (axis != null) { double lower = axis.getRange().getLowerBound(); double upper = axis.getRange().getUpperBound(); double x = lower; while (x <= upper) { Paint paint = gridPaint; if ((x == lower || x == upper) && gridPaint instanceof Color) { Color c = (Color) gridPaint; paint = new Color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha() / 3); } try { setDomainGridlinePaint(paint); getRenderer().drawDomainGridLine(g2, this, getDomainAxis(), dataArea, x); } finally { setDomainGridlinePaint(gridPaint); } x += this.xAxisStepSize; } } } } }
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());//w w w .ja v a 2s . co m green.add(c.getGreen()); blue.add(c.getBlue()); } } }
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 w w .jav a 2 s. 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)); } }
From source file:edu.csun.ecs.cs.multitouchj.ui.control.TexturedControl.java
public void render() { if (!isVisible()) { return;/* ww w. j av a 2 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:util.ui.PictureAreaIcon.java
private boolean colorsInEqualRange(final Color c1, final Color c2) { return Math.abs(c1.getRed() - c2.getRed()) <= MAX_COLOR_DIFF && Math.abs(c1.getBlue() - c2.getBlue()) <= MAX_COLOR_DIFF && Math.abs(c1.getGreen() - c2.getGreen()) <= MAX_COLOR_DIFF; }
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 w w w . j a va2s .com // 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:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.CompassRenderer.java
@Override public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, int seriesIndex) { // compute the right color for the paint int length = GuiUtils.getAvailableColors().length; Color color = GuiUtils.getAvailableColors()[index % length]; // get all the data points int numPoints = dataset.getItemCount(seriesIndex); // set STroke and Paint of the graphics g2.setStroke(new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); g2.setPaint(new Color(color.getRed(), color.getGreen(), color.getBlue(), 175)); // iterate through the points of the dataset for (int i = 0; i < numPoints; i++) { double theta = dataset.getXValue(seriesIndex, i); // the angle at the center double radius = dataset.getYValue(seriesIndex, i); // the frequency Point p0 = plot.translateToJava2D(0, 0, plot.getAxis(), dataArea); Point p1 = plot.translateToJava2D(theta, radius, plot.getAxis(), dataArea); Line2D line = new Line2D.Double(p0, p1); g2.draw(line);//from w ww.j ava 2 s .co m } }
From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java
private Color getTopLight(Color primary) { float hsbVals[] = new float[3]; Color.RGBtoHSB(primary.getRed(), primary.getGreen(), primary.getBlue(), hsbVals); hsbVals[1] = 0.3f;/*from w w w .j a v a 2 s. co m*/ hsbVals[2] = 0.97f; return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]); }