Forums

Full Version: yet another decorator demo
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
This demo is the result of my first endeavour into decorators.

Basically stolen from

http://goosebumps4all.net/34all/bb/showt...php?tid=19

Since it is based on the graphview demo and not as Björn's much nicer and more elaborated demo on the aggregate demo, I thought to post it here. It doesn't look particular fancy but it works and might help newbies to get an idea.
Further newbie stuff coming along with this demo includes predicate based edge color mapping and change of the default edge line width (see image below)

[attachment=63]

This demo needs the file socialnetRelations.xml to work.


ps the attachted version2 of this demo includes the solution for the visibility issue addressed in one of the replies of this thread - thanks lark for providing the solution
Hey,

I used this exemple to change the color of an edge according to a field value. If I was to change the width of a edge according to another field value, would I go about the same way? I saw DataSizeAction could help do the trick, what do you think?

Cheers Wink
Oops, nervermind, I found an easy solution there :
http://sourceforge.net/forum/message.php?msg_id=3298057

Cheers!
Great solution, thanks a lot for mention it.

As usual, feel invited to post a little demo here to make this trick commonly known.

cheers

martin
if you set the connectivity (Distance filter) to 1.
The nodes and edges go invisible but the edge text decorators are left visible.

This seems to be a problem, here is a fix?
I added
decorator.setVisible(decoratedItem.isVisible());

Thanks,
Lark

class EdgeLayout extends Layout {
public EdgeLayout(String group) {
super(group);
}
public void run(double frac) {
Iterator iter = m_vis.items(m_group);
while ( iter.hasNext() ) {
DecoratorItem decorator = (DecoratorItem)iter.next();
VisualItem decoratedItem = decorator.getDecoratedItem();
Rectangle2D bounds = decoratedItem.getBounds();

double x = bounds.getCenterX();
double y = bounds.getCenterY();

setX(decorator, null, x);
setY(decorator, null, y);
decorator.setVisible(decoratedItem.isVisible());
}
}
}
Hi Lark,

thanks for pointing that out.

Please see the attachted file for the Lark improved version of the EdgeDecoratorDemo

cheers

martin
Hi, could you please help me with the word size on the edge?
I just started studying prefuse, and tried your demo, looks cool, but seems the size of the words on the edge can not be changed... Sad

34all Wrote:Hi Lark,

thanks for pointing that out.

Please see the attachted file for the Lark improved version of the EdgeDecoratorDemo

cheers

martin
Hello Enigmaguo,

hope you are well.

Changing the size of the font is fortunately an easy one, just change the font size 11 in the following line from the demo

Code:
EDGE_DECORATOR_SCHEMA.setDefault(VisualItem.FONT, FontLib.getFont("Tahoma",11)); // and not too big


according to your needs.

cheers

martin
Hi, dear Martin,

There is a little problem when I run the revised version.
When the revised version was running,
I clicked the menu "Data" and try to open another graphml file with no "relation" field (e.g. socialnet2.xml).
However, it showed nodes without any edges, accompanied with some error messages.

I try to solve this problem at the following points, but failed. Sad
Would you please help me see if somethings I miss?
Thank you very much. Smile

I added the juegement of check if containg "relation" field.
I put this judgement at those marked "MAD" sections.
Code:
public boolean judgeMultipleRelation() {
    boolean isMultipleRelation = false;
    Schema edgeSchema = g.getEdgeTable().getSchema();
    for(int ci = 0; ci < edgeSchema.getColumnCount(); ci++) {
        if(edgeSchema.getColumnName(ci).equals("relation")) {
            isMultipleRelation = true;
            break;
        }
    }
    return isMultipleRelation;
}
Hello Reliefi,

hope you are very well.

I am sorry but I didn't really get the point. This demo is of course meant for xml files which contain the relation information. If you want to use other files you would most likely just not add the decorator to the visualization and use another layout. I assume I miss your question so please clarify what you want to achieve.

Thanks and happy prefusing

martin
Pages: 1 2
Reference URL's