Class BasicStrokeBuilder

java.lang.Object
org.bzdev.obnaming.misc.BasicStrokeBuilder

public class BasicStrokeBuilder extends Object
Create a BasicStroke pragmatically. This class uses the same design as BasicStrokeParm but can be used directly instead of by using a factory.

The rationale for this class is that ExpressionParser does not provide floats, just doubles, and the constructors for BasicStroke use floats.

  • Constructor Details

    • BasicStrokeBuilder

      public BasicStrokeBuilder()
  • Method Details

    • setWidth

      public BasicStrokeBuilder setWidth(double width)
      Set the line width. The width is in user-space units (that is, in units of points).
      Parameters:
      width - the line width
      Returns:
      this object
    • getWidth

      public double getWidth()
      Get the line width. The width is in user-space units (that is, in units of points).
      Returns:
      the line width
    • setCap

      Set the cap for a line. The cap is a decoration applied to the start or end of an enclosed subpath of a line.
      Parameters:
      cap - the cap
      Returns:
      this object
    • getCap

      public BasicStrokeParm.Cap getCap()
      Get the cap for a line. The cap is a decoration applied to the start or end of an enclosed subpath of a line.
      Returns:
      the current cap
    • setJoin

      Set the join type. The choices are beveled, mitered, and round.
      Parameters:
      join - decoration used to join two line segments
      Returns:
      this object
    • getJoin

      public BasicStrokeParm.Join getJoin()
      Get the joint type. The choices are beveled, mitered, and round.
      Returns:
      the decoration used to join two line segments
    • setMiterLimit

      public BasicStrokeBuilder setMiterLimit(double miterLimit)
      Set the miter limit. Mitered joins are trimmed when the ratio of the miter length to the stroke width is greater than the miter limit. Trimming converts the miter decoration to a bevel decoration.
      Parameters:
      miterLimit - the miter limit
      Returns:
      this object
    • getMiterLimit

      public double getMiterLimit()
      Get the miter limit. Mitered joins are trimmed when the ratio of the miter length to the stroke width is greater than the miter limit. Trimming converts the miter decoration to a bevel decoration.
      Returns:
      the miter limit
    • setDashPhase

      public BasicStrokeBuilder setDashPhase(double phase)
      Set the dash phase. The dash phase is the distance in user space representing the offset into a dash pattern at which to start.
      Parameters:
      phase - the dash phase
      Returns:
      this object
    • getDashPhase

      public double getDashPhase()
      Get the dash phase. The dash phase is the distance in user space representing the offset into a dash pattern at which to start.
      Returns:
      the dash phase
    • setDashIncr

      public BasicStrokeBuilder setDashIncr(double dashIncr)
      Set the dash increment. Dashed lines are specified by a string consisting of the characters "-" and " ". Each character is replaced with a dash or space whose user-space length is this value.
      Parameters:
      dashIncr - the dash increment
      Returns:
      this object
    • getDashIncr

      public double getDashIncr()
      Get the dash increment. Dashed lines are specified by a string consisting of the characters "-" and " ". Each character is replaced with a dash or space whose user-space length is this value.
      Returns:
      the dash increment
    • setDashPattern

      public BasicStrokeBuilder setDashPattern(String pattern)
      Set the dash pattern. Dashed lines are specified by a string consisting of the characters "-" and " ". If the string has a length of zero or consists a sequence of '-' with no spaces, the line is solid. Otherwise the pattern should be represented by a sequence of "-" or " " giving the length of dashes or empty space respectively as multiples of the value of dashIncrement. Such a pattern must start with a '-' and end with a ' '.* Each "-" and each " " represents a component of a segment whose length is dashIncrement. Thus, if dashIncrement is 10.0, then the pattern "-- - " will consist of a dash of length 20.0, a space of length 10.0, a dash of length 10.0, and a space of length 10.0, with the pattern repeating as needed. Note that a pattern ending with a '-' is not necessary as the dashPhase parameter can be used to create the same effect.
      Parameters:
      pattern - the dash pattern
      Returns:
      this object
    • getDashPattern

      public String getDashPattern()
      Set the dash pattern. Dashed lines are specified by a string consisting of the characters "-" and " ". If the string has a length of zero, the line is solid. Otherwise the pattern should be represented by a sequence of "-" or " " giving the length of dashes or empty space respectively as multiples of the value of dashIncrement.
      Returns:
      the dash pattern
    • createStroke

      public BasicStroke createStroke()
      Create a stroke.
      Returns:
      the stroke corresponding to this builder's configuration.