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

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

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

org.netbeans.editor.view.spi
Interface FlyView


public interface FlyView

Interface marking the flyweight views.
Flyweight views are immutable view instances that can be shared in arbitrary number of occurrences.
They are typically only leaf views usually built on top of flyweight elements.

A view can be rendered differently in various rendering contexts. Rendering contexts can affect measurements done by the view. Therefore there are methods that can replicate the view into a new instance in a particular context.

Flyweight views cannot hold a reference to parent and their getParent() returns null.
A call to setParent() would throw an exception.
Their getElement() returns null.
getStartOffset() always returns 0.
getEndOffset() returns length of the text that they represent.
getContainer() always returns null.


Nested Class Summary
static interface FlyView.Parent
          Interface that views capable of maintaining flyweight views as their children must implement.
 
Method Summary
 FlyView flyInstance(View parent)
          Create an instance of the view dependent on the context given by the parent view.
 CharSequence getText()
          Get the text represented by this view.
 View regularInstance(View parent, int startOffset, int endOffset)
          Create a regular instance that will act as a normal view.
 

Method Detail

flyInstance

FlyView flyInstance(View parent)
Create an instance of the view dependent on the context given by the parent view. If this view instance satisfies the conditions imposed by parent's context (e.g. this view's measurements match those with the given parent's container font rendering context) then this instance can be returned instead of creating a new one. Note: The parent view should only be used to perform the necessary initialization of the new instance (or verification that existing instance can be created) but it should never be held by the flyweight view permanently.

Parameters:
parent - instance of view that will act as parent for the view in the given context. The possibly created instance of the view can use the parent but it must not hold the reference to it permanently.
Returns:
a this view instance if measurements of this view satisfy the context of the parent or a new view instance otherwise.

regularInstance

View regularInstance(View parent,
                     int startOffset,
                     int endOffset)
Create a regular instance that will act as a normal view. This can be used in certain contexts where a regular view would be needed typically for a short term use.
Caller ensures that the text represented by the given offset range matches the text returned by getText().
Caller is also responsible to remove this view in case the text in the particular area changes.


getText

CharSequence getText()
Get the text represented by this view.

Returns:
non-null instance of a character sequence. In case the view does not represent any text an empty sequence must be returned.

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.