List of usage examples for java.awt Transparency TRANSLUCENT
int TRANSLUCENT
To view the source code for java.awt Transparency TRANSLUCENT.
Click Source Link
From source file:Main.java
public static void main(String[] argv) throws Exception { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); BufferedImage bimage = gc.createCompatibleImage(100, 100, Transparency.TRANSLUCENT); }
From source file:Utils.java
public static BufferedImage createTranslucentImage(int width, int height) { return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration() .createCompatibleImage(width, height, Transparency.TRANSLUCENT); }
From source file:Utils.java
/** * Creates an image compatible with the current display * /*ww w . jav a2 s .com*/ * @return A BufferedImage with the appropriate color model */ public static BufferedImage createCompatibleImage(int width, int height) { GraphicsConfiguration configuration = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getDefaultConfiguration(); return configuration.createCompatibleImage(width, height, Transparency.TRANSLUCENT); }
From source file:org.github.jipsg.sanselan.ManagedImageBufferedImageFactory.java
public BufferedImage getColorBufferedImage(final int width, final int height, final boolean hasAlpha) { final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice gd = ge.getDefaultScreenDevice(); final GraphicsConfiguration gc = gd.getDefaultConfiguration(); return gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT); }
From source file:org.b3log.symphony.model.Character.java
/** * Creates an image with the specified content (a character). * * @param content the specified content//from w w w . j ava 2 s.c o m * @return image */ public static BufferedImage createImage(final String content) { final BufferedImage ret = new BufferedImage(500, 500, Transparency.TRANSLUCENT); final Graphics g = ret.getGraphics(); g.setClip(0, 0, 50, 50); g.fillRect(0, 0, 50, 50); g.setFont(new Font(null, Font.PLAIN, 40)); g.setColor(Color.BLACK); g.drawString(content, 5, 40); g.dispose(); return ret; }
From source file:org.apache.pdfbox.pdmodel.graphics.shading.ShadingContext.java
/** * Constructor./*from w w w. j a v a 2s .c o m*/ * * @param shading the shading type to be used * @param cm the color model to be used * @param xform transformation for user to device space * @param matrix the pattern matrix concatenated with that of the parent content stream * @throws java.io.IOException if there is an error getting the color space * or doing background color conversion. */ public ShadingContext(PDShading shading, ColorModel cm, AffineTransform xform, Matrix matrix) throws IOException { this.shading = shading; shadingColorSpace = shading.getColorSpace(); // create the output color model using RGB+alpha as color space ColorSpace outputCS = ColorSpace.getInstance(ColorSpace.CS_sRGB); outputColorModel = new ComponentColorModel(outputCS, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); bboxRect = shading.getBBox(); if (bboxRect != null) { transformBBox(matrix, xform); } // get background values if available COSArray bg = shading.getBackground(); if (bg != null) { background = bg.toFloatArray(); rgbBackground = convertToRGB(background); } }
From source file:net.team2xh.crt.gui.util.GUIToolkit.java
/** * Provides a BufferedImage in the format most compatible with current graphics card. * * @param w Width of the image/* w ww . ja va 2s .c o m*/ * @param h Height of the image * @return Optimized BufferedImage */ public static BufferedImage getEfficientBuffer(int w, int h) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = env.getDefaultScreenDevice(); GraphicsConfiguration config = device.getDefaultConfiguration(); return config.createCompatibleImage(w, h, Transparency.TRANSLUCENT); }
From source file:coolmap.canvas.datarenderer.renderer.impl.NumberComposite.java
private void updateLegend() { try {/* w w w. j a v a 2s. c om*/ ArrayList<Image> legends = new ArrayList<Image>(4); if (singleRenderer != null && singleRenderer.getLegend() != null) { legends.add(singleRenderer.getLegend()); } if (rowGroupRenderer != null && rowGroupRenderer.getLegend() != null) { legends.add(rowGroupRenderer.getLegend()); } if (columnGroupRenderer != null && columnGroupRenderer.getLegend() != null) { legends.add(columnGroupRenderer.getLegend()); } if (rowColumnGroupRenderer != null && rowColumnGroupRenderer.getLegend() != null) { legends.add(rowColumnGroupRenderer.getLegend()); } if (!legends.isEmpty()) { int margin = 5; int imageWidth = 0; int imageHeight = 0; for (Image l : legends) { imageHeight += margin * 2 + l.getHeight(null); if (imageWidth < l.getWidth(null)) { imageWidth = l.getWidth(null); } } imageWidth += margin * 2; if (imageWidth > 0 && imageHeight > 0) { legend = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration() .createCompatibleImage(imageWidth, imageHeight, Transparency.TRANSLUCENT); Graphics2D g2D = legend.createGraphics(); g2D.translate(margin, 0); for (Image l : legends) { g2D.translate(0, margin); g2D.drawImage(l, 0, 0, null); g2D.translate(0, margin + l.getHeight(null)); } g2D.dispose(); } } } catch (Exception e) { } }
From source file:org.apache.pdfbox.rendering.TilingPaint.java
/** * Returns the pattern image in parent stream coordinates. *//* w w w.ja v a2 s . c o m*/ private BufferedImage getImage(PageDrawer drawer, PDTilingPattern pattern, PDColorSpace colorSpace, PDColor color, AffineTransform xform, Rectangle2D anchorRect) throws IOException { ColorSpace outputCS = ColorSpace.getInstance(ColorSpace.CS_sRGB); ColorModel cm = new ComponentColorModel(outputCS, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); float width = (float) Math.abs(anchorRect.getWidth()); float height = (float) Math.abs(anchorRect.getHeight()); // device scale transform (i.e. DPI) (see PDFBOX-1466.pdf) Matrix xformMatrix = new Matrix(xform); float xScale = Math.abs(xformMatrix.getScalingFactorX()); float yScale = Math.abs(xformMatrix.getScalingFactorY()); width *= xScale; height *= yScale; int rasterWidth = Math.max(1, ceiling(width)); int rasterHeight = Math.max(1, ceiling(height)); // create raster WritableRaster raster = cm.createCompatibleWritableRaster(rasterWidth, rasterHeight); BufferedImage image = new BufferedImage(cm, raster, false, null); Graphics2D graphics = image.createGraphics(); // flip a -ve YStep around its own axis (see gs-bugzilla694385.pdf) if (pattern.getYStep() < 0) { graphics.translate(0, rasterHeight); graphics.scale(1, -1); } // flip a -ve XStep around its own axis if (pattern.getXStep() < 0) { graphics.translate(rasterWidth, 0); graphics.scale(-1, 1); } // device scale transform (i.e. DPI) graphics.scale(xScale, yScale); // apply only the scaling from the pattern transform, doing scaling here improves the // image quality and prevents large scale-down factors from creating huge tiling cells. Matrix newPatternMatrix; newPatternMatrix = Matrix.getScaleInstance(Math.abs(patternMatrix.getScalingFactorX()), Math.abs(patternMatrix.getScalingFactorY())); // move origin to (0,0) newPatternMatrix.concatenate(Matrix.getTranslateInstance(-pattern.getBBox().getLowerLeftX(), -pattern.getBBox().getLowerLeftY())); // render using PageDrawer drawer.drawTilingPattern(graphics, pattern, colorSpace, color, newPatternMatrix); graphics.dispose(); return image; }
From source file:net.sf.maltcms.chromaui.charts.GradientPaintScale.java
private void update() { this.lookupImage = ImageTools.createModifiedLookupImage(this.colors, this.st, this.alpha, this.beta, Transparency.TRANSLUCENT, 1.0f); this.lookupColors = createLookupColors(); }