0

I'm using jung library to draw my grap, so I was wondering if there is any way to create vertex in a different shape rather than creating an ellipse. For instance, I want octagon. This is how I set the shape:

    Transformer<String,Shape> vertexSize = new Transformer<String,Shape>(){

    @Override
    public Shape transform(String str) {
        Ellipse2D circle = new Ellipse2D.Double(-5, -5, 10, 10);
        if(drugnames.contains(str)){
            return AffineTransform.getScaleInstance(3,3).createTransformedShape(circle);
        }
        else{
            return AffineTransform.getScaleInstance(1,1).createTransformedShape(circle);
        }

        // TODO Auto-generated method stub
    }
};
Ahmet Tanakol
  • 849
  • 2
  • 20
  • 40

1 Answers1

0
VisualizationViewer.getRenderContext().setVertexShapeTransformer(vst)

where vst is a Transformer<V, Shape>.

AbstractVertexShapeTransformer can do a lot of the heavy lifting for you.

See PluggableRendererDemo for examples of these things in action (source is part of the distribution).

Zach Saucier
  • 24,871
  • 12
  • 85
  • 147
Joshua O'Madadhain
  • 2,704
  • 1
  • 14
  • 18