Skip to content

Commit

Permalink
Remove groups from semantic net and fix some parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-jung committed Oct 13, 2024
1 parent ac8776b commit 2ce39ef
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 53 deletions.
59 changes: 38 additions & 21 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -952,30 +952,24 @@
<val default="true">false</val>
<val>true</val>
</param>
<param name="generate-termstats" required="false" desc="Set this parameter to force the generation of a terminology statistics XML file. Usually the transtype tries to auto-detect if this should be done. The condition is fulfilled, if the transtype is 'termbrowser-responsive' and a &lt;termstatsref&gt; element needs to be available on the terminology map. But this does not work, if the transtype has been extended." type="enum">
<val>true</val>

<param name="generate-termstats" desc="Set this parameter to force the generation of a terminology statistics XML file. Usually the transtype tries to auto-detect if this should be done. The condition is fulfilled, if the transtype is 'termbrowser-responsive' and a &lt;termstatsref&gt; element needs to be available on the terminology map. But this does not work, if the transtype has been extended." type="enum">
<val default="true">true</val>
<val>false</val>
</param>
<param name="args.termstats" desc="Terminology statistics XML file from previous build" type="file"/>
<param name="term.semantic-net.layout.improvedLayout" desc="When enabled, the network will use the Kamada Kawai algorithm for initial layout. For networks larger than 100 nodes, clustering will be performed automatically to reduce the amount of nodes. This can greatly improve the stabilization times. If the network is very interconnected (no or few leaf nodes), this may not work and it will revert back to the old method. Performance will be improved in the future." type="enum">
<val default="true">true</val>
<val>false</val>
</param>
<param name="term.semantic-net.edges.color" desc="Color of semantic net edges" type="string">
<val default="true">orange</val>
</param>

<!-- Semantic net edges -->
<param name="term.semantic-net.edges.color.color" desc="Color of semantic net edges" type="string"/>
<param name="term.semantic-net.edges.color.highlight" desc="Color of semantic net edges when highlighted" type="string"/>
<param name="term.semantic-net.edges.color.hover" desc="Color of semantic net edges when hovered" type="string"/>
<param name="term.semantic-net.edges.width" desc="Width of semantic net edges" type="string"/>

<param name="term.semantic-net.physics.stabilization.enabled" desc="Toggle the stabilization. This is an optional property. If undefined, it is automatically set to true when any of the properties of this object are defined." type="enum">
<val default="true">true</val>
<val>false</val>
</param>
<param name="term.semantic-net.physics.stabilization.iterations" desc="The physics module tries to stabilize the network on load up til a maximum number of iterations defined here. If the network stabilized with less, you are finished before the maximum number." type="string">
<val default="true">1000</val>
</param>
<param name="term.semantic-net.physics.stabilization.updateInterval" desc="When stabilizing, the DOM can freeze. You can chop the stabilization up into pieces to show a loading bar for instance. The interval determines after how many iterations the stabilizationProgress event is triggered." type="string">
<val default="true">50</val>
</param>
<!-- Semantic net physics -->
<param name="term.semantic-net.physics.forceAtlas2Based.gravitationalConstant" desc="This is similar to the barnesHut method except that the falloff is linear instead of quadratic. The connectivity is also taken into account as a factor of the mass. If you want the repulsion to be stronger, decrease the value (so -1000, -2000)." type="string">
<val default="true">-50</val>
</param>
Expand All @@ -988,19 +982,42 @@
<param name="term.semantic-net.physics.forceAtlas2Based.springConstant" desc="This is how 'sturdy' the springs are. Higher values mean stronger springs." type="string">
<val default="true">0.08</val>
</param>
<param name="term.semantic-net.physics.stabilization.enabled" desc="Toggle the stabilization. This is an optional property. If undefined, it is automatically set to true when any of the properties of this object are defined." type="enum">
<val default="true">true</val>
<val>false</val>
</param>
<param name="term.semantic-net.physics.stabilization.iterations" desc="The physics module tries to stabilize the network on load up til a maximum number of iterations defined here. If the network stabilized with less, you are finished before the maximum number." type="string">
<val default="true">1000</val>
</param>
<param name="term.semantic-net.physics.stabilization.updateInterval" desc="When stabilizing, the DOM can freeze. You can chop the stabilization up into pieces to show a loading bar for instance. The interval determines after how many iterations the stabilizationProgress event is triggered." type="string">
<val default="true">50</val>
</param>

<param name="term.semantic-net.term.border" desc="Semantic net term node border" type="string">
<val default="true">1</val>
<!-- Semantic net term -->
<param name="term.semantic-net.term.border.color" desc="Semantic net term node border color" type="string">
<val default="true">#96c3ff</val>
</param>
<param name="term.semantic-net.term.background" desc="Semantic net term node background" type="string">
<val default="true">yellow</val>
<param name="term.semantic-net.term.border.width" desc="Semantic net term node border width" type="string">
<val default="true">1</val>
</param>
<param name="term.semantic-net.term.font.color" desc="Semantic net term node font color" type="string">
<val default="true">#1471bb</val>
<param name="term.semantic-net.term.border.width.selected" desc="Semantic net selected term node border width" type="string">
<val default="true">1</val>
</param>
<param name="term.semantic-net.term.background" desc="Semantic net term node background" type="string"/>
<param name="term.semantic-net.term.font.color" desc="Semantic net term node font color" type="string"/>
<param name="term.semantic-net.term.font.size" desc="Semantic net term node font size in px. Use only a digit." type="string">
<val default="true">9</val>
</param>
<param name="term.semantic-net.term.font.face" desc="Semantic net term node font face." type="string">
<val default="true">9</val>
</param>
<param name="term.semantic-net.term.hover.border" desc="Semantic net term hover border." type="string"/>
<param name="term.semantic-net.term.hover.background" desc="Semantic net term hover background." type="string"/>
<param name="term.semantic-net.term.hover.fontColor" desc="Semantic net term hover font color." type="string"/>
<param name="term.semantic-net.term.highlight.border" desc="Semantic net highlighted term border." type="string"/>
<param name="term.semantic-net.term.highlight.background" desc="Semantic net highlighted term background." type="string"/>
<param name="term.semantic-net.term.highlight.fontColor" desc="Semantic net highlighted term font color." type="string"/>

</transtype>

</plugin>
3 changes: 3 additions & 0 deletions samples/terminology.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<param name="webhelp.publishing.template" path="../publishing"/>
<param name="webhelp.publishing.template.descriptor" value="termbrowser.opt"/>
<param name="args.termstats" href="termstats.xml"/>
<param name="term.semantic-net.term.border.color" value="#b1ff00"/>
<param name="term.semantic-net.term.background" value="red"/>
<param name="term.semantic-net.physics.forceAtlas2Based.springLength" value="500"/>
</publication>
</deliverable>

Expand Down
64 changes: 32 additions & 32 deletions xsl/termbrowser/semantic-net.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

<!-- Edges -->
<!-- NOTE: Color codes are NOT suffixed with a semicolon. Write '#96c3ff', not '#96c3ff;'. -->
<xsl:param name="term.semantic-net.edges.color" as="xs:string" select="'#5a6e82'"/>
<xsl:param name="term.semantic-net.edges.color.color" as="xs:string" select="'#5a6e82'"/>
<xsl:param name="term.semantic-net.edges.color.highlight" as="xs:string" select="'#7c6fff'"/>
<xsl:param name="term.semantic-net.edges.color.hover" as="xs:string" select="'#1800ff'"/>
<xsl:param name="term.semantic-net.edges.width" as="xs:string" select="'1'"/>

<!-- Layout -->
Expand Down Expand Up @@ -128,11 +130,38 @@
edges: {
width: <xsl:value-of select="$term.semantic-net.edges.width"/>,
arrows: 'to',
color: '<xsl:value-of select="$term.semantic-net.edges.color"/>'
color: {
color: '<xsl:value-of select="$term.semantic-net.edges.color.color"/>',
highlight: '<xsl:value-of select="$term.semantic-net.edges.color.highlight"/>',
hover: '<xsl:value-of select="$term.semantic-net.edges.color.hover"/>',
}
},
layout: {
improvedLayout: <xsl:value-of select="$term.semantic-net.layout.improvedLayout"/>
},
nodes: {
borderWidth: '<xsl:value-of select="$term.semantic-net.term.border.width"/>',
borderWidthSelected: '<xsl:value-of select="$term.semantic-net.term.border.width.selected"/>',
radius: 1500,
color: {
border: '<xsl:value-of select="$term.semantic-net.term.border.color"/>',
background: '<xsl:value-of select="$term.semantic-net.term.background"/>',
hover: {
border: '<xsl:value-of select="$term.semantic-net.term.hover.border"/>',
background: '<xsl:value-of select="$term.semantic-net.term.hover.background"/>',
},
highlight: {
border: '<xsl:value-of select="$term.semantic-net.term.highlight.border"/>',
background: '<xsl:value-of select="$term.semantic-net.term.highlight.background"/>',
}
},
font: {
color: '<xsl:value-of select="$term.semantic-net.term.font.color"/>',
size: <xsl:value-of select="$term.semantic-net.term.font.size"/>,
face: '<xsl:value-of select="$term.semantic-net.term.font.face"/>'
},
shape: 'box'
},
physics: {
forceAtlas2Based: {
gravitationalConstant: <xsl:value-of select="$term.semantic-net.physics.forceAtlas2Based.gravitationalConstant"/>,
Expand All @@ -148,31 +177,6 @@
iterations: <xsl:value-of select="$term.semantic-net.physics.stabilization.iterations"/>,
updateInterval: <xsl:value-of select="$term.semantic-net.physics.stabilization.updateInterval"/>
}
},
groups: {
term: {
borderWidth: '<xsl:value-of select="$term.semantic-net.term.border.width"/>',
borderWidthSelected: '<xsl:value-of select="$term.semantic-net.term.border.width.selected"/>',
radius: 1500,
color: {
border: '<xsl:value-of select="$term.semantic-net.term.border.color"/>',
background: '<xsl:value-of select="$term.semantic-net.term.background"/>',
hover: {
border: '<xsl:value-of select="$term.semantic-net.term.hover.border"/>',
background: '<xsl:value-of select="$term.semantic-net.term.hover.background"/>',
},
highlight: {
border: '<xsl:value-of select="$term.semantic-net.term.highlight.border"/>',
background: '<xsl:value-of select="$term.semantic-net.term.highlight.background"/>',
}
},
font: {
color: '<xsl:value-of select="$term.semantic-net.term.font.color"/>',
size: <xsl:value-of select="$term.semantic-net.term.font.size"/>,
face: '<xsl:value-of select="$term.semantic-net.term.font.face"/>'
},
shape: 'box'
}
}
};

Expand Down Expand Up @@ -245,10 +249,6 @@
</xsl:template>

<!-- Generate data set for autocomplete search box -->
<!--
TODO: Populate also the @keys (which are used as term node IDs) to the search function, otherwise the search does not work.
See how to do that here: https://jqueryui.com/autocomplete/#custom-data
-->
<xsl:template match="*[contains(@class, ' termmap/termref ')]" mode="semantic-net-search">
<xsl:variable name="filename" select="@href" as="xs:string"/>
<xsl:variable name="filepath" select="'file:///' || encode-for-uri(replace($temp.dir, '\\', '/')) || '/' || $filename"/>
Expand All @@ -264,7 +264,7 @@
<xsl:variable name="filepath" select="'file:///' || encode-for-uri(replace($temp.dir, '\\', '/')) || '/' || $filename"/>
<xsl:variable name="label" select="sj:jsonEscape(document($filepath)/termentry/title[1]/text()[1])"/>
<xsl:variable name="delim" select="if (following-sibling::*[contains(@class, ' termmap/termref ')]) then ', ' else ' '" as="xs:string"/>
<xsl:value-of select="'{id: ''' || $termId || ''', group: ''term'', label: ''' || $label || '''}' || $delim"/>
<xsl:value-of select="'{id: ''' || $termId || ''', label: ''' || $label || '''}' || $delim"/>
</xsl:template>

<!-- Generate edges between nodes -->
Expand Down

0 comments on commit 2ce39ef

Please sign in to comment.