Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with JInternalFrame with Image, Zoom

Posted on 2003-11-25
10
Medium Priority
?
680 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
8 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 352 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 348 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

824 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