Class WrappedSyntaxView.WrappedLine

  • All Implemented Interfaces:
    javax.swing.SwingConstants
    Enclosing class:
    WrappedSyntaxView

    class WrappedSyntaxView.WrappedLine
    extends javax.swing.text.View
    Simple view of a line that wraps if it doesn't fit within the horizontal space allocated. This class tries to be lightweight by carrying little state of its own and sharing the state of the outer class with its siblings.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int nlines  
      private boolean widthChangePending  
      • Fields inherited from class javax.swing.text.View

        BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
      • Fields inherited from interface javax.swing.SwingConstants

        BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
    • Constructor Summary

      Constructors 
      Constructor Description
      WrappedLine​(javax.swing.text.Element elem)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) int calculateLineCount()
      Calculate the number of lines that will be rendered by logical line when it is wrapped.
      float getPreferredSpan​(int axis)
      Determines the preferred span for this view along an axis.
      private void handleDocumentEvent​(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)  
      void insertUpdate​(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)  
      java.awt.Shape modelToView​(int pos, java.awt.Shape a, javax.swing.text.Position.Bias b)
      Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
      void paint​(java.awt.Graphics g, java.awt.Shape a)
      Renders using the given rendering surface and area on that surface.
      void removeUpdate​(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)  
      int viewToModel​(float fx, float fy, java.awt.Shape a, javax.swing.text.Position.Bias[] bias)
      Provides a mapping from the view coordinate space to the logical coordinate space of the model.
      • Methods inherited from class javax.swing.text.View

        append, breakView, changedUpdate, createFragment, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getNextVisualPositionFrom, getParent, getResizeWeight, getStartOffset, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, replace, setParent, setSize, updateChildren, updateLayout, viewToModel
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • nlines

        private int nlines
      • widthChangePending

        private boolean widthChangePending
    • Constructor Detail

      • WrappedLine

        WrappedLine​(javax.swing.text.Element elem)
    • Method Detail

      • calculateLineCount

        final int calculateLineCount()
        Calculate the number of lines that will be rendered by logical line when it is wrapped.
      • getPreferredSpan

        public float getPreferredSpan​(int axis)
        Determines the preferred span for this view along an axis.
        Specified by:
        getPreferredSpan in class javax.swing.text.View
        Parameters:
        axis - may be either X_AXIS or Y_AXIS
        Returns:
        the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.
        See Also:
        View.getPreferredSpan(int)
      • paint

        public void paint​(java.awt.Graphics g,
                          java.awt.Shape a)
        Renders using the given rendering surface and area on that surface. The view may need to do layout and create child views to enable itself to render into the given allocation.
        Specified by:
        paint in class javax.swing.text.View
        Parameters:
        g - the rendering surface to use
        a - the allocated region to render into
        See Also:
        View.paint(java.awt.Graphics, java.awt.Shape)
      • modelToView

        public java.awt.Shape modelToView​(int pos,
                                          java.awt.Shape a,
                                          javax.swing.text.Position.Bias b)
                                   throws javax.swing.text.BadLocationException
        Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
        Specified by:
        modelToView in class javax.swing.text.View
        Parameters:
        pos - the position to convert
        a - the allocated region to render into
        Returns:
        the bounding box of the given position is returned
        Throws:
        javax.swing.text.BadLocationException - if the given position does not represent a valid location in the associated document.
      • viewToModel

        public int viewToModel​(float fx,
                               float fy,
                               java.awt.Shape a,
                               javax.swing.text.Position.Bias[] bias)
        Provides a mapping from the view coordinate space to the logical coordinate space of the model.
        Specified by:
        viewToModel in class javax.swing.text.View
        Parameters:
        fx - the X coordinate
        fy - the Y coordinate
        a - the allocated region to render into
        Returns:
        the location within the model that best represents the given point in the view
        See Also:
        View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
      • handleDocumentEvent

        private void handleDocumentEvent​(javax.swing.event.DocumentEvent e,
                                         java.awt.Shape a,
                                         javax.swing.text.ViewFactory f)
      • insertUpdate

        public void insertUpdate​(javax.swing.event.DocumentEvent e,
                                 java.awt.Shape a,
                                 javax.swing.text.ViewFactory f)
        Overrides:
        insertUpdate in class javax.swing.text.View
      • removeUpdate

        public void removeUpdate​(javax.swing.event.DocumentEvent e,
                                 java.awt.Shape a,
                                 javax.swing.text.ViewFactory f)
        Overrides:
        removeUpdate in class javax.swing.text.View