Advertisement

12.01.2007 at 12:01PM PST, ID: 22995373
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Java Zoom-Pan effect with functional mouselisteners

Tags: zoom, java, pan
Hi,
    I am looking to create a zoom - pan effect on a jpanel with multiple elements in it with various listeners. I can create the zoom-pan effect relatively easily with Graphics2D's transformations and then drawing the panel. However, once that is done, all the components with mouselisteners are out of whack because their size and location are in the original coordinates instead of zoomed coordinates. I can't scale the mouse coordinates to fix this either, since i am using java's intrinsic mouselisteners to get the mousemoved,clicked etc events (or can i?) Any suggestions to work around this?

Thanks
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: zhtet
Solution Provided By: objects
Participating Experts: 1
Solution Grade: A
Views: 58
Translate:
Loading Advertisement...
12.01.2007 at 01:51PM PST, ID: 20389408

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.01.2007 at 02:37PM PST, ID: 20389521

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.01.2007 at 03:30PM PST, ID: 20389675

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.01.2007 at 03:40PM PST, ID: 20389707

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.01.2007 at 03:59PM PST, ID: 20389751

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.01.2007 at 04:17PM PST, ID: 20389799

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.01.2007 at 04:47PM PST, ID: 20389882

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.01.2007 at 04:59PM PST, ID: 20389913

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.01.2007 at 09:32PM PST, ID: 20390345

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.01.2007 at 10:53PM PST, ID: 20390437

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.01.2007 at 11:00PM PST, ID: 20390450

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.02.2007 at 02:26AM PST, ID: 20390755

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.02.2007 at 02:28AM PST, ID: 20390757

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.02.2007 at 03:08AM PST, ID: 20390796

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.02.2007 at 03:30PM PST, ID: 20392824

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.02.2007 at 04:39PM PST, ID: 20393066

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
12.01.2007 at 01:51PM PST, ID: 20389408

Rank: Guru

u should be able to transform the event coords.
 
12.01.2007 at 02:37PM PST, ID: 20389521
Hi objects,
      Unless I am interpreting it wrongly, I am not sure if that can help me. Reason being I have a onMouseEnter for each sub-jPanel within the main jPanel that I am performing the zoom on. So after I perform a zoom of scale 2.0 on each axis with Graphics2D within paintComponent, a panel with dimensions (0,0,100,100) for example will still trigger onMouseEnter within those dimensions instead of within (0,0,200,200)
     I can go through each of those sub jpanels and resize & relocate them so the mouse events trigger correctly and use this as the "zoom" instead of graphics2d's scale, and it **should** work i believe, but I am trying to avoid that if possible.

Thanks
 
12.01.2007 at 03:30PM PST, ID: 20389675

Rank: Guru

the mouse event will fire when the mouse is in the panel, and tx used is really irrelevant.
 
12.01.2007 at 03:40PM PST, ID: 20389707
Hi again,
        I've tested this earlier and the mouse event doesn't fire till i get into the boundaries of the old jpanel dimension (0,0,100,100) in the previous example, instead of firing in the new dimensions of (0,0,200,200). Any reasons why? I am basically just scaling the entire jpanel using graphics2d.

Thanks
 
12.01.2007 at 03:59PM PST, ID: 20389751

Rank: Guru

scaling doesn't change the dimensions of the panel. panel dimensions are always in screen coords.
 
12.01.2007 at 04:17PM PST, ID: 20389799
so does that mean I would have to manually resize the dimensions of the panel in order for the mouseEvents to fire correctly in the scaled/zoomed image?

Thanks
 
12.01.2007 at 04:47PM PST, ID: 20389882

Rank: Guru

well the mouse events are really firing correctly, they are just in screen coords.
If you need them in a different coord space then you need to transform them
 
12.01.2007 at 04:59PM PST, ID: 20389913
Sorry for going back and forth, i'll increase the point value accordingly. The thing is i really dont mind which coord space the mouse events are; I just need the onMouseEnter/Over/etc for each of the jPanel to fire even in the resized/zoomed components. What is the best way to go about achieving this in your opinion?

If I transform the mouse events manually, dont i have to manually check for each of the mouseEvents for enter/over, instead of using the callbacks from Java?

Thanks
 
12.01.2007 at 09:32PM PST, ID: 20390345

Rank: Guru

what exactly are you referring to as a 'zoomed' component.
Regardless of what transformations you do for your painting the component itself does not change in dimensions.

> If I transform the mouse events manually, dont i have to manually check for each of the mouseEvents > for enter/over, instead of using the callbacks from Java?

No, the mouse listener will get called when an event occurs. If you want the coords of the event in a different coord space then you just need to transform them appropriately.

 
12.01.2007 at 10:53PM PST, ID: 20390437
when i refer to zoomed component, i mean a jFrame which is of fixed height and width, but the contents of the jFrame has everything resized to be larger. So zoom of 2.0 in the e.g. above means object of (0,0,100,100) dimensions is now (0,0,200,200).
Each time i do a "zoom"/scale, even though everything is drawn bigger, but the components are still the same size, so for the user, everything is twice the size but since the mouseOver/Enter/etc events are still based on the original smaller components, so everything is inaccurate. Does that make sense now?

Thanks
 
12.01.2007 at 11:00PM PST, ID: 20390450

Rank: Guru

yes, I understand. And what I've said above still holds.
You need to transform the (screen) coordinates into the coordinate system of the coords you are comparing against (or visa versa)
 
12.02.2007 at 02:26AM PST, ID: 20390755
i c... so basically there is no way for me to use the auto check provided by java except to get the screen coord of the mouse event and then perform a manual check myself for the objects it intersect in the viewport?

Thanks
 
12.02.2007 at 02:28AM PST, ID: 20390757

Rank: Guru

what viewport are you referring to?
 
12.02.2007 at 03:08AM PST, ID: 20390796
screen viewport or rather the root jFrame... so basically i would do something like

given mouseEvent me and scale s and translate t
take (0,0) (top left) and transform into the xformed coord sys ((0,0) * s + t) to get its point in xformed coord sys.
then ((diff of the current (0,0) and xformed (0,0)) + (me.x, me.y)) to get mouseEvent's position in xformed sys.
then reverse xform this point ((p-t)/s) to get point it corresponds to in image of original size
then go through the obj hierarchy to find components it intersect with and then manually call the mouseEvents for those components with me argument

correct?

Thanks
 
12.02.2007 at 03:30PM PST, ID: 20392824

Rank: Guru

you'll find life a easier by using a tx matrix.

What i usually do when dealing with multiple coord systems it to have my code operate in a single coord system, and transform any coords that are recieved into that system.
That way there isn't any confusion as to what coordinate system a given point is in.
Accepted Solution
 
12.02.2007 at 04:39PM PST, ID: 20393066
Thanks i got it!
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628