List of usage examples for java.awt Color getBlue
public int getBlue()
From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.WellsModel.java
/** * Handles the selection of a cell//from w w w . j a va 2 s . co m * * @param cell The selected cell. * @param well The well to handle. * @param results The collection of objects to update. */ private void handleCellSelection(CellDisplay cell, WellImageSet well, List<DataObject> results) { String description = cell.getDescription(); Color c = cell.getHighlight(); WellData data = (WellData) well.getHierarchyObject(); data.setWellType(description); well.setDescription(description); results.add(data); if (c == null || !cell.isSpecified()) { data.setRed(null); } else { data.setRed(c.getRed()); data.setGreen(c.getGreen()); data.setBlue(c.getBlue()); data.setAlpha(c.getAlpha()); } well.setHighlight(c); }
From source file:com.siteview.ecc.report.xls.JRXlsExporter.java
/** * *//*from w w w .j av a2s . c o m*/ protected static HSSFColor getNearestColor(Color awtColor) { HSSFColor color = (HSSFColor) hssfColorsCache.get(awtColor); if (color == null) { Map triplets = HSSFColor.getTripletHash(); if (triplets != null) { Collection keys = triplets.keySet(); if (keys != null && keys.size() > 0) { Object key = null; HSSFColor crtColor = null; short[] rgb = null; int diff = 0; int minDiff = 999; for (Iterator it = keys.iterator(); it.hasNext();) { key = it.next(); crtColor = (HSSFColor) triplets.get(key); rgb = crtColor.getTriplet(); diff = Math.abs(rgb[0] - awtColor.getRed()) + Math.abs(rgb[1] - awtColor.getGreen()) + Math.abs(rgb[2] - awtColor.getBlue()); if (diff < minDiff) { minDiff = diff; color = crtColor; } } } } hssfColorsCache.put(awtColor, color); } return color; }
From source file:com.hp.autonomy.frontend.reports.powerpoint.PowerPointServiceImpl.java
/** * Internal implementation to add a sunburst chart (actually a doughnut chart) to a slide, based on a template. * @param template the parsed template information. * @param slide the slide to add to./*from w w w . j a va 2s .co m*/ * @param anchor optional bounding rectangle to draw onto, in PowerPoint coordinates. * If null, we'll use the bounds from the original template chart. * @param data the sunburst data. * @param shapeId the slide shape ID, should be unique within the slide. * @param relId the relation ID to the chart data. * @throws TemplateLoadException if we can't create the sunburst; most likely due to an invalid template. */ private static void addSunburst(final SlideShowTemplate template, final XSLFSlide slide, final Rectangle2D.Double anchor, final SunburstData data, final int shapeId, final String relId) throws TemplateLoadException { final String[] categories = data.getCategories(); final double[] values = data.getValues(); final String title = data.getTitle(); slide.getXmlObject().getCSld().getSpTree().addNewGraphicFrame() .set(template.getDoughnutChartShapeXML(relId, shapeId, "chart" + shapeId, anchor)); final XSSFWorkbook workbook = new XSSFWorkbook(); final XSSFSheet sheet = workbook.createSheet(); final XSLFChart baseChart = template.getDoughnutChart(); final CTChartSpace chartSpace = (CTChartSpace) baseChart.getCTChartSpace().copy(); final CTChart ctChart = chartSpace.getChart(); final CTPlotArea plotArea = ctChart.getPlotArea(); if (StringUtils.isEmpty(title)) { if (ctChart.getAutoTitleDeleted() != null) { ctChart.getAutoTitleDeleted().setVal(true); } ctChart.unsetTitle(); } final CTDoughnutChart donutChart = plotArea.getDoughnutChartArray(0); final CTPieSer series = donutChart.getSerArray(0); final CTStrRef strRef = series.getTx().getStrRef(); strRef.getStrCache().getPtArray(0).setV(title); sheet.createRow(0).createCell(1).setCellValue(title); strRef.setF(new CellReference(sheet.getSheetName(), 0, 1, true, true).formatAsString()); final CTStrRef categoryRef = series.getCat().getStrRef(); final CTStrData categoryData = categoryRef.getStrCache(); final CTNumRef numRef = series.getVal().getNumRef(); final CTNumData numericData = numRef.getNumCache(); final String[] fillColors = data.getColors(); final String[] strokeColors = data.getStrokeColors(); final boolean overrideFill = ArrayUtils.isNotEmpty(fillColors); final boolean overrideStroke = ArrayUtils.isNotEmpty(strokeColors); final boolean overrideColors = overrideFill || overrideStroke; final List<CTDPt> dPtList = series.getDPtList(); final CTDPt templatePt = (CTDPt) dPtList.get(0).copy(); if (overrideColors) { dPtList.clear(); final CTShapeProperties spPr = templatePt.getSpPr(); final CTLineProperties ln = spPr.getLn(); // We need to unset any styles on the existing template if (overrideFill) { unsetSpPrFills(spPr); } if (overrideStroke) { unsetLineFills(ln); } } categoryData.setPtArray(null); numericData.setPtArray(null); CTLegend legend = null; final int[] showInLegend = data.getShowInLegend(); int nextLegendToShow = 0, nextLegendToShowIdx = -1; if (showInLegend != null) { // We need to write legendEntry elements to hide the legend for chart series we don't want. // Note this only works in PowerPoint, and not OpenOffice. legend = ctChart.isSetLegend() ? ctChart.getLegend() : ctChart.addNewLegend(); Arrays.sort(showInLegend); nextLegendToShow = showInLegend[++nextLegendToShowIdx]; } for (int idx = 0; idx < values.length; ++idx) { final CTStrVal categoryPoint = categoryData.addNewPt(); categoryPoint.setIdx(idx); categoryPoint.setV(categories[idx]); final CTNumVal numericPoint = numericData.addNewPt(); numericPoint.setIdx(idx); numericPoint.setV(Double.toString(values[idx])); if (overrideColors) { final CTDPt copiedPt = (CTDPt) templatePt.copy(); copiedPt.getIdx().setVal(idx); if (overrideFill) { final Color color = Color.decode(fillColors[idx % fillColors.length]); final CTSolidColorFillProperties fillClr = copiedPt.getSpPr().addNewSolidFill(); fillClr.addNewSrgbClr().setVal( new byte[] { (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue() }); } if (overrideStroke) { final Color strokeColor = Color.decode(strokeColors[idx % strokeColors.length]); final CTSolidColorFillProperties strokeClr = copiedPt.getSpPr().getLn().addNewSolidFill(); strokeClr.addNewSrgbClr().setVal(new byte[] { (byte) strokeColor.getRed(), (byte) strokeColor.getGreen(), (byte) strokeColor.getBlue() }); } dPtList.add(copiedPt); } if (legend != null) { // We're hiding some legend elements. Should we show this index? if (nextLegendToShow == idx) { // We show this index, find the next one to show. ++nextLegendToShowIdx; if (nextLegendToShowIdx < showInLegend.length) { nextLegendToShow = showInLegend[nextLegendToShowIdx]; } } else { // We hide this index. If there's already a matching legend entry in the XML, update it, // otherwise we create a new legend entry. boolean found = false; for (int ii = 0, max = legend.sizeOfLegendEntryArray(); ii < max; ++ii) { final CTLegendEntry legendEntry = legend.getLegendEntryArray(ii); final CTUnsignedInt idxLegend = legendEntry.getIdx(); if (idxLegend != null && idxLegend.getVal() == idx) { found = true; if (legendEntry.isSetDelete()) { legendEntry.getDelete().setVal(true); } else { legendEntry.addNewDelete().setVal(true); } } } if (!found) { final CTLegendEntry idxLegend = legend.addNewLegendEntry(); idxLegend.addNewIdx().setVal(idx); idxLegend.addNewDelete().setVal(true); } } } XSSFRow row = sheet.createRow(idx + 1); row.createCell(0).setCellValue(categories[idx]); row.createCell(1).setCellValue(values[idx]); } categoryData.getPtCount().setVal(categories.length); numericData.getPtCount().setVal(values.length); categoryRef.setF(new CellRangeAddress(1, values.length, 0, 0).formatAsString(sheet.getSheetName(), true)); numRef.setF(new CellRangeAddress(1, values.length, 1, 1).formatAsString(sheet.getSheetName(), true)); try { writeChart(template.getSlideShow(), slide, baseChart, chartSpace, workbook, relId); } catch (IOException | InvalidFormatException e) { throw new TemplateLoadException("Error writing chart in loaded template", e); } }
From source file:org.kurento.test.browser.WebPage.java
public boolean compareColor(String videoTag, Color expectedColor, boolean logWarn) { @SuppressWarnings("unchecked") List<Long> realColor = (List<Long>) browser .executeScriptAndWaitOutput("return kurentoTest.colorInfo['" + videoTag + "'].currentColor;"); long red = realColor.get(0); long green = realColor.get(1); long blue = realColor.get(2); double distance = Math.sqrt((red - expectedColor.getRed()) * (red - expectedColor.getRed()) + (green - expectedColor.getGreen()) * (green - expectedColor.getGreen()) + (blue - expectedColor.getBlue()) * (blue - expectedColor.getBlue())); String expectedColorStr = "[R=" + expectedColor.getRed() + ", G=" + expectedColor.getGreen() + ", B=" + expectedColor.getBlue() + "]"; String realColorStr = "[R=" + red + ", G=" + green + ", B=" + blue + "]"; boolean out = distance <= browser.getColorDistance(); if (!out) {/*from w ww. j a va 2 s .c om*/ if (logWarn) { log.warn("Color NOT detected in video stream. Expected: {}, Real: {}", expectedColorStr, realColorStr); } } else { log.debug("Detected color in video stream. Expected: {}, Real: {}", expectedColorStr, realColorStr); } return out; }
From source file:com.dlya.facturews.DlyaPdfExporter2.java
/** * *//*from w w w . j ava2 s . c o m*/ private static void preparePen(PdfContentByte pdfContentByte, JRPen pen, int lineCap) { float lineWidth = pen.getLineWidth().floatValue(); if (lineWidth <= 0) { return; } pdfContentByte.setLineWidth(lineWidth); pdfContentByte.setLineCap(lineCap); Color color = pen.getLineColor(); pdfContentByte.setRGBColorStroke(color.getRed(), color.getGreen(), color.getBlue()); switch (pen.getLineStyleValue()) { case DOUBLE: { pdfContentByte.setLineWidth(lineWidth / 3); pdfContentByte.setLineDash(0f); break; } case DOTTED: { switch (lineCap) { case PdfContentByte.LINE_CAP_BUTT: { pdfContentByte.setLineDash(lineWidth, lineWidth, 0f); break; } case PdfContentByte.LINE_CAP_PROJECTING_SQUARE: { pdfContentByte.setLineDash(0, 2 * lineWidth, 0f); break; } } break; } case DASHED: { switch (lineCap) { case PdfContentByte.LINE_CAP_BUTT: { pdfContentByte.setLineDash(5 * lineWidth, 3 * lineWidth, 0f); break; } case PdfContentByte.LINE_CAP_PROJECTING_SQUARE: { pdfContentByte.setLineDash(4 * lineWidth, 4 * lineWidth, 0f); break; } } break; } case SOLID: default: { pdfContentByte.setLineDash(0f); break; } } }
From source file:edu.ku.brc.specify.tasks.subpane.ESResultsTablePanel.java
/** * Builds the "more" panel./*from w w w . j av a 2 s . co m*/ * */ protected void buildMorePanel() { FormLayout formLayout = new FormLayout("15px,0px,p", "p"); PanelBuilder builder = new PanelBuilder(formLayout); CellConstraints cc = new CellConstraints(); moreBtn = createButton( String.format(getResourceString("MoreEntries"), new Object[] { (rowCount - topNumEntries) }));//(rowCount - topNumEntries)+" more..."); moreBtn.setCursor(handCursor); moreBtn.setBorderPainted(false); builder.add(createLabel(" "), cc.xy(1, 1)); builder.add(moreBtn, cc.xy(3, 1)); morePanel = builder.getPanel(); Color bgColor = table.getBackground(); bgColor = new Color(Math.max(bgColor.getRed() - 10, 0), Math.max(bgColor.getGreen() - 10, 0), Math.max(bgColor.getBlue() - 10, 0)); Color fgColor = new Color(Math.min(bannerColor.getRed() + 10, 255), Math.min(bannerColor.getGreen() + 10, 255), Math.min(bannerColor.getBlue() + 10, 255)); morePanel.setBackground(bgColor); moreBtn.setBackground(bgColor); moreBtn.setForeground(fgColor); add(builder.getPanel(), BorderLayout.SOUTH); moreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { morePanel.setVisible(false); showTopNumEntriesBtn.setVisible(true); showingAllRows = true; setDisplayRows(rowCount, Integer.MAX_VALUE); esrPane.revalidateScroll(); } }); morePanel.setVisible(false); }
From source file:userinterface.graph.AxisSettings.java
public void save(Element axis) throws SettingException { axis.setAttribute("heading", getHeading()); Font headingFont = getHeadingFont().f; axis.setAttribute("headingFontName", headingFont.getName()); axis.setAttribute("headingFontSize", "" + headingFont.getSize()); axis.setAttribute("headingFontStyle", "" + headingFont.getStyle()); Color headingFontColor = getHeadingFont().c; axis.setAttribute("headingFontColourR", "" + headingFontColor.getRed()); axis.setAttribute("headingFontColourG", "" + headingFontColor.getGreen()); axis.setAttribute("headingFontColourB", "" + headingFontColor.getBlue()); Font numberFont = getNumberFont().f; axis.setAttribute("numberFontName", numberFont.getName()); axis.setAttribute("numberFontSize", "" + numberFont.getSize()); axis.setAttribute("numberFontStyle", "" + numberFont.getStyle()); Color numberFontColor = getHeadingFont().c; axis.setAttribute("numberFontColourR", "" + numberFontColor.getRed()); axis.setAttribute("numberFontColourG", "" + numberFontColor.getGreen()); axis.setAttribute("numberFontColourB", "" + numberFontColor.getBlue()); axis.setAttribute("showMajor", showGrid() ? "true" : "false"); Color gridColor = gridColour.getColorValue(); axis.setAttribute("majorColourR", "" + gridColor.getRed()); axis.setAttribute("majorColourG", "" + gridColor.getGreen()); axis.setAttribute("majorColourB", "" + gridColor.getBlue()); axis.setAttribute("logarithmic", isLogarithmic() ? "true" : "false"); axis.setAttribute("minValue", "" + getMinValue()); axis.setAttribute("maxValue", "" + getMaxValue()); axis.setAttribute("majorGridInterval", "" + getGridInterval()); axis.setAttribute("logBase", "" + getLogBase()); axis.setAttribute("logStyle", "" + getLogStyle()); axis.setAttribute("minimumPower", "" + getMinimumPower()); axis.setAttribute("maximumPower", "" + getMaximumPower()); axis.setAttribute("autoscale", isAutoScale() ? "true" : "false"); }
From source file:net.sf.jasperreports.engine.export.JExcelApiExporter.java
protected static int rgbDistance(Color awtColor, RGB rgb) { return Math.abs(rgb.getRed() - awtColor.getRed()) + Math.abs(rgb.getGreen() - awtColor.getGreen()) + Math.abs(rgb.getBlue() - awtColor.getBlue()); }
From source file:com.chart.SwingChart.java
/** * /*from w w w .j av a2s . c o m*/ * @param color JavaFX color * @return AWT Color */ final java.awt.Color scene2awtColor(javafx.scene.paint.Color color) { return new java.awt.Color((float) color.getRed(), (float) color.getGreen(), (float) color.getBlue()); }
From source file:savant.view.tracks.BAMTrackRenderer.java
private Color makeTransparent(Color c) { return new Color(c.getRed(), c.getGreen(), c.getBlue(), 90); }