List of usage examples for java.awt Color getRed
public int getRed()
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:net.sf.maltcms.chromaui.foldChangeViewer.tasks.FoldChangeViewLoaderWorker.java
@Override public void run() { ProgressHandle handle = ProgressHandleFactory.createHandle("Creating fold change plot"); try {// w w w. java2 s . 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:de.brendamour.jpasskit.PKPass.java
protected String convertColorToString(final Color color) { if (color != null) { return "rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")"; }//w ww. j a v a2s . c o m return null; }
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;// ww w. j av a 2 s .com 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:omeis.providers.re.HSBStrategy.java
/** * Retrieves the color for each active channels. * // ww w .j a v a2s .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: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: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);// ww w . j av a 2 s . co 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 w w w . j av a 2 s . c o m*/ 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; }
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();// w w w . ja va 2s. 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.fanniemae.ezpie.actions.HighlightScan.java
private boolean checkIfColorInRange(Color colorFound, Color toCompare, int range) { int red = colorFound.getRed() - toCompare.getRed(); int green = colorFound.getGreen() - toCompare.getGreen(); int blue = colorFound.getBlue() - toCompare.getBlue(); if (Math.abs(red) < range && Math.abs(green) < range && Math.abs(blue) < range) return true; return false; }