|
Replies:
13
-
Last Post:
Aug 18, 2008 8:10 AM
by: Dmitri Trembove...
|
Threads:
[
Previous
|
Next
]
|
|
|
|
|
|
Generic ZoomPanel?
Posted:
Aug 10, 2008 2:27 PM
|
|
|
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 generic panel that allows for arbitrary content.
Michael
Message was edited by: mmo18
|
|
|
|
|
|
|
Re: [JAVA2D] Generic ZoomPanel?
Posted:
Aug 10, 2008 3:08 PM
in response to: mmo18
|
|
|
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
java2d@JAVADESKTOP.ORG 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 generic 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 listserv@java.sun.com and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > listserv@java.sun.com and include in the body of the message "help".
=========================================================================== To unsubscribe, send email to listserv@java.sun.com and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to listserv@java.sun.com and include in the body of the message "help".
|
|
|
|
|
|
|
|
Re: [JAVA2D] Generic ZoomPanel?
Posted:
Aug 11, 2008 3:32 PM
in response to: Dmitri Trembove...
|
|
|
Alas, neither JXLayer nor JXTransformer do work properly.
To get an idea what I mean by "do not work properly" try the below test program. If the scaling-factor (at the begin of "ZoomPanelUI") is set to 1.0, things work OK, if I change it to e.g. 0.5 then part of the content is not drawn, elements disappear and reappear almost at random while hovering with the mouse over it and it is not possible to click the intended button.
With JXTransformer I get similar effects and - strange enough - the same
Exception in thread "AWT-EventQueue-1" java.lang.InternalError: Win32OSSD_Lock cannot nest locks
that I reported already for JGUI (my second append). Seems to be trickier than I ever thought, this generic ZoomPanel.... 
Michael
PS.: my little test program. It draws a couple of buttons and connects two of them with a red line (just to test the drawing).
package test;
import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GridLayout; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseWheelEvent; import java.util.ArrayList;
import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JScrollPane;
import org.jdesktop.jxlayer.JXLayer; import org.jdesktop.jxlayer.plaf.AbstractLayerUI; import javax.swing.JApplet;
@SuppressWarnings("serial") public class Test extends JApplet { private JPanel viewer; private ArrayList<JButton> buttons = new ArrayList<JButton>(); private Container mainPanel; @Override public void init() { this.mainPanel = getContentPane(); this.mainPanel.setLayout(new BorderLayout()); this.setLayout(new BorderLayout()); this.viewer = new JPanel() { @Override public void paint(final Graphics g) { super.paint(g); addConnections(g); } }; this.viewer.setLayout(new GridLayout(4,4)); for (int i = 0; i < 16; i++) { JButton button = new JButton("button " + i) { { this.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println(getText() + " pressed"); } }); } }; this.buttons.add(button); this.viewer.add(button); }
JXLayer<JComponent> zoomPanel = new JXLayer<JComponent>(this.viewer, new ZoomPanelUI<JComponent>()); this.mainPanel.add(new JScrollPane(zoomPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER); } void addConnections(final Graphics g) { JButton b1 = this.buttons.get(4); JButton b2 = this.buttons.get(11); Point l1 = b1.getLocation(); Dimension s1 = b1.getSize(); Point l2 = b2.getLocation(); Dimension s2 = b2.getSize(); g.setColor(Color.RED); g.drawLine(l1.x + s1.width/2, l1.y + s1.height/2, l2.x + s2.width/2, l2.y + s2.height/2); } @Override public void start() { // empty } static class ZoomPanelUI<V extends JComponent> extends AbstractLayerUI<V> { private double scalingFactor = 1.0; // works // private double scalingFactor = 0.5; // does not work... /** * @return the scalingFactor */ double getScalingFactor() { return this.scalingFactor; } /** * @param scalingFactor the scalingFactor to set */ void setScalingFactor(double scalingFactor) { this.scalingFactor = scalingFactor; } // override paintLayer(), not paint() @Override protected void paintLayer(Graphics2D g2, JXLayer<V> layer) { java.awt.geom.AffineTransform backup = g2.getTransform(); try { g2.scale(this.scalingFactor, this.scalingFactor); super.paintLayer(g2, layer); } finally { g2.setTransform(backup); } } // catch MouseEvents: @Override protected void processMouseMotionEvent(final MouseEvent e, final JXLayer<V> layer) { translateMouseLocation(e); super.processMouseMotionEvent(e, layer); } @Override protected void processMouseEvent(final MouseEvent e, final JXLayer<V> layer) { translateMouseLocation(e); super.processMouseEvent(e, layer); } @Override protected void processMouseWheelEvent(final MouseWheelEvent e, JXLayer<V> layer) { translateMouseLocation(e); super.processMouseWheelEvent(e, layer); } private void translateMouseLocation(final MouseEvent e) { final Point p = e.getPoint(); p.setLocation((int)(p.x / this.scalingFactor), (int)(p.y / this.scalingFactor)); } } }
|
|
|
|
|
|
|
|
|
|
Re: Generic ZoomPanel?
Posted:
Aug 11, 2008 7:47 AM
in response to: imagero
|
|
|
Hi and thanks, sounded almost too good to be true!
Alas, I can't get this to work and the javadocs aren't exactly very verbose, either.
I wrapped my viewer (a JPanel) in that AffinePanel and added a slider to my control panel (which is NOT part of the above viewer), so that I can control the zoom factor. In the slider's event listener I modify the zoom factor and then call the AffinePanel's scale(...)-method to change the zoom factor.
But strange enough, whenever I move the slider (i.e. whenever I call the scale-method), I get the following exception and my app hangs:
Exception in thread "AWT-EventQueue-1" java.lang.InternalError: Win32OSSD_Lock cannot nest locks at sun.java2d.loops.ScaledBlit.Scale(Native Method) at sun.java2d.pipe.DrawImage.scaleSurfaceData(DrawImage.java:970) at sun.java2d.pipe.DrawImage.renderImageScale(DrawImage.java:625) at sun.java2d.pipe.DrawImage.tryCopyOrScale(DrawImage.java:304) at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:257) at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:77) at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:996) at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:182) at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3002) at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2987) at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1397) at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1326) at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:314) at javax.swing.RepaintManager.paint(RepaintManager.java:1141) at javax.swing.JComponent.paint(JComponent.java:1026) at test.Test$6.paint(Test.java:386) at com.imagero.swing.renderer.AffinePanel.paintComponent(AffinePanel.java:247) at javax.swing.JComponent.paint(JComponent.java:1040) at javax.swing.JComponent.paintToOffscreen(JComponent.java:5135) at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1395) at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1326) at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:314) at javax.swing.RepaintManager.paint(RepaintManager.java:1141) at javax.swing.JComponent._paintImmediately(JComponent.java:5083) at javax.swing.JComponent.paintImmediately(JComponent.java:4893) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:736) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:692) at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:672) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:141) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:222) at java.awt.EventQueue.dispatchEvent(EventQueue.java:610) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:286) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:196) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:186) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:181) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:173) at java.awt.EventDispatchThread.run(EventDispatchThread.java:134)
Any idea, what I might be missing to get this going?
Cheers, Michael
|
|
|
|
|
|
|
|
Re: [JAVA2D] Generic ZoomPanel?
Posted:
Aug 11, 2008 9:25 AM
in response to: mmo18
|
|
|
I believe that bug has been fixed in recent releases. Which java version is this on?
Thanks, Dmitri
java2d@JAVADESKTOP.ORG wrote: > Hi and thanks, sounded almost too good to be true! > > Alas, I can't get this to work and the javadocs aren't exactly very verbose, either. > > I wrapped my viewer (a JPanel) in that AffinePanel and added a slider to my control panel (which is NOT part of the above viewer), so that I can control the zoom factor. In the slider's event listener I modify the zoom factor and then call the AffinePanel's scale(...)-method to change the zoom factor. > > But strange enough, whenever I move the slider (i.e. whenever I call the scale-method), I get the following exception and my app hangs: > > Exception in thread "AWT-EventQueue-1" java.lang.InternalError: Win32OSSD_Lock cannot nest locks > at sun.java2d.loops.ScaledBlit.Scale(Native Method) > at sun.java2d.pipe.DrawImage.scaleSurfaceData(DrawImage.java:970) > at sun.java2d.pipe.DrawImage.renderImageScale(DrawImage.java:625) > at sun.java2d.pipe.DrawImage.tryCopyOrScale(DrawImage.java:304) > at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:257) > at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:77) > at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:996) > at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:182) > at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3002) > at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2987) > at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1397) > at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1326) > at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:314) > at javax.swing.RepaintManager.paint(RepaintManager.java:1141) > at javax.swing.JComponent.paint(JComponent.java:1026) > at test.Test$6.paint(BusinessServiceViewer.java:386) > at com.imagero.swing.renderer.AffinePanel.paintComponent(AffinePanel.java:247) > at javax.swing.JComponent.paint(JComponent.java:1040) > at javax.swing.JComponent.paintToOffscreen(JComponent.java:5135) > at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1395) > at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1326) > at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:314) > at javax.swing.RepaintManager.paint(RepaintManager.java:1141) > at javax.swing.JComponent._paintImmediately(JComponent.java:5083) > at javax.swing.JComponent.paintImmediately(JComponent.java:4893) > at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:736) > at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:692) > at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:672) > at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:141) > at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:222) > at java.awt.EventQueue.dispatchEvent(EventQueue.java:610) > at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:286) > at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:196) > at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:186) > at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:181) > at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:173) > at java.awt.EventDispatchThread.run(EventDispatchThread.java:134) > > Any idea, what I might be missing to get this going? > > Cheers, > Michael > [Message sent by forum member 'mmo18' (mmo18)] > > http://forums.java.net/jive/thread.jspa?messageID=292595 > > =========================================================================== > To unsubscribe, send email to listserv@java.sun.com and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > listserv@java.sun.com and include in the body of the message "help".
=========================================================================== To unsubscribe, send email to listserv@java.sun.com and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to listserv@java.sun.com and include in the body of the message "help".
|
|
|
|
|
|
|
|
Re: Generic ZoomPanel?
Posted:
Aug 11, 2008 4:47 PM
in response to: mmo18
|
|
|
Well, I think that you making something wrong here.
Just look at this stacktrace part:
at javax.swing.JComponent.paint(JComponent.java:1026) at test.Test$6.paint(Test.java:386) at com.imagero.swing.renderer.AffinePanel.paintComponent(AffinePanel.java:247) at javax.swing.JComponent.paint(JComponent.java:1040)
It looks like a circular call - paint - paintComponent - paint.
|
|
|
|
|
|
|
|
Re: Generic ZoomPanel?
Posted:
Aug 15, 2008 3:08 AM
in response to: imagero
|
|
|
I went to your site and downloaded jgui 3.0. But I could not find where to download the source code. I assume you make that available since it's an open source project?
Also, if you do have the source I could build the JavaDocs myself, but since I don't , could you include the index.html files? It's hard to navigate the JavaDocs in your distribution since you've only included the leaf html files.
|
|
|
|
|
|
|
|
Re: Generic ZoomPanel?
Posted:
Aug 15, 2008 12:03 PM
in response to: robross
|
|
|
Hmm, it was a build error. Please download again.
|
|
|
|
|
|
|
|
Re: Generic ZoomPanel?
Posted:
Aug 11, 2008 8:39 AM
in response to: mmo18
|
|
|
Hello Michael
JXLayer is very similar to what you described, it is a universal decorator for Swing components.
It works like a JScrollPane and allows you to create any kind of visual decorations for your components
Piet Blok recently blogged about his MagnifierUI (the webstart demo is included)
Thanks
alexp
|
|
|
|
|
|
|
|
Re: Generic ZoomPanel?
Posted:
Aug 12, 2008 3:01 PM
in response to: alexfromsun
|
|
|
Hi, I tried JXTransformer. Things seem to work at first except: if I embedded the JXTransformer-Panel into a JScrollPanel then - as soon as I shift the view - I get again this dreaded Exception in thread "AWT-EventQueue-1" java.lang.InternalError: Win32OSSD_Lock cannot nest locks 
What am I missing??? I seem to be so close!
You can try yourself: ------------------------------------ package test;
import java.awt.BorderLayout; import java.awt.Container; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.geom.AffineTransform;
import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JScrollPane;
import org.jdesktop.swinghelper.transformer.JXTransformer; import javax.swing.JApplet;
@SuppressWarnings("serial") public class TestJXTransformer extends JApplet { @Override public void init() { Container mainPanel = getContentPane(); mainPanel.setLayout(new BorderLayout()); this.setLayout(new BorderLayout()); JPanel viewer = new JPanel(); viewer.setLayout(new GridLayout(4,4)); for (int i = 0; i < 16; i++) { JButton button = new JButton("button " + i) { { this.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println(getText() + " pressed"); } }); } }; viewer.add(button); } JXTransformer transfomer = new JXTransformer(viewer); JPanel zoomPanel = new JPanel(); zoomPanel.add(transfomer); mainPanel.add(new JScrollPane(zoomPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER); double scale = 1.5; AffineTransform at = transfomer.getTransform(); at.scale(scale, scale); transfomer.setTransform(at); } } ------------------------------------
Cheers and thanks, Michael
Message was edited by: mmo18
|
|
|
|
|
|
|
|
Re: [JAVA2D] Generic ZoomPanel?
Posted:
Aug 12, 2008 3:49 PM
in response to: mmo18
|
|
|
I'll ask once again, what java release is this with?
Dmitri
java2d@JAVADESKTOP.ORG wrote: > Hi, I tried JXTransformer. Things seem to work at first except: if I embedded the JXTransformer-Panel into a JScrollPanel then - as soon as I shift the view - I get again this dreaded > Exception in thread "AWT-EventQueue-1" java.lang.InternalError: Win32OSSD_Lock cannot nest locks >  > > What am I missing??? I seem to be so close! > > You can try yourself: > ------------------------------------ > package test; > > import java.awt.BorderLayout; > import java.awt.Container; > import java.awt.FlowLayout; > import java.awt.GridLayout; > import java.awt.event.ActionEvent; > import java.awt.event.ActionListener; > import java.awt.geom.AffineTransform; > > import javax.swing.BoxLayout; > import javax.swing.JButton; > import javax.swing.JPanel; > import javax.swing.JScrollPane; > > import org.jdesktop.swinghelper.transformer.JXTransformer; > import javax.swing.JApplet; > > @SuppressWarnings("serial") > public class TestJXTransformer extends JApplet > { > @Override > public void init() { > Container mainPanel = getContentPane(); > mainPanel.setLayout(new BorderLayout()); > > this.setLayout(new BorderLayout()); > > JPanel viewer = new JPanel(); > viewer.setLayout(new GridLayout(4,4)); > for (int i = 0; i < 16; i++) { > JButton button = new JButton("button " + i) { > { > this.addActionListener(new ActionListener() > { > @Override > public void actionPerformed(ActionEvent e) { > System.out.println(getText() + " pressed"); > } > }); > } > }; > viewer.add(button); > } > > JXTransformer transfomer = new JXTransformer(viewer); > // for some strange reason one can apparently not add a JXTransformer directly to > // a ScrollPanel - if one first adds it to another JPanel things seem to work: > JPanel zoomPanel = new JPanel(); > zoomPanel.add(transfomer); > > mainPanel.add(new JScrollPane(zoomPanel, > JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, > JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), > BorderLayout.CENTER); > > double scale = 1.5; > AffineTransform at = transfomer.getTransform(); > at.scale(scale, scale); > transfomer.setTransform(at); > } > } > ------------------------------------ > > Cheers and thanks, > Michael > [Message sent by forum member 'mmo18' (mmo18)] > > http://forums.java.net/jive/thread.jspa?messageID=292912 > > =========================================================================== > To unsubscribe, send email to listserv@java.sun.com and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > listserv@java.sun.com and include in the body of the message "help".
=========================================================================== To unsubscribe, send email to listserv@java.sun.com and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to listserv@java.sun.com and include in the body of the message "help".
|
|
|
|
|
|
|
|
Re: [JAVA2D] Generic ZoomPanel?
Posted:
Aug 17, 2008 2:29 PM
in response to: Dmitri Trembove...
|
|
|
Sorry - I had overlooked your question - apologies!
I am using Java v(1.)6.0_06.
Michael
|
|
|
|
|
|
|
|
Re: [JAVA2D] Generic ZoomPanel?
Posted:
Aug 18, 2008 8:10 AM
in response to: mmo18
|
|
|
Hi Michael,
Thanks. I believe this bug has been fixed in 7 and 6u10 - could you please try those releases (at least the 6u10, from jdk6.dev.java.net) and see if it's still reproducible.
Thanks, Dmitri
java2d@JAVADESKTOP.ORG wrote: > Sorry - I had overlooked your question - apologies! > > I am using Java v(1.)6.0_06. > > Michael > [Message sent by forum member 'mmo18' (mmo18)] > > http://forums.java.net/jive/thread.jspa?messageID=293785 > > =========================================================================== > To unsubscribe, send email to listserv@java.sun.com and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > listserv@java.sun.com and include in the body of the message "help".
=========================================================================== To unsubscribe, send email to listserv@java.sun.com and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to listserv@java.sun.com and include in the body of the message "help".
|
|
|
|
|