Class StrokeUtility


  • public class StrokeUtility
    extends Object
    This class provides helper methods to work with Strokes and line-styles.
    Author:
    Thomas Morgner
    • Field Detail

      • STROKE_SOLID

        public static final int STROKE_SOLID
        A constant defining a stroke-type.
        See Also:
        Constant Field Values
      • STROKE_DASHED

        public static final int STROKE_DASHED
        A constant defining a stroke-type.
        See Also:
        Constant Field Values
      • STROKE_DOTTED

        public static final int STROKE_DOTTED
        A constant defining a stroke-type.
        See Also:
        Constant Field Values
      • STROKE_DOT_DASH

        public static final int STROKE_DOT_DASH
        A constant defining a stroke-type.
        See Also:
        Constant Field Values
      • STROKE_DOT_DOT_DASH

        public static final int STROKE_DOT_DOT_DASH
        A constant defining a stroke-type.
        See Also:
        Constant Field Values
      • STROKE_NONE

        public static final int STROKE_NONE
        A constant defining a stroke-type.
        See Also:
        Constant Field Values
    • Method Detail

      • createStroke

        public static Stroke createStroke​(int type,
                                          float width)
        Creates a new Stroke-Object for the given type and with.
        Parameters:
        type - the stroke-type. (Must be one of the constants defined in this class.)
        width - the stroke's width.
        Returns:
        the stroke, never null.
      • getStrokeWidth

        public static float getStrokeWidth​(Stroke s)
        Tries to extract the stroke-width from the given stroke object.
        Parameters:
        s - the stroke.
        Returns:
        the stroke's width.
      • getStrokeType

        public static int getStrokeType​(Stroke s)
        Tries to deduct the stroke-type from the given stroke object. This will result in funny return values if the stroke was not created by the createStroke(int, float) method.
        Parameters:
        s - the stroke.
        Returns:
        the stroke's width.
      • translateStrokeStyle

        public static BorderStyle translateStrokeStyle​(Stroke s)