Problem overriding DefaultEdgeStyleOGL2d

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Problem overriding DefaultEdgeStyleOGL2d

Van Parunak
I'm trying to customize the visualization of a network projection. I've
been very successful customizing the node display along these lines:

> import java.awt.Color;
>
> import repast.simphony.visualizationOGL2D.DefaultStyleOGL2D;
>
> public class AssistAgentStyle extends DefaultStyleOGL2D {
>    ...
>     @Override
>     public Color getColor(Object agent) {
>         return Color.green;
>    }
>    ....
> }
So I thought I'd have no problem doing something similar with the edges:

> import java.awt.Color;
>
> import repast.simphony.space.graph.RepastEdge;
> import repast.simphony.visualizationOGL2D.DefaultEdgeStyleOGL2D;
>
> public class AssistEdgeStyle extends DefaultEdgeStyleOGL2D {
>    
>     @Override
>     public Color getColor(RepastEdge<Object> edge) {
>         if (edge.getWeight() > 0.) {
>             return Color.green;
>         }
>         else {
>             return Color.gray;
>         }
>     }
>    
>     @Override
>     public int getLineWidth(RepastEdge<Object> edge) {
>         if (edge.getWeight() > 0.) {
>             return 1;
>         }
>         else {
>             return 2;
>         }
>     }
>
> }
But the compiler complains about the @Override statements:

> The method xxx must override or implement a supertype method.

It suggests removing the @Override notation, but when I do, it complains:

> Name clash: the method xxx has the same erasure as xxx of type
> DefaultEdgeStyleOGL2D but does not override it.
What am I missing? I should have thought that I could extend
DefaultStyleOGL2D and DefaultEdgeStyleOGL2D in the same way.




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem overriding DefaultEdgeStyleOGL2d

srcnick
I think you want RepastEdge<?> as the argument type for those methods, i.e.

public Color getColor(RepastEdge<?> edge)


Nick

> On Jul 13, 2017, at 10:50 AM, Van Parunak <[hidden email]> wrote:
>
> I'm trying to customize the visualization of a network projection. I've
> been very successful customizing the node display along these lines:
>
>> import java.awt.Color;
>>
>> import repast.simphony.visualizationOGL2D.DefaultStyleOGL2D;
>>
>> public class AssistAgentStyle extends DefaultStyleOGL2D {
>>   ...
>>    @Override
>>    public Color getColor(Object agent) {
>>        return Color.green;
>>   }
>>   ....
>> }
> So I thought I'd have no problem doing something similar with the edges:
>
>> import java.awt.Color;
>>
>> import repast.simphony.space.graph.RepastEdge;
>> import repast.simphony.visualizationOGL2D.DefaultEdgeStyleOGL2D;
>>
>> public class AssistEdgeStyle extends DefaultEdgeStyleOGL2D {
>>
>>    @Override
>>    public Color getColor(RepastEdge<Object> edge) {
>>        if (edge.getWeight() > 0.) {
>>            return Color.green;
>>        }
>>        else {
>>            return Color.gray;
>>        }
>>    }
>>
>>    @Override
>>    public int getLineWidth(RepastEdge<Object> edge) {
>>        if (edge.getWeight() > 0.) {
>>            return 1;
>>        }
>>        else {
>>            return 2;
>>        }
>>    }
>>
>> }
> But the compiler complains about the @Override statements:
>
>> The method xxx must override or implement a supertype method.
>
> It suggests removing the @Override notation, but when I do, it complains:
>
>> Name clash: the method xxx has the same erasure as xxx of type
>> DefaultEdgeStyleOGL2D but does not override it.
> What am I missing? I should have thought that I could extend
> DefaultStyleOGL2D and DefaultEdgeStyleOGL2D in the same way.
>
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem overriding DefaultEdgeStyleOGL2d

Van Parunak

That does it. Thank you, Nick!


On 7/13/17 16:17, Nick Collier wrote:
I think you want RepastEdge<?> as the argument type for those methods, i.e. 

public Color getColor(RepastEdge<?> edge) 


Nick

On Jul 13, 2017, at 10:50 AM, Van Parunak [hidden email] wrote:

I'm trying to customize the visualization of a network projection. I've
been very successful customizing the node display along these lines:

import java.awt.Color;

import repast.simphony.visualizationOGL2D.DefaultStyleOGL2D;

public class AssistAgentStyle extends DefaultStyleOGL2D {
  ...
   @Override
   public Color getColor(Object agent) {
       return Color.green;
  }
  ....
}
So I thought I'd have no problem doing something similar with the edges:

import java.awt.Color;

import repast.simphony.space.graph.RepastEdge;
import repast.simphony.visualizationOGL2D.DefaultEdgeStyleOGL2D;

public class AssistEdgeStyle extends DefaultEdgeStyleOGL2D {

   @Override
   public Color getColor(RepastEdge<Object> edge) {
       if (edge.getWeight() > 0.) {
           return Color.green;
       }
       else {
           return Color.gray;
       }
   }

   @Override
   public int getLineWidth(RepastEdge<Object> edge) {
       if (edge.getWeight() > 0.) {
           return 1;
       }
       else {
           return 2;
       }
   }

}
But the compiler complains about the @Override statements:

The method xxx must override or implement a supertype method. 
It suggests removing the @Override notation, but when I do, it complains:

Name clash: the method xxx has the same erasure as xxx of type
DefaultEdgeStyleOGL2D but does not override it.
What am I missing? I should have thought that I could extend
DefaultStyleOGL2D and DefaultEdgeStyleOGL2D in the same way.




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest

    

--
H. Van Dyke Parunak, Ph.D.
President, ABC Research, LLC

Superior solutions through Agent-Based and Complex systems
1027 Ferdon Road
Ann Arbor, MI 48104-3630
email: van.parunak@...
cell: 734 395 3253
www.ABCResearch.org

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Loading...