Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

oracle.javatools.editor
Class BasicView

java.lang.Object
  extended by javax.swing.text.View
      extended by oracle.javatools.editor.BasicView
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, javax.swing.SwingConstants

public class BasicView
extends javax.swing.text.View
implements java.beans.PropertyChangeListener

A BasicView is an implementation of the View interface, for rendering the BasicDocumentElement used by the BasicDocument.


Field Summary
 
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
BasicView(javax.swing.text.Element elem)
          Create a new BasicView based on the given Element.
 
Method Summary
 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  void 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.
 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.
 
Methods inherited from class javax.swing.text.View
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicView

public BasicView(javax.swing.text.Element elem)
Create a new BasicView based on the given Element. It is assumed currently that the element passed in is the root/leaf element of RootElement.

Method Detail

paint

public void paint(java.awt.Graphics graphics,
                  java.awt.Shape viewShape)
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 class javax.swing.text.View
Parameters:
graphics - the rendering surface to use
viewShape - the allocated region to render into
See Also:
View.paint(java.awt.Graphics, java.awt.Shape)

paintUnderlines

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.

Parameters:
graphics - the graphics context
clipRect - the rectangle of the clipped area that should be painted
styledList - the styled fragments list
startRow - the starting row (inclusive)
endRow - the ending row (exclusive)

paintLineUnderlines

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).

Parameters:
graphics - the graphics context
clipRect - the rectangle of the clipped area that should be painted
startOffset - the start offset of the starting line (inclusive)
endOffset - the end offset of the ending line (exclusive)

paintRangeUnderlines

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).

Parameters:
graphics - the graphics context
clipRect - the rectangle of the clipped area that should be painted
styledList - the styled fragments list
fontHighlightList - the font attribute highlight fragments
startOffset - the start offset of the starting line (inclusive)
endOffset - the end offset of the ending line (exclusive)

paintUnderlineSegment

protected void 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.

Parameters:
graphics - the graphics context
clipRect - the rectangle of the clipped area that should be painted
styledList - the styled fragments list
fontHighlightList - the font attribute highlight fragments
underlineFragment - 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)

paintRightMargin

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.

Parameters:
graphics - the graphics context
clipRect - the rectangle of the clipped area that should be painted

paintRow

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. Note that a given StyledFragment may span more than one line.

Parameters:
graphics - the graphics context
clipRect - the rectangle of the clipped area that should be painted
row - the row to paint

paintSegment

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. Use the RenderFragment provided to get the text and highlight styles to perform the paint.

Parameters:
graphics - the graphics context
clipRect - the rectangle of the clipped area that should be painted
renderFragment - the render fragment we are painting
startOffset - the starting offset of this segment of text
endOffset - the ending offset of this segment of text
x - the x position to start painting the text at
y - the y position to paint the text at
Returns:
the x position for the next paint (on the same line) to start at

modelToView

public java.awt.Shape modelToView(int offset,
                                  java.awt.Shape viewShape,
                                  javax.swing.text.Position.Bias bias)
                           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 class javax.swing.text.View
Parameters:
offset - the position to convert >= 0
viewShape - the allocated region to render into
bias - the bias toward the previous character or the next character represented by the offset, in case the position is a boundary of two views.
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
java.lang.IllegalArgumentException - for an invalid bias argument
See Also:
View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])

modelToView

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
Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

Overrides:
modelToView in class javax.swing.text.View
Parameters:
startOffset - the starting offset of the region to model
startBias - the bias of the starting offset
endOffset - the ending offset of the region to model
endBias - the bias of the ending offset
viewShape - the allocated region to render into
Returns:
the bounding box of the region specified
Throws:
javax.swing.text.BadLocationException - if the given position does not represent a valid location in the associated document
java.lang.IllegalArgumentException - for an invalid bias argument
See Also:
View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])

viewToModel

public 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. The biasReturn argument will be filled in to indicate that the point given is closer to the next character in the model or the previous character in the model.

Specified by:
viewToModel in class javax.swing.text.View
Parameters:
fx - the X coordinate >= 0
fy - the Y coordinate >= 0
viewShape - the allocated region to render into
biasReturn - the bias for the offset
Returns:
the location within the model that best represents the given point in the view >= 0. The biasReturn argument will be * filled in to indicate that the point given is closer to the next * character in the model or the previous character in the model.

updateDamage

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.


insertUpdate

public 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.

Overrides:
insertUpdate in class javax.swing.text.View
Parameters:
e - the change information from the associated document
a - the current allocation of the view
f - the factory to use to rebuild if the view has children
See Also:
View.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)

removeUpdate

public 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.

Overrides:
removeUpdate in class javax.swing.text.View
Parameters:
e - the change information from the associated document
a - the current allocation of the view
f - the factory to use to rebuild if the view has children
See Also:
View.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)

changedUpdate

public 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.

Overrides:
changedUpdate in class javax.swing.text.View
Parameters:
e - the change information from the associated document
a - the current allocation of the view
f - the factory to use to rebuild if the view has children
See Also:
View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)

getPreferredSpan

public float getPreferredSpan(int axis)
Calculate the span of this view based on the size of the underlying document (number of lines, widest line.)

Specified by:
getPreferredSpan in class javax.swing.text.View
Parameters:
axis - the axis to calculate
Returns:
the preferred span (size) across the given axis

getMinimumSpan

public float getMinimumSpan(int axis)
Determine the minimum span for this view along the given axis. This view is not resizable (i.e., it does not re-flow text based on the size of the text.) Just return preferred size.

Overrides:
getMinimumSpan in class javax.swing.text.View
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the minimum span the view can be rendered into.

getMaximumSpan

public float getMaximumSpan(int axis)
Determines the maximum span for this view along an axis. This view is not resizable, so just return the preferred size.

Overrides:
getMaximumSpan in class javax.swing.text.View
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the maximum span the view can be rendered into.

getBreakWeight

public int getBreakWeight(int axis,
                          float pos,
                          float len)
Determines how attractive a break opportunity in this view is. This view does not support breaking behavior.

Overrides:
getBreakWeight in class javax.swing.text.View
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
pos - 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.
Returns:
the weight, which should be a value between ForcedBreakWeight and BadBreakWeight.

getRowForLine

public int getRowForLine(int line)
Return the row that the given line appears on. Folded blocks mean that many lines can map to one row.

Parameters:
line -
Returns:
the row of the editor on where the line is represented

getLineForRow

public int getLineForRow(int row)
Return the first line that appears on the given row. Code folding means that many lines can map to a single row.

Parameters:
row -
Returns:
the first line that is represented on the given row

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
This method gets called when a bound property is changed.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
event - A PropertyChangeEvent object describing the event source and the property that has changed.

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

Copyright © 1997, 2009, Oracle. All rights reserved.