It may not be exactly what you want, but I did a print preview panel where I had to scale Printable pages down into a small window. In order to get past the problem where moving the cursor over the window redrew what was underneath the cursor at original scale, I ended up removing the mouse listeners and key listeners. The panel was meant to be read-only and uneditable, so this worked for me.
Steve Sinai --- On Sun, 8/10/08, Dmitri Trembovetski <[EMAIL PROTECTED]> wrote: From: Dmitri Trembovetski <[EMAIL PROTECTED]> Subject: Re: [JAVA2D] Generic ZoomPanel? To: [EMAIL PROTECTED] Date: Sunday, August 10, 2008, 3:08 PM In general transforming Swing components is a little tricky. Take a look at this helper class though: http://weblogs.java.net/blog/alexfromsun/archive/2006/07/jxtransformer_t.html I believe Alex updated it since. Thanks, Dmitri [EMAIL PROTECTED] wrote: > Hi all, > a question re. the Java 2D API: > > I would like to create a generic ZoomPanel, i.e. a Panel that would allow to display the objects contained in it using an adjustable zoom factor. > Ideally this Panel would be used much like a JScrollPanel, i.e.: > > The JScrollPanel allows to wrap some content in a scrollable panel by just using: > > 1) main.add(new JScrollPane(someContentPanel)); > > Ideally I would like to apply the Zoompanel in the exact same way, i.e.: > > 2) main.add(new ZoomPanel(someContentPanel)); > > This would even allow to combine the two, e.g. like: > > 3) main.add(new JScrollPane(new ZoomPanel(someContentPanel))); > > > > Using Google and some API documentation I found misc. code snippets, which I condensed into the following: > > class ZoomPanel extends JPanel > { > private double scalingFactor = 0.50; > > ZoomPanel(final JComponent comp) { > setLayout(new BorderLayout()); > add(comp, BorderLayout.CENTER); > } > /** > * @return the scalingFactor > */ > double getScalingFactor() { > return this.scalingFactor; > } > /** > * @param scalingFactor the scalingFactor to set > */ > void setScalingFactor(double scalingFactor) { > this.scalingFactor = scalingFactor; > } > @Override > public Dimension getPreferredSize() { > final Dimension size = getLayout().preferredLayoutSize(this); > return new Dimension((int)(size.width * this.scalingFactor), > (int)(size.height * this.scalingFactor)); > } > @Override > public boolean isOptimizedDrawingEnabled() { > return false; > } > @Override > public void paint(Graphics g) { > Graphics2D g2 = (Graphics2D) g; > java.awt.geom.AffineTransform backup = g2.getTransform(); > g2.scale(this.scalingFactor, this.scalingFactor); > super.paint(g2); > g2.setTransform(backup); > } > } > > > If applied as shown under 3) the above ZoomPanel does indeed display a zoomed copy of all children contained in "someContentPanel". > So, at first everything looks fine. However, if I move with the mouse over that panel, then certain children appear (i.e. are repainted) in their original size and location and obviously also the mouse positions are not properly translated and all clicks etc. go to wrong positions. So obviously the above is too simple (would have been too nice...) and does not cover every aspect that has to be taken care of in such a zoom panel > > Has someone implemented something like this and could give me a list or at least a rough sketch, what all is still missing to achieve a generic panel? What needs to be overriden, added, replaced or whatever it takes to get this fully operational and usable? > > Note: I do NOT know, what "someContentPanel" contains. As I said: I am trying to create a [b]generic[/b] panel that allows for arbitrary content. > > Michael > [Message sent by forum member 'mmo18' (mmo18)] > > http://forums.java.net/jive/thread.jspa?messageID=292502 > > =========================================================================== > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". hasEML = false; ReplyReply All JSifyForm("forward_bottom1605134131"); Move...Inbox var oMoveHandlebottom = new MoveButton("bottom_move1605134131", "bottom_move_select1605134131"); var oReplyHandlebottom = new SplitButton("1605134131bottom_reply", "1605134131bottom_reply_all"); Go to Previous message | Go to Next message | Back to Messages Select Message Encoding ASCII (ASCII)Greek (ISO-8859-7)Greek (Windows-1253)Latin-10 (ISO-8859-16)Latin-3 (ISO-8859-3)Latin-6 (ISO-8859-10)Latin-7 (ISO-8859-13)Latin-8 (ISO-8859-14)Latin-9 (ISO-8859-15)W. European (850)W. European (CP858)W. European (HPROMAN8)W. European (MACROMAN8)W. European (Windows-1252)Armenia (ARMSCII-8)Baltic Rim (ISO-8859-4)Baltic Rim (WINDOWS-1257)Cyrillic (866)Cyrillic (ISO-8859-5)Cyrillic (KOI8-R)Cyrillic (KOI8-RU)Cyrillic (KOI8-T)Cyrillic (KOI8-U)Cyrillic (WINDOWS-1251)Latin-2 (852)Latin-2 (ISO-8859-2)Latin-2 (WINDOWS-1250)Turkish (ISO-8859-9)Turkish (WINDOWS-1254)Arabic (ISO-8859-6, ASMO-708)Arabic (WINDOWS-1256)Hebrew (856)Hebrew (862)Hebrew (WINDOWS-1255)Chinese Simplified (GB-2312-80)Chinese Simplified (GB18030)Chinese Simplified (HZ-GB-2312)Chinese Simplified (ISO-2022-CN)Chinese Simplified (WINDOWS-936)Chinese Trad.-Hong Kong (BIG5-HKSCS)Chinese Traditional (BIG5)Chinese Traditional (EUC-TW)Japanese (SHIFT_JIS)Japanese (EUC-JP)Japanese (ISO-2022-JP)Korean (ISO-2022-KR)Korean (EUC-KR)Thai (TIS-620-2533)Thai (WINDOWS-874)Vietnamese (TCVN-5712)Vietnamese (VISCII)Vietnamese (WINDOWS-1258)Unicode (UTF-7)Unicode (UTF-8)Unicode (UTF-16)Unicode (UTF-32) | Full Headers Search Mail Search the Web gLaunchProfile.stop("T5"); gLaunchProfile.start("T3"); showMsg("message1605134131"); #message1605134131 { visibility:visible; overflow-y:auto; } #yui-main { background-color:#D6DEEC } YAHOO.util.Event.on("flag0", "click", YAHOO.mc.flag.flagMsg); YAHOO.util.Event.on('encode_select1605134131', "change", function() { document.changeEncForm1605134131.submit(); }); YAHOO.util.Event.on("domainkeys", "click", function(e) { YAHOO.util.Event.preventDefault(e); window.open(YAHOO.util.Event.getTarget(e).href, 'remote', 'width=640,height=480,top=100,left=100,resizable=yes'); }); YAHOO.mc.flagKey = { FLAG_TITLE : 'Clear flag', UNFLAG_TITLE : 'Flag this message' }; var frmWarnMsg = 'Warning! You are about to send information to someone other than Yahoo! If you do not want anyone outside of Yahoo! to have this information, click \"Cancel\" now.'; frmWarnMsg += '\n' + 'Remember: Yahoo! will NEVER ask you for your password in an unsolicited phone call or an unsolicited email.'; var pwdWarnShown = 'false'; var pwdWarnMsg = 'Warning! You are about to enter a password in a form that will not be sent to Yahoo!.'; pwdWarnMsg += '\n' + 'Remember: Yahoo! will NEVER ask you for your password in an unsolicited phone call or an unsolicited email.'; var lnkWarnMsg = 'Warning! It appears that you are about to access a website that has non-standard web address format.'; lnkWarnMsg += ' ' + 'Such sites may contain harmful entities such as viruses.'; lnkWarnMsg += ' ' + 'We recommend you use extreme caution.'; var theMainWindow = { showFormWarning: function(msgFrm) { return confirm(frmWarnMsg); }, showPasswordWarning: function(msgFrm) { if (pwdWarnShown == 'false') { pwdWarnShown = 'true'; alert(pwdWarnMsg); } }, showLinkWarning: function(msgFrm) { return confirm(lnkWarnMsg); } }; YAHOO.util.Event.on("printIcon", "click", function(e) { YAHOO.util.Event.preventDefault(e); var pWin = window.open(YAHOO.util.Event.getTarget(e).href, "Print", "menubar=1,resizable=1,scrollbars=yes,dependent=yes,width=800,height=600"); pWin.focus(); }); YAHOO.mc.shortcuts.init(); YAHOO.util.Event.on(["forward_top1605134131", "forward_bottom1605134131"], "click", forwardAsAttachment); function forwardAsAttachment(e) { if (YAHOO.mc.shortcuts.ctrlKey) { var elTarget = YAHOO.util.Event.getTarget(e); createElement("input", "fA", "1", elTarget.form); } } YAHOO.mc.classicScOptions = "http://us.f509.mail.yahoo.com/ym/Preferences?.rand=1605134131#yahoo_shortcuts"; YAHOO.mc.shortcutsUrl = "http://mail.yimg.com/us.js.yimg.com/lib/lw/ysc_csc_ymailm_3.1.5.js"; gLaunchProfile.start("SCRenderTime"); YAHOO.util.Event.on(window, "load", function () { window.setTimeout(function() { YAHOO.ShortcutsExt = YAHOO.ShortcutsExt || {}; YAHOO.ShortcutsExt.contentReady = true; var n = document.createElement('script'); n.src = YAHOO.mc.shortcutsUrl; document.getElementsByTagName("head")[0].appendChild(n); }, 0); }); gLaunchProfile.stop("SCRenderTime"); gLaunchProfile.start("adLoadTime"); if(window.yzq_d==null)window.yzq_d=new Object(); window.yzq_d['V1ctAUWTfrQ-']='&U=12apl7teo%2fN%3dV1ctAUWTfrQ-%2fC%3d-1%2fD%3dRS%2fB%3d-1%2fV%3d0'; if(window.yzq_d==null)window.yzq_d=new Object(); window.yzq_d['WFctAUWTfrQ-']='&U=12bsbakoi%2fN%3dWFctAUWTfrQ-%2fC%3d-2%2fD%3dRS2%2fB%3d-2%2fV%3d0'; Copyright © 1994-2008 Yahoo! Inc. All rights reserved. Terms of Service - Copyright/IP Policy - Guidelines NOTICE: We collect personal information on this site. =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".