Extension SDK 10.1.2

oracle.javatools.editor
Class BasicView

java.lang.Object
  extended byjavax.swing.text.View
      extended byoracle.javatools.editor.BasicView
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener, 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.
 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.)
 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  int paintLine(java.awt.Graphics graphics, TextBuffer textBuffer, java.awt.Rectangle viewRect, java.awt.Rectangle clipRect, int line, StyledFragmentsList styledList, int styledIndex, HighlightedFragmentsList highlightedList)
          Paints the specified line of the view with the given styles and highlights.
protected  void paintRightMargin(java.awt.Graphics graphics, java.awt.Rectangle viewRect, 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  int paintSegment(java.awt.Graphics graphics, TextBuffer textBuffer, java.awt.Rectangle viewRect, java.awt.Rectangle clipRect, BaseStyle textStyle, HighlightStyle highlightStyle, 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 viewRect, java.awt.Rectangle clipRect, TextBuffer textBuffer, StyledFragmentsList styledList, int startLine, int endLine)
          Paints the underlines 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, javax.swing.text.ViewFactory factory)
          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.

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 viewRect,
                               java.awt.Rectangle clipRect,
                               TextBuffer textBuffer,
                               StyledFragmentsList styledList,
                               int startLine,
                               int endLine)
Paints the underlines in the editor view.

Parameters:
graphics - the graphics context
viewRect - the rectangle of the view area (for insets/margins)
clipRect - the rectangle of the clipped area that should be painted
textBuffer - the text buffer
styledList - the styled fragments list
startLine - the starting line (inclusive)
endLine - the ending line (exclusive)

paintRightMargin

protected void paintRightMargin(java.awt.Graphics graphics,
                                java.awt.Rectangle viewRect,
                                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
viewRect - the rectangle of the view area (for insets/margins)
clipRect - the rectangle of the clipped area that should be painted

paintLine

protected int paintLine(java.awt.Graphics graphics,
                        TextBuffer textBuffer,
                        java.awt.Rectangle viewRect,
                        java.awt.Rectangle clipRect,
                        int line,
                        StyledFragmentsList styledList,
                        int styledIndex,
                        HighlightedFragmentsList highlightedList)
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
textBuffer - the data we are painting
viewRect - the rectangle of the view area (for insets/margins)
clipRect - the rectangle of the clipped area that should be painted
line - the line to paint
styledList - the list of Styled Fragments
styledIndex - the styled fragment to start from
highlightedList - the list of Highlighted Fragments
Returns:
the index of the next styled fragment for starting the next line

paintSegment

protected int paintSegment(java.awt.Graphics graphics,
                           TextBuffer textBuffer,
                           java.awt.Rectangle viewRect,
                           java.awt.Rectangle clipRect,
                           BaseStyle textStyle,
                           HighlightStyle highlightStyle,
                           int startOffset,
                           int endOffset,
                           int x,
                           int y)
Paints a small segment text indicated by the start and end offsets. Use the text and highlight styles provided to perform the paint.

Parameters:
graphics - the graphics context
textBuffer - the text buffer with our data
viewRect - the rectangle of the main view (for editor insets)
clipRect - the rectangle of the clipped area that should be painted
textStyle - the text style to paint this segment with
highlightStyle - the overriding highlight style to paint with
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.

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)

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.

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)

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.

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,
                            javax.swing.text.ViewFactory factory)
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.

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.

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.

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

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.

Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS

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.

Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS

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.

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.

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.

Extension SDK

 

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