Class BowTieSvgExporter

java.lang.Object
neqsim.process.safety.risk.bowtie.BowTieSvgExporter
All Implemented Interfaces:
Serializable

public class BowTieSvgExporter extends Object implements Serializable
Exports BowTie models to SVG format for visualization.

This class generates SVG (Scalable Vector Graphics) representations of bow-tie diagrams for use in reports, presentations, and web applications. The SVG output follows standard bow-tie visualization conventions with threats on the left, the hazard in the center, and consequences on the right.

SVG Structure

  • Left side: Threats with prevention barriers
  • Center: Hazard (top event)
  • Right side: Consequences with mitigation barriers

Usage Example

BowTieModel model = new BowTieModel("HAZARD-001", "Vessel Rupture");
// ... configure model ...

BowTieSvgExporter exporter = new BowTieSvgExporter(model);
String svg = exporter.export();
Files.writeString(Path.of("bowtie.svg"), svg);
Since:
3.3.0
Version:
1.0
Author:
NeqSim Development Team
See Also:
  • Field Details

  • Constructor Details

    • BowTieSvgExporter

      public BowTieSvgExporter(BowTieModel model)
      Creates an SVG exporter for the specified bow-tie model.
      Parameters:
      model - bow-tie model to export
    • BowTieSvgExporter

      public BowTieSvgExporter(BowTieModel model, int width, int height)
      Creates an SVG exporter with custom dimensions.
      Parameters:
      model - bow-tie model to export
      width - canvas width in pixels
      height - canvas height in pixels
  • Method Details

    • export

      public String export()
      Exports the bow-tie model to SVG format.
      Returns:
      SVG string
    • getSvgHeader

      private String getSvgHeader()
      Gets SVG header.
      Returns:
      SVG header string
    • getSvgFooter

      private String getSvgFooter()
      Gets SVG footer.
      Returns:
      SVG footer string
    • getStyles

      private String getStyles()
      Gets CSS styles for the SVG.
      Returns:
      style definitions
    • getTitle

      private String getTitle()
      Gets the title section.
      Returns:
      title SVG elements
    • getThreats

      private String getThreats()
      Gets threat elements.
      Returns:
      threat SVG elements
    • getBarriersForThreat

      private List<BowTieModel.Barrier> getBarriersForThreat(BowTieModel.Threat threat)
      Gets barriers linked to a specific threat.
      Parameters:
      threat - the threat
      Returns:
      list of barriers linked to the threat
    • getBarriersForConsequence

      private List<BowTieModel.Barrier> getBarriersForConsequence(BowTieModel.Consequence consequence)
      Gets barriers linked to a specific consequence.
      Parameters:
      consequence - the consequence
      Returns:
      list of barriers linked to the consequence
    • getHazard

      private String getHazard()
      Gets hazard element.
      Returns:
      hazard SVG element
    • getConsequences

      private String getConsequences()
      Gets consequence elements.
      Returns:
      consequence SVG elements
    • getConnectors

      private String getConnectors()
      Gets connector lines.
      Returns:
      connector SVG elements
    • getLegend

      private String getLegend()
      Gets legend.
      Returns:
      legend SVG elements
    • getStatistics

      private String getStatistics()
      Gets statistics section.
      Returns:
      statistics SVG elements
    • escapeXml

      private String escapeXml(String text)
      Escapes XML special characters.
      Parameters:
      text - text to escape
      Returns:
      escaped text
    • truncate

      private String truncate(String text, int maxLen)
      Truncates text to specified length.
      Parameters:
      text - text to truncate
      maxLen - maximum length
      Returns:
      truncated text
    • exportToHtml

      public String exportToHtml()
      Exports the bow-tie model to HTML with embedded SVG.
      Returns:
      HTML string
    • getWidth

      public int getWidth()
      Gets the canvas width.
      Returns:
      width in pixels
    • setWidth

      public void setWidth(int width)
      Sets the canvas width.
      Parameters:
      width - width in pixels
    • getHeight

      public int getHeight()
      Gets the canvas height.
      Returns:
      height in pixels
    • setHeight

      public void setHeight(int height)
      Sets the canvas height.
      Parameters:
      height - height in pixels