站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

BaseView (Editor Library) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.lib/1 1.14.0 3

org.netbeans.editor
Class BaseView

java.lang.Object
  extended by javax.swing.text.View
      extended by org.netbeans.editor.BaseView
All Implemented Interfaces:
SwingConstants
Direct Known Subclasses:
LeafView

public abstract class BaseView
extends View

Base abstract view serves as parent for both leaf and branch views.


Field Summary
protected  int helperInd
          Index of this view as child view in its parent.
protected  Insets insets
          Border insets of this view.
protected static int INSETS_BOTTOM
          Bottom insets paint type.
protected static int INSETS_TOP
          Top insets paint type.
protected static int MAIN_AREA
          Main area paint type.
protected  boolean packed
          Is this view packed
 
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
BaseView(Element elem)
          Construct new base view
 
Method Summary
 void displayHierarchy()
          Display view hierarchy on console.
 float getAlignment(int axis)
          Get aligment along an X_AXIS or Y_AXIS
protected abstract  int getBaseX(int y)
           
 JTextComponent getComponent()
          Get component hosting this view.
protected  EditorUI getEditorUI()
          Get editor UI
abstract  int getHeight()
          Get height of the view
 Insets getInsets()
          Get insets of this view.
protected abstract  int getPaintAreas(Graphics g, int clipY, int clipHeight)
          Returns binary composition of regions that should be painted.
protected abstract  int getPosFromY(int y)
          Get position when knowing y-coord
 float getPreferredSpan(int axis)
          Get preferred span over axis
protected  int getStartY()
          Get y base value for this view.
protected abstract  int getViewStartY(BaseView view, int helperInd)
          Get child view's y base value.
protected abstract  int getYFromPos(int pos)
          Get y-coord value from position
protected  void invalidateStartY()
          Informs the view that if it had cached start y of itself it should invalidate it as it is no longer valid and it should call getViewStartY() to get updated value.
 boolean isPacked()
          Getter for packed flag
abstract  void modelToViewDG(int pos, org.netbeans.editor.DrawGraphics dg)
           
 void paint(Graphics g, Shape allocation)
          It divides painting into three areas: INSETS_TOP, MAIN_AREA, INSETS_BOTTOM.
protected abstract  void paintAreas(Graphics g, int clipY, int clipHeight, int paintAreas)
          Paint either top insets, main area, or bottom insets.
protected  void setHelperInd(int ind)
          This function is used to correct information about which index this child view occupies in parent view's array of children.
 void setPacked(boolean packed)
          Setter for packed flag
 String toString()
           
abstract  void updateMainHeight()
          Update height of main area as result of some important change.
 
Methods inherited from class javax.swing.text.View
append, breakView, changedUpdate, createFragment, forwardUpdate, forwardUpdateToView, getAttributes, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getNextVisualPositionFrom, getParent, getResizeWeight, getStartOffset, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, insertUpdate, isVisible, modelToView, modelToView, modelToView, preferenceChanged, remove, removeAll, removeUpdate, replace, setParent, setSize, updateChildren, updateLayout, viewToModel, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INSETS_TOP

protected static final int INSETS_TOP
Top insets paint type.

See Also:
Constant Field Values

MAIN_AREA

protected static final int MAIN_AREA
Main area paint type.

See Also:
Constant Field Values

INSETS_BOTTOM

protected static final int INSETS_BOTTOM
Bottom insets paint type.

See Also:
Constant Field Values

packed

protected boolean packed
Is this view packed


helperInd

protected int helperInd
Index of this view as child view in its parent. This gives the parent view a hint at which index it should search for this view. If this index is incorrect, the parent view searches the whole array of children. However this gives good optimization of child views search process.


insets

protected Insets insets
Border insets of this view. Can be null

Constructor Detail

BaseView

public BaseView(Element elem)
Construct new base view

Method Detail

isPacked

public boolean isPacked()
Getter for packed flag


setPacked

public void setPacked(boolean packed)
Setter for packed flag


getAlignment

public float getAlignment(int axis)
Get aligment along an X_AXIS or Y_AXIS

Overrides:
getAlignment in class View

modelToViewDG

public abstract void modelToViewDG(int pos,
                                   org.netbeans.editor.DrawGraphics dg)
                            throws BadLocationException
Throws:
BadLocationException

getYFromPos

protected abstract int getYFromPos(int pos)
                            throws BadLocationException
Get y-coord value from position

Throws:
BadLocationException

getPosFromY

protected abstract int getPosFromY(int y)
Get position when knowing y-coord


getBaseX

protected abstract int getBaseX(int y)

getPaintAreas

protected abstract int getPaintAreas(Graphics g,
                                     int clipY,
                                     int clipHeight)
Returns binary composition of regions that should be painted. It can be binary composition of INSETS_TOP, MAIN_AREA and INSETS_BOTTOM.

Parameters:
g - Graphics to paint through
clip - clipping area of graphics object

paintAreas

protected abstract void paintAreas(Graphics g,
                                   int clipY,
                                   int clipHeight,
                                   int paintAreas)
Paint either top insets, main area, or bottom insets.

Parameters:
g - Graphics to paint through
clip - clipping area of graphics object
paintAreas - binary composition of paint areas

paint

public void paint(Graphics g,
                  Shape allocation)
It divides painting into three areas: INSETS_TOP, MAIN_AREA, INSETS_BOTTOM. It paints them sequentially using paintArea() method until it returns false. This implementation also supposes that allocation is instance of Rectangle to save object creations. The root view in TextUI implementation will take care to ensure child views will get rectangle instances.

Specified by:
paint in class View

getComponent

public JTextComponent getComponent()
Get component hosting this view.


getInsets

public Insets getInsets()
Get insets of this view.


setHelperInd

protected void setHelperInd(int ind)
This function is used to correct information about which index this child view occupies in parent view's array of children. It is called by parent view.


getViewStartY

protected abstract int getViewStartY(BaseView view,
                                     int helperInd)
Get child view's y base value. This function is called by children of this view to get its y offset.

Parameters:
view - is child view of this view for which the offset should be computed.
helperInd - is index that child view has cached to ease the parent view to search for it in its children array. If this index is correct, parent uses it. If it's incorrect parent view searches through the whole array of its children to find the child. It then calls children's setParentInd() to correct its location index.

invalidateStartY

protected void invalidateStartY()
Informs the view that if it had cached start y of itself it should invalidate it as it is no longer valid and it should call getViewStartY() to get updated value.


getStartY

protected int getStartY()
Get y base value for this view.


getHeight

public abstract int getHeight()
Get height of the view


updateMainHeight

public abstract void updateMainHeight()
Update height of main area as result of some important change. Propagate to child views if necessary.


getPreferredSpan

public float getPreferredSpan(int axis)
Get preferred span over axis

Specified by:
getPreferredSpan in class View

getEditorUI

protected EditorUI getEditorUI()
Get editor UI


displayHierarchy

public void displayHierarchy()
Display view hierarchy on console. Current view is marked with asterisk.


toString

public String toString()
Overrides:
toString in class Object

org.netbeans.modules.editor.lib/1 1.14.0 3

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.