List of usage examples for java.awt Graphics2D setRenderingHint
public abstract void setRenderingHint(Key hintKey, Object hintValue);
From source file:org.squidy.designer.shape.VisualShape.java
@Override protected final void paint(PPaintContext paintContext) { super.paint(paintContext); Graphics2D g = paintContext.getGraphics(); // Set default font. g.setFont(internalFont);//from w w w . jav a2 s . c o m // if (!renderingHintsSet) { if (isRenderPrimitive()) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED); g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED); g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE); g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } else { // Use anti aliasing -> May slow down performance. g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DEFAULT); g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } // renderingHintsSet = true; // } // Paint the shapes visual representation. paintShape(paintContext); // Allows visual debugging if enabled. if (DebugConstants.ENABLED) { paintDebug(paintContext); } }
From source file:com.igormaznitsa.jhexed.renders.svg.SVGImage.java
public void render(final Graphics2D g) throws IOException { final Object antialiasText = g.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); final Object antialiasDraw = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); final Object antialiasAlpha = g.getRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION); try {// w w w . j ava 2 s .c o m processAntialias(this.quality, g); this.svgGraphicsNode.primitivePaint(g); } finally { g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, antialiasText == null ? RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT : antialiasText); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antialiasDraw == null ? RenderingHints.VALUE_ANTIALIAS_DEFAULT : antialiasDraw); g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, antialiasAlpha == null ? RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT : antialiasAlpha); } }
From source file:org.bigbluebuttonproject.fileupload.document.impl.FileSystemSlideManager.java
/** * This method create thumbImage of the image file given and save it in outFile. * Compression quality is also given. thumbBounds is used for calculating the size of the thumb. * //from w w w . java 2 s. c om * @param infile slide image to create thumb * @param outfile output thumb file * @param compressionQuality the compression quality * @param thumbBounds the thumb bounds * * @throws IOException Signals that an I/O exception has occurred. */ public void resizeImage(File infile, File outfile, float compressionQuality, int thumbBounds) throws IOException { // Retrieve jpg image to be resized Image image = ImageIO.read(infile); // get original image size for thumb size calculation int imageWidth = image.getWidth(null); int imageHeight = image.getHeight(null); float thumbRatio = (float) thumbBounds / Math.max(imageWidth, imageHeight); int thumbWidth = (int) (imageWidth * thumbRatio); int thumbHeight = (int) (imageHeight * thumbRatio); // draw original image to thumbnail image object and // scale it to the new size on-the-fly BufferedImage thumbImage = new BufferedImage(thumbWidth, thumbHeight, BufferedImage.TYPE_INT_RGB); Graphics2D graphics2D = thumbImage.createGraphics(); graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null); // Find a jpeg writer ImageWriter writer = null; Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName("jpg"); if (iter.hasNext()) { writer = (ImageWriter) iter.next(); } ImageWriteParam iwp = writer.getDefaultWriteParam(); iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); iwp.setCompressionQuality(compressionQuality); // Prepare output file ImageOutputStream ios = ImageIO.createImageOutputStream(outfile); writer.setOutput(ios); // write to the thumb image writer.write(thumbImage); // Cleanup ios.flush(); writer.dispose(); ios.close(); }
From source file:business.ImageManager.java
public void doDrawCircle(Graphics2D big, int x, int y, Color color) { //setup para os rastros big.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); big.setStroke(new BasicStroke()); big.setColor(color);// w w w . j a v a 2 s .co m //draw on graph big.drawOval(x, x, y, y); }
From source file:business.ImageManager.java
public ImageIcon getArrow(double angle) { BufferedImage img = new BufferedImage(40, 40, BufferedImage.TRANSLUCENT); Graphics2D big = img.createGraphics(); //setup para os rastros big.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); big.setStroke(//from ww w . j a va 2s . c om new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1f, new float[] { 5f }, 0f)); big.setColor(Color.red); int cx = this.getYellowBall().getIconWidth() / 2; int cy = this.getYellowBall().getIconHeight() / 2; AffineTransform at = AffineTransform.getTranslateInstance(cx, cy); at.rotate(Math.toRadians(angle)); // at.scale(2.0, 2.0); Shape shape = at.createTransformedShape(createArrow()); big.setPaint(Color.red); big.draw(shape); ImageIcon ret = new ImageIcon(img); return (ret); // tenta com o icone...angle. }
From source file:business.ImageManager.java
private void doDrawPath(Graphics2D big, Point ori, Point dest, Color color) { //setup para os rastros big.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); big.setStroke(new BasicStroke(0.75f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1f, new float[] { 3f, 5f, 7f, 5f, 11f, 5f, 15f, 5f, 21f, 5f, 27f, 5f, 33f, 5f }, 0f)); big.setColor(color);// w w w. jav a2 s . c o m //draw path Path2D.Double path = new Path2D.Double(); path.moveTo(ori.getX(), ori.getY()); path.lineTo(dest.getX(), dest.getY()); //draw on graph big.draw(path); }
From source file:business.ImageManager.java
private void doDrawPathOrdemArmy(Graphics2D big, Point ori, Point dest, Color color) { //setup para os rastros big.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); big.setComposite(alcom);/*from w w w .j a v a2 s .co m*/ big.setStroke(new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1f, new float[] { 3f, 5f, 7f, 5f, 11f, 5f, 15f, 5f, 21f, 5f, 27f, 5f, 33f, 5f }, 0f)); big.setColor(color); //draw path Path2D.Double path = new Path2D.Double(); path.moveTo(ori.getX(), ori.getY()); path.curveTo(dest.getX() + 10, dest.getY() - 10, dest.getX() - 10, dest.getY() + 10, dest.getX(), dest.getY()); //draw on graph big.draw(path); }
From source file:business.ImageManager.java
private void doDrawPathOrdem(Graphics2D big, Point ori, Point dest, Color color) { //setup para os rastros big.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); big.setStroke(new BasicStroke(1.75f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1f, new float[] { 3f, 5f, 7f, 5f, 11f, 5f, 15f, 5f, 21f, 5f, 27f, 5f, 33f, 5f }, 0f)); big.setColor(color);/* w w w .j av a 2s . co m*/ //draw path Path2D.Double path = new Path2D.Double(); path.moveTo(ori.getX(), ori.getY()); path.curveTo(dest.getX() - 20, dest.getY() + 20, dest.getX() + 20, dest.getY() - 20, dest.getX() + 12, dest.getY()); //path.lineTo(dest.getX(), dest.getY()); //draw on graph big.draw(path); }
From source file:business.ImageManager.java
private void doDrawRastro(Graphics2D big, int direcao, int x, int y, Color color) { //setup para os rastros big.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); big.setStroke(// www .j a v a 2 s . com new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1f, new float[] { 5f }, 0f)); big.setColor(color); //draw path Path2D.Double path = new Path2D.Double(); path.moveTo(x + 38, y + 38); path.lineTo(x + coordRastros[direcao - 1][0], y + coordRastros[direcao - 1][1]); //draw on graph big.draw(path); }
From source file:edu.ku.brc.ui.IconManager.java
/** * Gets a scaled icon and if it doesn't exist it creates one and scales it * @param icon image to be scaled//from w w w . java 2s . co m * @param iconSize the icon size (Std) * @param scaledIconSize the new scaled size in pixels * @return the scaled icon */ public Image getFastScale(final ImageIcon icon, final IconSize iconSize, final IconSize scaledIconSize) { if (icon != null) { int width = scaledIconSize.size(); int height = scaledIconSize.size(); if ((width < 0) || (height < 0)) { //image is nonstd, revert to original size width = icon.getIconWidth(); height = icon.getIconHeight(); } Image imgMemory = createImage(icon.getImage().getSource()); //make sure all pixels in the image were loaded imgMemory = new ImageIcon(imgMemory).getImage(); BufferedImage thumbImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics2D = thumbImage.createGraphics(); graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); graphics2D.drawImage(imgMemory, 0, 0, width, height, null); graphics2D.dispose(); imgMemory = thumbImage; return imgMemory; } //else log.error("Couldn't find icon [" + iconSize + "] to scale to [" + scaledIconSize + "]"); return null; }