List of usage examples for java.awt Color getRed
public int getRed()
From source file:lucee.runtime.img.Image.java
/** * add a border to image//from w w w. j a v a2 s .c om * @param thickness * @param color * @param borderType */ public void addBorder(int thickness, Color color, int borderType) throws ExpressionException { double colorArray[] = { color.getRed(), color.getGreen(), color.getBlue() }; BorderExtender borderExtender = new BorderExtenderConstant(colorArray); ParameterBlock params = new ParameterBlock(); params.addSource(image()); params.add(thickness); params.add(thickness); params.add(thickness); params.add(thickness); if (BORDER_TYPE_CONSTANT == borderType) params.add(borderExtender); else params.add(BorderExtender.createInstance(borderType)); //else if(BORDER_TYPE_WRAP==borderType)params.add(BorderExtender.createInstance(BorderExtender.BORDER_REFLECT)); image((JAI.create("border", params)).getAsBufferedImage()); }
From source file:slash.navigation.mapview.browser.BrowserMapView.java
String asColor(Color color) { return encodeByte((byte) color.getRed()) + encodeByte((byte) color.getGreen()) + encodeByte((byte) color.getBlue()); }
From source file:com.dlya.facturews.DlyaPdfExporter2.java
protected void exportFrame(JRPrintFrame frame) throws DocumentException, IOException, JRException { if (frame.getModeValue() == ModeEnum.OPAQUE) { int x = frame.getX() + getOffsetX(); int y = frame.getY() + getOffsetY(); Color backcolor = frame.getBackcolor(); pdfContentByte.setRGBColorFill(backcolor.getRed(), backcolor.getGreen(), backcolor.getBlue()); pdfContentByte.rectangle(x, jasperPrint.getPageHeight() - y, frame.getWidth(), -frame.getHeight()); pdfContentByte.fill();// w w w . ja v a 2s . c o m } setFrameElementsOffset(frame, false); try { exportElements(frame.getElements()); } finally { restoreElementOffsets(); } exportBox(frame.getLineBox(), frame); }
From source file:com.dlya.facturews.DlyaPdfExporter2.java
/** * */// w w w.java 2 s .c o m public void exportText(JRPrintText text) throws DocumentException { AbstractPdfTextRenderer textRenderer = text.getLeadingOffset() == 0 ? new PdfTextRenderer(jasperReportsContext, getPropertiesUtil().getBooleanProperty(JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT)) : new SimplePdfTextRenderer(jasperReportsContext, getPropertiesUtil().getBooleanProperty(JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT)//FIXMECONTEXT replace with getPropertiesUtil in all exporters );//FIXMETAB optimize this textRenderer.initialize(this, pdfContentByte, text, getOffsetX(), getOffsetY()); JRStyledText styledText = textRenderer.getStyledText(); if (styledText == null) { return; } double angle = 0; switch (text.getRotationValue()) { case LEFT: { angle = Math.PI / 2; break; } case RIGHT: { angle = -Math.PI / 2; break; } case UPSIDE_DOWN: { angle = Math.PI; break; } case NONE: default: { } } AffineTransform atrans = new AffineTransform(); atrans.rotate(angle, textRenderer.getX(), jasperPrint.getPageHeight() - textRenderer.getY()); pdfContentByte.transform(atrans); if (text.getModeValue() == ModeEnum.OPAQUE) { Color backcolor = text.getBackcolor(); pdfContentByte.setRGBColorFill(backcolor.getRed(), backcolor.getGreen(), backcolor.getBlue()); pdfContentByte.rectangle(textRenderer.getX(), jasperPrint.getPageHeight() - textRenderer.getY(), textRenderer.getWidth(), -textRenderer.getHeight()); pdfContentByte.fill(); } if (styledText.length() > 0) { //tagHelper.startText(); /* */ textRenderer.render(); //tagHelper.endText(); } atrans = new AffineTransform(); atrans.rotate(-angle, textRenderer.getX(), jasperPrint.getPageHeight() - textRenderer.getY()); pdfContentByte.transform(atrans); /* */ exportBox(text.getLineBox(), text); }
From source file:com.jcraft.weirdx.XColormap.java
private void alloc(int i, Color color) { colors[i] = color;/* ww w. ja v a2 s . com*/ r[i] = (byte) color.getRed(); g[i] = (byte) color.getGreen(); b[i] = (byte) color.getBlue(); }
From source file:com.projity.contrib.calendar.JXXMonthView.java
/** * {@inheritDoc}//w ww .ja v a 2s .c om */ protected void paintComponent(Graphics g) { Object oldAAValue = null; Graphics2D g2 = (g instanceof Graphics2D) ? (Graphics2D) g : null; if (g2 != null && _antiAlias) { oldAAValue = g2.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } Rectangle clip = g.getClipBounds(); updateIfNecessary(); if (isOpaque()) { g.setColor(getBackground()); g.fillRect(clip.x, clip.y, clip.width, clip.height); } g.setColor(getForeground()); Color shadowColor = g.getColor(); shadowColor = new Color(shadowColor.getRed(), shadowColor.getGreen(), shadowColor.getBlue(), (int) (.20 * 255)); FontMetrics fm = g.getFontMetrics(); // Reset the calendar. _cal.setTimeInMillis(_firstDisplayedDate); // Center the calendars vertically in the available space. int y = _startY; for (int row = 0; row < _numCalRows; row++) { // Center the calendars horizontally in the available space. int x = _startX; int tmpX, tmpY; // Check if this row falls in the clip region. _bounds.x = 0; _bounds.y = _startY + row * (_calendarHeight + CALENDAR_SPACING); _bounds.width = getWidth(); _bounds.height = _calendarHeight; if (!_bounds.intersects(clip)) { _cal.add(Calendar.MONTH, _numCalCols); y += _calendarHeight + CALENDAR_SPACING; continue; } for (int column = 0; column < _numCalCols; column++) { String monthName = _monthsOfTheYear[_cal.get(Calendar.MONTH)]; monthName = monthName + " " + _cal.get(Calendar.YEAR); _bounds.x = _ltr ? x : x - _calendarWidth; _bounds.y = y + _boxPaddingY; _bounds.width = _calendarWidth; _bounds.height = _boxHeight; if (_bounds.intersects(clip)) { // Paint month name background. paintMonthStringBackground(g, _bounds.x, _bounds.y, _bounds.width, _bounds.height); // Paint month name. g.setColor(getForeground()); tmpX = _ltr ? x + (_calendarWidth / 2) - (fm.stringWidth(monthName) / 2) : x - (_calendarWidth / 2) - (fm.stringWidth(monthName) / 2) - 1; tmpY = y + _boxPaddingY + _boxHeight - fm.getDescent(); g.drawString(monthName, tmpX, tmpY); if ((_dropShadowMask & MONTH_DROP_SHADOW) != 0) { g.setColor(shadowColor); g.drawString(monthName, tmpX + 1, tmpY + 1); g.setColor(getForeground()); } } _bounds.x = _ltr ? x : x - _calendarWidth; _bounds.y = y + _boxPaddingY + _boxHeight + _boxPaddingY + _boxPaddingY; _bounds.width = _calendarWidth; _bounds.height = _boxHeight; if (_bounds.intersects(clip)) { _cal.set(Calendar.DAY_OF_MONTH, _cal.getActualMinimum(Calendar.DAY_OF_MONTH)); Calendar weekCal = (Calendar) _cal.clone(); // Paint short representation of day of the week. int dayIndex = _firstDayOfWeek - 1; int month = weekCal.get(Calendar.MONTH); // dayIndex = (_cal.get(Calendar.DAY_OF_WEEK) -1) %7; for (int i = 0; i < DAYS_IN_WEEK; i++) { // PROJITY_MODIFICATION // set the week calendar to the current day of week and make sure it's still in this month weekCal.set(Calendar.DAY_OF_WEEK, dayIndex + 1); if (weekCal.get(Calendar.MONTH) != month) weekCal.roll(Calendar.DAY_OF_YEAR, 7); // make sure in this month tmpX = _ltr ? x + (i * (_boxPaddingX + _boxWidth + _boxPaddingX)) + _boxPaddingX + (_boxWidth / 2) - (fm.stringWidth(_daysOfTheWeek[dayIndex]) / 2) : x - (i * (_boxPaddingX + _boxWidth + _boxPaddingX)) - _boxPaddingX - (_boxWidth / 2) - (fm.stringWidth(_daysOfTheWeek[dayIndex]) / 2); tmpY = y + _boxPaddingY + _boxHeight + _boxPaddingY + _boxPaddingY + fm.getAscent(); boolean flagged = _flaggedWeekDates[dayIndex]; boolean colored = _coloredWeekDates[dayIndex]; calculateBoundsForDay(_bounds, weekCal, true); drawDay(colored, flagged, false, g, _daysOfTheWeek[dayIndex], tmpX, tmpY); // if ((_dropShadowMask & WEEK_DROP_SHADOW) != 0) { // calculateBoundsForDay(_bounds,weekCal,true); // add shadow arg // drawDay(colored,flagged,false,g,_daysOfTheWeek[dayIndex], tmpX + 1, // tmpY + 1); // } if (_selectedWeekDays[dayIndex]) { paintSelectedDayBackground(g, _bounds.x, _bounds.y, _bounds.width, _bounds.height); } dayIndex++; if (dayIndex == 7) { dayIndex = 0; } } int lineOffset = 2; // Paint a line across bottom of days of the week. g.drawLine(_ltr ? x + 2 : x - 3, lineOffset + y + (_boxPaddingY * 3) + (_boxHeight * 2), _ltr ? x + _calendarWidth - 3 : x - _calendarWidth + 2, lineOffset + y + (_boxPaddingY * 3) + (_boxHeight * 2)); if ((_dropShadowMask & MONTH_LINE_DROP_SHADOW) != 0) { g.setColor(shadowColor); g.drawLine(_ltr ? x + 3 : x - 2, y + (_boxPaddingY * 3) + (_boxHeight * 2) + 1, _ltr ? x + _calendarWidth - 2 : x - _calendarWidth + 3, y + (_boxPaddingY * 3) + (_boxHeight * 2) + 1); g.setColor(getForeground()); } } // Check if the month to paint falls in the clip. _bounds.x = _startX + (_ltr ? column * (_calendarWidth + CALENDAR_SPACING) : -(column * (_calendarWidth + CALENDAR_SPACING) + _calendarWidth)); _bounds.y = _startY + row * (_calendarHeight + CALENDAR_SPACING); _bounds.width = _calendarWidth; _bounds.height = _calendarHeight; // Paint the month if it intersects the clip. If we don't move // the calendar forward a month as it would have if paintMonth // was called. if (_bounds.intersects(clip)) { paintMonth(g, column, row); } else { _cal.add(Calendar.MONTH, 1); } x += _ltr ? _calendarWidth + CALENDAR_SPACING : -(_calendarWidth + CALENDAR_SPACING); } y += _calendarHeight + CALENDAR_SPACING; } // Restore the calendar. _cal.setTimeInMillis(_firstDisplayedDate); if (g2 != null && _antiAlias) { g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldAAValue); } }
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
public void modifyPointLight(int k, PointLightParams par, boolean on) { if (k < 0 || k >= pointLights.size()) { return;// ww w . j a v a 2 s. c o m } EditablePointLight l = pointLights.get(k); l.setEnabled(on); Color c = par.getColor(); l.setLightColor(new Color3f(c.getRed() / 512.f, c.getGreen() / 512.f, c.getGreen() / 512.f)); l.setAttenuation(par.getConstantAttenuation(), par.getLinearAttenuation(), par.getQuadraticAttenuation()); }
From source file:net.sf.jasperreports.engine.export.JExcelApiMetadataExporter.java
protected void setColourUsed(Colour colour, Color reportColour) { if (log.isDebugEnabled()) { log.debug("Modifying palette colour " + colour.getValue() + " to " + reportColour); }//from w w w . j av a 2 s . c om int red = reportColour.getRed(); int green = reportColour.getGreen(); int blue = reportColour.getBlue(); workbook.setColourRGB(colour, red, green, blue); RGB customRGB = new RGB(red, green, blue); usedColours.put(colour, customRGB); }
From source file:net.sf.jasperreports.engine.export.JRXlsMetadataExporter.java
/** * */// ww w .j ava 2 s. c o m protected HSSFColor getWorkbookColor(Color awtColor) { HSSFColor color = null; if (awtColor != null) { byte red = (byte) awtColor.getRed(); byte green = (byte) awtColor.getGreen(); byte blue = (byte) awtColor.getBlue(); XlsExporterConfiguration configuration = getCurrentConfiguration(); if (configuration.isCreateCustomPalette()) { try { color = palette.findColor(red, green, blue) != null ? palette.findColor(red, green, blue) : palette.addColor(red, green, blue); } catch (Exception e) { if (customColorIndex < MAX_COLOR_INDEX) { palette.setColorAtIndex(customColorIndex, red, green, blue); color = palette.getColor(customColorIndex++); } else { color = palette.findSimilarColor(red, green, blue); } } } } return color == null ? getNearestColor(awtColor) : color; }
From source file:net.sf.jasperreports.engine.export.JExcelApiExporter.java
protected void setColourUsed(Colour colour, Color reportColour) { if (log.isDebugEnabled()) { log.debug("Modifying palette colour " + colour.getValue() + " to " + reportColour); }/*ww w. j a v a 2 s. c om*/ int red = reportColour.getRed(); int green = reportColour.getGreen(); int blue = reportColour.getBlue(); workbook.setColourRGB(colour, red, green, blue); RGB customRGB = new RGB(red, green, blue); usedColours.put(colour, customRGB); }