📄 states.xsl
字号:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Template: States.xsl
Displays States as circles (InitialState, FinaleState, SynchState, DeepHistoryState, ShallowHistoryState, ChoiceState, JunctionState)
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/2000/svg" xmlns:UML="org.omg.xmi.namespace.UML">
<xsl:import href="../Common/Styling.xsl"/>
<xsl:import href="../Common/StereotypeCompartment.xsl"/>
<xsl:import href="../Common/Name.xsl"/>
<xsl:output media-type="image/svg+xml" method="xml" indent="yes"/>
<!-- PseudoState -->
<xsl:template name="PseudoState">
<xsl:param name="DiagramID" select="@xmi.id"/>
<xsl:param name="SemanticID" select="UML:GraphElement.semanticModel/UML:Uml1SemanticModelBridge/UML:Uml1SemanticModelBridge.element/*/@xmi.idref"/>
<xsl:variable name="Kind" select="key('xmi.id', $SemanticID)/@kind"/>
<!-- Main PseudoState group -->
<g transform="translate({UML:GraphElement.position/XMI.field[1]}, {UML:GraphElement.position/XMI.field[2]})" id="{$DiagramID}">
<xsl:apply-templates select="." mode="FontStyle"/>
<xsl:apply-templates select="." mode="StrokeStyle"/>
<xsl:apply-templates select="." mode="isVisible"/>
<title><xsl:value-of select="key('xmi.id', $SemanticID)/@name"/></title>
<desc><xsl:text>PseudoState : </xsl:text><xsl:value-of select="$Kind"/></desc>
<!-- State outline variables -->
<xsl:variable name="rx" select="UML:GraphNode.size/XMI.field[1] div 2"/>
<xsl:variable name="ry" select="UML:GraphNode.size/XMI.field[2] div 2"/>
<xsl:choose>
<xsl:when test="$Kind = 'join' or $Kind = 'fork'">
<!-- Rectangle shape -->
<!-- The outline shape, a rectangle -->
<rect width="{UML:GraphNode.size/XMI.field[1]}" height="{UML:GraphNode.size/XMI.field[2]}">
<xsl:apply-templates select="." mode="FillStyle">
<xsl:with-param name="SemanticID" select="$SemanticID"/>
</xsl:apply-templates>
</rect>
</xsl:when>
<xsl:when test="$Kind = 'junction'">
<!-- Rhombus shape -->
<!-- The outline shape, a rhombus -->
<path d="M {$rx} 0 L {$rx * 2} {$ry} {$rx} {$ry * 2} 0 {$ry} z">
<xsl:apply-templates select="." mode="FillStyle"/>
</path>
</xsl:when>
<xsl:otherwise>
<!-- Round shape -->
<!-- The outline shape, a circle -->
<ellipse cx="{$rx}" cy = "{$ry}" rx="{$rx}" ry="{$ry}">
<xsl:apply-templates select="." mode="FillStyle">
<xsl:with-param name="SemanticID" select="$SemanticID"/>
</xsl:apply-templates>
</ellipse>
</xsl:otherwise>
</xsl:choose>
<!-- State special text-->
<xsl:choose>
<xsl:when test="$Kind = 'deepHistory'"><text text-anchor="middle" x="{$rx}" y="{$ry}" style="baseline-shift: -50%" fill="black" stroke="none">H*</text></xsl:when>
<xsl:when test="$Kind = 'shallowHistory'"><text text-anchor="middle" x="{$rx}" y="{$ry}" style="baseline-shift: -50%" fill="black" stroke="none">H</text></xsl:when>
</xsl:choose>
<!-- Contained nodes -->
<xsl:for-each select="UML:GraphElement.contained/UML:GraphNode">
<xsl:choose>
<xsl:when test="UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo = 'StereotypeCompartment'">
<!-- State stereotypes -->
<xsl:call-template name="StereotypeCompartment"/>
</xsl:when>
<xsl:when test="UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo = 'Name'">
<!-- State name -->
<xsl:call-template name="Name">
<xsl:with-param name="SemanticID" select="$SemanticID"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</g>
</xsl:template>
<!-- Final State -->
<xsl:template name="FinalState">
<xsl:param name="DiagramID" select="@xmi.id"/>
<xsl:param name="SemanticID" select="UML:GraphElement.semanticModel/UML:Uml1SemanticModelBridge/UML:Uml1SemanticModelBridge.element/*/@xmi.idref"/>
<!-- Main FinalState group -->
<g transform="translate({UML:GraphElement.position/XMI.field[1]}, {UML:GraphElement.position/XMI.field[2]})" id="{$DiagramID}">
<xsl:apply-templates select="." mode="FontStyle"/>
<xsl:apply-templates select="." mode="StrokeStyle"/>
<xsl:apply-templates select="." mode="isVisible"/>
<title><xsl:value-of select="key('xmi.id', $SemanticID)/@name"/></title>
<desc><xsl:text>FinalState</xsl:text></desc>
<!-- State outline variables -->
<xsl:variable name="rx" select="UML:GraphNode.size/XMI.field[1] div 2"/>
<xsl:variable name="ry" select="UML:GraphNode.size/XMI.field[2] div 2"/>
<!-- The outline shape, a double circle -->
<ellipse cx="{$rx}" cy = "{$ry}" rx="{$rx}" ry="{$ry}">
<xsl:apply-templates select="." mode="FillStyle"/>
</ellipse>
<ellipse cx="{$rx}" cy = "{$ry}" rx="{$rx * 0.75}" ry="{$ry * 0.75}" fill="black" stroke="none"/>
<!-- Contained nodes -->
<xsl:for-each select="UML:GraphElement.contained/UML:GraphNode">
<xsl:choose>
<xsl:when test="UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo = 'StereotypeCompartment'">
<!-- State stereotypes -->
<xsl:call-template name="StereotypeCompartment"/>
</xsl:when>
<xsl:when test="UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo = 'Name'">
<!-- State name -->
<xsl:call-template name="Name">
<xsl:with-param name="SemanticID" select="$SemanticID"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</g>
</xsl:template>
<!-- Synch State -->
<xsl:template name="SynchState">
<xsl:param name="DiagramID" select="@xmi.id"/>
<xsl:param name="SemanticID" select="UML:GraphElement.semanticModel/UML:Uml1SemanticModelBridge/UML:Uml1SemanticModelBridge.element/*/@xmi.idref"/>
<!-- Main SynchState group -->
<g transform="translate({UML:GraphElement.position/XMI.field[1]}, {UML:GraphElement.position/XMI.field[2]})" id="{$DiagramID}">
<xsl:apply-templates select="." mode="FontStyle"/>
<xsl:apply-templates select="." mode="StrokeStyle"/>
<xsl:apply-templates select="." mode="isVisible"/>
<title><xsl:value-of select="key('xmi.id', $SemanticID)/@name"/></title>
<desc><xsl:text>SynchState</xsl:text></desc>
<!-- State outline variables -->
<xsl:variable name="rx" select="UML:GraphNode.size/XMI.field[1] div 2"/>
<xsl:variable name="ry" select="UML:GraphNode.size/XMI.field[2] div 2"/>
<!-- The outline shape, a circle -->
<ellipse cx="{$rx}" cy = "{$ry}" rx="{$rx}" ry="{$ry}">
<xsl:apply-templates select="." mode="FillStyle"/>
</ellipse>
<!-- Synchronization bound -->
<xsl:variable name="SynchBound" select="key('xmi.id', $SemanticID)/@bound"/>
<text text-anchor="middle" x="{$rx}" y="{$ry}" style="baseline-shift: -50%" fill="black" stroke="none">
<xsl:choose>
<xsl:when test="$SynchBound = 0 or $SynchBound = 'unlimited'">*</xsl:when>
<xsl:otherwise><xsl:value-of select="$SynchBound"/></xsl:otherwise>
</xsl:choose>
</text>
<!-- Contained nodes -->
<xsl:for-each select="UML:GraphElement.contained/UML:GraphNode">
<xsl:choose>
<xsl:when test="UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo = 'StereotypeCompartment'">
<!-- State stereotypes -->
<xsl:call-template name="StereotypeCompartment"/>
</xsl:when>
<xsl:when test="UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/@typeInfo = 'Name'">
<!-- State name -->
<xsl:call-template name="Name">
<xsl:with-param name="SemanticID" select="$SemanticID"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</g>
</xsl:template>
</xsl:stylesheet>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -