Solved

Help with JInternalFrame with Image, Zoom

Posted on 2003-11-25
10
671 Views
Last Modified: 2012-08-14
Hi
i'll try to make this question clear as possible

I got a class : NormalView.java
in this class i create a JInternalFrame

private JInternalFrame jif = new JInternalFrame();

then i put an image inside :
private BufferedImage image;
image = pPerspective.getImage();

in my other class : AppGui.java i create two NormalView with different names :

testNormal = new NormalView(perspective, 400, 500, false);
perspective.addObserver(testNormal);
            
testNormal2 = new NormalView(perspective, 400, 500, false);
perspective.addObserver(testNormal2);

Now, when i load my program, i have 2 JInternalFrame with an image inside.
When i SELECT one of them, i can do some action : zoom n translation
thats no problem :

AffineTransform tx = new AffineTransform();
tx.scale(ratio, ratio);
...


the thing is now, i do this on only one of them ( the one i selected )
what i need to do now, is when i click on the other JInternalFrame, it
need to take the same perspective of the other JInternalFrame with
the zooomed image or translate image.


HOW CAN I DO THIS

thx for your help
0
Comment
Question by:Ital
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
10 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 88 total points
ID: 9823809
You could maintain a map of frames and transforms. When the focus shifts (listen) you can ask for the transform of the other frame:

AffineTransform otherTx = (AffineTransform)transforms.get("otherFrame");
((Graphics2D)g).setTransform(otherTx);
0
 

Author Comment

by:Ital
ID: 9824905
CEJH i'M not to sure that would work
the thing is i can zooom 10 times, do 5 translation

but when i select the other JInternalFrame i should have the same
image. I thoughj somehting like that would work but it dosent :

      private class EventHandler extends FocusAdapter{
            private NormalView normalView = null;
            public EventHandler(NormalView z){
                  normalView = z;
                  System.out.print("inx");
            }
      
            public void focusGained(FocusEvent e){
                  normalView.draw();
                  System.out.print("in");
            }
      }

maybe explain more your idea, maybe an example
thx
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9825332
Can you post your source code...

I thing CEHJ's method will work...

You can combine AffineTransformations together to get the sum of all it's parts...  you should just then be able to apply this transformation to the other window...

Either that, or store a list of transformations up to this point, and apply them one at a time to the other window...

This would allow you to "undo" transformations, and you just strip the tail off the list...

Tim
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:Ital
ID: 9825848


TimYates
>Can you post your source code...

what you want me to post ?? i cant post evrything you know !!

I just dont see it, maybe with an exmaple, with the source code i gave
would help.

is this any use :

     private class EventHandler extends FocusAdapter{
          private NormalView normalView = null;
          public EventHandler(NormalView z){
               normalView = z;
               System.out.print("inx");
          }
     
          public void focusGained(FocusEvent e){
               normalView.draw();
               System.out.print("in");
          }
     }


sorry, i just dont see it, an example would be great or more info
Ital
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9825881
Just use that code and work my suggestion into it
0
 

Author Comment

by:Ital
ID: 9825887
ok
i'll try that
thx
i'll get back to you
0
 
LVL 92

Assisted Solution

by:objects
objects earned 87 total points
ID: 9827710
Have each frame share the same transform (pass it in the frames ctor), and reapply it whenever the frame recieves focus.
0
 
LVL 92

Expert Comment

by:objects
ID: 11662701
the comment I posted would solve Ital's problem.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question