Class DexpiLayoutEngine

java.lang.Object
neqsim.process.processmodel.dexpi.DexpiLayoutEngine

final class DexpiLayoutEngine extends Object
Computes auto-layout positions for DEXPI XML export.

Equipment is arranged left-to-right following process flow topology using a topological sort of the process graph. Each column holds one or more equipment items at a fixed X spacing. Multi- outlet equipment (separators) fan out vertically to separate rows.

Positions and labels are written as DEXPI-compliant <Position>, <Scale>, and <Label> XML elements on each Equipment and PipingComponent element.

Version:
1.0
Author:
NeqSim
  • Field Details

    • X_SPACING

      private static final double X_SPACING
      Horizontal spacing between equipment columns (mm in drawing space).
      See Also:
    • Y_BRANCH_OFFSET

      private static final double Y_BRANCH_OFFSET
      Vertical spacing for branch lines below the main process line.
      See Also:
    • X_START

      private static final double X_START
      Starting X coordinate.
      See Also:
    • Y_BASE

      private static final double Y_BASE
      Base Y coordinate for the main process line.
      See Also:
    • DEFAULT_SCALE

      private static final double DEFAULT_SCALE
      Default scale factor for equipment shapes.
      See Also:
    • FONT_NAME

      private static final String FONT_NAME
      Font name for labels.
      See Also:
    • TAG_FONT_HEIGHT

      private static final double TAG_FONT_HEIGHT
      Font height for tag name labels.
      See Also:
    • TAG_LABEL_OFFSET_Y

      private static final double TAG_LABEL_OFFSET_Y
      Vertical offset of tag name label above equipment center.
      See Also:
    • BAR_FONT_HEIGHT

      private static final double BAR_FONT_HEIGHT
      Font height for equipment bar label text.
      See Also:
    • BAR_WIDTH

      private static final double BAR_WIDTH
      Width of equipment bar label box.
      See Also:
    • BAR_ROW_HEIGHT

      private static final double BAR_ROW_HEIGHT
      Row height within equipment bar label table.
      See Also:
    • BAR_OFFSET_Y

      private static final double BAR_OFFSET_Y
      Vertical offset from equipment center to top of bar label.
      See Also:
    • INSTRUMENT_OFFSET_Y

      static final double INSTRUMENT_OFFSET_Y
      Vertical offset from process line to instrument bubble center.
      See Also:
    • INSTRUMENT_X_SPACING

      static final double INSTRUMENT_X_SPACING
      Horizontal spacing between instrument bubbles on the same equipment.
      See Also:
    • INSTRUMENT_BUBBLE_RADIUS

      static final double INSTRUMENT_BUBBLE_RADIUS
      Radius of instrument bubble for connection point calculations.
      See Also:
    • SIGNAL_LINE_WEIGHT

      private static final double SIGNAL_LINE_WEIGHT
      Line weight for measuring/signal lines.
      See Also:
    • PROCESS_LINE_WEIGHT

      private static final double PROCESS_LINE_WEIGHT
      Line weight for process piping lines.
      See Also:
    • LINE_COLOR_R

      private static final String LINE_COLOR_R
      Presentation colour R for process piping lines (olive).
      See Also:
    • LINE_COLOR_G

      private static final String LINE_COLOR_G
      Presentation colour G for process piping lines (olive).
      See Also:
    • LINE_COLOR_B

      private static final String LINE_COLOR_B
      Presentation colour B for process piping lines (olive).
      See Also:
    • MIN_SHEET_WIDTH

      private static final double MIN_SHEET_WIDTH
      Minimum drawing sheet width (A3 landscape in mm).
      See Also:
    • MIN_SHEET_HEIGHT

      private static final double MIN_SHEET_HEIGHT
      Minimum drawing sheet height (A3 landscape in mm).
      See Also:
    • BORDER_MARGIN

      private static final double BORDER_MARGIN
      Margin between outer edge and inner border.
      See Also:
    • TITLE_BLOCK_HEIGHT

      private static final double TITLE_BLOCK_HEIGHT
      Title block height at the bottom-right.
      See Also:
    • TITLE_BLOCK_WIDTH

      private static final double TITLE_BLOCK_WIDTH
      Title block width.
      See Also:
    • TITLE_ROW_HEIGHT

      private static final double TITLE_ROW_HEIGHT
      Row height inside title block.
      See Also:
    • TITLE_FONT_HEIGHT

      private static final double TITLE_FONT_HEIGHT
      Font height for title block text.
      See Also:
    • TITLE_MAIN_FONT_HEIGHT

      private static final double TITLE_MAIN_FONT_HEIGHT
      Font height for the main drawing title.
      See Also:
    • ARROW_LENGTH

      private static final double ARROW_LENGTH
      Length of flow direction arrow heads.
      See Also:
    • ARROW_HALF_WIDTH

      private static final double ARROW_HALF_WIDTH
      Half-width of flow direction arrow heads.
      See Also:
    • TABLE_ROW_HEIGHT

      private static final double TABLE_ROW_HEIGHT
      Height of the stream data table header row.
      See Also:
    • TABLE_COL_WIDTH

      private static final double TABLE_COL_WIDTH
      Width of each stream column in the stream table.
      See Also:
    • TABLE_LABEL_WIDTH

      private static final double TABLE_LABEL_WIDTH
      Width of the row-label column in the stream table.
      See Also:
    • TABLE_FONT_HEIGHT

      private static final double TABLE_FONT_HEIGHT
      Font height for stream table text.
      See Also:
    • TABLE_TOP_Y

      private static final double TABLE_TOP_Y
      Top of the stream table (Y coordinate).
      See Also:
    • BATTERY_LIMIT_PADDING

      private static final double BATTERY_LIMIT_PADDING
      Padding around equipment for battery limit boundary (mm).
      See Also:
    • BATTERY_LIMIT_LINE_WEIGHT

      private static final double BATTERY_LIMIT_LINE_WEIGHT
      Line weight for battery limit boundary (bold dashed).
      See Also:
    • LEGEND_WIDTH

      private static final double LEGEND_WIDTH
      Width of the symbol legend box (mm).
      See Also:
    • LEGEND_ROW_HEIGHT

      private static final double LEGEND_ROW_HEIGHT
      Row height in the legend box (mm).
      See Also:
    • LEGEND_FONT_HEIGHT

      private static final double LEGEND_FONT_HEIGHT
      Font height for legend text.
      See Also:
    • REVISION_ROW_HEIGHT

      private static final double REVISION_ROW_HEIGHT
      Row height in revision history table (mm).
      See Also:
  • Constructor Details

    • DexpiLayoutEngine

      private DexpiLayoutEngine()
  • Method Details

    • computeLayout

      static Map<String, DexpiLayoutEngine.EquipmentPosition> computeLayout(ProcessSystem processSystem)
      Computes layout positions for all equipment in a process system.

      Returns a map from equipment name to its DexpiLayoutEngine.EquipmentPosition. The positions are computed using a topological ordering of the process graph, placing equipment left-to-right. Multi- outlet equipment branches are fanned out vertically.

      Parameters:
      processSystem - the process system to lay out
      Returns:
      map of equipment name to computed position
    • appendPosition

      static void appendPosition(Document document, Element element, DexpiLayoutEngine.EquipmentPosition pos)
      Appends a DEXPI Position element to an equipment element.
      Parameters:
      document - the XML document
      element - the equipment element
      pos - the computed position
    • appendScale

      static void appendScale(Document document, Element element, DexpiLayoutEngine.EquipmentPosition pos)
      Appends a DEXPI Scale element to an equipment element.
      Parameters:
      document - the XML document
      element - the equipment element
      pos - the computed position containing scale factors
    • appendTagNameLabel

      static void appendTagNameLabel(Document document, Element element, String tagName, DexpiLayoutEngine.EquipmentPosition pos, String labelId, String equipmentId)
      Appends an EquipmentTagNameLabel to an equipment element.
      Parameters:
      document - the XML document
      element - the equipment element
      tagName - the equipment tag name to display
      pos - the equipment position
      labelId - the unique label ID
      equipmentId - the equipment element ID (for TextStringFormatSpecification)
    • appendConnectionLine

      static void appendConnectionLine(Document document, Element parent, double fromX, double fromY, double toX, double toY)
      Appends a process piping line (CenterLine) connecting two nozzle positions.

      Uses orthogonal routing (horizontal-vertical-horizontal segments) when source and target are at different Y coordinates. Horizontal connections use a single straight segment. Line style matches the DEXPI standard process piping presentation (olive colour, 0.5 weight).

      Parameters:
      document - the XML document
      parent - the parent element (PipingNetworkSegment)
      fromX - source X coordinate
      fromY - source Y coordinate
      toX - destination X coordinate
      toY - destination Y coordinate
    • appendCoordinate

      private static void appendCoordinate(Document document, Element parent, double x, double y)
      Appends a single Coordinate element to a CenterLine.
      Parameters:
      document - the XML document
      parent - the CenterLine element
      x - the X coordinate
      y - the Y coordinate
    • appendEquipmentBarLabel

      static void appendEquipmentBarLabel(Document document, Element element, String tagName, DexpiLayoutEngine.EquipmentPosition pos, String labelId, String equipmentId, double pressure, double temperature, double flowRate)
      Appends an EquipmentBarLabel below an equipment element showing operating data.

      Renders a table with border lines and rows for equipment identity, operating pressure, operating temperature, and flow rate. This follows the DEXPI standard pattern for equipment data labels on P&IDs.

      Parameters:
      document - the XML document
      element - the equipment element
      tagName - the equipment tag name
      pos - the equipment position
      labelId - the unique label ID
      equipmentId - the equipment element ID
      pressure - operating pressure in bara (NaN to omit)
      temperature - operating temperature in C (NaN to omit)
      flowRate - operating flow rate in MSm3/day (NaN to omit)
    • appendEquipmentBarLabel

      static void appendEquipmentBarLabel(Document document, Element element, String tagName, DexpiLayoutEngine.EquipmentPosition pos, String labelId, String equipmentId, double pressure, double temperature, double flowRate, List<String[]> extraRows)
      Appends an equipment bar label with operating data and optional extra rows.
      Parameters:
      document - the XML document
      element - the equipment element
      tagName - the equipment tag name
      pos - the equipment position
      labelId - the unique label ID
      equipmentId - the equipment element ID
      pressure - operating pressure in bara (NaN to omit)
      temperature - operating temperature in C (NaN to omit)
      flowRate - operating flow rate in MSm3/day (NaN to omit)
      extraRows - additional label-value pairs to display (may be null)
    • appendNozzlePosition

      static void appendNozzlePosition(Document document, Element nozzleElement, double x, double y)
      Appends a Position and Scale to a Nozzle element for graphical rendering.
      Parameters:
      document - the XML document
      nozzleElement - the Nozzle element
      x - the x coordinate
      y - the y coordinate
    • appendBarPolyLine

      private static void appendBarPolyLine(Document document, Element parent, double x1, double y1, double x2, double y2)
      Appends a PolyLine element used as a border in an equipment bar label.
      Parameters:
      document - the XML document
      parent - the label element
      x1 - start X
      y1 - start Y
      x2 - end X
      y2 - end Y
    • appendBarText

      private static void appendBarText(Document document, Element parent, String text, double x, double y, String justification)
      Appends a Text element used in an equipment bar label row.
      Parameters:
      document - the XML document
      parent - the label element
      text - the text string
      x - the text X position
      y - the text Y position
      justification - the text justification (e.g. "LeftBottom", "CenterBottom")
    • resolveInletStreams

      static List<StreamInterface> resolveInletStreams(ProcessEquipmentInterface unit)
      Resolves all inlet streams for a process equipment unit. Handles both TwoPortEquipment (single inlet via getInletStream()) and multi-port equipment like Separator and Mixer (via getInletStreams()).
      Parameters:
      unit - the process equipment
      Returns:
      list of inlet streams (never null, may be empty)
    • formatValue

      private static String formatValue(double value)
      Formats a numeric value for display in equipment bar labels.
      Parameters:
      value - the value to format
      Returns:
      formatted string
    • computeInstrumentPosition

      static double[] computeInstrumentPosition(DexpiLayoutEngine.EquipmentPosition equipmentPos, int instrumentIndex, int totalInstruments)
      Computes the layout position for an instrument bubble attached to a specific equipment.

      Instruments are placed above (higher Y) the equipment, offset by INSTRUMENT_OFFSET_Y. Multiple instruments on the same equipment are spaced horizontally.

      Parameters:
      equipmentPos - the parent equipment position
      instrumentIndex - 0-based index of this instrument on the equipment
      totalInstruments - total number of instruments on this equipment
      Returns:
      the instrument position {x, y}
    • appendMeasuringLine

      static void appendMeasuringLine(Document document, Element parent, double tapX, double tapY, double bubbleX, double bubbleY)
      Appends a measuring line (CenterLine) connecting an equipment nozzle to an instrument bubble.

      The line runs vertically from a point on the process line up to the bottom of the instrument bubble. Uses green signal-line colour per DEXPI convention.

      Parameters:
      document - the XML document
      parent - the InformationFlow element to append to
      tapX - X coordinate on the process line (tap point)
      tapY - Y coordinate on the process line
      bubbleX - X coordinate of the instrument bubble center
      bubbleY - Y coordinate of the instrument bubble center
    • appendSignalLine

      static void appendSignalLine(Document document, Element parent, double fromX, double fromY, double toX, double toY)
      Appends a signal conveying line (dashed, blue) between two instrument bubbles.
      Parameters:
      document - the XML document
      parent - the InformationFlow element
      fromX - source bubble center X
      fromY - source bubble center Y
      toX - target bubble center X
      toY - target bubble center Y
    • computeSheetSize

      static double[] computeSheetSize(Map<String, DexpiLayoutEngine.EquipmentPosition> positions)
      Computes the required drawing sheet dimensions to enclose all equipment, instruments, and labels with adequate margin. The result is at least A3 landscape (420 x 297 mm).
      Parameters:
      positions - the computed equipment layout positions
      Returns:
      a two-element array {width, height} in mm
    • computePageGrid

      static int[] computePageGrid(double totalWidth, double totalHeight, double maxPageWidth, double maxPageHeight)
      Computes the number of drawing pages needed for a large flowsheet.

      When the total equipment extent exceeds an A1 landscape sheet (841 x 594 mm), the flowsheet is split into multiple pages. Each page has its own Drawing element with border, title block, and continuation markings.

      Parameters:
      totalWidth - the total layout width in mm
      totalHeight - the total layout height in mm
      maxPageWidth - maximum page width (default 841 mm for A1)
      maxPageHeight - maximum page height (default 594 mm for A1)
      Returns:
      the number of pages as [columns, rows]
    • appendContinuationArrow

      static void appendContinuationArrow(Document document, Element parent, double x, double y, String direction, String targetSheet)
      Appends a continuation arrow marking at the edge of a drawing page.

      Per ISO 10628 and NORSOK Z-003, when a P&ID spans multiple sheets, continuation arrows indicate where the process continues on adjacent sheets. The arrow is labeled with the destination sheet number.

      Parameters:
      document - the XML document
      parent - the Drawing element
      x - the arrow X position
      y - the arrow Y position
      direction - "RIGHT", "LEFT", "UP", or "DOWN"
      targetSheet - the destination sheet identifier (e.g. "Sheet 2")
    • appendDrawing

      static void appendDrawing(Document document, Element parent, String drawingName, String drawingNumber, String revision, String date, double sheetWidth, double sheetHeight)
      Appends a complete DEXPI <Drawing> element with border, column/row markers, and a professional title block. The sheet dimensions are auto-computed to fit all content.
      Parameters:
      document - the XML document
      parent - the PlantModel root element
      drawingName - the drawing title (e.g. process name)
      drawingNumber - the drawing number (e.g. "PID-001")
      revision - the revision string (e.g. "A")
      date - the drawing date string
      sheetWidth - the computed sheet width in mm
      sheetHeight - the computed sheet height in mm
    • appendDrawingBorderLines

      private static void appendDrawingBorderLines(Document document, Element border, double sheetWidth, double sheetHeight)
      Appends the outer and inner border rectangles.
      Parameters:
      document - the XML document
      border - the DrawingBorder element
      sheetWidth - the sheet width in mm
      sheetHeight - the sheet height in mm
    • appendBorderRect

      private static void appendBorderRect(Document document, Element parent, double x1, double y1, double x2, double y2, double lineWeight)
      Appends a rectangle as a closed PolyLine.
      Parameters:
      document - the XML document
      parent - the parent element
      x1 - left X
      y1 - bottom Y
      x2 - right X
      y2 - top Y
      lineWeight - the line weight
    • appendColumnRowMarkers

      private static void appendColumnRowMarkers(Document document, Element border, double sheetWidth, double sheetHeight)
      Appends column/row zone markers along the border edges (A-F vertical, 1-8 horizontal).
      Parameters:
      document - the XML document
      border - the DrawingBorder element
      sheetWidth - the sheet width in mm
      sheetHeight - the sheet height in mm
    • appendBorderText

      private static void appendBorderText(Document document, Element parent, String text, double x, double y)
      Appends a border zone label (column number or row letter).
      Parameters:
      document - the XML document
      parent - the DrawingBorder element
      text - the label text
      x - X coordinate
      y - Y coordinate
    • appendBorderTick

      private static void appendBorderTick(Document document, Element parent, double x1, double y1, double x2, double y2)
      Appends a short tick mark line in the border margin.
      Parameters:
      document - the XML document
      parent - the DrawingBorder element
      x1 - start X
      y1 - start Y
      x2 - end X
      y2 - end Y
    • appendTitleBlock

      private static void appendTitleBlock(Document document, Element drawing, String drawingName, String drawingNumber, String revision, String date, double sheetWidth)
      Appends the title block label in the bottom-right corner of the drawing.
      Parameters:
      document - the XML document
      drawing - the Drawing element
      drawingName - the drawing title
      drawingNumber - the drawing number
      revision - the revision
      date - the date string
      sheetWidth - the width of the drawing sheet in layout units
    • appendTitleCell

      private static void appendTitleCell(Document document, Element parent, double x1, double y1, double x2, double y2, String text)
      Appends a cell in the title block with a border and text.
      Parameters:
      document - the XML document
      parent - the label element
      x1 - left X
      y1 - bottom Y
      x2 - right X
      y2 - top Y
      text - the cell text
    • appendTitleText

      private static void appendTitleText(Document document, Element parent, String text, double x, double y, double fontSize, String justification)
      Appends a text element for the title block.
      Parameters:
      document - the XML document
      parent - the parent element
      text - the text string
      x - X position
      y - Y position
      fontSize - font height
      justification - text justification
    • appendFlowArrow

      static void appendFlowArrow(Document document, Element parent, double fromX, double fromY, double toX, double toY)
      Appends a solid triangular flow-direction arrow at the midpoint of a connection line.

      The arrow points from source to destination. For horizontal lines, the arrow points right. For orthogonal routed lines, the arrow is placed on the first horizontal segment. The arrow is rendered as a filled PolyLine triangle in the process line colour.

      Parameters:
      document - the XML document
      parent - the PipingNetworkSegment element
      fromX - source X coordinate
      fromY - source Y coordinate
      toX - destination X coordinate
      toY - destination Y coordinate
    • appendStreamLabel

      static void appendStreamLabel(Document document, Element parent, String streamNumber, double fromX, double fromY, double toX, double toY)
      Appends a stream number label at the midpoint of a connection line.
      Parameters:
      document - the XML document
      parent - the PipingNetworkSegment element
      streamNumber - the stream/line number text to display
      fromX - source X coordinate
      fromY - source Y coordinate
      toX - destination X coordinate
      toY - destination Y coordinate
    • appendStreamTable

      static void appendStreamTable(Document document, Element parent, List<DexpiLayoutEngine.StreamTableEntry> streamData)
      Appends a process conditions table (stream table) at the bottom of the drawing.

      The table shows key process data (temperature, pressure, flow, phase) for each major stream in the process. This follows the standard P&ID convention of including a stream data table.

      Parameters:
      document - the XML document
      parent - the Drawing or PlantModel element
      streamData - ordered list of stream data entries
    • appendTableText

      private static void appendTableText(Document document, Element parent, String text, double x, double y, String justification)
      Appends a text element for the stream table.
      Parameters:
      document - the XML document
      parent - the label element
      text - the text string
      x - X position
      y - Y position
      justification - text justification
    • appendBatteryLimitBoundary

      static void appendBatteryLimitBoundary(Document document, Element parent, Map<String, DexpiLayoutEngine.EquipmentPosition> positions, String areaLabel)
      Appends a dashed battery-limit boundary rectangle around all equipment.

      Per NORSOK Z-003 and ISO 10628, battery limits are shown as bold dash-dot lines enclosing the process unit boundary. The boundary is computed from the extremes of all equipment positions with padding.

      Parameters:
      document - the XML document
      parent - the Drawing or PlantModel element
      positions - all equipment positions
      areaLabel - the battery limit label (e.g. "AREA 100 - GAS PROCESSING")
    • appendFailPositionMarker

      static void appendFailPositionMarker(Document document, Element parent, String failPosition, double x, double y)
      Appends a valve fail-position marker text (FC, FO, FL) near a valve position.

      Per NORSOK Z-003, valve fail positions are marked adjacent to the valve symbol: FC = fail closed, FO = fail open, FL = fail last position.

      Parameters:
      document - the XML document
      parent - the PipingComponent (valve) element
      failPosition - the fail position code (FC, FO, or FL)
      x - the valve X coordinate
      y - the valve Y coordinate
    • appendPstMarker

      static void appendPstMarker(Document document, Element parent, double x, double y)
      Appends a PST (Partial Stroke Test) annotation marker near a safety valve.

      Per IEC 61508 and IEC 61511, valves with partial stroke test capability are annotated with a "PST" label and a distinctive marker to indicate online diagnostic capability.

      Parameters:
      document - the XML document
      parent - the parent element
      x - the valve center X
      y - the valve center Y
    • appendHeatTraceMark

      static void appendHeatTraceMark(Document document, Element parent, String traceType, double fromX, double fromY, double toX, double toY)
      Appends a heat trace indication on a pipe segment.

      Per ISO 10628 and NORSOK Z-003, heat traced lines are indicated with a zigzag marking along the pipe and an "HT" or specific heat trace type code.

      Parameters:
      document - the XML document
      parent - the parent element
      traceType - the heat trace type code (e.g. "ET" for electric, "ST" for steam)
      fromX - source X
      fromY - source Y
      toX - destination X
      toY - destination Y
    • appendWeightAnnotation

      static void appendWeightAnnotation(Document document, Element parent, double dryWeightKg, double operatingWeightKg, double x, double y)
      Appends an equipment weight and center-of-gravity annotation marker.

      Shows the equipment dry weight and operating weight in a small annotation box below the equipment symbol. Used for mechanical design and layout planning.

      Parameters:
      document - the XML document
      parent - the parent element
      dryWeightKg - the equipment dry weight in kg (0 to omit)
      operatingWeightKg - the operating weight in kg (0 to omit)
      x - the equipment center X
      y - the equipment symbol bottom Y
    • appendSamplePoint

      static void appendSamplePoint(Document document, Element parent, String tag, double x, double y)
      Appends a sample point symbol on a process line.

      Per ISO 10628, sample points are indicated with a small circle (or filled dot) with an "SP" label on the process line where grab or online samples can be taken.

      Parameters:
      document - the XML document
      parent - the parent element
      tag - the sample point tag (e.g. "SP-001")
      x - the sample point X
      y - the sample point Y
    • appendGaugeGlass

      static void appendGaugeGlass(Document document, Element parent, double x, double yTop, double yBottom)
      Appends a gauge glass (level gauge) symbol on a vessel.

      Per ISO 10628, sight/gauge glasses on vessels are represented as a narrow rectangle alongside the vessel with connection stubs at top and bottom.

      Parameters:
      document - the XML document
      parent - the parent element
      x - the gauge glass X position (vessel wall edge)
      yTop - the top connection Y
      yBottom - the bottom connection Y
    • appendInsulationMark

      static void appendInsulationMark(Document document, Element parent, String insulationCode, double fromX, double fromY, double toX, double toY)
      Appends insulation marking on a process line between two points.

      Per ISO 10628 and NORSOK Z-003, insulation is indicated by a short perpendicular tick mark on the process line with a code letter: H = hot insulation, C = cold insulation, P = personnel protection, A = acoustic.

      Parameters:
      document - the XML document
      parent - the PipingNetworkSegment element
      insulationCode - the insulation code (H, C, P, A)
      fromX - source X
      fromY - source Y
      toX - destination X
      toY - destination Y
    • appendOrientationMarker

      static void appendOrientationMarker(Document document, Element parent, String orientation, double x, double y)
      Appends an orientation marker (H or V) next to equipment, per ISO 10628 convention.
      Parameters:
      document - the XML document
      parent - the equipment element
      orientation - the orientation string ("H" or "V")
      x - equipment center X
      y - equipment center Y
    • appendSilMarker

      static void appendSilMarker(Document document, Element parent, int silLevel, double x, double y)
      Appends a SIL level marker below an instrument bubble.

      Per NORSOK Z-003 and IEC 61511, safety instrumented functions are marked with their SIL level (SIL 1, SIL 2, SIL 3) below the instrument bubble. The text is shown in a distinctive style.

      Parameters:
      document - the XML document
      parent - the ProcessInstrumentationFunction element
      silLevel - the SIL level (1, 2, or 3)
      x - the instrument bubble center X
      y - the instrument bubble center Y
    • appendSolenoidMarker

      static void appendSolenoidMarker(Document document, Element parent, double valveX, double valveY, double controllerX, double controllerY)
      Appends a solenoid actuator diamond symbol near a valve position.

      Per ISA 5.1, solenoid-actuated valves (ESD, blowdown, HIPPS) are indicated with a small diamond symbol on the valve actuator stem, connected to the controller by a signal line.

      Parameters:
      document - the XML document
      parent - the parent element to append drawing primitives to
      valveX - the valve center X
      valveY - the valve center Y
      controllerX - the controller bubble center X
      controllerY - the controller bubble center Y
    • appendStyledConnectionLine

      static void appendStyledConnectionLine(Document document, Element parent, double fromX, double fromY, double toX, double toY, int lineType, String colorR, String colorG, String colorB)
      Appends a connection line with a specific line type for utility services.

      Per ISO 10628 and NORSOK Z-003, different piping services use distinct line styles: solid for process, dashed for steam/utility, dotted for drain, dash-dot for instrument air, etc.

      Parameters:
      document - the XML document
      parent - the PipingNetworkSegment element
      fromX - source X
      fromY - source Y
      toX - destination X
      toY - destination Y
      lineType - ISO/DEXPI line type (0=solid, 1=dashed, 2=dotted, 3=dash-dot)
      colorR - red component (0-1)
      colorG - green component (0-1)
      colorB - blue component (0-1)
    • appendUtilityConnectionPoint

      static void appendUtilityConnectionPoint(Document document, Element parent, String utilityCode, double x, double y, double targetX, double targetY)
      Appends a utility supply connection point with label and dashed connection line.

      Per ISO 10628, utility connections (instrument air, steam, cooling water, nitrogen) are shown as labeled connection stubs with dashed lines and a utility code identifier.

      Parameters:
      document - the XML document
      parent - the parent element
      utilityCode - short code for the utility (e.g. "IA", "STM", "CW", "N2")
      x - connection X coordinate
      y - connection Y coordinate
      targetX - equipment or valve X coordinate the utility connects to
      targetY - equipment or valve Y coordinate the utility connects to
    • appendLineIdLabel

      static void appendLineIdLabel(Document document, Element parent, String lineSize, String fluidCode, String lineNumber, String pipingClass, double fromX, double fromY, double toX, double toY)
      Appends a formatted line identification label per ISO 10628 / NORSOK Z-003.

      The standard line ID format is: SIZE"-FLUID_CODE-LINE_NUMBER-PIPING_CLASS. For example: 6"-HC-001-A1B. The label is placed above the pipe midpoint.

      Parameters:
      document - the XML document
      parent - the PipingNetworkSegment element
      lineSize - pipe nominal size (e.g. "6\"")
      fluidCode - fluid code (e.g. "HC")
      lineNumber - line number (e.g. "001")
      pipingClass - piping class code (e.g. "A1B", "150#")
      fromX - source X
      fromY - source Y
      toX - destination X
      toY - destination Y
    • appendRevisionHistory

      static void appendRevisionHistory(Document document, Element drawing, List<String[]> revisions, double sheetWidth)
      Appends a revision history table above the title block.

      Per NORSOK Z-003, the P&ID title block includes a revision history showing rev number, date, description, drawn by, and checked by for each revision.

      Parameters:
      document - the XML document
      drawing - the Drawing element
      revisions - list of revision entries [rev, date, description, drawnBy, checkedBy]
      sheetWidth - the drawing sheet width
    • appendRevisionCell

      private static void appendRevisionCell(Document document, Element parent, double x1, double y1, double x2, double y2, String text)
      Appends a cell for the revision history table.
      Parameters:
      document - the XML document
      parent - the label element
      x1 - left X
      y1 - bottom Y
      x2 - right X
      y2 - top Y
      text - the cell text
    • appendSymbolLegend

      static void appendSymbolLegend(Document document, Element parent, List<String[]> entries)
      Appends a symbol legend box listing line types, valve symbols, and abbreviations.

      Per ISO 10628, P&IDs include a legend explaining line type conventions and abbreviations. The legend is placed bottom-left to avoid overlap with the stream table and title block.

      Parameters:
      document - the XML document
      parent - the Drawing or PlantModel element
      entries - list of legend entries [lineType, description]
    • appendLegendText

      private static void appendLegendText(Document document, Element parent, String text, double x, double y, String justification, String fontSize)
      Appends text for the symbol legend box.
      Parameters:
      document - the XML document
      parent - the label element
      text - the text string
      x - X position
      y - Y position
      justification - text justification
      fontSize - font height as string