Package eu.kartoffelquadrat.svgpatcher
Class IdPatcher
java.lang.Object
eu.kartoffelquadrat.svgpatcher.Patcher
eu.kartoffelquadrat.svgpatcher.IdPatcher
ID patcher extension. Utility class to replace Omnigraffle object name tags by node id
attributes. Replaces all title elements that start with "VID" prefix by proper ID tags. Removes
all remaining title tags, to ensure browser does not display popups on hover.
- Author:
- Maximilian Schiedermeier 2022
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
IdPatcher
Constructor for ID Patcher utility class.- Parameters:
svg- the raw svg document object
-
-
Method Details
-
execute
This method does the actual DOM transformation we are interested in. If in Omnigraffle an object is marked with something like "VID-XYZ", where VID is a standard prefix for "Vector Identifier" and "XYZ" is the actual unique name describing the purpose of the object, then we ant to set this entire string as "id" in the dom. Similarly, the transformer detects objects marked with a "TID-" prefix, for "template ID". In the SVG generated by omnigraffle we have something like: (Tags removed so javadoc plugin is not confused) g id="Graphic_3" titleVID-SQUARE1/title rect x="230.8" y="193.9" width="105" height="105" fill="#40ff40"/ rect x="230.8" y="193.9" width="105" height="105" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/ text transform="translate(235.8 237.176)" fill="black" tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="34.156" y="15" 361/tspan /text /g What we want is: g id="VID-SQUARE1" rect x="230.8" y="193.9" width="105" height="105" fill="#40ff40"/ rect x="230.8" y="193.9" width="105" height="105" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/ text transform="translate(235.8 237.176)" fill="black" tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="34.156" y="15" 361/tspan /text /g p This method handles this transformation for an entire svg document.
-