简体   繁体   中英

how to use different shapes for jung shape transform

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
    }
};
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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM