Solved

Help with JInternalFrame with Image, Zoom

Posted on 2003-11-25
10
662 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

803 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