Solved

Help with JInternalFrame with Image, Zoom

Posted on 2003-11-25
10
664 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

831 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