das-developers / das2java

The original das2 library. Provides interactive publication-ready 2-D plotting
https://das2.org
GNU Lesser General Public License v3.0
4 stars 0 forks source link

GrannyTextEditor should support <img> tag, deprecate url property of annotations #21

Open jbfaden opened 2 years ago

jbfaden commented 2 years ago

Right now an annotation can be a granny text string or an image. When it is an image, it is the URL of the image. This allows somewhat arbitrary images to be inserted onto the plot. However, since granny text strings allow <b>, <i>, and <u> it would make sense to add support for images within the strings as well, and then the strange image mode for an annotation could be dropped. This would also allow a figure with a caption to be inserted using a granny text string.

In Autoplot, the annotation command

annotation(text='<img src="https://das2.org/das2new-300.png"><br>Das2 Logo') could be used.
jbfaden commented 2 years ago

I've added support for drawing plot symbols, so that a legend can be made. Some examples:

jbfaden commented 2 years ago

Here's a Jython version of the image, which I'm incorporating now: https://github.com/autoplot/dev/blob/master/demos/2021/20211108/demoImageAnnotation.jy

jbfaden commented 2 years ago

I decided though it might be nice, I can't recall where the original request that images could be used in annotations came from and I'm quitting that task for now. Performance is an issue too, where the read in image should be read in and kept in memory since it might be drawn several times a second.

jbfaden commented 2 years ago

After further consideration, I decided to finish this off. There is already the 'feature' where images can be referenced and drawn in Autoplot (for example with unplotting), so I shouldn't be too concerned about the feature being misused. It keeps a 10-second cache of images, since it takes a bit of time to create the image from a file.

Note the <img> tag is not supported.

Also I remembered this was introduced because Allison wanted to use externally-rendered LaTeX on her plot.

jbfaden commented 2 years ago

The problem with the img tag is that you can't specify the scale. It would be nice if you could say !(painter;img;http://autoplot.org/wiki/images/Logo96.png;50%) or <img src='http://autoplot.org/wiki/images/Logo96.png' width='50%'>

but the width in html refers to the container of the image (the screen).

The 50% in the first one can be 50%, 1em, or 10px. I think I'll hold off on the second since it's not clean how they relate.

jbfaden commented 2 years ago

This ticket is close to being closed, but there's still an issue where the y-height of any line is constant for the entire label, so text and images can collide. For example, "Das 2
!(painter;img;http://autoplot.org/wiki/images/Logo96.png;50%)
Das 2" doesn't draw properly. Some logic which calculates the height of a line and then advances y by this height is needed. image

jbfaden commented 10 months ago

"""Das 2 !(painter;img;http://autoplot.org/wiki/images/Logo96.png;50%) Das 2""" renders properly now, I notice: image

jbfaden commented 9 months ago

I noticed today that this does not clip properly when used with an annotation within a plot. See https://github.com/das-developers/das2java/issues/92