Hi guys, I’m having some trouble programatically seeing an IImageShape image.
Originally I tried following this guide but it did not work and would not allow me to set images manually afterwards.
Create Diagram Image Shape with API - Visual Paradigm Know-how
When following the tutorial this appears…
Right clicking > set linked image > desired image, does nothing
Same for right clicking > set image > desired image
When doing my method the same result happens when running the code, but right clicking > set image > desired image, makes the image appear perfectly.
Just wondering where I’m going wrong here, thanks.
My attempt is the following…
IImageShapeUIModel imageShape = (IImageShapeUIModel) diagramManager.createDiagramElement(technologiesDiagram, IModelElementFactory.instance().createImageShape());
String imagePath = "/Users/{my_name}/Documents/AppEngine.png";
imageShape.setImagePath(imagePath);
imageShape.setEmbeddedPath(imagePath);
imageShape.setDisplayImagePath(imagePath);
imageShape.setLinkedFilePath(imagePath);
imageShape.setMode(IImageShapeUIModel.EMBEDDED);
BufferedImage image = null;
try {
File file = new File(imagePath);
image = ImageIO.read(file);
imageShape.setImage(image);
System.out.println(file.getAbsolutePath());
} catch (Exception ex) {
ex.printStackTrace();
}
imageShape.setBounds(100, 100, 284, 137);
System.out.println(imageShape.getEmbeddedPath()); //PRINTS SAME AS IMAGEPATH
System.out.println(imageShape.getDisplayImagePath()); //PRINTS SAME AS IMAGEPATH
System.out.println(imageShape.getImagePath()); //PRINTS SAME AS IMAGEPATH
System.out.println(imageShape.getLinkedFilePath()); //PRINTS SAME AS IMAGEPATH
Image test = imageShape.getImage();
System.out.println(test.equals((Image) image)); //PRINTS TRUE