List of usage examples for java.awt TexturePaint TexturePaint
public TexturePaint(BufferedImage txtr, Rectangle2D anchor)
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.PlotInstanceLegendCreator.java
private static Paint createTransparentCheckeredPaint(Color color, int checkerSize) { int s = checkerSize; BufferedImage bufferedImage = new BufferedImage(2 * s, 2 * s, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = bufferedImage.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // Anti-alias! RenderingHints.VALUE_ANTIALIAS_ON); Color c1 = DataStructureUtils.setColorAlpha(color, (int) (color.getAlpha() * .8)); Color c2 = DataStructureUtils.setColorAlpha(color, (int) (color.getAlpha() * .2)); g2.setStroke(new BasicStroke(0)); g2.setPaint(c2);//ww w .j a va 2s . c om g2.setColor(c2); g2.fillRect(0, 0, s, s); g2.fillRect(s, s, s, s); g2.setPaint(c1); g2.setColor(c1); g2.fillRect(0, s, s, s); g2.fillRect(s, 0, s, s); // paint with the texturing brush Rectangle2D rect = new Rectangle2D.Double(0, 0, 2 * s, 2 * s); return new TexturePaint(bufferedImage, rect); }
From source file:org.pentaho.platform.uifoundation.chart.JFreeChartEngine.java
/** * @param textureNode/*from www . j a v a 2 s .c o m*/ * root node that holds texture information * @return */ public static Paint getTexturePaint(final Node textureNode, final int width, final int height, final IPentahoSession session) { if (textureNode == null) { return null; } double x1 = 0.0; double y1 = 0.0; double x2 = width; double y2 = height; BufferedImage texture = (BufferedImage) JFreeChartEngine .getImage(textureNode.selectSingleNode(JFreeChartEngine.TEXTURE_IMAGE_NODE_NAME), session); if (textureNode.selectSingleNode(JFreeChartEngine.X1_NODE_NAME) != null) { x1 = Double.parseDouble(textureNode.selectSingleNode(JFreeChartEngine.X1_NODE_NAME).getText()); } if (textureNode.selectSingleNode(JFreeChartEngine.Y1_NODE_NAME) != null) { y1 = Double.parseDouble(textureNode.selectSingleNode(JFreeChartEngine.Y1_NODE_NAME).getText()); } if (textureNode.selectSingleNode(JFreeChartEngine.X2_NODE_NAME) != null) { x2 = Double.parseDouble(textureNode.selectSingleNode(JFreeChartEngine.X2_NODE_NAME).getText()); } if (textureNode.selectSingleNode(JFreeChartEngine.Y2_NODE_NAME) != null) { y2 = Double.parseDouble(textureNode.selectSingleNode(JFreeChartEngine.Y2_NODE_NAME).getText()); } Rectangle2D anchor = new Rectangle2D.Double(x1, y1, x2, y2); Paint paint = new TexturePaint(texture, anchor); return paint; }
From source file:com.att.aro.diagnostics.GraphPanel.java
/** * Creating DchTail and FachTail Cross Hatch * /*from w ww.j a v a2 s . co m*/ * @return Paint The Tail state paint object */ private static Paint getTailPaint(Color color) { BufferedImage bufferedImage = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = bufferedImage.createGraphics(); g2.setColor(Color.white); g2.fillRect(0, 0, 5, 5); g2.setColor(color); g2.drawLine(0, 0, 5, 5); g2.drawLine(5, 5, 0, 0); g2.drawLine(0, 5, 5, 0); Rectangle2D rect = new Rectangle2D.Double(0, 0, 5, 5); return new TexturePaint(bufferedImage, rect); }
From source file:org.apache.pdfbox.rendering.PageDrawer.java
private void drawBufferedImage(BufferedImage image, AffineTransform at) throws IOException { graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite()); setClip();/*w w w. jav a 2 s . c o m*/ PDSoftMask softMask = getGraphicsState().getSoftMask(); if (softMask != null) { AffineTransform imageTransform = new AffineTransform(at); imageTransform.scale(1, -1); imageTransform.translate(0, -1); Paint awtPaint = new TexturePaint(image, new Rectangle2D.Double(imageTransform.getTranslateX(), imageTransform.getTranslateY(), imageTransform.getScaleX(), imageTransform.getScaleY())); awtPaint = applySoftMaskToPaint(awtPaint, softMask); graphics.setPaint(awtPaint); Rectangle2D unitRect = new Rectangle2D.Float(0, 0, 1, 1); graphics.fill(at.createTransformedShape(unitRect)); } else { int width = image.getWidth(null); int height = image.getHeight(null); AffineTransform imageTransform = new AffineTransform(at); imageTransform.scale(1.0 / width, -1.0 / height); imageTransform.translate(0, -height); graphics.drawImage(image, imageTransform, null); } }
From source file:org.apache.pdfbox.rendering.PageDrawer.java
@Override public void showTransparencyGroup(PDFormXObject form) throws IOException { TransparencyGroup group = new TransparencyGroup(form, false); graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite()); setClip();/*from w ww. j a v a2 s . c o m*/ // both the DPI xform and the CTM were already applied to the group, so all we do // here is draw it directly onto the Graphics2D device at the appropriate position PDRectangle bbox = group.getBBox(); AffineTransform prev = graphics.getTransform(); float x = bbox.getLowerLeftX(); float y = pageSize.getHeight() - bbox.getLowerLeftY() - bbox.getHeight(); graphics.setTransform(AffineTransform.getTranslateInstance(x * xform.getScaleX(), y * xform.getScaleY())); PDSoftMask softMask = getGraphicsState().getSoftMask(); if (softMask != null) { BufferedImage image = group.getImage(); Paint awtPaint = new TexturePaint(image, new Rectangle2D.Float(0, 0, image.getWidth(), image.getHeight())); awtPaint = applySoftMaskToPaint(awtPaint, softMask); // todo: PDFBOX-994 problem here? graphics.setPaint(awtPaint); graphics.fill(new Rectangle2D.Float(0, 0, bbox.getWidth() * (float) xform.getScaleX(), bbox.getHeight() * (float) xform.getScaleY())); } else { graphics.drawImage(group.getImage(), null, null); } graphics.setTransform(prev); }
From source file:org.apache.pdfbox.rendering.TilingPaint.java
/** * Creates a new tiling Paint. The parameters color and colorSpace must be null for a colored * tiling Paint (because it has its own colors), and non null for an uncolored tiling Paint. * * @param drawer renderer to render the page * @param pattern tiling pattern dictionary * @param colorSpace color space for this tiling * @param color color for this tiling// w w w . j av a2 s. c o m * @param xform device scale transform * * @throws java.io.IOException if something goes wrong while drawing the pattern */ TilingPaint(PageDrawer drawer, PDTilingPattern pattern, PDColorSpace colorSpace, PDColor color, AffineTransform xform) throws IOException { // pattern space -> user space patternMatrix = Matrix.concatenate(drawer.getInitialMatrix(), pattern.getMatrix()); Rectangle2D anchorRect = getAnchorRect(pattern); paint = new TexturePaint(getImage(drawer, pattern, colorSpace, color, xform, anchorRect), anchorRect); }
From source file:org.eclipse.birt.chart.device.g2d.G2dRendererBase.java
protected void fillWithPatternImage(Shape shape, Fill fill) throws ChartException { java.awt.Image img = createImageFromModel(fill); BufferedImage bimg = convertPatternImage(img); if (bimg != null) { _g2d.setPaint(new TexturePaint(bimg, new Rectangle(0, 0, bimg.getWidth(), bimg.getHeight()))); _g2d.fill(shape);/*w ww. jav a 2 s .c om*/ } }
From source file:VASSAL.build.module.map.MapShader.java
protected TexturePaint getTexture(double zoom) { if (zoom == 1.0) { return getTexture(); }/*from w w w .java 2 s . c om*/ TexturePaint texture = textures.get(zoom); if (texture == null) { texture = new TexturePaint(getShadePattern(zoom), getPatternRect(zoom)); textures.put(zoom, texture); } return texture; }
From source file:VASSAL.build.module.map.MapShader.java
protected void buildTexture() { if (getShadePattern() != null) { texture = new TexturePaint(getShadePattern(), getPatternRect()); } }