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

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

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

org.netbeans.lib.editor.view
Class ViewUtilitiesImpl

java.lang.Object
  extended by org.netbeans.lib.editor.view.ViewUtilitiesImpl

public class ViewUtilitiesImpl
extends Object

Various utility methods related to views.


Method Summary
static String axisToString(int axis)
           
static void checkViewHierarchy(View v)
           
static int findLowerViewIndex(View view, int offset, boolean lowerAdjacent)
          The semantics is the same like findViewIndex() but if there are any empty views at the offset (e.g.
static int findUpperViewIndex(View view, int offset, boolean excludeAtOffset)
          The semantics is the same like findViewIndex() but if there are any empty views at the offset (e.g.
static int findViewIndex(View view, int offset)
          Find the child view index that best represents the given offset.
static int findViewIndexBounded(View view, int offset)
          Find child index representing the given offset or -1 if the offset is not represented by any child view i.e.
static Rectangle maybeNew(Rectangle r, int x, int y, int width, int height)
          Return existing rectangle or create new one.
static Rectangle maybeNew(Rectangle origRect, Rectangle testRect)
          Return existing rectangle or create new one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findViewIndexBounded

public static int findViewIndexBounded(View view,
                                       int offset)
Find child index representing the given offset or -1 if the offset is not represented by any child view i.e. it is outside of the bounds of this view or when the given view does not have any children.

Parameters:
view - view having children to be inspected.
offset - the position >= 0.
Returns:
index of the child view representing the given position or -1 if offset < view.getStartOffset() || offset >= view.getEndOffset() || getViewCount() == 0 .

findViewIndex

public static int findViewIndex(View view,
                                int offset)
Find the child view index that best represents the given offset.
Algorithm uses binary search.
The semantics is similar to javax.swing.text.Element.getElementIndex(int) semantics.

Parameters:
view - view having children to be inspected.
offset - the position >= 0
Returns:
index of the child view representing the given position.
0 if offset < getView(0).getStartOffset().
getViewCount() - 1 if offset >= getView(viewCount - 1).getEndOffset() .
-1 if getViewCount() == 0.

findLowerViewIndex

public static int findLowerViewIndex(View view,
                                     int offset,
                                     boolean lowerAdjacent)
The semantics is the same like findViewIndex() but if there are any empty views at the offset (e.g. because of removal) then they are skipped and the first empty view is returned.

Parameters:
view - view having children to be inspected.
offset - the position >= 0
lowerAdjacent - if set to true and the returned child view would start right at offset then return the non-empty left adjacent view (which ends at the offset). This may be useful e.g. in case of removal when the view was affected by removal (view's end was removed) but now after removal it seems that it naturally ends at offset.
Returns:
index of the child view representing the given offset.

findUpperViewIndex

public static int findUpperViewIndex(View view,
                                     int offset,
                                     boolean excludeAtOffset)
The semantics is the same like findViewIndex() but if there are any empty views at the offset (e.g. because of removal) then they are skipped and the first non-empty view starting at the offset is returned.

Parameters:
view - view having children to be inspected.
offset - the position >= 0
excludeAtOffset - if set to true and the returned non-empty child view would start right at offset then return the left adjacent view (which ends at the offset). This may be useful e.g. in case of insertion to not replace a view that starts right at the offset and was not in fact affected by insertion.
Returns:
index of the child view representing the given offset.

maybeNew

public static Rectangle maybeNew(Rectangle r,
                                 int x,
                                 int y,
                                 int width,
                                 int height)
Return existing rectangle or create new one.

Parameters:
r - rectangle which is checked to correspond to next parameters.
x - x coordinate of returned rectangle.
y - y coordinate of returned rectangle.
width - width of returned rectangle.
height - height of returned rectangle.
Returns:
rectangle r passed to this method in case it corresponds to all the other parameters. Newly created rectangle instance otherwise.

maybeNew

public static Rectangle maybeNew(Rectangle origRect,
                                 Rectangle testRect)
Return existing rectangle or create new one.

Parameters:
origRect - rectangle which is checked to correspond to tested rect.
testRect - rectangle being tested for equality to origRect.
Returns:
rectangle origRect passed to this method in case it corresponds to testRect. Newly created rectangle instance (being equal to testRect) otherwise.

axisToString

public static String axisToString(int axis)

checkViewHierarchy

public static void checkViewHierarchy(View v)

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.