I want to use a user defined icon as vertex. It works if the png file is saved in the resource folder, however i want to get the png file from a local folder
Actions.directory.toString() - folder location as String - working
the vertex appears without any shape
BufferedImage img = ImageIO.read(new File(Actions.directory.toString() + "/" + Actions.hm.get(key)));
icon = new ImageIcon(img);
System.out.println("icon " +icon);
mxStylesheet stylesheet1 = ShowGraphEditor.graph.getStylesheet();
Hashtable<String, Object> attributestyle = new Hashtable<String, Object>();
attributestyle.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_IMAGE);
attributestyle.put(mxConstants.STYLE_IMAGE, getClass().getResource(Actions.directory.toString() + "/" + Actions.hm.get(key)) );
attributestyle.put(mxConstants.STYLE_VERTICAL_LABEL_POSITION, mxConstants.ALIGN_CENTER);
stylesheet1.putCellStyle(eventName, attributestyle);
GraphMenu.getGraph().insertVertex(null, instance.getID().toString(), instance, GraphMenu.x,GraphMenu.y, 80, 30, eventName);
I've tried:
attributestyle.put(mxConstants.STYLE_IMAGE, icon)