Class JXLabel.Renderer

  • All Implemented Interfaces:
    javax.swing.SwingConstants, javax.swing.text.TabExpander
    Enclosing class:
    JXLabel

    static class JXLabel.Renderer
    extends javax.swing.text.WrappedPlainView
    Root text view that acts as an renderer.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javax.swing.text.ViewFactory factory  
      private float height  
      (package private) JXLabel host  
      (package private) boolean invalidated  
      private javax.swing.text.View view  
      private float width  
      • 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
      Renderer​(JXLabel c, javax.swing.text.ViewFactory f, javax.swing.text.View v, boolean wordWrap)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.swing.text.AttributeSet getAttributes()
      Fetches the attributes to use when rendering.
      java.awt.Container getContainer()
      Fetches the container hosting the view.
      javax.swing.text.Document getDocument()
      Returns the document model underlying the view.
      int getHeight()  
      float getPreferredSpan​(int axis)  
      javax.swing.text.View getView​(int n)
      Gets the n-th view in this container.
      int getViewCount()
      Returns the number of views in this view.
      javax.swing.text.ViewFactory getViewFactory()
      Fetches the factory to be used for building the various view fragments that make up the view that represents the model.
      int getWidth()  
      void paint​(java.awt.Graphics g, java.awt.Shape allocation)
      Renders the view.
      void preferenceChanged​(javax.swing.text.View child, boolean width, boolean height)  
      void setParent​(javax.swing.text.View parent)
      Sets the view parent.
      void setSize​(float width, float height)
      Sets the view size.
      protected void updateLayout​(javax.swing.event.DocumentEvent.ElementChange ec, javax.swing.event.DocumentEvent e, java.awt.Shape a)  
      • Methods inherited from class javax.swing.text.WrappedPlainView

        calculateBreakPosition, changedUpdate, drawLine, drawLine, drawSelectedText, drawSelectedText, drawUnselectedText, drawUnselectedText, getLineBuffer, getMaximumSpan, getMinimumSpan, getTabSize, insertUpdate, loadChildren, nextTabStop, removeUpdate
      • Methods inherited from class javax.swing.text.BoxView

        baselineLayout, baselineRequirements, calculateMajorAxisRequirements, calculateMinorAxisRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAlignment, getAxis, getChildAllocation, getOffset, getResizeWeight, getSpan, getViewAtPoint, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, layoutMajorAxis, layoutMinorAxis, modelToView, paintChild, replace, setAxis, viewToModel
      • Methods inherited from class javax.swing.text.CompositeView

        getBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getViewAtPosition, getViewIndex, getViewIndexAtPosition, modelToView, setInsets, setParagraphInsets
      • Methods inherited from class javax.swing.text.View

        append, breakView, createFragment, forwardUpdateToView, getBreakWeight, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewIndex, insert, isVisible, modelToView, remove, removeAll, updateChildren, viewToModel
      • Methods inherited from class java.lang.Object

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

      • invalidated

        boolean invalidated
      • width

        private float width
      • height

        private float height
      • view

        private javax.swing.text.View view
      • factory

        private javax.swing.text.ViewFactory factory
    • Constructor Detail

      • Renderer

        Renderer​(JXLabel c,
                 javax.swing.text.ViewFactory f,
                 javax.swing.text.View v,
                 boolean wordWrap)
    • Method Detail

      • updateLayout

        protected void updateLayout​(javax.swing.event.DocumentEvent.ElementChange ec,
                                    javax.swing.event.DocumentEvent e,
                                    java.awt.Shape a)
        Overrides:
        updateLayout in class javax.swing.text.View
      • preferenceChanged

        public void preferenceChanged​(javax.swing.text.View child,
                                      boolean width,
                                      boolean height)
        Overrides:
        preferenceChanged in class javax.swing.text.BoxView
      • getAttributes

        public javax.swing.text.AttributeSet getAttributes()
        Fetches the attributes to use when rendering. At the root level there are no attributes. If an attribute is resolved up the view hierarchy this is the end of the line.
        Overrides:
        getAttributes in class javax.swing.text.View
      • paint

        public void paint​(java.awt.Graphics g,
                          java.awt.Shape allocation)
        Renders the view.
        Overrides:
        paint in class javax.swing.text.WrappedPlainView
        Parameters:
        g - the graphics context
        allocation - the region to render into
      • setParent

        public void setParent​(javax.swing.text.View parent)
        Sets the view parent.
        Overrides:
        setParent in class javax.swing.text.CompositeView
        Parameters:
        parent - the parent view
      • getViewCount

        public int getViewCount()
        Returns the number of views in this view. Since this view simply wraps the root of the view hierarchy it has exactly one child.
        Overrides:
        getViewCount in class javax.swing.text.CompositeView
        Returns:
        the number of views
        See Also:
        getView(int)
      • getView

        public javax.swing.text.View getView​(int n)
        Gets the n-th view in this container.
        Overrides:
        getView in class javax.swing.text.CompositeView
        Parameters:
        n - the number of the view to get
        Returns:
        the view
      • getDocument

        public javax.swing.text.Document getDocument()
        Returns the document model underlying the view.
        Overrides:
        getDocument in class javax.swing.text.View
        Returns:
        the model
      • setSize

        public void setSize​(float width,
                            float height)
        Sets the view size.
        Overrides:
        setSize in class javax.swing.text.WrappedPlainView
        Parameters:
        width - the width
        height - the height
      • getPreferredSpan

        public float getPreferredSpan​(int axis)
        Overrides:
        getPreferredSpan in class javax.swing.text.WrappedPlainView
      • getContainer

        public java.awt.Container getContainer()
        Fetches the container hosting the view. This is useful for things like scheduling a repaint, finding out the host components font, etc. The default implementation of this is to forward the query to the parent view.
        Overrides:
        getContainer in class javax.swing.text.View
        Returns:
        the container
      • getViewFactory

        public javax.swing.text.ViewFactory getViewFactory()
        Fetches the factory to be used for building the various view fragments that make up the view that represents the model. This is what determines how the model will be represented. This is implemented to fetch the factory provided by the associated EditorKit.
        Overrides:
        getViewFactory in class javax.swing.text.View
        Returns:
        the factory
      • getWidth

        public int getWidth()
        Overrides:
        getWidth in class javax.swing.text.BoxView
      • getHeight

        public int getHeight()
        Overrides:
        getHeight in class javax.swing.text.BoxView