List of usage examples for java.awt Color equals
public boolean equals(Object obj)
From source file:net.sf.maltcms.chromaui.charts.overlay.Peak1DHeatmapOverlay.java
/** * * @param g2/*from w w w. j ava 2s .c o m*/ * @param chartPanel */ @Override public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) { if (isVisible()) { Shape savedClip = g2.getClip(); Rectangle2D dataArea = chartPanel.getScreenDataArea(); g2.clip(dataArea); JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); RectangleEdge xAxisEdge = plot.getDomainAxisEdge(); ValueAxis yAxis = plot.getRangeAxis(); RectangleEdge yAxisEdge = plot.getRangeAxisEdge(); Color c = g2.getColor(); Color fillColor = peakAnnotations.getColor(); if (fillColor == null || fillColor.equals(Color.WHITE) || fillColor.equals(new Color(255, 255, 255, 0))) { Logger.getLogger(getClass().getName()) .info("Peak annotation color was null or white, using color from treatment group!"); fillColor = peakAnnotations.getChromatogram().getTreatmentGroup().getColor(); } g2.setColor(ChartCustomizer.withAlpha(fillColor, 0.5f)); for (IPeakAnnotationDescriptor descr : peakAnnotations.getMembers()) { double x = descr.getApexTime(); double xx = xAxis.valueToJava2D(x, dataArea, xAxisEdge); double width = xAxis.valueToJava2D(1, dataArea, xAxisEdge); double mzRange = (descr.getMassValues()[descr.getMassValues().length - 1] - descr.getMassValues()[0]); double y = mzRange / 2.0d; double yy = yAxis.valueToJava2D(y, dataArea, yAxisEdge); double height = yAxis.valueToJava2D(mzRange, dataArea, yAxisEdge); AffineTransform at = AffineTransform.getTranslateInstance(xx, yy); at.concatenate(AffineTransform.getTranslateInstance(-x, -y)); Rectangle2D.Double r = new Rectangle2D.Double(xx - (width / 2.0d), yy, width, height); g2.fill(at.createTransformedShape(r)); } g2.setColor(c); g2.setClip(savedClip); } }
From source file:biogenesis.Organism.java
private static int getTypeColor(Color c) { if (c.equals(Color.RED) || c.equals(Utils.ColorDARK_RED)) return RED; if (c.equals(Color.GREEN) || c.equals(Utils.ColorDARK_GREEN)) return GREEN; if (c.equals(Color.CYAN) || c.equals(Utils.ColorDARK_CYAN)) return CYAN; if (c.equals(Color.BLUE) || c.equals(Utils.ColorDARK_BLUE)) return BLUE; if (c.equals(Color.MAGENTA) || c.equals(Utils.ColorDARK_MAGENTA)) return MAGENTA; if (c.equals(Color.PINK) || c.equals(Utils.ColorDARK_PINK)) return PINK; if (c.equals(Color.ORANGE) || c.equals(Utils.ColorDARK_ORANGE)) return ORANGE; if (c.equals(Color.WHITE) || c.equals(Utils.ColorDARK_WHITE)) return WHITE; if (c.equals(Color.GRAY) || c.equals(Utils.ColorDARK_GRAY)) return GRAY; if (c.equals(Color.YELLOW) || c.equals(Utils.ColorDARK_YELLOW)) return YELLOW; if (c.equals(Utils.ColorBROWN)) return BROWN; return NOCOLOR; }
From source file:ExtendedTableCellRenderer.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { super.setForeground(table.getSelectionForeground()); super.setBackground(table.getSelectionBackground()); } else {/*from ww w .j av a2s. c o m*/ super.setForeground((unselectedForeground != null) ? unselectedForeground : table.getForeground()); super.setBackground((unselectedBackground != null) ? unselectedBackground : table.getBackground()); } setFont(table.getFont()); if (hasFocus) { setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); if (table.isCellEditable(row, column)) { super.setForeground(UIManager.getColor("Table.focusCellForeground")); super.setBackground(UIManager.getColor("Table.focusCellBackground")); } } else { setBorder(NO_FOCUS_BORDER); } setValue(value); Color background = getBackground(); boolean colorMatch = (background != null) && (background.equals(table.getBackground())) && table.isOpaque(); setOpaque(!colorMatch); return this; }
From source file:net.sf.maltcms.chromaui.charts.overlay.Peak2DOverlay.java
/** * * @param g2/*from w w w. j ava2s .c om*/ * @param chartPanel */ @Override public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) { if (isVisible()) { JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); if (plot.getDataset() instanceof Chromatogram2DDataset) { dataset = (ADataset2D<IChromatogram2D, IScan2D>) plot.getDataset(); } else { throw new IllegalArgumentException("Unsupported dataset type: " + plot.getDataset().getClass()); } if (shapes == null) { shapes = renderer.generatePeak2DShapes(peakAnnotations, dataset, non2DPeaks); } else { XYDataset xyds = plot.getDataset(); if (xyds != dataset || drawOutlines) { shapes = renderer.generatePeak2DShapes(peakAnnotations, dataset, non2DPeaks); } } Color fillColor = peakAnnotations.getColor(); if (fillColor == null || fillColor.equals(Color.WHITE) || fillColor.equals(new Color(255, 255, 255, 0))) { Logger.getLogger(getClass().getName()) .fine("Peak annotation color was null or white, using color from treatment group!"); fillColor = peakAnnotations.getChromatogram().getTreatmentGroup().getColor(); } if (isVisible()) { renderer.draw(g2, chartPanel, plot, fillColor, shapes, selectedPeaks); } } }
From source file:com.seleniumtests.it.driver.TestBrowserSnapshot.java
/** * Test page contains fixed header (yellow) and footer (orange) of 5 pixels height. Detect how many * pixels of these colors are present in picture * Also count red pixels which is a line not to remove when cropping * @param picture//from w ww . j av a 2s .co m * @return * @throws IOException */ private int[] getHeaderAndFooterPixels(File picture) throws IOException { BufferedImage image = ImageIO.read(picture); int topPixels = 0; int bottomPixels = 0; int securityLine = 0; for (int height = 0; height < image.getHeight(); height++) { Color color = new Color(image.getRGB(0, height)); if (color.equals(Color.YELLOW)) { topPixels++; } else if (color.equals(Color.ORANGE)) { bottomPixels++; } else if (color.equals(Color.RED) || color.equals(Color.GREEN)) { securityLine++; } } return new int[] { topPixels, bottomPixels, securityLine }; }
From source file:com.seleniumtests.it.driver.TestBrowserSnapshot.java
/** * Read the capture file to detect dimension * It assumes that picture background is white and counts the number of white pixels in width and height (first column and first row) * @return/*from w w w . j av a 2 s .co m*/ * @throws IOException */ private Dimension getViewPortDimension(File picture) throws IOException { BufferedImage image = ImageIO.read(picture); int width = 0; int height = 0; for (width = 0; width < image.getWidth(); width++) { Color color = new Color(image.getRGB(width, 0)); if (!(color.equals(Color.WHITE) || color.equals(Color.YELLOW) || color.equals(Color.ORANGE) || color.equals(Color.GREEN) || color.equals(Color.RED))) { break; } } for (height = 0; height < image.getHeight(); height++) { Color color = new Color(image.getRGB(5, height)); if (!(color.equals(Color.WHITE) || color.equals(Color.YELLOW) || color.equals(Color.ORANGE) || color.equals(Color.GREEN) || color.equals(Color.RED))) { break; } } return new Dimension(width, height); }
From source file:robots.ScrapBot.java
private void scrapWeapons(Weapon wep1, Weapon wep2) throws Exception { final Point item1 = pointProvider.getPoint(PointPlace.item1); final Point item2 = pointProvider.getPoint(PointPlace.item2); final Point viewBackpack = pointProvider.getPoint(PointPlace.viewBackpack); final Point nextButton = pointProvider.getPoint(PointPlace.nextButton); final Point firstSlot = pointProvider.getPoint(PointPlace.firstSlot); final int widthBetween = pointProvider.getPoint(PointPlace.spaceBetween).x; final int heightBetween = pointProvider.getPoint(PointPlace.spaceBetween).y; final Point craft = pointProvider.getPoint(PointPlace.craft); final Point ok1 = pointProvider.getPoint(PointPlace.ok1); final Point ok2 = pointProvider.getPoint(PointPlace.ok2); final Point samplingPoint = pointProvider.getPoint(PointPlace.samplingPoint); final Color samplingColor = new Color(41, 37, 38); leftClick(item1.x, item1.y);/* w w w. ja va2 s.c om*/ leftClick(viewBackpack.x, viewBackpack.y); // -1 because the first slot is invSlot 1 int xOffset = (wep1.getInventorySlot() - 1) % 10; int yOffset = (wep1.getInventorySlot() - 1) / 10; if (yOffset > 4) { for (int i = 0; i < (yOffset / 5); i++) { leftClick(nextButton.x, nextButton.y); } } leftClick(firstSlot.x + (xOffset * widthBetween), firstSlot.y + ((yOffset % 5) * heightBetween)); leftClick(item2.x, item2.y); leftClick(viewBackpack.x, viewBackpack.y); // -1 because the first slot is invSlot 1 int xOffset2 = (wep2.getInventorySlot() - 1) % 10; int yOffset2 = (wep2.getInventorySlot() - 1) / 10; if (yOffset2 > 4) { for (int i = 0; i < (yOffset2 / 5); i++) { leftClick(nextButton.x, nextButton.y); } } leftClick(firstSlot.x + (xOffset2 * widthBetween), firstSlot.y + ((yOffset2 % 5) * heightBetween)); leftClick(craft.x, craft.y); // Wait until done crafting Color currentColor = getPixelColor(samplingPoint.x, samplingPoint.y); while (currentColor.equals(samplingColor)) { currentColor = getPixelColor(samplingPoint.x, samplingPoint.y); } leftClick(ok1.x, ok1.y); leftClick(ok2.x, ok2.y); }
From source file:net.sf.maltcms.chromaui.charts.overlay.Peak1DOverlay.java
/** * * @param g2//from www.j a v a 2 s . c o m * @param chartPanel */ @Override public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) { JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ADataset1D<IChromatogram1D, IScan> newDataset; if (plot.getDataset() instanceof EIC1DDataset || plot.getDataset() instanceof Chromatogram1DDataset || plot.getDataset() instanceof TopViewDataset) { newDataset = (ADataset1D<IChromatogram1D, IScan>) plot.getDataset(); } else { throw new IllegalArgumentException("Unsupported dataset type: " + plot.getDataset().getClass()); } Color fillColor = peakAnnotations.getColor(); if (fillColor == null || fillColor.equals(Color.WHITE) || fillColor.equals(new Color(255, 255, 255, 0))) { fillColor = peakAnnotations.getChromatogram().getTreatmentGroup().getColor(); } if (shapes == null) { shapes = renderer.generatePeakShapes(peakAnnotations, newDataset); this.dataset = newDataset; } else { XYDataset xyds = plot.getDataset(); if (xyds != dataset || drawOutlines) { shapes = renderer.generatePeakShapes(peakAnnotations, newDataset); this.dataset = newDataset; } } if (isVisible()) { renderer.draw(g2, chartPanel, plot, fillColor, shapes, selectedPeaks); } }
From source file:robots.ScrapBot.java
public void combineMetal(Metal metalType) throws Exception { final Point combineScrapButton = pointProvider.getPoint(PointPlace.combineScrapButton); final Point combineReclaimedButton = pointProvider.getPoint(PointPlace.combineReclaimedButton); final Point metal1 = pointProvider.getPoint(PointPlace.metal1); final Point metal2 = pointProvider.getPoint(PointPlace.metal2); final Point metal3 = pointProvider.getPoint(PointPlace.metal3); final Point craft = pointProvider.getPoint(PointPlace.craft); final Point empty = pointProvider.getPoint(PointPlace.empty); final Point nextItem = pointProvider.getPoint(PointPlace.nextItem); final Point ok1 = pointProvider.getPoint(PointPlace.ok1); final Point ok2 = pointProvider.getPoint(PointPlace.ok2); final Point samplingPoint = pointProvider.getPoint(PointPlace.samplingPoint); final Color samplingColor = new Color(41, 37, 38); final Color outOfMetal = new Color(42, 39, 37); // Select crafting option switch (metalType) { case SCRAP:/*ww w. j av a2s . c o m*/ outputter.output("Combining Scrap Metal..."); leftClick(combineScrapButton.x, combineScrapButton.y); break; case RECLAIMED: outputter.output("Combining Reclaimed Metal..."); leftClick(combineReclaimedButton.x, combineReclaimedButton.y); break; default: break; } while (true) { leftClick(metal1.x, metal1.y); if (getPixelColor(nextItem.x, nextItem.y).equals(outOfMetal)) break; leftClick(nextItem.x, nextItem.y); leftClick(metal2.x, metal2.y); if (getPixelColor(nextItem.x, nextItem.y).equals(outOfMetal)) break; leftClick(nextItem.x, nextItem.y); leftClick(metal3.x, metal3.y); if (getPixelColor(nextItem.x, nextItem.y).equals(outOfMetal)) break; leftClick(nextItem.x, nextItem.y); leftClick(craft.x, craft.y); // Wait until done crafting Color currentColor = getPixelColor(samplingPoint.x, samplingPoint.y); while (currentColor.equals(samplingColor)) { currentColor = getPixelColor(samplingPoint.x, samplingPoint.y); } leftClick(ok1.x, ok1.y); leftClick(ok2.x, ok2.y); } leftClick(empty.x, empty.y); outputter.output("Metal Combined."); }
From source file:EditorDropTarget4.java
protected void dragUnderFeedback(DropTargetDragEvent dtde, boolean acceptedDrag) { if (draggingFile) { // When dragging a file, change the background color Color newColor = (dtde != null && acceptedDrag ? feedbackColor : backgroundColor); if (newColor.equals(pane.getBackground()) == false) { changingBackground = true;//from ww w . j a v a 2 s .com pane.setBackground(newColor); changingBackground = false; pane.repaint(); } } else { if (dtde != null && acceptedDrag) { // Dragging text - move the insertion cursor Point location = dtde.getLocation(); pane.getCaret().setVisible(true); pane.setCaretPosition(pane.viewToModel(location)); } else { pane.getCaret().setVisible(false); } } }