[SOLVED] Images being ignored; background being ‘guessed’? 
Posted: 06 May 2012 03:50 PM   [ Ignore ]
Avatar
Rank
Joined  2012-04-15
Total Posts:  38
New Member

Well,

I’ve got a method to add SVG images to a MTRoundRectangle-class:

/**
     * Adds an SVG image to this MTRoundRectangle. It won't separately be
     * interactable, but it will receive all interactions with its parent
     * 
     * @param fileName
     *            Assuming that the image is in the root of the default data
     *            directory &#xpr;oject_folder%/src/data/, the name of the file
     *            (without extension)
     * @param pos
     *            The position, relative to the position of the upper left
     *            corner of this MTRoundRectangle, where the upper left corner
     *            of the SVG image must be drawn
     * @param factor
     *            The factor for resizing the original image file. Must be
     *            greater than <value>0</value>. Otherwise,
     *            <code>IllegalArgumentException</code> will be thrown
     */
    private void addSVGImage(final String fileName, final Vector3D pos,
            final 
float factor{
        
final MTSvg svg = new MTSvg(Scene.mtApp"data"
                
MTApplication.separator fileName ".svg");
        
this.addChild(svg);
        if (
factor <= 0{
            
throw new IllegalArgumentException(
                    
"Invalid argument for method addSVGImage in class StateGraph.\nfactor - "
                            
factor "\nfactor must be greater than 0");
        
else {
            
if (factor != 1f{
                svg
.setWidthXYGlobal((svg.getWidthXYGlobal() * factor MainClass.screenWidth)
                        / 
InstanceManager.MODEL_RESOLUTION_WIDTH);
            
}
        }
        svg
.setPositionGlobal(new Vector3D(this.getCenterPointGlobal().x
                
pos.+ (svg.getWidthXYGlobal() / 2), this
                
.getCenterPointGlobal().y
                
pos.y
                
+ (svg.getHeightXYGlobal() / 2)));
        
svg.transform(this.getGlobalMatrix());
        
svg.setPickable(false);
    
}

It used to work properly when I added the image I use as a background. But when I tried to add another image, it simply didn’t appear. So, testing deeper, I decided to remove the background addition to check if the second image was being obstructed by the first one but, for my surprise, when I removed the sentence, I got exactly that same white background, and the second image kept non-appearing. So I thought that maybe the MTRoundRectangle constructor, by default, draws a white background, exactly the same one that could be seen with my image. So I tested changing the fill color but there’s no change.

In conclusion, my question, any clues, any kind of explanation of this?

Thanks.

SOLUTION: I had made non-visible all the children from another class, but I forgot to manage the events to reset them to visible. Working fine now.

Profile