Extension SDK 10.1.2

oracle.javatools.editor
Class BasicEditorUI

java.lang.Object
  extended byjavax.swing.plaf.ComponentUI
      extended byjavax.swing.plaf.TextUI
          extended byjavax.swing.plaf.basic.BasicTextUI
              extended byjavax.swing.plaf.basic.BasicEditorPaneUI
                  extended byoracle.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 inherited from class javax.swing.plaf.basic.BasicTextUI
javax.swing.plaf.basic.BasicTextUI.BasicCaret, javax.swing.plaf.basic.BasicTextUI.BasicHighlighter
 
Constructor Summary
BasicEditorUI()
           
 
Method Summary
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 paintSafely(java.awt.Graphics graphics)
          Paints the interface safely with a guarantee that the model won't change from the view of this thread.
 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
 
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, paintBackground, setView, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI, update, viewToModel
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicEditorUI

public BasicEditorUI()
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.

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.

Returns:
the caret object

paintSafely

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

Parameters:
graphics - the graphics context

getPreferredSize

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

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.

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.

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.

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.

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.

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.

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

Extension SDK

 

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