Package org.fife.ui.rsyntaxtextarea
Class WrappedSyntaxView.WrappedLine
- java.lang.Object
-
- javax.swing.text.View
-
- org.fife.ui.rsyntaxtextarea.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
-
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
-
-
-
-
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 classjavax.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 classjavax.swing.text.View
- Parameters:
g
- the rendering surface to usea
- 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 classjavax.swing.text.View
- Parameters:
pos
- the position to converta
- 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 classjavax.swing.text.View
- Parameters:
fx
- the X coordinatefy
- the Y coordinatea
- 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 classjavax.swing.text.View
-
removeUpdate
public void removeUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
- Overrides:
removeUpdate
in classjavax.swing.text.View
-
-