Please help me Image rotation

I want to develop new iPhone application. I am a new iPhone developer . my application have one UIImage it will rotating on touch base . when user Touch and drag the image it will rotating touch base .. When user continues touch drag it will rotating faster ... just like fan .. base on speed .. when user touch the image stop the rotation....
i spent lot more time in this application... I got some example form this forum it is not realistic .... could any help for me........ with example ...'
Nalan.

Hello DUbbz
This is a my code :
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
timerIsCountingDown = NO;
currentTimerValue = 0;
NSArray *myTouches = [event touchesForView:self] allObjects;
UITouch *t = myTouches objectAtIndex:0;
Begantime = t.timestamp;
CGPoint pointInView = [touches anyObject] locationInView:self;
touchXStart = pointInView.x;
touchYStart = pointInView.y;
-(void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
degree = self angle:touchXStart y0:touchYStart x1:touchXEnd y1:touchYEnd;
timerIsCountingDown = YES;
UIView beginAnimations:nil context:NULL;
UIView setAnimationBeginsFromCurrentState:YES;
//UIView setAnimationDuration:0.05;
UIView setAnimationDelegate:self;
UIView setAnimationCurve:UIViewAnimationCurveEaseIn;
// timer = NSTimer scheduledTimerWithTimeInterval: 0.02 target: self selector:@selector(hadleTimer:) userInfo: nil repeats: YES;
angle += 10;
if (angle > 6.283)
angle = 0;
CGAffineTransform transform=CGAffineTransformMakeRotation(angle);
imageView.transform = transform;
imageView.alpha = 1.0;
UIView commitAnimations;
-(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
NSArray *myTouches = [event touchesForView:self] allObjects;
UITouch *t = myTouches objectAtIndex:0;
Endtime = t.timestamp;
CGPoint pointInView = [touches anyObject] locationInView:self;
touchXEnd = pointInView.x;
touchYEnd = pointInView.y;
CGFloat time = Begantime - Endtime;
CGFloat speed = distance / time;
NalaN
Thank you for your reply .... Rotating image clockwise ant anticlockwise ...
you are a iPhone developer .... please keep touch with me... I am new iPhone developer .. i have lot of confusion with the IPhone SDk.. could you please send me iPhone reference free ebook with example ...... But xcode documentation is very confused... .. I lost month i spent in this concept.....
NalaN.

Similar Messages

  • Please help - Dreamweaver Image Map Tool/Outlook for Mac

    Hello:
    I was wondering if you could help me navigate through an issue I am having with the image map tool.  I have created a design file is PSD, saved it as a JPG, then transferred it into Dreamweaver to link the design to a web page.  However, I would like to embed different links within one HTML file to e-mail out, so I used the image map tool to do so.  However, when I copy/paste the completed HTML into an Outlook for Mac message (Command A; Command C; Command V), the image map/additional links do not transfer over once the file is pasted in an e-mail.  I also tested this with G-mail and the Apple E-mail app, and was not successful.  Please help.

    You can't paste images into e-mails.  Use absolute links to images hosted on your domain server like this:
    <img src="http://yourdomain.com/images/your_map.jpg">
    See HTML E-mails: what you need to know
    http://alt-web.com/Articles/HTML-Emails.shtml
    Nancy O.

  • Urgent- Please help with image overlaying

    Hi,
    Please,please, can someone help me with an imaging issue and show me what I'm doing wrong.
    I'm a swing beginner and I'm trying to create a application for a board game. Currently I'm using JLabel components to try and create jpeg pieces over a JPanel component that has the board background.
    Currently I've written the code for the board background component and the pieces but can't get the image to appear on the background.
    Please can someone show me what I'm doing wrong.
    If someone can help me get this working, I've got 16 dollars from other posts in this forum I can give you.
    Thanks.
    public class BoardPanel extends JPanel {
    public BoardPanel()
    //Overwrite abstract painting method
    public void paintComponent(Graphics g)
    super.paintComponent(g);
              g.drawImage(backgroundImage,0,0,this.getWidth(), this.getHeight(), null);
    private Image backgroundImage = new ImageIcon("./Board.gif").getImage();
    public class PieceIcon extends JLabel {
    public PieceIcon(String symbol)
    System.out.println("./"+symbol+".jpg");
              pieceImage = new ImageIcon("./"+symbol+".jpg");
    public void paintComponent(Graphics g)
              super.paintComponent(g);
              g.drawImage(pieceImage,playerBoardPos.getX(),playerBoardPos.getY(), this);
    private Image pieceImage;
    Main:
    JPanel content = new JPanel();
    PieceIcon testPiece = new PieceIcon("Dog");
    BoardPanel boardIcon = new BoardPanel();
    getContentPane().add(content, java.awt.BorderLayout.CENTER);
    content.add(boardIcon, java.awt.BorderLayout.CENTER);
    boardIcon.setLayout(new javax.swing.OverlayLayout(boardIcon));
    boardIcon.add(testPiece);

    Oh, and since you probably won't be needing a layout manager, try the following:
    setLayout(null);
    ChessPeice peice1 = new ChessPeice(...);
    add(peice1);
    peice1.setBounds(x, y, width, height);also, your ChessPeice paintComponent method should look more like:
    ... //in constructor
    setPreferredSize(new Dimension(image.width, image.height));
    setOpaque(false);
    public void paintComponent(Graphics g){
       g.drawImage(...);
    }Make sure that if you call the component's getSize method to determine the width and height you do it after pack has been called. If you call getSize before then, it will return 0 for the width and height values.
    Another advantage to this approach is that the peices only draw in the areas they need to.
    Hope this helps.

  • PSE newbie frustrated, please help with image resizing

    Hi!
    Tutorials aren't helping me, nor is trial and error. I just want to resize some photos I downloaded to my computer, then upload them to a website to use as my avatar or signature. There are specific pixel dimensions I must adhere to. I want to keep the photo in it's entirety, but when I resize it, it distorts a bit, looks fuzzy...
    I can't figure out what the heck I am doing wrong. Some pictures turn out just fine and others look really bad. I know it can be done because I've seen the same pictures I'm trying to size, being used for the same thing I want to use them for, but theirs are clear, absolutely no distortion whatsoever. The pixel dimensions I have to work with are either 100x100, or 450 pixels wide by 90 pixels high.
    I hope this made sense, I'm not sure how else to word it. Please forgive my ignorance, I've really been trying.
    Thank-you
    B

    For an avatar it’s possibly best to crop to begin with so you get a true square.
    Open the image and select the crop tool and change the aspect ratio to 1 x 1 or 5 x 5 then drag out a square and move the image around inside it or drag the bounding box borders until you have it looking as you want. Then click the green check mark.
    On the top menu click Image > Resize > Image Size and in either the height or width box type 100 px (you only need to type the dimension once the other box will change to 100 automatically. Make sure you have the bottom three boxes checked:
    Scale Styles
    Constrain Proportions
    Resample Image
    With all three checked set the bottom dropdown to Bicubic and then hit OK.
    If you want to apply some sharpening select Enhance on the top menu and choose Unsharp Mask.
    Make sure the Radius is no more than 1.5 and use the amount slider to get the image looking as you want it then save.
      

  • Please help. my images/web page not displaying ( just outlines) when checking in my browser

    Hi. I am using an old dreamweaver. thats not the problem. I
    view my web site in browser to check all ok. When i click my link
    to next page, it will open it in new window as it should do, but
    displays no images (apart from my email link) just outlines.
    Is it my folder location?? it is c:/mywebsites/mywebfolder
    If i open each page directly to view they are all fine just
    when i go from my links..
    Helpppppp please

    Did you define your local site?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "janeie" <[email protected]> wrote in
    message
    news:es3v7h$mo9$[email protected]..
    > Hi. I am using an old dreamweaver. thats not the
    problem. I view my web
    > site in
    > browser to check all ok. When i click my link to next
    page, it will open
    > it in
    > new window as it should do, but displays no images
    (apart from my email
    > link)
    > just outlines.
    > Is it my folder location?? it is
    c:/mywebsites/mywebfolder
    > If i open each page directly to view they are all fine
    just when i go from
    > my
    > links..
    > Helpppppp please
    >

  • Please Help - Flash Image Viewer

    I read other posts with the same problem but no solution was
    offered, so I try to get some answers this way.
    I have a slide show with 5 images (
    http://www.interweb39.com) .
    The size of the image area is defined as 400x300. The images are
    400x300. The "place holder" shows that size. But when the slideshow
    is played (tested in different browsers) or uploaded to the site,
    the images are smaller. There is an area around the images that is
    not visible in design mode. I set the IW background to be the same
    as my page background, so it is not ugly, but the picture size is
    reduced!
    Thanks for your help
    Marianne

    Meanwhile I have used a different software that works.
    Marianne

  • Help w/ image rotation in slideshow

    Hi All,
    I've created a bit of a problem for myself. A client provided a folder full of images to add to a slideshow in DVDSP. I added all of the images as normal, then I noticed that a bunch of them were taken in portrait mode and needed to be rotated. I didn't see any way within DVDSP to rotate them, so I opened up the folder in Adobe Bridge and quickly rotated them. I went back and opened the project in DVDSP and the images did not rotate. I trashed the MPEG and PAR folders and reopened the project and the images still did not rotate. So I figured that DVDSP doesn't recognize whatever tag Bridge adds to the file to indicate that the image should be viewed rotated. Next, I thought that I would just have to open each one in Photoshop and rotate them and then re-save. The only problem is that when opening them in PS, the images are already rotated. So now I don't know what to do. I can't rotate them again in PS and DVDSP doesn't acknowledge that the images are rotated.
    Any suggestions?
    Thanks,
    Chris

    Actually, Bridge does more than just rotating the thumbnails. It apparently embeds some code in the metadata that instructs programs to open the image with rotation applied. When opening the image in PS, Preview, GraphicConverter, and a few other programs the image opens with the rotation from Bridge applied.
    In any event, I have an old PS action I created years ago that prepares images for slideshows. It fits them into a 720x480 frame and then applies any needed background extension and finally converts the image to a .9 pixel ratio image. I did that to all of the modified images from Bridge and it worked fine.
    If Apple ever bothers to update DVDSP again they should really address the inability of the program to handle this type of situation.

  • Please HELP! images being resized

    Hi, Ive produced a small website using iWeb.
    The website is NOT intended for the web but to go on disk to post to clients.
    The main point of the disc is they choose images from the browser then click 'download' to get at the hires version.
    In iWeb I have chosen that the download version is in it's 'Original (full quality)' state which is 7"x7" @300dpi (around 1mb file) - which was originally imported from an album in Apertuure.
    The problem is it's nowhere near that size! iWeb is making up a different size and screwing up the compression as well!!
    What am I missing? I just want the client to have access to the hires version I originally gave it.
    Thanks in advance for any help!

    iWeb is doing what it is supposed to do.
    The images on a webpage are not for downloading but for illustrating the page.
    Here's the solution:
    Zip each large image and make a note of the file size.
    Then store these zipped images in a folder on your server.
    The URL to a file is like:
    http://web.me.com/UserID/folder/image_01.zip
    Then in iWeb type some text indicating the zip file (with the file size), select the text and make a link to an EXTERNAL PAGE, being your zipped file.
    When you visitor clicks the link, the zip file will download. Your visitor has to open it and preceed as intended.
    Other solution:
    Instead of putting the files on the server yourself, select the text as before and make a LINK TO FILE on your computer.
    iWeb will upload the zipped files on your behalf.
    Message was edited by: Wyodor

  • Please help! Image only shows when i use Applets instead of Frame/JFrame

    The following classes don't work because the Canvas shows just background colour. However, when I let my class "MyContainer" extend Applet instead(and running the Applet instead of the StartUp class that creates a JFrame) of Frame/JFrame i get my Image on the Canvas showing, WHY?
    code:
    public class StartUp {
    public static void main(String[] arg) {
    MyContainer my = new MyContainer();
         my.setSize(500, 400);
         my.setVisible(true);
    public class MyContainer extends JFrame {
    MyCanvas m;
    public void MyContainer() {
         m=new MyCanvas();
         this.setSize(320, 320);
    this.setLayout(new GridLayout(1, 1, 0, 0));
    this.add(m);
    this.setVisible(true);
    public class MyCanvas extends Canvas {
    Image im;
    public MyCanvas() {
    im=Toolkit.getDefaultToolkit().createImage("c:\\miniferrari.jpg");
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    public void paint(Graphics g) {
    g.drawImage(im, 0, 0, this);
    private void jbInit() throws Exception {
    this.setBackground(Color.darkGray);

    as you are using a JFrame, you should refer to it's contentpane:
    this.getContentPane().setLayout(new GridLayout(1, 1, 0, 0));
    this.getContentPane().add(m);

  • Live Bookmark Feed failed to load. I cannot view any footage on BBC News site. Also I can no longer view images I have uploaded to a website. This has all materialised overnight. Please help.

    I have been uploading pictures of booksd to ABE.com for ages. I am able to view these images on the site. Today, without warning, I am unable to do this. Coincidentally, I note that I can no longer view film footage on the BBC news pages. The Latest Headlines column is also showing "Live Bookmark Feed failed to load". Please help.

    If images are missing then check that you aren't blocking images from some domains.
    *Check the permissions for the domain in the current tab in "Tools > Page Info > Permissions"
    *Check that images are enabled: Tools > Options > Content: [X] Load images automatically
    *Check the exceptions in "Tools > Options > Content: Load Images > Exceptions"
    *Check the "Tools > Page Info > Media" tab for blocked images (scroll through all the images with the cursor Down key).
    If an image in the list is grayed and there is a check-mark in the box "<i>Block Images from...</i>" then remove that mark to unblock the images from that domain.
    Make sure that you do not block third-party images permissions.default.images
    *http://kb.mozillazine.org/Images_or_animations_do_not_load
    There are also extensions (Tools > Add-ons > Extensions) and security software (firewall, anti-virus) that can block images.
    Try to remove the current Latest Headlines feed and create a new feed.<br />
    You can visit http://fxfeeds.mozilla.com/en-US/firefox/headlines.xml

  • Help please: Action for arbitrary image rotation: 300 different files, each at a different angle

    Hi everyone,
    I have some 300 images, all handheld shots done in an on-location studio set. They all need varying amounts of image rotation since they're handheld. There's a beaded curtain in the background, so manually I use the ruler tool, draw a line along a strand of beads, and then image/rotate/arbitrary.
    I need to create an action that will (1) do the arbitrary rotation and then (2) save and close the file.
    However, when I record this, the value of the rotation of the sample file I'm working is what gets recorded (not surprising). In other words, if image A needs 0.28 degrees of rotation, that's not what I want for image B which might need -0.15 degrees instead.  The action recorded 0.28.
    Is there a way to create an action that will simply rotate according to the ruler once I've drawn it?
    Thanks!
    Jerry

    True - and I am a keyboard shortcut dude.  But got it working (I was impressed that using the mouse to unclick the last step in the history worked...), and things are doing what I needed.
    And I'm hoping that my suggestion of the last-step undo will make CS5 on par with CS6 in this one small aspect, and perhaps help someone else...
    Many thanks to you!!! 
    BTW - all in the FWIW - you can see what our work as photographers looks like here:
    http://www.jerryandloisphotography.com.
    If you are at all into music/rock 'n roll, you'll probably have fun on our music/stage gallery.  Groups like YES, Heart, Thomas Dolby, etc. use a bit of our work - just a bit of fun...
    Again - thanks and best wishes,
    Jerry

  • Refresh image in a ScrollingImagePanel. Please help me!

    Hello friends. I am new at the "Java World". At first, sorry for my bad English. Lets go:
    In my aplication I have to show a tiff image in a ScrollingImagePanel.I aplly some efects on the image, for example rotate the image, etc.
    It is working fine, but I have problem to refresh the image in the same ScrollingImagePanel.The code compiles but I have exceptions when I run the method:
    public void atualiza(){
    if (ziboro == false){ //no images displayed yet.
         ziboro = true;     
         JInternalFrame test = new JInternalFrame("Test",true,true,true,true);
    test.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    test.addInternalFrameListener(this);
    test.setLocation(10,10);
    test.setSize(new Dimension(200,200));
    ScrollingImagePanel FlipVPanel = new ScrollingImagePanel(imagemBufa, 800, 800);
    test.getContentPane().add(FlipVPanel);
    displayPanel.add(test);
    test.setVisible(true);
    test.moveToFront();
    return; }
    //This part is my problem.
    teste.getContentPane().remove(FlipVPanel);//it causes exception
    ScrollingImagePanel FlipVPanel = new ScrollingImagePanel(imagemBufa, 800, 800);
    teste.getContentPane().add(FlipVPanel);
    teste.setVisible(true);
    teste.moveToFront();
    I think tyhe problem is when I try to remove the ScrollingImagePanel, because when I add a ScrollingImagePanel and I remove imediatly after , the ScrollingImagePanel disapear.
    Please help me, you are my hope.
    Thanks a lot, lot, lot, ....!

    I can't either with my Treo700wx, and from what I see with my plan, it's definitely because of Alltel.  They have a seperately priced option for picture messaging that I had with my old (non-smart) phone that isn't even an option with the smart-choice packages.
    So...I'm also listening.  Having the only way to send pictures with the phone being through email is pretty dumb.  We pay enough for the plans, you'd think they could include it...or at least offer it as an option.
    Post relates to: Treo 700wx (Alltel)

  • Need Help In Solving Rotation Image Problem

    1 down vote favorite
    Hi guys ,
    I need your help please. I have spent hours trying to solve it but not working.
    I have an image i am rotating when the user clicks on a button. But it is not working.
    I would like to see the image rotating gradually till it stops but it doesn't. This it what it does. After i click the button, i don't see it rotating. But when i minimize and maximize the main window, i see the image just rotate(flip) fast like that. It does the rotation but i don't see it as it is doing. It just rotate in a second after minimize and maximize the main window.
    I thimk the problem deals with updating the GUI as it is rotating but i don't know how to fix it.
    these are the code . Please i have trimed down the code for easy reading.
    public class KrusPanel extends JPanel{
         private Image crossingImage;
         private int currentRotationAngle;
         private int imageWidth;
         private int imageHeight;
         private AffineTransform affineTransform;
         private boolean clockwise;
         private static int ROTATE_ANGLE_OFFSET = 2;
         private int xCoordinate;
         private int yCoordinate;
         private javax.swing.Timer timer;
         private void initialize(){
          this.crossingImage = Toolkit.getDefaultToolkit().getImage("images/railCrossing3.JPG");
          this.imageWidth = this.getCrossingImage().getWidth(this);
          this.imageHeight = this.getCrossingImage().getHeight(this);
          this.affineTransform = new AffineTransform();
          this.setCurrentRotationAngle(90);
          timer = new javax.swing.Timer(20, new MoveListener());
    public KrusPanel (int x, int y) {
      this.setxCoordinate(x);
      this.setyCoordinate(y);
      this.setPreferredSize(new Dimension(50, 50));
      this.setBackground(Color.red);
      TitledBorder border = BorderFactory.createTitledBorder("image");
      this.setLayout(new FlowLayout());
      this.initialize();
    public void paintComponent(Graphics grp){
               Rectangle rect = this.getBounds();
               Graphics2D g2d = (Graphics2D)grp;
               g2d.setColor(Color.BLACK);
               this.getAffineTransform().setToTranslation(this.getxCoordinate(), this.getyCoordinate());
               this.getAffineTransform().rotate(Math.toRadians(this.getCurrentRotationAngle()), this.getCrossingImage().getWidth(this) /2,
                                       this.getCrossingImage().getHeight(this)/2);
              g2d.drawImage(this.getCrossingImage(), this.getAffineTransform(), this);
    public void rotateCrossing(){
                 this.currentRotationAngle += ROTATE_ANGLE_OFFSET;
                 int test = this.currentRotationAngle % 90;
                 if(test == 0){
                  this.setCurrentRotationAngle(this.currentRotationAngle);
                  timer.stop();
             repaint();
      private class MoveListener implements ActionListener {
             public void actionPerformed(ActionEvent e) {
                rotateCrossing();
                repaint();
    //  There are getters and setters method here but i have removed them to make the code shorter.
    }Next 2 Classes
    // I have removed many thins in this class so simplicity. This class is consists of Tiles of BufferdImage and the
    // KrusPanel class is at the array position [2][2]. It is the KrusPanel class that i want to rotate.
    public class SeePanel extends JPanel{
          private static KrusPanel crossing;
          private void initializeComponents(){
       timer = new javax.swing.Timer(70, new MoveListener());
       this.crossing = new CrossingPanel(261,261);
        public SeePanel(){
      this.initializeComponents();
         public void paintComponent(Graphics comp){
       super.paintComponent(comp);
      comp2D = (Graphics2D)comp;
      BasicStroke pen = new BasicStroke(15.0F, BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND);
         comp2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                 RenderingHints.VALUE_ANTIALIAS_ON);
         comp2D.setPaint(Color.red);
         comp2D.setBackground(Color.WHITE);
         comp2D.drawImage(img, 0, 0, null);
         comp2D.draw(this.horizontalRail);
         this.crossing.paintComponent(comp2D);
         this.rob.drawRobot(comp2D);
      public static void rotateCrossing(){
       this.crossing.getTimer().start();
       repaint();
    // i tried below code also it didn't work. so i put them in comments
       Runnable rotateCrossing1 = new Runnable(){  // to be removed
             public void run() {
            crossing.getTimer().start();
          SwingUtilities.invokeLater(rotateCrossing1);
    // MAIN CLASS
    // This is the GUI class which consists of buttons and others
    public class MainAPP{
       SeePanel = new SeePanel();
      // Buttons declarations here and others
    public MainAPP(){
      // all listener registers here
    // Here i call the rotateCrossing() of the SeePanel class but it is not working as i want.
    // I would like to see the image rotating gradually till it stops but it doesn't.
    //This it what it does. After i click the button, i don't see it rotating. But when i minimize and maximize the main window,
    // i see the image  just rotate(flip) fast like that.
    public void actionPerformed(ActionEvent e){
        SeePanel.rotateCrossing();                 
        public static main(string[] str){
    }Please do help me to fix it.
    thanks

    kap wrote:
    1 down vote favoriteHuh?
    ..Please i have trimed down the code for easy reading. ..Perhaps I am just lazy, but I don't actually like reading code until I've seen it compile in my editor & run. That is why I will advise that for better help sooner, post an SSCCE. For SSCCEs that use images, either generate an image in the code, or hot-link to an image available on the internet. I offer some [images at my site|http://pscode.org/media/#image] that you can hot-link to.

  • HI Please Help me with Zoom of a buffered image

    Hi All,
    Please help,
    I want to zoom the buffered image using Affine Transforms, the code shown below can rotate the buffered image now how to zoom the same buffered image using Affine Transforms.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import javax.swing.*;
    public class RotationBounds extends JPanel implements ActionListener
        BufferedImage image;
        AffineTransform at = new AffineTransform();
        Rectangle2D.Double bounds = new Rectangle2D.Double();
        double theta = 0;
        double thetaInc = Math.PI / 2;
        public void actionPerformed(ActionEvent e)
            theta += thetaInc;
            setTransform();
            repaint();
        private void setTransform()
            int iw = image.getWidth();
            int ih = image.getHeight();
            double cos = Math.abs(Math.cos(theta));
            double sin = Math.abs(Math.sin(theta));
            double width = iw * cos + ih * sin;
            double height = ih * cos + iw * sin;
            double x = (getWidth() - iw) / 2;
            double y = (getHeight() - ih) / 2;
            at.setToTranslation(x, y);
            at.rotate(theta, iw / 2.0, ih / 2.0);
            x = (getWidth() - width) / 2;
            y = (getHeight() - height) / 2;
            // Set bounding rectangle that will frame the image rotated
            // with this transform. Use this width and height to make a
            // new BuffferedImage that will hold this rotated image.
            // AffineTransformOp doesn't have this size information in
            // the translation/rotation transform it receives.
            bounds.setFrame(x - 1, y - 1, width + 1, height + 1);
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D) g;
            setBackground(Color.gray);
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
            if (image == null)
                initImage();
            g2.drawRenderedImage(image, at);
            // g2.setPaint(Color.blue);
            g2.draw(bounds);
            g2.setPaint(Color.green.darker());
            g2.fill(new Ellipse2D.Double(getWidth() / 2 - 2,
                getHeight() / 2 - 2, 4, 4));
        private void initImage()
            int w = 360, h = 300;
            image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = image.createGraphics();
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(new Color(220, 240, 240));
            g2.fillRect(0, 0, w, h);
            g2.setPaint(Color.red);
            g2.drawString("Text for test", 50, 50);
            g2.drawRect(0, 0, w - 1, h - 1);
            g2.dispose();
            g2.setTransform(at);
    //        setTransform();
        private JPanel getLast()
            JButton rotateButton = new JButton("Rotate");
            rotateButton.addActionListener(this);
             JButton zoomButton = new JButton("Zoom");
            JPanel panel = new JPanel();
            panel.add(rotateButton);
            panel.add(zoomButton);
            return panel;
        public static void main(String[] args)
            RotationBounds test = new RotationBounds();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(test);
            f.getContentPane().add(test.getLast(), "North");
            f.setSize(400, 400);
            f.setLocation(0, 0);
            f.setVisible(true);
    }Message was edited by:
    New_to_Java

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.util.Hashtable;
    import javax.swing.*;
    import javax.swing.event.*;
    public class RotationZoom extends JPanel {
        AffineTransform at = new AffineTransform();
        Point2D.Double imageLoc = new Point2D.Double(100.0, 50.0);
        Rectangle2D.Double bounds = new Rectangle2D.Double();
        BufferedImage image;
        double theta = 0;
        double scale = 1.0;
        final int PAD = 20;
        public RotationZoom() {
            initImage();
        public void addNotify() {
            super.addNotify();
            setTransform();
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            g2.drawRenderedImage(image, at);
            g2.setPaint(Color.red);
            g2.draw(bounds);
        public Dimension getPreferredSize() {
            return new Dimension((int)(imageLoc.x + Math.ceil(bounds.width))  + PAD,
                                 (int)(imageLoc.y + Math.ceil(bounds.height)) + PAD);
        private void update() {
            setTransform();
            revalidate();
            repaint();
        private void setTransform() {
            int iw = image.getWidth();
            int ih = image.getHeight();
            double cos = Math.abs(Math.cos(theta));
            double sin = Math.abs(Math.sin(theta));
            double width  = iw*cos + ih*sin;
            double height = ih*cos + iw*sin;
            at.setToTranslation(imageLoc.x, imageLoc.y);
            at.rotate(theta, scale*iw/2.0, scale*ih/2.0);
            at.scale(scale, scale);
            double x = imageLoc.x - scale*(width - iw)/2.0;
            double y = imageLoc.y - scale*(height - ih)/2.0;
            bounds.setFrame(x, y, scale*width, scale*height);
        private void initImage() {
            int w = 240, h = 180;
            int type = BufferedImage.TYPE_INT_RGB;
            image = new BufferedImage(w,h,type);
            Graphics2D g2 = image.createGraphics();
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setBackground(new Color(220,220,240));
            g2.clearRect(0,0,w,h);
            g2.setPaint(Color.red);
            g2.draw(new CubicCurve2D.Double(0, h, w*4/3.0, h/4.0,
                                            -w/3.0, h/4.0, w, h));
            g2.setPaint(Color.green.darker());
            g2.draw(new Rectangle2D.Double(w/3.0, h/3.0, w/3.0, h/3.0));
            g2.dispose();
        private JPanel getControls() {
            JSlider rotateSlider = new JSlider(-180, 180, 0);
            rotateSlider.setMajorTickSpacing(30);
            rotateSlider.setMinorTickSpacing(10);
            rotateSlider.setPaintTicks(true);
            rotateSlider.setPaintLabels(true);
            rotateSlider.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    int value = ((JSlider)e.getSource()).getValue();
                    theta = Math.toRadians(value);
                    update();
            rotateSlider.setBorder(BorderFactory.createTitledBorder("theta"));
            int min = 50, max = 200, inc = 25;
            JSlider zoomSlider = new JSlider(min, max, 100);
            zoomSlider.setMajorTickSpacing(inc);
            zoomSlider.setMinorTickSpacing(5);
            zoomSlider.setPaintTicks(true);
            zoomSlider.setLabelTable(getLabelTable(min, max, inc));
            zoomSlider.setPaintLabels(true);
            zoomSlider.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    int value = ((JSlider)e.getSource()).getValue();
                    scale = value/100.0;
                    update();
            zoomSlider.setBorder(BorderFactory.createTitledBorder("scale"));
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.weightx = 1.0;
            gbc.fill = GridBagConstraints.HORIZONTAL;
            gbc.gridwidth = GridBagConstraints.REMAINDER;
            panel.add(rotateSlider, gbc);
            panel.add(zoomSlider, gbc);
            return panel;
        private Hashtable getLabelTable(int min, int max, int inc) {
            Hashtable<Integer,JComponent> table = new Hashtable<Integer,JComponent>();
            for(int j = min; j <= max; j += inc) {
                JLabel label = new JLabel(String.format("%.2f", j/100.0));
                table.put(new Integer(j), label);
            return table;
        public static void main(String[] args) {
            RotationZoom test = new RotationZoom();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new JScrollPane(test));
            f.getContentPane().add(test.getControls(), "Last");
            f.setSize(500,500);
            f.setLocation(200,100);
            f.setVisible(true);
    }

  • Cant' move images from frame to frame inside a Grid in InDesign. Please Help

    When creating a grid in indesign there is an option to move images from frame to frame, and having them rotate around the frames to see where each image is best to be placed. Example I created a grid with 6 images (2 rows and 3 columns) and now i want image 1 to be where image 6 is. I know there's a way by hitting the arrows and some other keys and have all the images start rotating. I did it once I just can't remember. Please help. How do you move the an image from one frame to another frame without having to go to edit place?
    Thanks,
    Paola

    Swapping images

Maybe you are looking for