Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

oracle.javatools.editor
Class BasicEditorUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.TextUI
          extended by javax.swing.plaf.basic.BasicTextUI
              extended by javax.swing.plaf.basic.BasicEditorPaneUI
                  extended by oracle.javatools.editor.BasicEditorUI
All Implemented Interfaces:
javax.swing.text.ViewFactory

public class BasicEditorUI
extends javax.swing.plaf.basic.BasicEditorPaneUI

The BasicEditorUI overrides the default look and feel for the BasicEditorPane implementation in order to adhere to the locking policies in the document. The default BasicTextUI implementation makes the assumption that the document model used by the editor pane inherits from AbstractDocument, which is not true in our case. Because of this assumption, none of our locking calls are made when the editor is painted if the installed UI delegate is the Swing default one.


Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicTextUI
javax.swing.plaf.basic.BasicTextUI.BasicCaret, javax.swing.plaf.basic.BasicTextUI.BasicHighlighter
 
Method Summary
 void addPainter(BasicEditorPainter painter)
           
protected  javax.swing.text.Caret createCaret()
          Creates the object to use for a caret.
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent component)
          Creates a UI for the BasicEditorPane.
 void damageRange(javax.swing.text.JTextComponent component, int startOffset, int endOffset, javax.swing.text.Position.Bias startOffsetBias, javax.swing.text.Position.Bias endOffsetBias)
          Causes the portion of the view responsible for the given part of the model to be repainted.
 java.awt.Dimension getMaximumSize(javax.swing.JComponent component)
          Gets the maximum size for the editor component.
 java.awt.Dimension getMinimumSize(javax.swing.JComponent component)
          Gets the minimum size for the editor component.
 int getNextVisualPositionFrom(javax.swing.text.JTextComponent component, int offset, javax.swing.text.Position.Bias bias, int direction, javax.swing.text.Position.Bias[] biasRet)
          Provides a way to determine the next visually represented model location that one might place a caret.
 java.awt.Dimension getPreferredSize(javax.swing.JComponent component)
          Gets the preferred size for the editor component.
 void installUI(javax.swing.JComponent component)
          Installs the UI for a component.
 java.awt.Rectangle modelToView(javax.swing.text.JTextComponent component, int offset, javax.swing.text.Position.Bias bias)
          Converts the given location in the model to a place in the view coordinate system.
protected  void paintBackground(java.awt.Graphics g)
           
protected  void paintSafely(java.awt.Graphics g)
          Paints the interface safely with a guarantee that the model won't change from the view of this thread.
 void removePainter(BasicEditorPainter painter)
           
 int viewToModel(javax.swing.text.JTextComponent component, java.awt.Point point, javax.swing.text.Position.Bias[] biasReturn)
          Converts the given place in the view coordinate system to the nearest representative location in the model.
 
Methods inherited from class javax.swing.plaf.basic.BasicEditorPaneUI
getEditorKit, getPropertyPrefix, propertyChange, uninstallUI
 
Methods inherited from class javax.swing.plaf.basic.BasicTextUI
create, create, createHighlighter, createKeymap, damageRange, getComponent, getKeymapName, getRootView, getToolTipText, getVisibleEditorRect, installDefaults, installKeyboardActions, installListeners, modelChanged, modelToView, paint, setView, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, update, viewToModel
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createUI

public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent component)
Creates a UI for the BasicEditorPane.

Parameters:
component - the JTextPane component
Returns:
the UI

installUI

public void installUI(javax.swing.JComponent component)
Installs the UI for a component. We override this so that we can force the caret color black.

Overrides:
installUI in class javax.swing.plaf.basic.BasicEditorPaneUI
Parameters:
component - the editor component
See Also:
ComponentUI.installUI(javax.swing.JComponent)

createCaret

protected javax.swing.text.Caret createCaret()
Creates the object to use for a caret.

Overrides:
createCaret in class javax.swing.plaf.basic.BasicTextUI
Returns:
the caret object

paintBackground

protected void paintBackground(java.awt.Graphics g)
Overrides:
paintBackground in class javax.swing.plaf.basic.BasicTextUI

paintSafely

protected void paintSafely(java.awt.Graphics g)
Paints the interface safely with a guarantee that the model won't change from the view of this thread.

Overrides:
paintSafely in class javax.swing.plaf.basic.BasicTextUI
Parameters:
g - the graphics context

getPreferredSize

public java.awt.Dimension getPreferredSize(javax.swing.JComponent component)
Gets the preferred size for the editor component.

Overrides:
getPreferredSize in class javax.swing.plaf.basic.BasicTextUI
Parameters:
component - the editor component
Returns:
the preferred size of the editor component

getMinimumSize

public java.awt.Dimension getMinimumSize(javax.swing.JComponent component)
Gets the minimum size for the editor component.

Overrides:
getMinimumSize in class javax.swing.plaf.basic.BasicTextUI
Parameters:
component - the editor component
Returns:
the minimum size for this editor component

getMaximumSize

public java.awt.Dimension getMaximumSize(javax.swing.JComponent component)
Gets the maximum size for the editor component.

Overrides:
getMaximumSize in class javax.swing.plaf.basic.BasicTextUI
Parameters:
component - the editor component
Returns:
the maximum size for this editor component

modelToView

public java.awt.Rectangle modelToView(javax.swing.text.JTextComponent component,
                                      int offset,
                                      javax.swing.text.Position.Bias bias)
                               throws javax.swing.text.BadLocationException
Converts the given location in the model to a place in the view coordinate system.

Overrides:
modelToView in class javax.swing.plaf.basic.BasicTextUI
Parameters:
component - the text component for which this UI is installed
offset - the local location in the model to translate >= 0
Returns:
the coordinates as a rectangle, null if the model is not painted
Throws:
javax.swing.text.BadLocationException - if the given offset does not represent a valid location in the document
See Also:
TextUI.modelToView(javax.swing.text.JTextComponent, int)

viewToModel

public int viewToModel(javax.swing.text.JTextComponent component,
                       java.awt.Point point,
                       javax.swing.text.Position.Bias[] biasReturn)
Converts the given place in the view coordinate system to the nearest representative location in the model.

Overrides:
viewToModel in class javax.swing.plaf.basic.BasicTextUI
Parameters:
component - the text component for which this UI is installed
point - the location in the view to translate. This should be in the same coordinate system as the mouse events.
Returns:
the offset from the start of the document >= 0, -1 if the component doesn't yet have a positive size.
See Also:
TextUI.viewToModel(javax.swing.text.JTextComponent, java.awt.Point)

getNextVisualPositionFrom

public int getNextVisualPositionFrom(javax.swing.text.JTextComponent component,
                                     int offset,
                                     javax.swing.text.Position.Bias bias,
                                     int direction,
                                     javax.swing.text.Position.Bias[] biasRet)
                              throws javax.swing.text.BadLocationException
Provides a way to determine the next visually represented model location that one might place a caret.

Overrides:
getNextVisualPositionFrom in class javax.swing.plaf.basic.BasicTextUI
Parameters:
component - the text component for which this UI is installed
offset - the position to convert >= 0
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:
javax.swing.text.BadLocationException - if the given offset does not represent a valid location in the document
java.lang.IllegalArgumentException - for an invalid direction

damageRange

public void damageRange(javax.swing.text.JTextComponent component,
                        int startOffset,
                        int endOffset,
                        javax.swing.text.Position.Bias startOffsetBias,
                        javax.swing.text.Position.Bias endOffsetBias)
Causes the portion of the view responsible for the given part of the model to be repainted.

Overrides:
damageRange in class javax.swing.plaf.basic.BasicTextUI
Parameters:
component - the text component for which this UI is installed
startOffset - the beginning of the range >= 0
endOffset - the end of the range >= startOffset

addPainter

public void addPainter(BasicEditorPainter painter)

removePainter

public void removePainter(BasicEditorPainter painter)

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

Copyright © 1997, 2011, Oracle. All rights reserved.