The view supports breaking for the purpose of formatting. The fragments produced by breaking share the view that has primary responsibility for the element (i.e. they are nested classes and carry only a small amount of state of their own) so they can share its resources.
Since this view
represents text that may have tabs embedded in it, it implements the
TabableView interface. Tabs will only be
expanded if this view is embedded in a container that does
tab expansion. ParagraphView is an example of a container
that does tab expansion.
| Modifier and Type | Class and Description |
|---|---|
| public abstract static class | GlyphView.
A class to perform rendering of the glyphs. |
| pack-priv static class | GlyphView.
Class to hold data needed to justify this GlyphView in a ParagraphView.Row |
| Modifier and Type | Field and Description |
|---|---|
| private int[] | breakSpots
Cached breakpoints within the view |
| pack-priv static GlyphView. | defaultPainter
The prototype painter used by default. |
| pack-priv TabExpander | expander
how to expand tabs |
| pack-priv boolean | |
| private GlyphView. | |
| pack-priv int | |
| private float | minimumSpan
Cached minimum x-span value |
| pack-priv int | |
| pack-priv GlyphView. | painter
Glyph rendering functionality. |
| private byte[] | selections
Used by paint() to store highlighted view positions |
| pack-priv boolean | |
| pack-priv int | x
location for determining tab expansion against. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public View | Returns: the fragment of the view that represents the given span, if the view can be broken. If the view doesn't support breaking behavior, the view itself is returned.may be either View.X_AXIS or View.Y_AXIS axis, int the location in the model where the
fragment should start it's representation >= 0. p0, float the position along the axis that the
broken view would occupy >= 0. This may be useful for
things like tab calculations. pos, float specifies the distance along the axis
where a potential break is desired >= 0. len)Overrides javax. Breaks this view on the given axis at the given length. |
| public void | changedUpdate(DocumentEvent
the change information from the associated document e, Shape the current allocation of the view a, ViewFactory the factory to use to rebuild if the view has children f)Overrides javax. Gives notification from the document that attributes were changed in a location that this view is responsible for. |
| protected void | |
| protected final Object | |
| public View | Returns: the view fragment, or itself if the view doesn't support breaking into fragmentsthe starting offset >= 0. This should be a value
greater or equal to the element starting offset and
less than the element ending offset. p0, int the ending offset > p0. This should be a value
less than or equal to the elements end offset and
greater than the elements starting offset. p1)Overrides javax. Creates a view that represents a portion of the element. |
| public float | Returns: the desired alignment. This should be a value between 0.0 and 1.0 inclusive, where 0 indicates alignment at the origin and 1.0 indicates alignment to the full span away from the origin. An alignment of 0.5 would be the center of the view.may be either View.X_AXIS or View.Y_AXIS axis)Overrides javax. Determines the desired alignment for this view along an axis. |
| public Color | Returns: the background color to use to render the glyphsFetch the background color to use to render the glyphs. |
| private BreakIterator | |
| private int | getBreakSpot(int p0, int p1)
Returns a location to break at in the passed in region, or BreakIterator.DONE if there isn't a good location to break at in the specified region. |
| public int | Returns: the weight, which should be a value between View.ForcedBreakWeight and View.BadBreakWeight.may be either View.X_AXIS or View.Y_AXIS axis, float the potential location of the start of the
broken view >= 0. This may be useful for calculating tab
positions. pos, float specifies the relative length from pos
where a potential break is desired >= 0. len)Overrides javax. Determines how attractive a break opportunity in this view is. |
| public int | Returns: the ending offset into the modelOverrides javax. Fetches the portion of the model that this view is responsible for. |
| public Font | Returns: the font that the glyphs should be based uponFetch the font that the glyphs should be based upon. |
| public Color | Returns: the foreground color to use to render the glyphsFetch the foreground color to use to render the glyphs. |
| public GlyphView. | Returns: the currently installed glyph painterFetch the currently installed glyph painter. |
| pack-priv GlyphView. | |
| public float | Returns: the minimum span the view can be rendered intomay be either axis)View.X_AXIS or View.Y_AXISOverrides javax. Determines the minimum span for this view along an axis. |
| public int | Returns: the location within the model that best represents the next location visual position.the position to convert pos, Position.the allocated region to render into a, int the direction from the current position that can
be thought of as the arrow keys typically found on a keyboard.
This may be SwingConstants.WEST, SwingConstants.EAST,
SwingConstants.NORTH, or SwingConstants.SOUTH. direction, Position.Overrides javax. Provides a way to determine the next visually represented model location that one might place a caret. |
| public float | Returns: the span >= 0the starting document offset >= 0 p0, int the ending document offset >= p0 p1)Implements javax. Determines the span along the same axis as tab expansion for a portion of the view. |
| public float | Returns: the span the view would like to be rendered into >= 0. 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.may be either View.X_AXIS or View.Y_AXIS axis)Implements abstract javax. Determines the preferred span for this view along an axis. |
| public int | Returns: the starting offset into the modelOverrides javax. Fetches the portion of the model that this view is responsible for. |
| public float | Returns: the desired span >= 0the position the view would be located
at for the purpose of tab expansion >= 0. x, TabExpander how to expand the tabs when encountered. e)Implements javax. Determines the desired span when using the given tab expansion implementation. |
| public TabExpander | Returns: the TabExpander to use if tabs are present in this viewFetch the TabExpander to use if tabs are present in this view. |
| public Segment | Returns: theSegment containing the textthe starting document offset >= 0 p0, int the ending document offset >= p0 p1)Fetch a reference to the text that occupies the given range. |
| private void | |
| public void | insertUpdate(DocumentEvent
the change information from the associated document e, Shape the current allocation of the view a, ViewFactory the factory to use to rebuild if the view has children f)Overrides javax. Gives notification that something was inserted into the document in a location that this view is responsible for. |
| public boolean | Returns: true if the glyphs should have a strikethrough line,
otherwise falseDetermine if the glyphs should have a strikethrough line. |
| public boolean | Returns: true if the glyphs should be rendered as superscript,
otherwise falseDetermine if the glyphs should be rendered as superscript. |
| public boolean | Returns: true if the glyphs should be rendered as subscript,
otherwise falseDetermine if the glyphs should be rendered as subscript. |
| public boolean | Returns: true if the glyphs should be underlined, otherwise
falseDetermine if the glyphs should be underlined. |
| public Shape | Returns: the bounding box of the given positionthe position to convert >= 0 pos, Shape the allocated region to render into a, Position.either bPosition.Bias.Forward
or Position.Bias.BackwardImplements abstract javax. Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. |
| public void | paint(Graphics
the rendering surface to use g, Shape the allocated region to render into a)Implements abstract javax. Renders a portion of a text style run. |
| pack-priv final void | paintTextUsingColor(Graphics g, Shape a, Color c, int p0, int p1)
Paints the specified region of text in the specified color. |
| public void | removeUpdate(DocumentEvent
the change information from the associated document e, Shape the current allocation of the view a, ViewFactory the factory to use to rebuild if the view has children f)Overrides javax. Gives notification that something was removed from the document in a location that this view is responsible for. |
| public void | setGlyphPainter(GlyphView.
the painter to use for rendering glyphs pSets the painter to use for rendering glyphs. |
| private void | |
| pack-priv void | updateAfterChange()
Overrides javax. Updates the view to reflect the changes. |
| public int | Returns: the location within the model that best represents the given point of view >= 0the X coordinate >= 0 x, float the Y coordinate >= 0 y, Shape the allocated region to render into a, Position.either biasReturnPosition.Bias.Forward
or Position.Bias.Backward is returned as the
zero-th element of this arrayImplements abstract javax. Provides a mapping from the view coordinate space to the logical coordinate space of the model. |
| breakSpots | back to summary |
|---|---|
| private int[] breakSpots Cached breakpoints within the view | |
| defaultPainter | back to summary |
|---|---|
| pack-priv static GlyphView. The prototype painter used by default. | |
| expander | back to summary |
|---|---|
| pack-priv TabExpander expander how to expand tabs | |
| impliedCR | back to summary |
|---|---|
| pack-priv boolean impliedCR | |
| justificationInfo | back to summary |
|---|---|
| private GlyphView. | |
| length | back to summary |
|---|---|
| pack-priv int length | |
| minimumSpan | back to summary |
|---|---|
| private float minimumSpan Cached minimum x-span value | |
| offset | back to summary |
|---|---|
| pack-priv int offset | |
| painter | back to summary |
|---|---|
| pack-priv GlyphView. Glyph rendering functionality. | |
| selections | back to summary |
|---|---|
| private byte[] selections Used by paint() to store highlighted view positions | |
| skipWidth | back to summary |
|---|---|
| pack-priv boolean skipWidth | |
| x | back to summary |
|---|---|
| pack-priv int x location for determining tab expansion against. | |
| GlyphView | back to summary |
|---|---|
| public GlyphView(Element elem) Constructs a new view wrapped on an element.
| |
| breakView | back to summary |
|---|---|
| public View breakView(int axis, int p0, float pos, float len) Overrides javax. Breaks this view on the given axis at the given length. This is implemented to attempt to break on a whitespace location, and returns a fragment with the whitespace at the end. If a whitespace location can't be found, the nearest character is used.
| |
| changedUpdate | back to summary |
|---|---|
| public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) Overrides javax. Gives notification from the document that attributes were changed in a location that this view is responsible for. This is implemented to call preferenceChanged along both the horizontal and vertical axis.
| |
| checkPainter | back to summary |
|---|---|
| protected void checkPainter() Check to see that a glyph painter exists. If a painter doesn't exist, a default glyph painter will be installed. | |
| clone | back to summary |
|---|---|
| protected final Object clone() Overrides java. Creates a shallow copy. This is used by the createFragment and breakView methods.
| |
| createFragment | back to summary |
|---|---|
| public View createFragment(int p0, int p1) Overrides javax. Creates a view that represents a portion of the element. This is potentially useful during formatting operations for taking measurements of fragments of the view. If the view doesn't support fragmenting (the default), it should return itself. This view does support fragmenting. It is implemented to return a nested class that shares state in this view representing only a portion of the view.
| |
| getAlignment | back to summary |
|---|---|
| public float getAlignment(int axis) Overrides javax. Determines the desired alignment for this view along an axis. For the label, the alignment is along the font baseline for the y axis, and the superclasses alignment along the x axis.
| |
| getBackground | back to summary |
|---|---|
| public Color getBackground() Fetch the background color to use to render the
glyphs. If there is no background color, null should
be returned. This is implemented to call
| |
| getBreaker | back to summary |
|---|---|
| private BreakIterator getBreaker() Return break iterator appropriate for the current document. For non-i18n documents a fast whitespace-based break iterator is used. | |
| getBreakSpot | back to summary |
|---|---|
| private int getBreakSpot(int p0, int p1) Returns a location to break at in the passed in region, or BreakIterator.DONE if there isn't a good location to break at in the specified region. | |
| getBreakWeight | back to summary |
|---|---|
| public int getBreakWeight(int axis, float pos, float len) Overrides javax. Determines how attractive a break opportunity in
this view is. This can be used for determining which
view is the most attractive to call This is implemented to forward to the superclass for the Y_AXIS. Along the X_AXIS the following values may be returned.
| |
| getEndOffset | back to summary |
|---|---|
| public int getEndOffset() Overrides javax. Fetches the portion of the model that this view is responsible for.
| |
| getFont | back to summary |
|---|---|
| public Font getFont() Fetch the font that the glyphs should be based
upon. This is implemented to call
| |
| getForeground | back to summary |
|---|---|
| public Color getForeground() Fetch the foreground color to use to render the
glyphs. If there is no foreground color, null should
be returned. This is implemented to call
| |
| getGlyphPainter | back to summary |
|---|---|
| public GlyphView. Fetch the currently installed glyph painter. If a painter has not yet been installed, and a default was not yet needed, null is returned.
| |
| getJustificationInfo | back to summary |
|---|---|
| pack-priv GlyphView. | |
| getMinimumSpan | back to summary |
|---|---|
| public float getMinimumSpan(int axis) Overrides javax. Determines the minimum span for this view along an axis. This implementation returns the longest non-breakable area within
the view as a minimum span for
| |
| getNextVisualPositionFrom | back to summary |
|---|---|
| public int getNextVisualPositionFrom(int pos, Position. Overrides javax. Provides a way to determine the next visually represented model
location that one might place a caret. Some views may not be
visible, they might not be in the same order found in the model, or
they just might not allow access to some of the locations in the
model.
This method enables specifying a position to convert
within the range of >=0. If the value is -1, a position
will be calculated automatically. If the value < -1,
the
| |
| getPartialSpan | back to summary |
|---|---|
| public float getPartialSpan(int p0, int p1) Implements javax. Determines the span along the same axis as tab expansion for a portion of the view. This is intended for use by the TabExpander for cases where the tab expansion involves aligning the portion of text that doesn't have whitespace relative to the tab stop. There is therefore an assumption that the range given does not contain tabs. This method can be called while servicing the getTabbedSpan or getPreferredSize. It has to arrange for its own text buffer to make the measurements.
| |
| getPreferredSpan | back to summary |
|---|---|
| public float getPreferredSpan(int axis) Implements abstract javax. Determines the preferred span for this view along an axis.
| |
| getStartOffset | back to summary |
|---|---|
| public int getStartOffset() Overrides javax. Fetches the portion of the model that this view is responsible for.
| |
| getTabbedSpan | back to summary |
|---|---|
| public float getTabbedSpan(float x, TabExpander e) Implements javax. Determines the desired span when using the given tab expansion implementation.
| |
| getTabExpander | back to summary |
|---|---|
| public TabExpander getTabExpander() Fetch the TabExpander to use if tabs are present in this view.
| |
| getText | back to summary |
|---|---|
| public Segment getText(int p0, int p1) Fetch a reference to the text that occupies the given range. This is normally used by the GlyphPainter to determine what characters it should render glyphs for.
| |
| initSelections | back to summary |
|---|---|
| private void initSelections(int p0, int p1) Lazily initializes the selections field | |
| insertUpdate | back to summary |
|---|---|
| public void insertUpdate(DocumentEvent e, Shape a, ViewFactory f) Overrides javax. Gives notification that something was inserted into the document in a location that this view is responsible for. This is implemented to call preferenceChanged along the axis the glyphs are rendered.
| |
| isStrikeThrough | back to summary |
|---|---|
| public boolean isStrikeThrough() Determine if the glyphs should have a strikethrough line. If
| |
| isSubscript | back to summary |
|---|---|
| public boolean isSubscript() Determine if the glyphs should be rendered as superscript.
| |
| isSuperscript | back to summary |
|---|---|
| public boolean isSuperscript() Determine if the glyphs should be rendered as subscript.
| |
| isUnderline | back to summary |
|---|---|
| public boolean isUnderline() Determine if the glyphs should be underlined. If
| |
| modelToView | back to summary |
|---|---|
| public Shape modelToView(int pos, Shape a, Position. Implements abstract javax. Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
| |
| paint | back to summary |
|---|---|
| public void paint(Graphics g, Shape a) Implements abstract javax. Renders a portion of a text style run. | |
| paintTextUsingColor | back to summary |
|---|---|
| pack-priv final void paintTextUsingColor(Graphics g, Shape a, Color c, int p0, int p1) Paints the specified region of text in the specified color. | |
| removeUpdate | back to summary |
|---|---|
| public void removeUpdate(DocumentEvent e, Shape a, ViewFactory f) Overrides javax. Gives notification that something was removed from the document in a location that this view is responsible for. This is implemented to call preferenceChanged along the axis the glyphs are rendered.
| |
| setGlyphPainter | back to summary |
|---|---|
| public void setGlyphPainter(GlyphView. Sets the painter to use for rendering glyphs.
| |
| syncCR | back to summary |
|---|---|
| private void syncCR() | |
| updateAfterChange | back to summary |
|---|---|
| pack-priv void updateAfterChange() Overrides javax. Doc from javax. Updates the view to reflect the changes.
| |
| viewToModel | back to summary |
|---|---|
| public int viewToModel(float x, float y, Shape a, Position. Implements abstract javax. Provides a mapping from the view coordinate space to the logical coordinate space of the model.
| |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public abstract float | |
| public abstract int | Returns: the maximum model location possible for a break.the view to find the model location to break at. v, int the location in the model where the
fragment should start it's representation >= 0. p0, float the graphic location along the axis that the
broken view would occupy >= 0. This may be useful for
things like tab calculations. x, float specifies the distance into the view
where a potential break is desired >= 0. len)Determines the model location that represents the maximum advance that fits within the given span. |
| public abstract float | |
| public abstract float | |
| public int | Returns: the location within the model that best represents the next location visual position.the view to use v, int the position to convert >= 0 pos, Position.either b,Position.Bias.Forward
or Position.Bias.Backwardthe allocated region to render into a, int the direction from the current position that can
be thought of as the arrow keys typically found on a keyboard.
This may be SwingConstants.WEST, SwingConstants.EAST,
SwingConstants.NORTH, or SwingConstants.SOUTH. direction, Position.either biasRetPosition.Bias.Forward
or Position.Bias.Backward
is returned as the zero-th element of this arrayProvides a way to determine the next visually represented model location that one might place a caret. |
| public GlyphView. | Returns: a painter to use for the given GlyphViewthe v, int GlyphView to provide a painter forthe starting document offset >= 0 p0, int the ending document offset >= p0 p1)Create a painter to use for the given GlyphView. |
| public abstract float | Returns: the span the glyphs given a start locationthe v, int GlyphViewthe beginning position p0, int the ending position p1, TabExpander how to expand the tabs when encountered e, float the X coordinate x)Determine the span the glyphs given a start location (for tab expansion). |
| public abstract Shape | Returns: the bounding box of the given positionthe v, int GlyphView containing the
destination coordinate spacethe position to convert pos, Position.either bias,Position.Bias.Forward
or Position.Bias.BackwardBounds of the View a)Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. |
| public abstract void | |
| public abstract int | Returns: the location within the model that best represents the given point of viewthe v, float GlyphView to provide a mapping forthe X coordinate x, float the Y coordinate y, Shape the allocated region to render into a, Position.either biasReturnPosition.Bias.Forward
or Position.Bias.Backward
is returned as the zero-th element of this arrayProvides a mapping from the view coordinate space to the logical coordinate space of the model. |
| GlyphPainter | back to summary |
|---|---|
| protected GlyphPainter() Constructor for subclasses to call. | |
| getAscent | back to summary |
|---|---|
| public abstract float getAscent(GlyphView v) Returns of the ascent.
| |
| getBoundedPosition | back to summary |
|---|---|
| public abstract int getBoundedPosition(GlyphView v, int p0, float x, float len) Determines the model location that represents the maximum advance that fits within the given span. This could be used to break the given view. The result should be a location just shy of the given advance. This differs from viewToModel which returns the closest position which might be proud of the maximum advance.
| |
| getDescent | back to summary |
|---|---|
| public abstract float getDescent(GlyphView v) Returns of the descent.
| |
| getHeight | back to summary |
|---|---|
| public abstract float getHeight(GlyphView v) Returns of the height.
| |
| getNextVisualPositionFrom | back to summary |
|---|---|
| public int getNextVisualPositionFrom(GlyphView v, int pos, Position. Provides a way to determine the next visually represented model location that one might place a caret. Some views may not be visible, they might not be in the same order found in the model, or they just might not allow access to some of the locations in the model.
| |
| getPainter | back to summary |
|---|---|
| public GlyphView. Create a painter to use for the given GlyphView. If the painter carries state it can create another painter to represent a new GlyphView that is being created. If the painter doesn't hold any significant state, it can return itself. The default behavior is to return itself.
| |
| getSpan | back to summary |
|---|---|
| public abstract float getSpan(GlyphView v, int p0, int p1, TabExpander e, float x) Determine the span the glyphs given a start location (for tab expansion).
| |
| modelToView | back to summary |
|---|---|
| public abstract Shape modelToView(GlyphView v, int pos, Position. Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. This is shared by the broken views.
| |
| paint | back to summary |
|---|---|
| public abstract void paint(GlyphView v, Graphics g, Shape a, int p0, int p1) Paint the glyphs representing the given range. | |
| viewToModel | back to summary |
|---|---|
| public abstract int viewToModel(GlyphView v, float x, float y, Shape a, Position. Provides a mapping from the view coordinate space to the logical coordinate space of the model.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final int | |
| pack-priv final int | |
| pack-priv final boolean | |
| pack-priv final int | |
| pack-priv final BitSet | |
| pack-priv final int | |
| pack-priv final int |
| Access | Constructor and Description |
|---|---|
| pack-priv | JustificationInfo(int start, int end, int leadingSpaces, int contentSpaces, int trailingSpaces, boolean hasTab, BitSet spaceMap)
|
| contentSpaces | back to summary |
|---|---|
| pack-priv final int contentSpaces | |
| end | back to summary |
|---|---|
| pack-priv final int end | |
| hasTab | back to summary |
|---|---|
| pack-priv final boolean hasTab | |
| leadingSpaces | back to summary |
|---|---|
| pack-priv final int leadingSpaces | |
| spaceMap | back to summary |
|---|---|
| pack-priv final BitSet spaceMap | |
| start | back to summary |
|---|---|
| pack-priv final int start | |
| trailingSpaces | back to summary |
|---|---|
| pack-priv final int trailingSpaces | |
| JustificationInfo | back to summary |
|---|---|
| pack-priv JustificationInfo(int start, int end, int leadingSpaces, int contentSpaces, int trailingSpaces, boolean hasTab, BitSet spaceMap) | |