List of usage examples for java.awt Graphics2D scale
public abstract void scale(double sx, double sy);
From source file:Main.java
public static void main(String[] args) throws IOException { final int SCALE = 2; Image img = new ImageIcon(new URL("http://www.java2s.com/style/download.png")).getImage(); BufferedImage bi = new BufferedImage(SCALE * img.getWidth(null), SCALE * img.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics2D grph = (Graphics2D) bi.getGraphics(); grph.scale(SCALE, SCALE); grph.drawImage(img, 0, 0, null);//from w w w . jav a 2 s .co m grph.dispose(); ImageIO.write(bi, "png", new File("double_size.png")); }
From source file:ImagePanel.java
public void paintComponent(Graphics grp) { Graphics2D g2D = (Graphics2D) grp; g2D.scale(zoom, zoom); g2D.drawImage(image, 0, 0, this); }
From source file:Main.java
public void paint(Graphics g) { g.fillRect(0, 0, 20, 20);// w w w . j a va 2 s . c om Graphics2D g2 = (Graphics2D) g; g2.shear(5.3, 5.4); g2.rotate(30.0 * Math.PI / 180.0); g2.scale(2.0, 2.0); g.setColor(Color.red); g.fillRect(0, 0, 20, 20); }
From source file:Main.java
public void paint(Graphics g) { g.fillRect(0, 0, 20, 20);//ww w . jav a2 s . c o m Graphics2D g2 = (Graphics2D) g; g2.translate(50, 50); g2.rotate(30.0 * Math.PI / 180.0); g2.scale(2.0, 2.0); g.setColor(Color.red); g.fillRect(0, 0, 20, 20); }
From source file:Main.java
public void paint(Graphics g) { g.fillRect(0, 0, 20, 20);//from w ww . j av a2 s . co m Graphics2D g2 = (Graphics2D) g; g2.translate(5.3, 5.4); g2.rotate(30.0 * Math.PI / 180.0); g2.scale(2.0, 2.0); g.setColor(Color.red); g.fillRect(0, 0, 20, 20); }
From source file:MainClass.java
public void paint(Graphics g) { g.fillRect(0, 0, 20, 20);//w w w . j a va 2 s.com Graphics2D g2 = (Graphics2D) g; g2.translate(50, 50); g2.rotate(30.0 * Math.PI / 180.0); g2.scale(2.0, 2.0); g.setColor(Color.red); g.fillRect(0, 0, 20, 20); }
From source file:Main.java
public void paint(Graphics g) { g.fillRect(0, 0, 20, 20);//from w w w .j a va 2 s .c o m Graphics2D g2 = (Graphics2D) g; g2.translate(50, 50); g2.rotate(30.0 * Math.PI / 180.0, 13, 12); g2.scale(2.0, 2.0); g.setColor(Color.red); g.fillRect(0, 0, 20, 20); }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); int[] x = { 0, 100, 100, 0, 0, 75, 75, 125, 25, 50 }; int[] y = { 0, 10, 10, 100, 25, 125, 75, 75, 510, 50 }; Graphics2D g2d = (Graphics2D) g; AffineTransform at0 = g2d.getTransform(); g2d.scale(size / 100, size / 100); g.drawPolyline(x, y, x.length);//from www . jav a 2s. c o m g2d.setTransform(at0); }
From source file:net.sf.jasperreports.charts.util.ImageChartRendererFactory.java
@Override public Renderable getRenderable(JasperReportsContext jasperReportsContext, JFreeChart chart, ChartHyperlinkProvider chartHyperlinkProvider, Rectangle2D rectangle) { int dpi = JRPropertiesUtil.getInstance(jasperReportsContext) .getIntegerProperty(Renderable.PROPERTY_IMAGE_DPI, 72); double scale = dpi / 72d; BufferedImage bi = new BufferedImage((int) (scale * (int) rectangle.getWidth()), (int) (scale * rectangle.getHeight()), BufferedImage.TYPE_INT_ARGB); List<JRPrintImageAreaHyperlink> areaHyperlinks = null; Graphics2D grx = bi.createGraphics(); try {/*from w w w . ja v a 2 s . co m*/ grx.scale(scale, scale); if (chartHyperlinkProvider != null && chartHyperlinkProvider.hasHyperlinks()) { areaHyperlinks = ChartUtil.getImageAreaHyperlinks(chart, chartHyperlinkProvider, grx, rectangle); } else { chart.draw(grx, rectangle); } } finally { grx.dispose(); } try { return new SimpleDataRenderer( JRImageLoader.getInstance(jasperReportsContext).loadBytesFromAwtImage(bi, ImageTypeEnum.PNG), areaHyperlinks); } catch (JRException e) { throw new JRRuntimeException(e); } }
From source file:ScalingMethods.java
/** * Draws the picture five times, using the five different scaling * approaches described in the book. All five look the same, since * all are using default (nearest neighbor) filtering during the * scale operation./*from ww w . j av a2s .c o m*/ */ public void paintComponent(Graphics g) { int x = PADDING; int y = PADDING; // Simplest approach g.drawImage(picture, x, y, scaleW, scaleH, null); // Subregion approach x += scaleW + PADDING; g.drawImage(picture, x, y, x + scaleW, y + scaleH, 0, 0, picture.getWidth(), picture.getHeight(), null); // Graphics2D.scale approach x += scaleW + PADDING; Graphics2D g2d = (Graphics2D) g.create(); g2d.translate(x, y); g2d.scale(SCALE_FACTOR, SCALE_FACTOR); g2d.drawImage(picture, 0, 0, null); g2d.dispose(); // AffineTransform.scale approach x += scaleW + PADDING; g2d = (Graphics2D) g.create(); AffineTransform at = new AffineTransform(); at.translate(x, y); at.scale(SCALE_FACTOR, SCALE_FACTOR); g2d.drawImage(picture, at, null); g2d.dispose(); // getScaledInstance() approach x += scaleW + PADDING; Image scaledImg = picture.getScaledInstance(scaleW, scaleH, Image.SCALE_DEFAULT); g.drawImage(scaledImg, x, y, null); }