archi-contribs / specialization-plugin

Plugin for Archi to specialize concepts (figure, icon...)
Other
29 stars 2 forks source link

Image does not materialise in diagram #5

Closed peterprib closed 6 years ago

peterprib commented 6 years ago

Added tag icon and icon on models explorer changed to image but not diagram object. On some objects it changed the nature of image but reflection of original image. Properties showed image and had erratic behavior where properties content lost. One have to choose another object and come back to restore correct behavior

herve91 commented 6 years ago

Hi Peter,

I'm not sure to understand what you mean by "reflection of original image".

To change the icon on diagram objects, three conditions must be met:

  1. the diagram object must have an existing icon For instance, the Node element has got two figures. The left one does not have an icon, so the plugin cannot change it. The right one has got an icon, so the plugin can change it. this is the same for all the diagram objects that have got two figures. node figures

  2. an "icon" property should be set with an existing icon filename (that should be located in the editor/img subfolder) If the icon is changed in the model explorer, then I beleive this condition is met on your computer.

  3. the plugin should be configured to do so You may either choose the option "always replace icons with icon property" to replace icons in all your views, or create a "replace icons" property on one view with the value "true".

Hope this helps. If not, could you please provide me with instructions to reproduce your issue ?

Best regards Hervé

peterprib commented 6 years ago

This happens to properties

image This on image extensions/desktop-computer.png image

peterprib commented 6 years ago

Just worked out white was part of image. That is, it doesn't auto size image to box size

image

herve91 commented 6 years ago

At the moment, the icon (image) is shown with a 1:1 ratio. Currently, there is not possible to have auto resize. So you need to manually resize the image on disk. Please note that if you replace the png file while Archi is running, it may not change the image in the view because of the cache so you'll need to restart Archi to see the new image size.

I'm working to an update that will allow to dynamically resize the image but at the moment, I'm stuck because until now I fail to insert the resized image into Archi's cache which leads to a huge memory consumption.

peterprib commented 6 years ago

Would it not be better to transform at render time as the image my be resized anyway?

herve91 commented 6 years ago

It would definitively ease my life but as elements are meant to show icons not images.

The Eclipse framework redraw them very often and to speedup the process and reduce the memory consumption, the Archi developers have put in place a cache. So the icon (or image in our case) needs to be calculated from the icon/image file only once.

The way I develop my plugin does not allow it to access this cache so if I dynamically resize the image, this resizing will be done during every redraw and this will slow down Archi quite a lot and consume a lot of memory.

To void that, I'm working on developing my own cache. Once this is done, then I will be able to dynamically resize the images.

I'm not sure if I will finish before the end of the year. Else, it will be available early next year.

peterprib commented 6 years ago

As an interim measure why not on load resize to icon expectations. Maybe this would negate own cache

herve91 commented 6 years ago

I'm not sure to understand what your sentence means. My apologies.

The technical side:

My plugin is called by Archi when it needs to determine the filename that contains the icon. This means that the only thing my plugin does is to return the filename stated in the property if it exists, and the default filename if it doesn't.

I've got two options:

  1. find a way in the Eclipse framework to replace the calling class that creates the image from the filename and manage the cache (my preferred option)
  2. create a hidden ".resized" subfolder and create new files with resized images when necessary. then the standard Archi class will be able to use these files as any other file. But one caveat: how to detect that the source image file has changed in order to recreate the resized images.

At the moment, I am thinking to a syntax like: folder/filename --> image full size folder/filename:width --> resize the image to the specified width, keeping the aspect ratio folder/filename:width:height --> resize the image to the specified width and height folder/filename:auto --> resize the image to the exact size of the element (when the element's size is changed, the image would be automatically resized at the same time)