[mt4j] problems with MTimage and exit_on_close typo
Posted: 01 July 2011 04:34 AM   [ Ignore ]
Rank
Joined  2011-06-30
Total Posts:  4
New Member

Hello guys

I’m studying mt4j package for an university project and I’ve got two problems during my working.

1) Let’s image I’ve got a frame with a button, by clicking on the button so by activating the eventListener on it, it opens me an application rly similar to your StartHelloWorldExample, but showing an image instead of a textarea. So I guess instead of MTTextArea, it has to be an MTImage.

this is the code:

public void actionPerformed (ActionEvent e){
        String arg 
e.getActionCommand().toString();
        if (
arg.equals("button")) {
            
                String[] args 
= new String[1];
                
args[0] "file.jpg";
                
StartImageBrowser.main(args);

        
}

this is instead the helloWorld modified to reiceve ad input an MTImage instead of a MTTextArea:

ImageScene Class:

package basic.helloWorld;

import java.awt.Image;
import org.mt4j.MTApplication;
import org.mt4j.components.visibleComponents.widgets.MTImage;
import org.mt4j.input.inputProcessors.globalProcessors.CursorTracer;
import org.mt4j.sceneManagement.AbstractScene;
import org.mt4j.util.MTColor;
import org.mt4j.util.math.Vector3D;

import processing.core.PImage;

public class 
ImageScene extends AbstractScene {

    
    
    
public  PImage pimage;
    
    public 
ImageScene(MTApplication mtApplicationString namePImage image{
        super
(mtApplicationname);
        
        
this.setClearColor(new MTColor(146150188255));
        
//Show touches
        
this.registerGlobalInputProcessor(new CursorTracer(mtApplicationthis));
        
        
this.pimage image;
        
MTImage imageAdd = new MTImage(imagemtApplication);
        
imageAdd.setVisible(true);
        
        
//Center the image on the screen
        
imageAdd.setPositionGlobal(new Vector3D(mtApplication.width/2fmtApplication.height/2f));
        
        
//Add the image to our canvas
        
this.getCanvas().addChild(imageAdd);
        
        
        
        
    
}
    
@Override
    
public void init() {}
    
@Override
    
public void shutDown() {}
}

this is instead the StartImageScene:

package basic.helloWorld;

import org.mt4j.MTApplication;
import processing.core.PImage;


public class 
StartImageBrowser extends MTApplication {
    
private static final long serialVersionUID 1L;
    private static 
String currentImg;

    
    
    public static 
void main(String[] args{
        StartImageBrowser
.currentImg args[0];
        
initialize();
    
}
    
    
@Override
    
public void startUp() {
        PImage pimage 
this.loadImage(currentImg);
        
addScene(new ImageScene(this"ImageScene"pimage));
        
// TODO Auto-generated method stub
        
    
}
    
}

so, after all this, let’s start talking about my problems. as i’ve alrdy mentioned, I got two: the first one is the problem with the showing of the image once the application start:

http://postimage.org/image/36cxmks9w/

as you can see, the application run “correctly” by opening a new scene with the image inside the new rectangle (as you can see the rectangle has exactly the dimension of the image board size) and it gives me the possibility to work with (are up drag and drop, rotate and zoom options), but the image itself is not showing...just a blank space!

the second problem is regarding the closure of the 2nd application. When I activate the eventListener to make him run the mt4j application I’d like to be able to close the last one w/o closing the entire application. Instead this seems not to be possible because when I close the new frame made by ImageSceneBrowser, it automatically close the whole application. what do you think about it?

thanks for your help, and thanks for all this great job you’ve done!

Profile
 
 
Posted: 03 July 2011 06:41 AM   [ Ignore ]   [ # 1 ]
Rank
Joined  2011-06-30
Total Posts:  4
New Member

UP!

Profile
 
 
Posted: 05 July 2011 12:18 PM   [ Ignore ]   [ # 2 ]
Avatar
RankRankRankRank
Joined  2008-04-30
Total Posts:  612
Elite

Did you take a look at the javaGUI example of the mt4j examples?
It shows how to integrate mt4j scenes into a java frame with JButtons etc.
I would go from there.

 Signature 

MT4j - Multi-Touch for Java!

Profile