Zooming out with AffineTransform

I'm trying to create a generic container panel that can zoom and pan over arbitrary JComponents. Zooming in works fine. Zooming out is getting some odd side effects from the clip. Zooming out, then resizing the window doesn't show the whole image. The top and bottom are trimmed off, despite the large space available at the top and bottom of the window.
I've overridden paintChildren() to set the Graphics' transform. mutantGraphics.setClip(mutantClip) doesn't seem to matter; the clip only gets smaller.
How do I restore the clip to the larger size?
Thanks,
Dave
   public final class ZoomPanel
        extends JPanel
        private JPanel view;
        private AffineTransform transform;
        private AffineTransform inverse;
        private static final double ZOOMINRATE = 1.1;
        private static final double ZOOMOUTRATE = 1/ZOOMINRATE;
        private Dimension originalSize;
        //todo preferred size
        ZoomPanel(JPanel view)
            super(new BorderLayout());
            add(view);
            this.view = view;
            this.originalSize = view.getPreferredSize();
            this.setPreferredSize(originalSize);
            transform = new AffineTransform();
            try
                inverse = transform.createInverse();
            catch(NoninvertibleTransformException nte)
                throw new RuntimeException(nte);
        private void transformChanged()
            try
                inverse = transform.createInverse();
            catch(NoninvertibleTransformException nte)
                throw new RuntimeException(nte);
            view.repaint();
        public void zoomOut()
            transform.translate(getWidth()/2,getHeight()/2);
            transform.scale(ZOOMOUTRATE,ZOOMOUTRATE);
            transform.translate(-getWidth()/2,-getHeight()/2);
            transformChanged();
        public void zoomIn()
            transform.translate(getWidth()/2,getHeight()/2);
            transform.scale(ZOOMINRATE,ZOOMINRATE);
            transform.translate(-getWidth()/2,-getHeight()/2);
            transformChanged();
        protected void paintChildren(Graphics originalGraphics)
            Graphics2D mutantGraphics = (Graphics2D)originalGraphics.create();
            Shape originalClip = originalGraphics.getClip();
            System.out.println("originalClip "+originalClip);
            Shape mutantClip = inverse.createTransformedShape(originalClip);
            mutantGraphics.transform(transform);
            mutantGraphics.setClip(mutantClip);
            System.out.println("mutantGraphics.getClip() "+mutantGraphics.getClip().getBounds());
            mutantGraphics.setStroke(new BasicStroke(4));
            mutantGraphics.draw(mutantGraphics.getClip().getBounds());
            super.paintChildren(mutantGraphics);
    }

You'll need to modify the preferred size of your component as you zoom.
Typically, I would set the component's preferred size to fit the zoomed image (ie at 0.5 zoom the width and hieght would both be double the original size) and then stuff it into a JScrollPane.
At the moment you set the preferred size initially but never change it, so your image is being clipped by the bounds of the component - it can't render outside its bounds so the component needs to be at least as large as the view.

Similar Messages

  • Problems zooming out with a Flash Banner

    I have created a Flash banner for the home page of my website.  Here is the link to the page I am working on:  http://adirondackvic.org/CSSTest9July2012-2.html
    When I zoom in to increase the size of the web page, the Flash banner rescales automatically.  However, when I zoom out, to decrease the size of the web page, the Flash banner does not automatically rescale.  It remains the same size and you have to hit the refresh button to get it to rescale to fit the newly resized page. 
    Is there a fix for this?  I searched the forum and the web and have not found an answer.  I put a question on this in another forum, but received no responses. I found some discussions of the issue on the web and on this forum, but I was not able to figure out how to incorporate the suggestions into my page.  I tried changing the scale from exactfit to showall, as recommended, but that created a problem with the appearance of the page. (The banner no longer fit properly into the header window.) I also tried (as recommended by one of the entries in this forum) to change width="100%" height="100%" or width="100%" height="auto".  This fixed the problem for Internet Explorer, but then the entire banner disappeared in Firefox. 
    Please help!  I am at my wit's end....  Thank you.  ellen
    Here is the relevant  code:
    <div class="header"><!-- end .header -->
        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="960" height="100" align="absmiddle" id="FlashID" title="FlashBanner">
          <param name="movie" value="BannerTest16.swf">
          <param name="quality" value="high">
          <param name="wmode" value="opaque">
          <param name="swfversion" value="6.0.65.0">
          <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
          <param name="expressinstall" value="../Scripts/expressInstall.swf">
          <param name="LOOP" value="false">
          <param name="SCALE" value="exactfit">
          <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
          <!--[if !IE]>-->
          <object data="BannerTest16.swf" type="application/x-shockwave-flash" width="960" height="100" align="absmiddle">
            <!--<![endif]-->
            <param name="quality" value="high">
            <param name="wmode" value="opaque">
            <param name="swfversion" value="6.0.65.0">
            <param name="expressinstall" value="../Scripts/expressInstall.swf">
            <param name="LOOP" value="false">
            <param name="SCALE" value="exactfit">
                  <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
                  <div>
          <img src="Images/Banner102 -- Saint Regis Mountain from the Barnum Brook Trail --  June 2012-1.jpg" width="960" height="102" alt="Paul Smith's College VIC" align="absmiddle">         
                  </div>
            <!--[if !IE]>-->
          </object>
          <!--<![endif]-->
        </object>
      </div>

    Kevinsoffice wrote:
    iDevices are pretty much dead hardware since they dont support popular flash. How many mac forums are filled with people complaining about Apples choice not to support it. And with much better hardware coming out like the Samsung line there are better choices then iStuff.
    The evidence does not support that position.
    As expected,  Adobe has stopped developing Flash on mobile devices (iOS and Android)
    http://www.businessinsider.com/adobe-to-kill-mobile-flash-starting-august-15-2012-6
    http://www.digitaltrends.com/mobile/adobe-flash-for-android-gone-with-barely-a-whimper/
    Flash is dying, iStuff is alive and well.

  • When on the internet, how can I zoom out with out cuting off part of games and stuff?

    When I go to Mozilla Firefox, I can't see everything on the screen because it is zoomed in to much. When I go to view and zoom out, it zooms out but when I go to armorgames, part of the games I play are cut off so I can't see everything on the game. Plus, it just zooms back in when I leave Firefox and get back on. It wasn't always like that though. I want to know if I can set the default view to normal so I can see everything on the screen without having to scroll left and right, or having part of games cut off.

    Hi lilmikrymike15, <br>
    If you use View > Zoom > Reset, does the zoom level reset to the expected size?
    To set your default zoom level you usually need an add-on. Have you tried installing one named Default FullZoom Level or another named NoSquint? <br>
    Tools > Add-ons > Extensions category
    <br>
    You can also try disabling Firefox's use of hardware accelerated graphics. In order for this to take effect you usually need to restart Firefox. <br>
    Go to Firefox > Preferences > Advanced > General and uncheck the box for "Use hardware acceleration when available"
    If you restart Firefox, is the clarity improved?
    <br>
    Hope i have helped!

  • When I want to zoom in or zoom out with the mouse wheel and CONTROL button the letters get larger but remain within the same size paragraph and any pictures remain the same. I want the entire page to zoom.

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [[/questions/866940]]</blockquote>
    I want the entire page to zoom in and out when I use CONTROL + mouse wheel. Now the letters get larger but remain in the same size paragraph and also the pictures stay the same.

    It is indeed scandalous that Apple sells useless scanned music scores. There is a warning when you chose to download music tabs or notes but it doesn't say that the score lines are very small and cannot be zoomed. I spent $30 on two books but cannot really use them on my MBA as you cannot zoom except for the double click which only works page per page and is only a small improvement.
    The only way I can use the score more or less is on my ipad in landscape mode by increasing the font size to the max. The music score then becomes wider and you can read 2-3 lines per page without glasses.
    If you could transfer the file to the pdf  "side" of the library in ibooks the zoom would work..
    What does work is using the accessibility zoom mode option+command+= to zoom and then option+command+\ to smooth the picture but then your whole display desktop etc. are zoomed in.

  • HT1338 my trackpad is not letting me zoom out with fingers

    Just today my trackpad is no longer zooming images and pages when I use my two fingers on it. Has this happened to anyone and how do I fix?
    I've already confirmed these functions are checked in my Systems Preferences.

    Uncheck the trackpad settings and recheck them back, one by one.
    Restart the computer. This has helped many.

  • Using scroll wheel with modifier key to zoom out is not working

    I can't zoom out with the magnifying tool selected in all programs of the CS3 suite using the option key on a Mac. I can zoom in with no problem. I've been trying to figure this out for "8 hours" now!!!
    I do have this checked in the system preferences and Photoshop preferences. I don't think this is considered a keyboard shortcut but I do have universal access checked and zoom out checked in the system preferences.
    I searched this site and all of the internet looking for answers but can't seem to find much. I appreciate any help you can give. I'm way behind on my work today.
    Thank you!

    The default key for scrolling zoom is not Command but Control. To change this, go to System Preferences —> Universal Access and click on the Seeing tab. In the Zoom pane, click on the Options button, and in the sheet that drops down, select the text box at the bottom, highlight the character there, then press the modifier key you prefer.
    HTH
    Archie

  • How to open,view pdf document in a form with zoom in and zoom out functionality Please urgent

    Hi
    Anybody can help me with a sample code in c# to open a pdf document using forms and to give the functionality   zoom in and zoom out   with verticall and horizontal scroll bar. Please help
    Regards
    Pol
    polachan

    Hello polachan,
    you can find two sample projects with code at
    [1] and
    [2].
    [1]
    http://www.codeproject.com/Articles/579878/MoonPdfPanel-A-WPF-based-PDF-viewer-control
    [2]
    http://www.gnostice.com/nl_article.asp?id=159&t=How_To_Create_A_PDF_Viewer_in_PDFOne_NET_v2_x
    Regards,
    Bo Liu
    Developer-Hotline for MSDN Online Germany
    Disclaimer:
    Please take into consideration, that further inquiries cannot or will be answered with delay.
    For further information please contact us per telephone through the MSDN-Entwickler-Hotline:
    http://www.msdn-online.de/Hotline
    For this post by the MSDN-Entwickler-Hotline the following terms and conditions
    apply: Trademarks,
    Privacy
    as well as the separate
    terms of use for the MSDN-Entwickler-Hotline .

  • Camera zoom-out

    Hi.
    I'm using Motion 4 and I'm trying to achieve a camera zoom-out with some conditions. Here's a image to explain the size and the type of zoom I'm looking for. My background images have 3072x1536 pixels and my canvas in Motion is defined to be 1024x768 pixels.
    As you can see by the picture, I want to scale my camera view but I only want to do it through the upper right diagonal so that my bottom left point stays at the same place.
    I've already tried to change the camera between framing and viewpoint but If I got my layers appart in 3D space they all start to phase out because of the perspective. Considering a flat image on the background, how can I scale/zoom-out my camera to do the effect on the image?
    Thank you!

    Walk backwards, as there is no zoom in video mode. Either that, or look for an app that provides "video zoom".

  • Control + minus zoom out - please read

    I use the control + minus for zooming out with my left hand (using control key on RIGHT side of keyboard and don't need to remove right hand from mouse) so often it's subconscious. Now, when I use that keystroke it turns the cursor into the minus pen tool. PLEASE READ FURTHER.
    If I remove my hand from the mouse and use the control key on the LEFT side of the keyboard it works but I don't want to have to do that.  I have upgraded from CS4 to CS5, and it is still doing this, AND got a brand new keyboard. It works fine in Photoshop - it just does this in illustrator, and it's driving me NUTS.  so it's not my keyboard, and it shouldn't be illustrator since I upgraded. WHAT is going on?  I need this to function because I use it all the time and don't want to have to think before doing it, or have to slow myself down by using both hands.  HELP!  (and thanks to anyone who can tell me how to get out of this loop of hell!)
    [p.s. will be out of office for next week so may not be able to respond after today]

    Edit  >> Keyboard Shrcuts
    Though the PC or Mac both don't discrimate whether you use the left or right CMD or Ctrl in Illustrator,  I would still check these out.
    The PC also has a control panel for international keyboard languages & assistance for handicapped, take a look at those. I don't have a Win station in front of me at the moment to give you the exact name of those.

  • Aperture 3.4.1 Zoom out at 25% not working

    Hi,
    I just remarked that the Zoom Out at 25% with Aperture 3.4.1 doesn't work any more...the maximum Zoom Out is now fixed to the size
    of the window. I'm pretty sure that this worked on Aperture 3.4 though.
    While not a big problem, I like to view my photos at smaller size, to see how they look like on small printouts.
    Does someone have the same issue with Zoom Out with Aperture 3.4.1?
    Cheers,
    Gilles

    I could not get to work since Aperture 3.4 either. Zoom out now seems to stop, when the image fills the window.
    As a work-around, select more than one image in full screen mode, and you can zoom out to 25%.
    Or put the image on a Light-Table; then you can zoom out to really small thumbnail sizes.
    Regards
    Léonie
    Four image in Full screen view selected, zoomed in out differently (25%, 25%, 100%, 200%), for example:

  • Zoom problems with G30

    When I zoom out with the rocker switch on my G30, the zoom will return to a wide angle, especially if I lightly touch the telephoto end of the rocker. It will continue to return to wide angle by itself, even if I move the rocker switch to telephoto. This seems to occur when the weather is hot (we shoot outside much of the time) and the camera has been operating for an extended period. This zoom problem does not seem to happen if the touch screen and remote zoom are used and the camera is cool. I bought this camera 9/2013. Has anyone else experienced this issue? Could this be a defective zoom switch? Would updated firmware make any difference? Any help would be appreciated.

    Hi mimages!
    Thank you for posting.
    Based on your description, the camcorder will need to be examined by a technician at our Factory Service Center.  To start this process, you'll need to complete a Repair Request on our website.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • Screen zoomed in, won't zoom out

    The display was adjusted somehow and now all of my screen is zoomed in. I tried zooming out with the function keys and that didn't work. On my desktop I have to move the mouse to the bottom of the screen so it will scroll just to see my dock bar because I cant see my dock bar as if I normally could had things not been adjusted. Does anyone have an idea what I should do? Thanks

    Turn off Zoom from the Universal Access and Keyboard & Mouse panes of System Preferences.
    (55407)

  • I plugged my macbook pro into an external monitor, then unplugged it later and now it is stuck with black borders on top and bottom and zoomed out like it is still on the monitor. How do I fix it?

    I started using my external monitor with my macbook pro and as soon as I plug it in it to the monitor it adjusts the screen by zooming out a bit and creating about 3/4 of an inch black borders on the top and bottom of the screen. But these dont show up on the monitor so I assumed it was fine. But when I took it off the monitor, the borders were still there like it was still on the monitor. Any hellp? Its starting to mess with my eyes haha.

    Hi aefulcher,
    It sounds like you had the external display set to mirror the internal display so the resolution(s) were changed to match each other.
    OS X: How to use multiple displays with your Mac in Mountain Lion and earlier
    http://support.apple.com/kb/ht5019
    Check if the current resolution matches your screen's natiive resolution.
    Thank you for visiting Apple Support Communities.
    Nubz

  • MY IPOD APPEARS TO BE ZOOMED INTO THE SCREEN AT ALL TIMES, MAKING IT DIFFICULT TO DO SIMPLE TASKS SUCH AS GO BACK, OR SELECT A PLAYLIST, ETC. I'VE TRIED PULLING IT OUT WITH MY FINGERS BUT THAT DOESN'T WORK. PLEASE CAN YOU HELP!!! THANKS.

    I've got a touch iPod and for about a week now it's almost been permenently zoomed into the screen? I actually cannot get it to zoom back out. I've tried pulling the screen out with my fingers but that doesn't work. It's zoomed in on my home pages, on my music, settings everything! It makes simple things like deleting a number from my password login extreamly differcult. Please can someone help?!?! Thanks.

    Double tap the screen with three fingers to un-zoom.
    Then go to Settings > General > Accessibility > Zoom and turn this OFF.

  • When I zoom in + out with dodge tool the cursor changes

    So I just installed CS5 on a newly formatted PC.
    I didn't used to have this problem before before I completely formatted on HDD do to a virus + reinstalled Windows7, although now its getting on my nerves.
    Basically when I zoom in the dodge tool circle will change into a half circle and if I zoom in even more it will change into what seems to be two circles intertwined and if I zoom out around 35% it changes into 4 full circles???
    Even when I switch from my photoshop in the taskbar to firefox (without zooming back in) the cursor then changes into 4 normal mouse pointers???? For some reason it will quickly switch back if I press a button on my keyboard. But thats about it, maybe this might be a problem with my video driver maybe?
    Im using Inegrated Gfx: Intel GMA X4500

    Just updated driver... seems fine for now.

Maybe you are looking for

  • Can't get rid of extra line in div

    can someone check my code on my site www.coloredfortunecookies.com. towards the bottom of the quick order guide there is an extra space in between my pics and the header 2 text in both the jumbo and giant cookie div's.  i can't figure out how to get

  • Is it possible to bypass authority check in standard program?

    Dear gurus, I met a problem, i am trying to build a costom program, which will call a sap standard function module, but the problem is: in the standard function module , there is a check against authorization object p_tcode, i dont want to give user

  • Mapping test throughs exception for UDF that does'nt exist anymore

    Hello everybody, my mapping test throughs an exception for a UDF that I deleted? Any ideas? Regards Mario

  • How to print remunration statement in PDF

    Hi all, I just wanted to inquire if there is a way to print the remuneration statement in PDF format. I mean I can print the statements but if I want to see them in pdf can this be done. Thanks

  • IUser gives error in Web Dynpro

    Hi, I am trying to use the following code to capture portal user id nad pswd in web dynpro IWDClientUser user = WDClientUser.getCurrentUser(); IUser iuser = user.getSAPUser(); String name = iuser.getUniqueID(); I have included com.saop.security.api.j