Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mylar-dev] example implementation ofIGraphContentProviderinterface/ what are relationships

The answer I was looking for is probably in Del's patch for an
adjacency matrix content provider, but I haven't looked at that yet.


below is Ian's response:

I will try and get an example up on our Wiki
(http://wiki.eclipse.org/index.php/Mylar_Zest_Visualization
<http://wiki.eclipse.org/index.php/Mylar_Zest_Visualization>).
Basically we have multiple content providers.  One that is relationship
based and one that is entity based (we are currently looking at one that
uses an adjacency matrix). The graphconentprovider is the relationship
based one.

you are right, getElements returns all the relationships, but you have
to implement getSource or getDestination.  We pass the same object back
(your string) and you should return some object (doesn't matter what)
for these.  If a relationship only has a source (or destination) and not
both, then the entity will be created and no edge will be drawn.

The following code creates arcs for Strings of  numbers (you may want to
use .equals instead of == depending on how you create your strings).
public Object getDestination(Object rel) {
     // TODO Auto-generated method stub

      if ( rel == "1" ) {
         return "third";
     }
     else if ( rel == "2" ) {
         return "forth";
     }
     else if ( rel == "3") {
         return "fifth";
     }
     return null;
 }

 public Object getSource(Object rel) {
     // TODO Auto-generated method stub
     if ( rel == "0" ) {
         return "first";
     }
     else if ( rel == "1" ) {
         return "second";
     }
     else if ( rel == "2" ) {
         return "third";
     }
     else if ( rel == "3") {
         return "forth";
     }
     return null;
 }

Cheers,
ian

On 9/11/06, Mik Kersten <beatmik@xxxxxxx> wrote:
Ian: could you answer Raphael's question?

Raphael: sorry that you still haven't seen an answer to this--I pinged Ian a
while back but he may be on vacation.  Fyi, the Mylar visualization
prototype was using the relationship objects to encapsulate the kind of edge
between two nodes (e.g. Java call, inheritance).

Mik

> -----Original Message-----
> From: mylar-dev-bounces@xxxxxxxxxxx
> [mailto:mylar-dev-bounces@xxxxxxxxxxx]
> On Behalf Of Raphael Ackermann
> Sent: Wednesday, August 16, 2006 8:21 AM
> To: Mylar developer discussions
> Subject: [mylar-dev] example implementation of
> IGraphContentProviderinterface/ what are relationships
>
> Hi,
>
> I am developing a call graph view using zest. I have got my own
> ContentProvider which implements the IGraphContentProvider interface.
> I've based it on the GraphContentProvider implementation which is not
> up to date anymore, as getElements is now used instead of
> getRelationships.
>
>       /**
>        * Returns all the relationships in the graph for the given input.
>        * @input the input model object.
>        * @return all the relationships in the graph for the given input.
>        */
>       public Object[] getElements(Object input);
>
>
> my implementation is:
> public Object[] getElements(Object input) {
>               Object[] rels = null;
>               if (this.fCGModel != null) {
>                       int size = CGContentProvider.MAX <
> this.fCGModel.getConnectionSize() ? CGContentProvider.MAX :
> this.fCGModel.getConnectionSize();
>                       rels = new String[size];
>                       int length = CGContentProvider.MAX < rels.length ?
> CGContentProvider.MAX : rels.length;
>                       for (int i = 0; i < length; i++) {
>                               rels[i] = "" + i;
>                       }
>               }
>               return rels;
>       }
>
> in which I just return an array of strings from 0 to the number of the
> connections. But these don't seem to be relationships.
>
> So my question really is: what are relationship objects supposed to be
> like? Does anybody have a sample implementation of getElements() where
> something different from just an array of numbers is returned?
>
> Raphael
> _______________________________________________
> mylar-dev mailing list
> mylar-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/mylar-dev


_______________________________________________
mylar-dev mailing list
mylar-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/mylar-dev



Back to the top