List of usage examples for java.awt RenderingHints RenderingHints
public RenderingHints(Key key, Object value)
From source file:Main.java
public static void main(String[] args) throws Exception { ImageIcon ii = new ImageIcon("C:/Java_Dev/test.jpg"); BufferedImage bi = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = (Graphics2D) bi.createGraphics(); g2d.addRenderingHints(/*from w w w.ja v a 2 s . com*/ new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY)); boolean b = g2d.drawImage(ii.getImage(), 0, 0, 50, 50, null); System.out.println(b); ImageIO.write(bi, "jpg", new File("C:/Java_Dev/test.jpg")); }
From source file:Text.java
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHints(rh);/*from www.j av a 2s.c om*/ Font font = new Font("New Roma", Font.BOLD, 40); g2d.setFont(font); g2d.drawString("text", 20, 30); }
From source file:PrintLineByLine.java
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHints(rh);//from w w w . j a va 2 s . c om g2d.setFont(new Font("Purisa", Font.PLAIN, 13)); g2d.drawString("Line 1", 20, 30); g2d.drawString("Line 2", 20, 60); g2d.drawString("Line 3", 20, 90); g2d.drawString("Line 4", 20, 120); g2d.drawString("Line 5", 20, 150); g2d.drawString("Line 6", 20, 180); }
From source file:ColorFadingAnimation.java
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(new Color(50, 50, 50)); RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHints(rh);// w ww .ja v a 2s.c o m g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha_rectangle)); g2d.fill(rect); }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D twoD = (Graphics2D) g; RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); twoD.setRenderingHints(rh);/*from w ww .java 2 s. c o m*/ twoD.setColor(Color.BLACK); twoD.drawString(raised, 5, 90); }
From source file:Main.java
ThreeDimensionalBorder(Color color, int transparency, int shadowWidth) { this.color = color; shadowPad = shadowWidth;//from w w w. java 2 s . c om stroke = new BasicStroke(thickness); strokePad = thickness / 2; hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int pad = radius + strokePad; int bottomPad = pad + strokePad + shadowPad; int rightPad = pad + strokePad + shadowPad; insets = new Insets(pad, pad, bottomPad + shadowPad, rightPad); }
From source file:FontRenderContextRenderingHints.java
public void paint(Graphics g) { Graphics2D g2D = (Graphics2D) g; int w = getSize().width; int h = getSize().height; RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2D.setRenderingHints(qualityHints); AffineTransform at = new AffineTransform(); at.setToTranslation(-300, -400);//from w w w . j a va 2s.c o m at.shear(-0.5, 0.0); FontRenderContext frc = new FontRenderContext(at, false, false); TextLayout tl = new TextLayout("World!", font, frc); Shape outline = tl.getOutline(null); g2D.setColor(Color.blue); BasicStroke wideStroke = new BasicStroke(2.0f); g2D.setStroke(wideStroke); g2D.draw(outline); }
From source file:Main.java
public void drawImage() { Graphics2D g = img.createGraphics(); RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHints(hints);//www .ja v a 2 s. c om g.setColor(Color.RED); int x = (int) mouse.getX(); int y = (int) mouse.getY(); g.setStroke(new BasicStroke(2)); int s = 3; g.drawLine(x - s, y, x + s, y); g.drawLine(x, y - s, x, y + s); l.setIcon(new ImageIcon(img)); g.dispose(); }
From source file:Main.java
public void drawImage() { Graphics2D g = img.createGraphics(); RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHints(hints);//from ww w . ja v a 2s . com g.setStroke(new BasicStroke(4)); for (Ellipse2D shape : shapes) { g.setColor(Color.blue); g.fill(shape); if (shape.contains(mouse)) { g.setColor(Color.RED); } else { g.setColor(Color.YELLOW); } g.draw(shape); } l.setIcon(new ImageIcon(img)); g.dispose(); }
From source file:TimerBasedAnimation.java
public void paint(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2.setRenderingHints(rh);/*from ww w.ja v a 2s .c o m*/ Dimension size = getSize(); if (initialize) { reset(size.width, size.height); initialize = false; } this.step(size.width, size.height); render(size.width, size.height, g2); }