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

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

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

org.netbeans.editor.view.spi
Class ViewRenderingContext

java.lang.Object
  extended by org.netbeans.editor.view.spi.ViewRenderingContext

public abstract class ViewRenderingContext
extends Object

Context used for rendering of a view. It provides methods useful for measuring of the view contents.
It also provides information about additional highlights that the view should respect when painting a particular text.

A particular view can obtain an instance of ViewRenderingContext by using methods in RenderingContextView.

Only one thread at the time can safely use the rendering context. It does not have to be event dispatch thread.


Constructor Summary
ViewRenderingContext()
           
 
Method Summary
abstract  float getAscent(View v)
           
abstract  int getBoundedPosition(View v, int p0, float x, float len)
          Determines the model location that represents the maximum advance that fits within the given span.
abstract  float getDescent(View v)
           
abstract  float getHeight(View v)
           
 int getNextVisualPositionFrom(View v, int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet)
          Provides a way to determine the next visually represented model location that one might place a caret.
abstract  float getSpan(View v, int p0, int p1, TabExpander e, float x)
           
abstract  Shape modelToView(View v, int pos, Position.Bias bias, Shape a)
          Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
static ViewRenderingContext obtainContext(View v)
          Find instance of the ViewRenderingContext for the given view.
abstract  void paint(View v, Graphics g, Shape a, int p0, int p1)
          Paint the glyphs representing the given range.
abstract  int viewToModel(View v, float x, float y, Shape a, Position.Bias[] biasReturn)
          Provides a mapping from the view coordinate space to the logical coordinate space of the model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewRenderingContext

public ViewRenderingContext()
Method Detail

obtainContext

public static ViewRenderingContext obtainContext(View v)
Find instance of the ViewRenderingContext for the given view.


getSpan

public abstract float getSpan(View v,
                              int p0,
                              int p1,
                              TabExpander e,
                              float x)

getHeight

public abstract float getHeight(View v)

getAscent

public abstract float getAscent(View v)

getDescent

public abstract float getDescent(View v)

paint

public abstract void paint(View v,
                           Graphics g,
                           Shape a,
                           int p0,
                           int p1)
Paint the glyphs representing the given range.


modelToView

public abstract Shape modelToView(View v,
                                  int pos,
                                  Position.Bias bias,
                                  Shape a)
                           throws BadLocationException
Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. This is shared by the broken views.

Parameters:
pos - the position to convert
a - the allocated region to render into
rightToLeft - true if the text is rendered right to left.
Returns:
the bounding box of the given position
Throws:
BadLocationException - if the given position does not represent a valid location in the associated document
See Also:
View.modelToView(int, java.awt.Shape, javax.swing.text.Position.Bias)

viewToModel

public abstract int viewToModel(View v,
                                float x,
                                float y,
                                Shape a,
                                Position.Bias[] biasReturn)
Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Parameters:
x - the X coordinate
y - the Y coordinate
a - the allocated region to render into
rightToLeft - true if the text is rendered right to left
Returns:
the location within the model that best represents the given point of view
See Also:
View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])

getBoundedPosition

public abstract int getBoundedPosition(View v,
                                       int p0,
                                       float x,
                                       float len)
Determines the model location that represents the maximum advance that fits within the given span. This could be used to break the given view. The result should be a location just shy of the given advance. This differs from viewToModel which returns the closest position which might be proud of the maximum advance.

Parameters:
v - the view to find the model location to break at.
p0 - the location in the model where the fragment should start it's representation >= 0.
pos - the graphic location along the axis that the broken view would occupy >= 0. This may be useful for things like tab calculations.
len - specifies the distance into the view where a potential break is desired >= 0.
Returns:
the maximum model location possible for a break.
See Also:
View.breakView(int, int, float, float)

getNextVisualPositionFrom

public int getNextVisualPositionFrom(View v,
                                     int pos,
                                     Position.Bias b,
                                     Shape a,
                                     int direction,
                                     Position.Bias[] biasRet)
                              throws BadLocationException
Provides a way to determine the next visually represented model location that one might place a caret. Some views may not be visible, they might not be in the same order found in the model, or they just might not allow access to some of the locations in the model.

Parameters:
v - the view to use
pos - the position to convert >= 0
a - the allocated region to render into
direction - the direction from the current position that can be thought of as the arrow keys typically found on a keyboard. This may be SwingConstants.WEST, SwingConstants.EAST, SwingConstants.NORTH, or SwingConstants.SOUTH.
Returns:
the location within the model that best represents the next location visual position.
Throws:
BadLocationException
IllegalArgumentException - for an invalid direction

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.