Total members 10261 | Gratitudes |It is currently Tue May 22, 2012 5:11 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Code Snippet
 Code subject: Shearing in java
PostPosted: Tue Nov 11, 2008 9:15 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

Shearing in java graphics
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;

public class ShearWithTransform extends JComponent {
  Shape shape;
 
   public ShearWithTransform() {
    shape = create();
  }
  private Shape create() {
    return new Ellipse2D.Double(100, 50, 100, 50);
  }
  public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    AffineTransform affineTransform1 = AffineTransform.
          getTranslateInstance(0, 0);
    g2d.transform(affineTransform1);
    g2d.setPaint(Color.red);
    g2d.draw(shape);

    AffineTransform affineTransform2 = AffineTransform.
          getTranslateInstance(0, 0);
      affineTransform2.shear(-.8, 0);
      g2d.transform(affineTransform2);
      g2d.transform(AffineTransform.getTranslateInstance(100, 100));
     
    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT,
        BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0);
    g2d.setStroke(stroke);
    g2d.draw(shape);
  }
  public static void main(String[] a) {
    JFrame frame = new JFrame("Shear the oval");
    frame.getContentPane().add(new ShearWithTransform());
    frame.setSize(300, 250);
    frame.show();
  }
}


Attachments:
File comment: shear in java
shear.gif
shear.gif [ 4.96 KiB | Viewed 1271 times ]

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )
TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 video chat application in java
 navigating to database using java
 java mobile apps
 need help in java
 Read your gmail using Java code
 Java Programing to communicating port parallel
 Java Chat
 Steganography in java
 java code for listing folder contents from remote folder
 java

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: No registered users and 3 guests



Jump to:  
Previous Code Snippet | Next Code Snippet 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team