Package org.jdesktop.swingx
Class JXLabel.Renderer
- java.lang.Object
-
- javax.swing.text.View
-
- javax.swing.text.CompositeView
-
- javax.swing.text.BoxView
-
- javax.swing.text.WrappedPlainView
-
- org.jdesktop.swingx.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
-
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
-
-
-
-
Field Detail
-
host
JXLabel host
-
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 classjavax.swing.text.View
-
preferenceChanged
public void preferenceChanged(javax.swing.text.View child, boolean width, boolean height)
- Overrides:
preferenceChanged
in classjavax.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 classjavax.swing.text.View
-
paint
public void paint(java.awt.Graphics g, java.awt.Shape allocation)
Renders the view.- Overrides:
paint
in classjavax.swing.text.WrappedPlainView
- Parameters:
g
- the graphics contextallocation
- the region to render into
-
setParent
public void setParent(javax.swing.text.View parent)
Sets the view parent.- Overrides:
setParent
in classjavax.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 classjavax.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 classjavax.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 classjavax.swing.text.View
- Returns:
- the model
-
setSize
public void setSize(float width, float height)
Sets the view size.- Overrides:
setSize
in classjavax.swing.text.WrappedPlainView
- Parameters:
width
- the widthheight
- the height
-
getPreferredSpan
public float getPreferredSpan(int axis)
- Overrides:
getPreferredSpan
in classjavax.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 classjavax.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 classjavax.swing.text.View
- Returns:
- the factory
-
getWidth
public int getWidth()
- Overrides:
getWidth
in classjavax.swing.text.BoxView
-
getHeight
public int getHeight()
- Overrides:
getHeight
in classjavax.swing.text.BoxView
-
-