Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2004

Tip: Looking for answers? Try searching our database.

Java 2D scaling and mouse coordinates problems

Thread view: 
Ju - 04 Jan 2004 18:56 GMT
Hi there !

I made a simple drawing applet in Java, using Graphics 2D API. You can
draw shapes, select them,

drag them, etc.

I tried to add zooming abilities by overriding the paintComponent
method of the JPanel:

public void paintComponent(Graphics g) {
 super.paintComponent(g);
 Graphics2D g2 = (Graphics2D) g;

 g2.scale(zoomValue, zoomValue);
 ....// draw shapes
}

zoomValue is a double that changes when clicking on ZoomOut or ZoomIn
buttons in the applet.

The scale works okay for shapes displayed on the JPanel. But the mouse
coordinates are not

affected by the scale. So I can't select the shapes properly with the
mouse.

Do you know a simple way to scale the mouse coordinates ?

Thank you very much !

Julien
ak - 04 Jan 2004 21:00 GMT
> I made a simple drawing applet in Java, using Graphics 2D API. You can
> draw shapes, select them,
[quoted text clipped - 20 lines]
> affected by the scale. So I can't select the shapes properly with the
> mouse.

why not to scale the shape itself?

--

____________

http://reader.imagero.com the best java image reader.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.