changing JGraphModelAdapter attributMap per vertex

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

changing JGraphModelAdapter attributMap per vertex

DIMAS K I R
hi.

does anyone know how to change attributMap per vertices in
JGraphModelAdapter? (i'm using JGraph for visualisizing)

i have tried this line of code, but it didn't works..
it returned java.lang.NullPointerException

/////////////////////

//create attribut map method
public Map createTriggerVertexAttributeMap(){
        Map map = new Hashtable();
        // Make sure the cell is resized on insert
        GraphConstants.setResize(map, true);
        // Add a nice looking gradient background
        GraphConstants.setGradientColor(map, Color.red);
        // Add a Border Color Attribute to the Map
        GraphConstants.setBorderColor(map, Color.BLUE);
        // Add a White Background
        GraphConstants.setBackground(map, Color.yellow);
        // Make Vertex Opaque
        GraphConstants.setOpaque(map, true);
        GraphConstants.setBorder(map,new javax.swing.border.BevelBorder(0));
        GraphConstants.setAutoSize(map,true);
        GraphConstants.setIcon(map, new
ImageIcon(getClass().getResource("/img/dbRootDiagrams.GIF")));
        return map;
    }

//graphUtama is ListenableDirectedWeightedGraph
JGraphModelAdapter JGraphModel = new JGraphModelAdapter(graphUtama);
jgraph = new JGraph( JGraphModel );
JGraphModel.createDefaultEdgeAttributes(graphUtama);
JGraphModel.createDefaultVertexAttributes();

String inserted = new String("test");
graphUtama.addVertex(inserted);
jgraph.getModel().getAttributes(inserted).applyMap(createTriggerVertexAttributeMap());

/////////////////////////

thx before