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

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

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

org.netbeans.editor
Class EditorUI

java.lang.Object
  extended by org.netbeans.editor.EditorUI
All Implemented Interfaces:
PropertyChangeListener, EventListener, ChangeListener, SettingsChangeListener
Direct Known Subclasses:
ExtEditorUI

public class EditorUI
extends Object
implements ChangeListener, PropertyChangeListener, SettingsChangeListener

Editor UI for the component. All the additional UI features like advanced scrolling, info about fonts, abbreviations, keyword matching are based on this class.


Field Summary
static String COMPONENT_PROPERTY
           
static Insets defaultLineNumberMargin
          Default margin on the left and right side of the line number
static String LINE_HEIGHT_CHANGED_PROP
           
static String OVERWRITE_MODE_PROPERTY
           
static int SCROLL_DEFAULT
          Default scrolling type is used for the standard setDot() call.
static int SCROLL_FIND
          Scrolling type for find operations, that can request additional configurable area in each direction, so the context around is visible too.
static int SCROLL_MOVE
          Scrolling type used for regular caret moves.
static int SCROLL_SMALLEST
          Scrolling type where the smallest covering for the requested rectangle is used.
 
Constructor Summary
EditorUI()
          Construct extended UI for the use with a text component
EditorUI(BaseDocument printDoc)
          Construct extended UI for printing the given document
EditorUI(BaseDocument printDoc, boolean usePrintColoringMap, boolean lineNumberEnabled)
          Construct extended UI for printing the given document and specify which set of colors should be used.
 
Method Summary
 boolean addLayer(DrawLayer layer, int visibility)
          Deprecated. Please use Highlighting SPI instead, for details see Editor Library 2.
 void addPropertyChangeListener(PropertyChangeListener l)
           
 void addPropertyChangeListener(String propertyName, PropertyChangeListener l)
           
 void adjustCaret(int percentFromWindowTop)
          Set the dot according to the currently visible screen window.
 void adjustWindow(int caretPercentFromWindowTop)
           
 void caretMoveDot(int offset, Rectangle scrollRect, int scrollPolicy)
          Deprecated.  
 void caretSetDot(int offset, Rectangle scrollRect, int scrollPolicy)
          Deprecated.  
protected  Map createColoringMap()
          Deprecated. Use Editor Settings or Editor Settings Storage API instead. This method is never called.
protected  JComponent createExtComponent()
           
protected  JToolBar createToolBarComponent()
          Construct the toolbar component appropriate for this editor.
 DrawLayer findLayer(String layerName)
          Deprecated. Please use Highlighting SPI instead, for details see Editor Library 2.
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
           
 Abbrev getAbbrev()
           
 Coloring getColoring(String coloringName)
          Deprecated. Use Editor Settings API instead.
 Map<String,Coloring> getColoringMap()
          Deprecated. Use Editor Settings API instead.
 JTextComponent getComponent()
           
 Object getComponentLock()
          Get the lock assuring the component will not be changed by installUI() or uninstallUI().
 Coloring getDefaultColoring()
          Deprecated. Use Editor Settings API instead.
 BaseDocument getDocument()
          Get the document to work on.
 JComponent getExtComponent()
          Get extended editor component.
 Rectangle getExtentBounds()
           
 Rectangle getExtentBounds(Rectangle r)
          Get position of the component extent.
 GlyphGutter getGlyphGutter()
           
 int getLineAscent()
           
 int getLineHeight()
           
 int getLineNumberDigitWidth()
          Returns width of the one digit
 Insets getLineNumberMargin()
          Returns the line number margin
static Frame getParentFrame(Component c)
          Finds the frame - parent of editor component
 Object getProperty(Object key)
           
protected static Map<String,Coloring> getSharedColoringMap(Class kitClass)
          Deprecated. Use Editor Settings API instead.
 int getSideBarWidth()
           
 StatusBar getStatusBar()
           
 Insets getTextMargin()
          Get the begining of the area covered by text
 JToolBar getToolBarComponent()
          Get the toolbar component appropriate for this editor.
 WordMatch getWordMatch()
           
 boolean hasExtComponent()
          Whether this ui uses extComponent or not.
protected  void initGlyphCorner(JScrollPane scroller)
           
protected  void installUI(JTextComponent c)
          Called when the BaseTextUI is being installed into the component.
 boolean isGlyphGutterVisible()
          Is glyph gutter created and visible for the document or not
 boolean isLineNumberEnabled()
           
protected  void modelChanged(BaseDocument oldDoc, BaseDocument newDoc)
           
protected  void paint(Graphics g)
          This method is called by textui to do the paint.
 void propertyChange(PropertyChangeEvent evt)
           
 void putProperty(Object key, Object value)
           
 DrawLayer removeLayer(String layerName)
          Deprecated. Please use Highlighting SPI instead, for details see Editor Library 2.
 void removePropertyChangeListener(PropertyChangeListener l)
           
 void removePropertyChangeListener(String propertyName, PropertyChangeListener l)
           
 void repaint(int startY)
           
 void repaint(int startY, int height)
           
 void repaintBlock(int startPos, int endPos)
          Repaint the block between the given positions.
 void repaintOffset(int pos)
           
 void scrollRectToVisible(Rectangle r, int scrollPolicy)
          Deprecated. use JComponent.scrollRectToVisible() instead of this method.
protected  void setGlyphGutter(GlyphGutter gutter)
           
 void setLineNumberEnabled(boolean lineNumberEnabled)
           
 void settingsChange(SettingsChangeEvent evt)
           
protected  void settingsChangeImpl(String settingName)
           
 void stateChanged(ChangeEvent evt)
           
protected  void uninstallUI(JTextComponent c)
          Called when the BaseTextUI is being uninstalled from the component.
protected  void update(Graphics g)
           
 void updateLineNumberWidth(int maxDigitCount)
          Update the width that will be occupied by the line number.
protected  void updateScrollPaneCornerColor()
           
 void updateTextMargin()
           
 boolean updateVirtualHeight(int height)
          Deprecated. virtual size is no longer used and effects of this method are ignored
 boolean updateVirtualWidth(int width)
          Deprecated. virtual size is no longer used and effects of this method are ignored
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OVERWRITE_MODE_PROPERTY

public static final String OVERWRITE_MODE_PROPERTY
See Also:
Constant Field Values

COMPONENT_PROPERTY

public static final String COMPONENT_PROPERTY
See Also:
Constant Field Values

SCROLL_DEFAULT

public static final int SCROLL_DEFAULT
Default scrolling type is used for the standard setDot() call. If the area is on the screen, it jumps to it, otherwise it centers the requested area vertically in the middle of the window and it uses smallest covering on the right side.

See Also:
Constant Field Values

SCROLL_MOVE

public static final int SCROLL_MOVE
Scrolling type used for regular caret moves. The scrollJump is used when the caret requests area outside the screen.

See Also:
Constant Field Values

SCROLL_SMALLEST

public static final int SCROLL_SMALLEST
Scrolling type where the smallest covering for the requested rectangle is used. It's useful for going to the end of the line for example.

See Also:
Constant Field Values

SCROLL_FIND

public static final int SCROLL_FIND
Scrolling type for find operations, that can request additional configurable area in each direction, so the context around is visible too.

See Also:
Constant Field Values

defaultLineNumberMargin

public static final Insets defaultLineNumberMargin
Default margin on the left and right side of the line number


LINE_HEIGHT_CHANGED_PROP

public static final String LINE_HEIGHT_CHANGED_PROP
See Also:
Constant Field Values
Constructor Detail

EditorUI

public EditorUI()
Construct extended UI for the use with a text component


EditorUI

public EditorUI(BaseDocument printDoc)
Construct extended UI for printing the given document


EditorUI

public EditorUI(BaseDocument printDoc,
                boolean usePrintColoringMap,
                boolean lineNumberEnabled)
Construct extended UI for printing the given document and specify which set of colors should be used.

Parameters:
printDoc - document that should be printed.
usePrintColoringMap - Ignored. of the regular ones.
lineNumberEnabled - if set to false the line numbers will not be printed. If set to true the visibility of line numbers depends on lineNumberVisibleSetting.
Method Detail

getSharedColoringMap

protected static Map<String,Coloring> getSharedColoringMap(Class kitClass)
Deprecated. Use Editor Settings API instead.

Tries to gather all colorings defined for the kit's mime type. If the mime type can't be determined from the editor kit's class passed in, this method will try to load colorings defined for the empty mime path (ie. all languages).

Parameters:
kitClass - The kit class for which the colorings should be loaded.
Returns:
The map with all colorings defined for the mime type of the editor kit class passed in. The returned map may be inaccurate, please use the new Editor Settings API and its FontColorSettings class.

installUI

protected void installUI(JTextComponent c)
Called when the BaseTextUI is being installed into the component.


uninstallUI

protected void uninstallUI(JTextComponent c)
Called when the BaseTextUI is being uninstalled from the component.


getComponentLock

public Object getComponentLock()
Get the lock assuring the component will not be changed by installUI() or uninstallUI(). It's useful for the classes that want to listen for the component change in EditorUI.


addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener l)

firePropertyChange

protected final void firePropertyChange(String propertyName,
                                        Object oldValue,
                                        Object newValue)

settingsChangeImpl

protected void settingsChangeImpl(String settingName)

settingsChange

public void settingsChange(SettingsChangeEvent evt)
Specified by:
settingsChange in interface SettingsChangeListener

stateChanged

public void stateChanged(ChangeEvent evt)
Specified by:
stateChanged in interface ChangeListener

modelChanged

protected void modelChanged(BaseDocument oldDoc,
                            BaseDocument newDoc)

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

createColoringMap

protected Map createColoringMap()
Deprecated. Use Editor Settings or Editor Settings Storage API instead. This method is never called.


getLineHeight

public int getLineHeight()

getLineAscent

public int getLineAscent()

getColoringMap

public Map<String,Coloring> getColoringMap()
Deprecated. Use Editor Settings API instead.

Tries to gather all colorings defined for the component's mime type. If this instance is not installed to any component the method will try to load colorings for the empty mime path (ie. all languages).

Returns:
The map with all colorings defined the mime type of this instance. The returned map may be inaccurate, please use the new Editor Settings API and its FontColorSettings class.

getDefaultColoring

public Coloring getDefaultColoring()
Deprecated. Use Editor Settings API instead.

Gets the default coloring. The default coloring is the one called FontColorNames.DEFAULT_COLORING and defined for the empty mime path (ie. all languages).


getColoring

public Coloring getColoring(String coloringName)
Deprecated. Use Editor Settings API instead.

Gets a coloring from the coloring map. This metod uses the coloring map returned by getColoringMap to find a coloring by its name.

Parameters:
coloringName - The name of the coloring to find.

update

protected void update(Graphics g)

getComponent

public final JTextComponent getComponent()

getDocument

public final BaseDocument getDocument()
Get the document to work on. Either component's document or printed document is returned. It can return null in case the component's document is not instance of BaseDocument.


getProperty

public Object getProperty(Object key)

putProperty

public void putProperty(Object key,
                        Object value)

getExtComponent

public JComponent getExtComponent()
Get extended editor component. The extended component should normally be used for editing files instead of just the JEditorPane because it offers status bar and possibly other useful components.
The component no longer includes toolbar - it's returned by a separate method #getToolbarComponent().
The getExtComponent() should not be used when the JEditorPane is included in dialog.

See Also:
hasExtComponent()

getToolBarComponent

public JToolBar getToolBarComponent()
Get the toolbar component appropriate for this editor.


createToolBarComponent

protected JToolBar createToolBarComponent()
Construct the toolbar component appropriate for this editor.

Returns:
non-null toolbar component or null if there is no appropriate toolbar component for this editor.

initGlyphCorner

protected void initGlyphCorner(JScrollPane scroller)

setGlyphGutter

protected void setGlyphGutter(GlyphGutter gutter)

getSideBarWidth

public final int getSideBarWidth()

createExtComponent

protected JComponent createExtComponent()

hasExtComponent

public boolean hasExtComponent()
Whether this ui uses extComponent or not.

See Also:
getExtComponent()

getAbbrev

public Abbrev getAbbrev()

getWordMatch

public WordMatch getWordMatch()

getStatusBar

public StatusBar getStatusBar()

findLayer

public DrawLayer findLayer(String layerName)
Deprecated. Please use Highlighting SPI instead, for details see Editor Library 2.

Find the layer with some layer name in the layer hierarchy.

Using of DrawLayers has been deprecated.


addLayer

public boolean addLayer(DrawLayer layer,
                        int visibility)
Deprecated. Please use Highlighting SPI instead, for details see Editor Library 2.

Add new layer and use its priority to position it in the chain. If there's the layer with same visibility then the inserted layer will be placed after it.

Using of DrawLayers has been deprecated.

Parameters:
layer - layer to insert into the chain

removeLayer

public DrawLayer removeLayer(String layerName)
Deprecated. Please use Highlighting SPI instead, for details see Editor Library 2.

Using of DrawLayers has been deprecated.


repaint

public void repaint(int startY)

repaint

public void repaint(int startY,
                    int height)

repaintOffset

public void repaintOffset(int pos)
                   throws BadLocationException
Throws:
BadLocationException

repaintBlock

public void repaintBlock(int startPos,
                         int endPos)
                  throws BadLocationException
Repaint the block between the given positions.

Throws:
BadLocationException

getParentFrame

public static Frame getParentFrame(Component c)
Finds the frame - parent of editor component


updateVirtualWidth

public boolean updateVirtualWidth(int width)
Deprecated. virtual size is no longer used and effects of this method are ignored

Possibly update virtual width. If the width is really updated, the method returns true.


updateVirtualHeight

public boolean updateVirtualHeight(int height)
Deprecated. virtual size is no longer used and effects of this method are ignored

Possibly update virtual height. If the height is really updated, the method returns true. There is a slight difference against virtual width in that if the height is shrinked too much the virtual height is shrinked too. 0 can be used to update to the real height.


isLineNumberEnabled

public boolean isLineNumberEnabled()

setLineNumberEnabled

public void setLineNumberEnabled(boolean lineNumberEnabled)

updateLineNumberWidth

public void updateLineNumberWidth(int maxDigitCount)
Update the width that will be occupied by the line number.

Parameters:
maxDigitCount - maximum digit count that can the line number have. if it's lower or equal to zero it will be computed automatically.

updateTextMargin

public void updateTextMargin()

getExtentBounds

public Rectangle getExtentBounds()

getExtentBounds

public Rectangle getExtentBounds(Rectangle r)
Get position of the component extent. The (x, y) are set to (0, 0) if there's no viewport or (-x, -y) if there's one.


getTextMargin

public Insets getTextMargin()
Get the begining of the area covered by text


scrollRectToVisible

public void scrollRectToVisible(Rectangle r,
                                int scrollPolicy)
Deprecated. use JComponent.scrollRectToVisible() instead of this method.

Scroll the editor window so that the given rectangle is visible.

Parameters:
r - rectangle to which the editor window should be scrolled.
scrollPolicy - the way how scrolling should be done. One of EditorUI.SCROLL_* constants.

adjustWindow

public void adjustWindow(int caretPercentFromWindowTop)

adjustCaret

public void adjustCaret(int percentFromWindowTop)
Set the dot according to the currently visible screen window. #param percentFromWindowTop percentage giving the distance of the caret from the top of the currently visible window.


caretSetDot

public void caretSetDot(int offset,
                        Rectangle scrollRect,
                        int scrollPolicy)
Deprecated. 

Set the position of the caret and scroll the extent if necessary.

Parameters:
offset - position where the caret should be placed
scrollRect - rectangle that should become visible. It can be null when no scrolling should be done.
scrollPolicy - policy to be used when scrolling.

caretMoveDot

public void caretMoveDot(int offset,
                         Rectangle scrollRect,
                         int scrollPolicy)
Deprecated. 

Set the position of the caret and scroll the extent if necessary.

Parameters:
offset - position where the caret should be placed
scrollRect - rectangle that should become visible. It can be null when no scrolling should be done.
scrollPolicy - policy to be used when scrolling.

paint

protected void paint(Graphics g)
This method is called by textui to do the paint. It is forwarded either to paint through the image and then copy the image area to the screen or to paint directly to this graphics. The real work occurs in draw-engine.


getLineNumberMargin

public Insets getLineNumberMargin()
Returns the line number margin


getLineNumberDigitWidth

public int getLineNumberDigitWidth()
Returns width of the one digit


isGlyphGutterVisible

public boolean isGlyphGutterVisible()
Is glyph gutter created and visible for the document or not


getGlyphGutter

public final GlyphGutter getGlyphGutter()

updateScrollPaneCornerColor

protected void updateScrollPaneCornerColor()

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.