public final class BasicView
extends javax.swing.text.View
implements java.beans.PropertyChangeListener
BasicView
is an implementation of the View
interface, for rendering the BasicDocumentElement
used by the
BasicDocument
.Constructor and Description |
---|
BasicView(javax.swing.text.Element elem)
Create a new BasicView based on the given Element.
|
Modifier and Type | Method and Description |
---|---|
void |
changedUpdate(javax.swing.event.DocumentEvent e,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
Gives notification from the document that attributes were changed
in a location that this view is responsible for.
|
int |
getBreakWeight(int axis,
float pos,
float len)
Determines how attractive a break opportunity in this view is.
|
int |
getLineForRow(int row)
Return the first line that appears on the given row.
|
float |
getMaximumSpan(int axis)
Determines the maximum span for this view along an
axis.
|
float |
getMinimumSpan(int axis)
Determine the minimum span for this view along the given axis.
|
float |
getPreferredSpan(int axis)
Calculate the span of this view based on the size of the underlying
document (number of lines, widest line.)
|
int |
getRowForLine(int line)
Return the row that the given line appears on.
|
void |
insertUpdate(javax.swing.event.DocumentEvent e,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
Gives notification that something was inserted into the document
in a location that this view is responsible for.
|
java.awt.Shape |
modelToView(int startOffset,
javax.swing.text.Position.Bias startBias,
int endOffset,
javax.swing.text.Position.Bias endBias,
java.awt.Shape viewShape)
Provides a mapping from the document model coordinate space to
the coordinate space of the view mapped to it.
|
java.awt.Shape |
modelToView(int offset,
java.awt.Shape viewShape,
javax.swing.text.Position.Bias bias)
Provides a mapping from the document model coordinate space
to the coordinate space of the view mapped to it.
|
void |
paint(java.awt.Graphics graphics,
java.awt.Shape viewShape)
Renders using the given rendering surface and area on that
surface.
|
protected void |
paintLineUnderlines(java.awt.Graphics graphics,
java.awt.Rectangle clipRect,
int startOffset,
int endOffset)
Paints the underline highlights in the editor view that are line-based
(where HighlightedText.isLineHighlight() returns true).
|
protected void |
paintRangeUnderlines(java.awt.Graphics graphics,
java.awt.Rectangle clipRect,
StyledFragmentsList styledList,
HighlightFragmentsList fontHighlightList,
int startOffset,
int endOffset)
Paints the underline highlights in the editor view that are range-based
(where HighlightedText.isLineHighlight() returns false).
|
protected void |
paintRightMargin(java.awt.Graphics graphics,
java.awt.Rectangle clipRect)
Paints the right margin line - this will check the current properties
to see whether, where, and what color to paint the right margin.
|
protected void |
paintRow(java.awt.Graphics graphics,
java.awt.Rectangle clipRect,
int row,
oracle.javatools.editor.BasicView.RenderFragmentGenerator generator,
HighlightStyle sentinelStyle)
Paints the specified line of the view with the given styles and
highlights.
|
protected int |
paintSegment(java.awt.Graphics graphics,
java.awt.Rectangle clipRect,
oracle.javatools.editor.BasicView.RenderFragment renderFragment,
int startOffset,
int endOffset,
int x,
int y)
Paints a small segment text indicated by the start and end offsets.
|
protected void |
paintUnderlines(java.awt.Graphics graphics,
java.awt.Rectangle clipRect,
StyledFragmentsList styledList,
int startRow,
int endRow)
Paints the underline highlights in the editor view.
|
protected oracle.javatools.editor.BasicView.PaintResult |
paintUnderlineSegment(java.awt.Graphics graphics,
java.awt.Rectangle clipRect,
StyledFragmentsList styledList,
HighlightFragmentsList fontHighlightList,
HighlightFragment underlineFragment,
int startOffset,
int endOffset)
Paints a single range-based underline fragment in the editor view.
|
protected oracle.javatools.editor.BasicView.PaintResult |
paintUnderlineSegment(java.awt.Graphics graphics,
java.awt.Rectangle clipRect,
StyledFragmentsList styledList,
HighlightFragmentsList fontHighlightList,
HighlightFragmentsList underlineHighlightList,
int underlineFragmentIndex,
int startOffset,
int endOffset)
Paints a single range-based underline fragment in the editor view.
|
void |
propertyChange(java.beans.PropertyChangeEvent event)
This method gets called when a bound property is changed.
|
void |
removeUpdate(javax.swing.event.DocumentEvent e,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
Gives notification from the document that attributes were removed
in a location that this view is responsible for.
|
protected void |
updateDamage(javax.swing.event.DocumentEvent changes,
java.awt.Shape viewShape)
Figures out what part of the view needs to be repainted based on
the given change.
|
int |
viewToModel(float fx,
float fy,
java.awt.Shape viewShape,
javax.swing.text.Position.Bias[] biasReturn)
Provides a mapping from the view coordinate space to the logical
coordinate space of the model.
|
append, breakView, createFragment, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getGraphics, getNextVisualPositionFrom, getParent, getResizeWeight, getStartOffset, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, isVisible, modelToView, preferenceChanged, remove, removeAll, replace, setParent, setSize, updateChildren, updateLayout, viewToModel
public BasicView(javax.swing.text.Element elem)
public void paint(java.awt.Graphics graphics, java.awt.Shape viewShape)
paint
in class javax.swing.text.View
graphics
- the rendering surface to useviewShape
- the allocated region to render intoView.paint(java.awt.Graphics, java.awt.Shape)
protected void paintUnderlines(java.awt.Graphics graphics, java.awt.Rectangle clipRect, StyledFragmentsList styledList, int startRow, int endRow)
graphics
- the graphics contextclipRect
- the rectangle of the clipped area that should be paintedstyledList
- the styled fragments liststartRow
- the starting row (inclusive)endRow
- the ending row (exclusive)protected void paintLineUnderlines(java.awt.Graphics graphics, java.awt.Rectangle clipRect, int startOffset, int endOffset)
graphics
- the graphics contextclipRect
- the rectangle of the clipped area that should be paintedstartOffset
- the start offset of the starting line (inclusive)endOffset
- the end offset of the ending line (exclusive)protected void paintRangeUnderlines(java.awt.Graphics graphics, java.awt.Rectangle clipRect, StyledFragmentsList styledList, HighlightFragmentsList fontHighlightList, int startOffset, int endOffset)
graphics
- the graphics contextclipRect
- the rectangle of the clipped area that should be paintedstyledList
- the styled fragments listfontHighlightList
- the font attribute highlight fragmentsstartOffset
- the start offset of the starting line (inclusive)endOffset
- the end offset of the ending line (exclusive)protected oracle.javatools.editor.BasicView.PaintResult paintUnderlineSegment(java.awt.Graphics graphics, java.awt.Rectangle clipRect, StyledFragmentsList styledList, HighlightFragmentsList fontHighlightList, HighlightFragmentsList underlineHighlightList, int underlineFragmentIndex, int startOffset, int endOffset)
graphics
- the graphics contextclipRect
- the rectangle of the clipped area that should be paintedstyledList
- the styled fragments listfontHighlightList
- the font attribute list that we are painting.underlineHighlightList
- the underline attribute list that we are painting.underlineFragmentIndex
- the index of the underline fragment that we are painting.startOffset
- the start offset of the starting line (inclusive)endOffset
- the end offset of the ending line (exclusive)protected oracle.javatools.editor.BasicView.PaintResult paintUnderlineSegment(java.awt.Graphics graphics, java.awt.Rectangle clipRect, StyledFragmentsList styledList, HighlightFragmentsList fontHighlightList, HighlightFragment underlineFragment, int startOffset, int endOffset)
graphics
- the graphics contextclipRect
- the rectangle of the clipped area that should be paintedstyledList
- the styled fragments listfontHighlightList
- the font attribute highlight fragmentsunderlineFragment
- the underline fragment that we are painting.startOffset
- the start offset of the starting line (inclusive)endOffset
- the end offset of the ending line (exclusive)protected void paintRightMargin(java.awt.Graphics graphics, java.awt.Rectangle clipRect)
graphics
- the graphics contextclipRect
- the rectangle of the clipped area that should be paintedprotected void paintRow(java.awt.Graphics graphics, java.awt.Rectangle clipRect, int row, oracle.javatools.editor.BasicView.RenderFragmentGenerator generator, HighlightStyle sentinelStyle)
graphics
- the graphics contextclipRect
- the rectangle of the clipped area that should be paintedrow
- the row to paintprotected int paintSegment(java.awt.Graphics graphics, java.awt.Rectangle clipRect, oracle.javatools.editor.BasicView.RenderFragment renderFragment, int startOffset, int endOffset, int x, int y)
graphics
- the graphics contextclipRect
- the rectangle of the clipped area that should be paintedrenderFragment
- the render fragment we are paintingstartOffset
- the starting offset of this segment of textendOffset
- the ending offset of this segment of textx
- the x position to start painting the text aty
- the y position to paint the text atpublic java.awt.Shape modelToView(int offset, java.awt.Shape viewShape, javax.swing.text.Position.Bias bias) throws javax.swing.text.BadLocationException
modelToView
in class javax.swing.text.View
offset
- the position to convert >= 0viewShape
- the allocated region to render intobias
- the bias toward the previous character or the next
character represented by the offset, in case the
position is a boundary of two views.javax.swing.text.BadLocationException
- if the given position does
not represent a valid location in the associated documentjava.lang.IllegalArgumentException
- for an invalid bias argumentView.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
public java.awt.Shape modelToView(int startOffset, javax.swing.text.Position.Bias startBias, int endOffset, javax.swing.text.Position.Bias endBias, java.awt.Shape viewShape) throws javax.swing.text.BadLocationException
modelToView
in class javax.swing.text.View
startOffset
- the starting offset of the region to modelstartBias
- the bias of the starting offsetendOffset
- the ending offset of the region to modelendBias
- the bias of the ending offsetviewShape
- the allocated region to render intojavax.swing.text.BadLocationException
- if the given position does not
represent a valid location in the associated documentjava.lang.IllegalArgumentException
- for an invalid bias argumentView.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
public int viewToModel(float fx, float fy, java.awt.Shape viewShape, javax.swing.text.Position.Bias[] biasReturn)
viewToModel
in class javax.swing.text.View
fx
- the X coordinate >= 0fy
- the Y coordinate >= 0viewShape
- the allocated region to render intobiasReturn
- the bias for the offsetprotected void updateDamage(javax.swing.event.DocumentEvent changes, java.awt.Shape viewShape)
public void insertUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
insertUpdate
in class javax.swing.text.View
e
- the change information from the associated documenta
- the current allocation of the viewf
- the factory to use to rebuild if the view has childrenView.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public void removeUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
removeUpdate
in class javax.swing.text.View
e
- the change information from the associated documenta
- the current allocation of the viewf
- the factory to use to rebuild if the view has childrenView.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public void changedUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
changedUpdate
in class javax.swing.text.View
e
- the change information from the associated documenta
- the current allocation of the viewf
- the factory to use to rebuild if the view has childrenView.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public float getPreferredSpan(int axis)
getPreferredSpan
in class javax.swing.text.View
axis
- the axis to calculatepublic float getMinimumSpan(int axis)
getMinimumSpan
in class javax.swing.text.View
axis
- may be either View.X_AXIS or View.Y_AXISpublic float getMaximumSpan(int axis)
getMaximumSpan
in class javax.swing.text.View
axis
- may be either View.X_AXIS or View.Y_AXISpublic int getBreakWeight(int axis, float pos, float len)
getBreakWeight
in class javax.swing.text.View
axis
- may be either View.X_AXIS or View.Y_AXISpos
- the potential location of the start of the
broken view >= 0. This may be useful for calculating tab
positions.len
- specifies the relative length from pos
where a potential break is desired >= 0.public int getRowForLine(int line)
line
- public int getLineForRow(int row)
row
- public void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange
in interface java.beans.PropertyChangeListener
event
- A PropertyChangeEvent object describing the event source
and the property that has changed.