Class LineNumber

    • Field Detail

      • OUTER

        protected static final Border OUTER
      • borderGap

        protected int borderGap
      • currentLineForeground

        protected Color currentLineForeground
      • alignment

        protected int alignment
      • alignmentX

        protected float alignmentX
      • minimumDisplayDigits

        protected int minimumDisplayDigits
      • lastDigits

        protected int lastDigits
      • lastHeight

        protected int lastHeight
      • lastLine

        protected int lastLine
    • Constructor Detail

      • LineNumber

        public LineNumber​(JTextComponent component)
        Create a LineNumber component for a JTextComponent. This minimum display width will be based on 3 digits.
        Parameters:
        component - the related text component
      • LineNumber

        public LineNumber​(JTextComponent component,
                          int minimumDisplayDigits)
        Create a LineNumber component for a JTextComponent.
        Parameters:
        component - the related text component
        minimumDisplayDigits - the number of digits used to calculate the minimum width of the component
    • Method Detail

      • getBorderGap

        public int getBorderGap()
        Gets the border gap
        Returns:
        the border gap in pixels
      • setBorderGap

        public void setBorderGap​(int borderGap)
        The border gap is used in calculating the left and right insets of the border. Default value is 5.
        Parameters:
        borderGap - the gap in pixels
      • getCurrentLineForeground

        public Color getCurrentLineForeground()
        Gets the current line rendering Color
        Returns:
        the Color used to render the current line number
      • setCurrentLineForeground

        public void setCurrentLineForeground​(Color currentLineForeground)
        The Color used to render the current line digits. Default is Color.RED.
        Parameters:
        currentLineForeground - the Color used to render the current line
      • getAlignment

        public int getAlignment()
        Gets the alignment
        Returns:
        the alignment of the painted line number
      • getMinimumDisplayDigits

        public int getMinimumDisplayDigits()
        Gets the minimum display digits
        Returns:
        the minimum display digits
      • setMinimumDisplayDigits

        public void setMinimumDisplayDigits​(int minimumDisplayDigits)
        Specify the minimum number of digits used to calculate the preferred width of the component. Default is 3.
        Parameters:
        minimumDisplayDigits - the number digits used in the preferred width calculation
      • setPreferredWidth

        protected void setPreferredWidth()
        Calculate the width needed to display the maximum line number
      • isCurrentLine

        protected boolean isCurrentLine​(Point viewPoint)
      • getTextLineNumber

        protected String getTextLineNumber​(Point viewPoint,
                                           int preferredHeight)
      • getOffsetX

        protected int getOffsetX​(int availableWidth,
                                 int stringWidth)
      • caretUpdate

        protected void caretUpdate​(CaretEvent evt)
      • documentChanged

        protected void documentChanged​(DocumentEvent evt)