SVG Text Icons as Tags, an Insertion Script, and a scripting beginner stumbles through #1640
Replies: 17 comments 22 replies
-
So, the result that you are trying to achieve is having tags like in Mindmanager? For example: It sounds interesting. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I tried to make something to solve this but I couldn't. I tried to get the icons throug the config methods (getIcon() , getIconRessource() and getImageIcon()) to see where the icons are internally stored. I got to the "svgUniverse" where you can load the new one, but I couldn't get further. I'm interested in this topic too. I want to know how to load temporary svg data into Freeplane to show it as icon or as attached image to the node. This way you can add diagrams an other dinamic info to a node. BR edo |
Beta Was this translation helpful? Give feedback.
-
If possible, please publish your Autohotkey scripts that are useful to be used with Freeplane. It may be helpful for the people. |
Beta Was this translation helpful? Give feedback.
-
Thanks, euu, but this script is definitely not ready yet. Its logic is flawed. The user probably doesn't want to toggle the icon in selected nodes. They more likely want to insert or remove the icon in all of them alike. Repairing right now. |
Beta Was this translation helpful? Give feedback.
-
Yes, it's a great tool. I didn't create it, it's a standard tool in Groovy, that I adapted to work with the new versions of Freeplane and added a few new features. |
Beta Was this translation helpful? Give feedback.
-
Thanks, Edo, looks like you're absolutely right. That seemed the most intuitive approach when I was testing, but for whatever reason I couldn't get the script not to iterate until the
Presenting Version 3:
Rgds - Jerome |
Beta Was this translation helpful? Give feedback.
-
I'm imagining a tag system. How it looks like:
How it works:
This script, for example, changes the text of the svg from "aaa" to "bbb":
|
Beta Was this translation helpful? Give feedback.
-
Hi All I tried the last script by euu2021, but it created the icons but FP 1.11.9 13 doesn't read those icons, instead, I load the icons in a normal FP way so they are visible: each to be visible requires the restart of FP after its creation...
|
Beta Was this translation helpful? Give feedback.
-
and 3) how to write inside the icon? In my case, the script just copies the template icon (I used 2 different templates ) But it doesn't write the name of the tag inside the icon, just keeps the original writing. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi, I'm not a programmer but interested in trying this solution: it creates the icons but I have to import them manually each time in the normal FP-way; maybe is this behaviour due to the absence of those 2 jars? If so where to find those jar files? And to be sure they are safe? |
Beta Was this translation helpful? Give feedback.
-
and this the node with it (when it is not new): |
Beta Was this translation helpful? Give feedback.
-
Thank you now it is working without loading new jars. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Let us not talk about the icons any longer. Instead, let us talk about how to add tags to Freeplane. But not as icons.
|
Beta Was this translation helpful? Give feedback.
-
Preview 1.12.1 alpha 01
|
Beta Was this translation helpful? Give feedback.
-
Greetings - I’ve known that SVG is a graphics format specified in XML, but I always figured it required specialized editing software or graphic or geometry chops. But it occurred to me the other day that SVG might have a means of displaying text entries. And indeed it does. Here’s an SVG icon about as basic as it gets:
The simplicity of this spec means that attractive, informative SVG icons can be created spontaneously through string scripting and batch processes. A text-based icon works more like a tag, visibly showcasing some commonality among nodes that may be at a distance from one another, making them easy to sort and filter. At times only text will do for recognition. If we want to visibly identify some nodes as relating to “IA Conf 2019” for example, we need a bespoke icon, not a generic jackrabbit or bullfrog or standard symbol.
Some of that spontaneity will be lost when deploying these icons in Freeplane however, because Freeplane requires a restart before new icons in
{userdir}/icons
are recognized. So I wanted to create a script that would work around this restriction.I have experience scripting in AutoHotkey and coding in some legacy languages, but am still a tyro in Groovy and Java. I had to wrestle with almost every line along the way. With thanks to the many folks who helped others with their coding, leaving me a discovery trail, I’m posting the script with a listing of my beginners’ errors and their resolution, to maybe give the next Freeplane scripter a foot forward.
The objective of the script is to enable the user to select the desired icon from the /icons folder, rather than from the table or hierarchy in the UI. It’s based on the “Add Custom Checkbox" script in the User Guide’s Scripting Samples:
Icons - Freeplane Documentation
Here are the beginner’s bumps I encountered in converting this script to one where the icon is selected from a folder:
c.userDirectory
worked ok, except I’d had to navigate to the/Icons
subfolder. Concatenation proved unsuccessful. To make it work required:toString()
to copyc.userDirectory
to a string fieldc.userDirectory
is a Windows-formatted path with backslashes, I tried to append\icons
to my path string. That didn’t work, but/icons
did, and the resulting path, with mixed slashes, was actually accepted as a parm by JFileChooser. But I have my pride and won't live with an improper parm, so:replace()
to convert the backslashes to forward. That didn’t work either at first.getName()
to strip the path from the selected filename.lastIndexOf('.')
to strip the extension, as Freeplane identifies the icon without it.The script then worked as expected. Here it is:
To help construct and verify the icons, I found Smart SVG Viewer version 0.5.0 alpha on github. That worked well, but icons that looked right in the Viewer were out of proportion in Freeplane, and displayed transparently, with no background color. Both these issues had the same root cause. The SVG text spec I’d cribbed from had a font-size denominated in “em”. The background rectangle had width and height at “100%”. Freeplane didn’t recognize these units, possibly because I used no SVG preamble in my simple-as-possible spec. So for a reliable match I elected to:
Now as it turns out, Freeplane will insert a new icon selected through this script. But until we restart Freeplane, with that icon already in the folder, Freeplane won’t display it. It’ll use a placeholder icon instead.
So I wonder whether it might be within a scripter’s capabilities to update Freeplane’s icon table with a newly-created SVG, to spare the restart. (Freeplane recognizes and displays the same new SVG when it’s inserted as an image rather than as an icon.)
Now to actually generate a new SVG icon based on some user text and maybe automate the color selection? I’ll be doing that in AutoHotkey to start, but there’s probably a way to do it in Groovy as well, to streamline the tagging process further.
That's enough for today. Thanks for any thoughts, cautions or enhancements!
Rgds - Jerome
Beta Was this translation helpful? Give feedback.
All reactions