Insert image as shape [message #1006590] |
Thu, 31 January 2013 22:27  |
Eclipse User |
|
|
|
Hi all, I wonder whether Graphiti supports custom image as shape or not. I want to create components arrangement. Each component already has its own image defined. So, what I need is to arrange those image in Graphiti editor.
Thanks in advance.
Emerson
|
|
|
|
|
|
|
|
Re: Insert image as shape [message #1012018 is a reply to message #1011979] |
Wed, 20 February 2013 12:54   |
Eclipse User |
|
|
|
Thanks Michael, now it works 
However, to make sure I will use the feature, I want to ask, can I add/register the picture at run time. E.g, user just added a picture through a form, then, he opens the Graphiti editor. At that time, the picture shows up in the palette, ready to be included in the canvas. If this is not possible, maybe I will code the feature myself. But, if it is possible, I'll worship Graphiti for make me save my precious hours.
Thanks as always.
Emerson
|
|
|
|
Re: Insert image as shape [message #1063192 is a reply to message #1012910] |
Wed, 12 June 2013 11:14   |
Eclipse User |
|
|
|
I have additional question about images
in my resize feature I'm resizing my Images to the correct size
and i want to put resized image into the shape, how i can do this? If i try with this code i get nothing/no image
(through debug mode, i can see that all images are correct "mapped" into the hashmap")
for (Shape shapeInside : cs.getChildren()) {//find/manipulate alls hapes(text,image,rectangle...)
if(shapeInside.getGraphicsAlgorithm() instanceof Image){//find my Image
int iconSide=...;//compute new Image Size
conv.rasterizeImage("name", ""+this.elementToResize, iconSide,iconSide ); //convert new Image
imgName= "name"+"_"+this.elementToResize+".png";
iwas=new ImageProvider();
Image entityIcon;
IGaService gaService = Graphiti.getGaService();
int id = iwas.getImageId(imgName); //output is an index for the given imgName
Image imgIcon = gaService.createImage(shapeInside,ImageProvider.resizedIcons[id]);
imgIcon.setWidth(iconSide);
imgIcon.setHeight(iconSide);
imgIcon.setProportional(true);
imgIcon.setX(20);
imgIcon.setY(20);
gaService.setLocationAndSize(imgIcon, 0, 0, iconSide, iconSide);
}
...
}
if i change the id to for example to 0 or 4(and this image exists/ was resized at the last start) in the line:
Image imgIcon = gaService.createImage(shapeInside,ImageProvider.resizedIcons[id]);
so the Image is displayed correct
what I'm doing wrong? or how can i do this another way?
|
|
|
Re: Insert image as shape [message #1064078 is a reply to message #1063192] |
Mon, 17 June 2013 09:56  |
Eclipse User |
|
|
|
Andrej,
in the resize feature you would typically only adapt the size of already
existing images in the diagram (the images should have already been added in
an add feature).
So in the add feature you would code something like this (gac is the
container shape for the image):
Image image = gaService.createImage(gac, SketchImageProvider.IMG_GRAPHITI);
image.setStretchH(true);
image.setStretchV(true);
image.setProportional(true);
while in the resize feature a simply gaService.setLocationAndSize(image,
.....) should be enough.
Michael
|
|
|
Powered by
FUDForum. Page generated in 0.04933 seconds