Class HardcopyWriter.Column

java.lang.Object
jmri.util.davidflanagan.HardcopyWriter.Column
Enclosing class:
HardcopyWriter

public static class HardcopyWriter.Column extends Object
Class to represent a column in the output. This has a start position, width and alignment. This allows left, center or right alignment, with or without wrapping.
  • Field Details

  • Constructor Details

    • Column

      public Column(int position, int width, HardcopyWriter.Align alignment)
      Create a Column with specified position, width and alignment
      Parameters:
      position - The position of the column in points
      width - The width of the column in points
      alignment - The alignment of the column
    • Column

      public Column(int position, HardcopyWriter.Align alignment)
      Create a Column with specified position and alignment. The width will be calculated up to the next column.
      Parameters:
      position - The position of the column in points
      alignment - The alignment of the column
    • Column

      public Column(int position, int width)
      Create a Column with specified position and width with LEFT alignment
      Parameters:
      position - The position of the column in points
      width - The width of the column in points
  • Method Details

    • setWidth

      public void setWidth(int width)
      Sets the width of the column in points
      Parameters:
      width - The new width of the column in points
    • getWidth

      public int getWidth()
      Gets the width of the column in points
      Returns:
      The width of the column in points
    • getStartPos

      public int getStartPos(double strlen)
      Gets the starting position of text of length strlen (in points)
      Parameters:
      strlen - The length of the text in points
      Returns:
      The starting position of the text in points
    • getPosition

      public int getPosition()
      Gets the starting position of the column in points
      Returns:
      The starting position of the column in points
    • getAlignment

      Gets the alignment of the column
      Returns:
      The alignment of the column
    • isWrap

      public boolean isWrap()
      Gets whether the column is a wrap column
      Returns:
      true if the column is a wrap column
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • stretchColumns

      public static ArrayList<HardcopyWriter.Column> stretchColumns(Collection<HardcopyWriter.Column> columns, int width, int gap)
      Stretch the columns to fit the specified width. The columns are assumed to be sorted by position. The input widths are treated as ratios. There is a gap between the columns.
      Parameters:
      columns - The columns to stretch
      width - The width to stretch to in points
      gap - The gap between the columns in points
      Returns:
      The stretched columns