Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Java Programming Code Examples

Java > Java2D Code Examples

Transformations

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
Transformations package com.ack.gui.awt.geometry; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; public class Transformations extends Frame { public static void main( String[] argv ) { Transformations myExample = new Transformations( "Transformations" ); } public Transformations( String title ) { super( title ); setSize( 600, 600 ); addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent we ) { dispose(); System.exit( 0 ); } } ); setVisible( true ); } public void paint( Graphics g ) { Graphics2D g2d = (Graphics2D) g; Rectangle2D rect1 = new Rectangle2D.Double( 132, 42, 100, 100 ); AffineTransform at = AffineTransform.getRotateInstance( ( 10 * Math.PI ) / 180 ); at.concatenate( AffineTransform.getScaleInstance( 2, 2 ) ); at.concatenate( AffineTransform.getShearInstance( 1, 0 ) ); at.concatenate( AffineTransform.getTranslateInstance( -100, 0 ) ); g2d.setTransform( at ); g2d.setColor( Color.red ); g2d.fill( rect1 ); } }