From: SourceForge.net <no...@so...> - 2011-07-29 15:37:16
|
The following forum message was posted by tkanstren at http://sourceforge.net/projects/jung/forums/forum/252062/topic/4629999: Hello all, I am trying to use JUNG to create an FSM representation. I am going with the examples, javadocs and the tutorial, and tried to search this forum. I managed to turn the vertex into an ellipse by doing something like this BasicVisualizationServer<State, String> vv = new BasicVisualizationServer<State, String>(layout); vv.getRenderContext().setVertexShapeTransformer(new EllipseVertexTransformer()); where EllipseVertexTransformer extends AbstractVertexShapeTransformer and does public Shape transform(State state) { return factory.getEllipse(state); } to create the ellipse then I use setAspectRatioTransformer to set aspect ratio to 0.5 and setSizeTransformer to set size to 100. I also use vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); to show the label on the vertex, centered. This gives me some default size but does not take into account the size/width/number of lines in the label. I would prefer something like "gimme and FSM with these states and transitions" but if not then something like "gimme a vertex shaped like an ellipse with the label inside it, automatic sizing plz". Is any of this possible? Or perhaps some general hints of reference to an example on building a nice and shiny FSM using JUNG? something like this: http://www.graphviz.org/content/fsm Seems like a basic question but could not find the answer. cheers & thanks, Teemu |