Solved

Help with JInternalFrame with Image, Zoom

Posted on 2003-11-25
10
658 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
 

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now