Extending a class

12 views
Skip to first unread message

Sacha Camilleri

unread,
Mar 24, 2015, 2:07:28 PM3/24/15
to jfeat...@googlegroups.com

Hi there, 

I am trying to extend the Gabor class and override one of its methods so it can better serve my requirements. However I am finding an issue to create an instance of my extended Gabor class since Gabor is called through its wrapper class as bellow:

public class Gabor extends LireWrapper {

    
public Gabor() {
        
super(new net.semanticmetadata.lire.imageanalysis.Gabor());
    
}
}

Obviously if I call the wrapper class this will create an instance of the original Gabor class and not my extended class. I tried to create my own wrapper class but I found that this is not possible since LireWrapper (which the Gabor wrapper extends) is not visible. 

Is there a simple way to extend such a class? I am using the Processing IDE but if required I can also use Eclipse.

I know that this query might not be directly related to the Library as such but I cannot find any help. 

Therefore any help would be greatly appreciated! 

Thanks,
Sacha

Franz Graf

unread,
Mar 24, 2015, 4:09:45 PM3/24/15
to jfeat...@googlegroups.com

Hi Sacha,
The easiest way that comes to my mind is the following :

First extend the Gabor class from LIRE directly (let's call it  MyGabor)
Then add a wrapper class same as the JFeatureLib-Gabor class that creates an instance of My Gabor. Just like in the code you mentioned.

That should work.

Good luck
Franz

--
Dr. Franz Graf
http://www.Locked.de

--
You received this message because you are subscribed to the Google Groups "JFeatureLib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jfeaturelib...@googlegroups.com.
To post to this group, send email to jfeat...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

matt von

unread,
Mar 24, 2015, 8:55:24 PM3/24/15
to jfeat...@googlegroups.com
Hi Franz,

Thanks for your reply! 

That was exactly my first attempt and I tough it should work fine. To make sure that I understood you, I created the following class: 

public class GaborWrapper extends LireWrapper {
   
public GaborWrapper() {
       
super(new MyGabor());
   
}
}


...where MyGabor is the class that I created which extends the LIRE Gabor class. 

The problem is that the JFeatureLib-Gabor class extends the LireWrapper (as shown in the code above) which is not public but a protected class. Therefore the Processing IDE is giving me the following error:

The type LireWrapper is not visible

Did I misunderstood your suggestion or I have to look for an alternative?

Thanks again for your reply,

Sacha

Franz Graf

unread,
Mar 25, 2015, 2:06:30 AM3/25/15
to jfeat...@googlegroups.com

Hi Matt,

Oh LireWrapper is not public! Well, until I can fix that you have two options
A) the dirty one is to copy the code of my class
B) make a package hierarchy similar to JFeatureLib "de.lmu....." and place your wrapper in the same package (in your code base) as the original wrapper.

This way you soul be able to extend the package private LireWrapper.

Good luck
Franz

--
Dr. Franz Graf
http://www.Locked.de

matt von

unread,
Mar 25, 2015, 8:49:38 AM3/25/15
to jfeat...@googlegroups.com
Hi Franz,

Thanks again for your reply and dedication! 

I chose the first option (dirty one hehe) but it is good enough for what I am doing and worked perfectly fine. 

You will be referenced in my work accordingly :) 

Thanks,
Sacha

Franz Graf

unread,
Mar 25, 2015, 8:52:05 AM3/25/15
to jfeat...@googlegroups.com
Hi Mat,

great to hear that it seems to work.
If you publish your work, just send a note her and I can link it on
the site as well.

Good luck!
Franz
Dr. Franz Graf
Website: http://www.Locked.de
Google+: https://plus.google.com/u/0/107945158062341260943
Xing: https://www.xing.com/profile/Franz_Graf4

matt von

unread,
Mar 25, 2015, 9:14:04 AM3/25/15
to jfeat...@googlegroups.com
Oh that would be greatly, hopefully in the near feature ;)

Thanks 
Reply all
Reply to author
Forward
0 new messages