javax.swing.plaf.basic
Class BasicTextUI.UpdateHandler

java.lang.Object
  extended byjavax.swing.plaf.basic.BasicTextUI.UpdateHandler
All Implemented Interfaces:
DocumentListener, EventListener, LayoutManager, LayoutManager2, java.beans.PropertyChangeListener, UIResource
Enclosing class:
BasicTextUI

class BasicTextUI.UpdateHandler
extends Object
implements java.beans.PropertyChangeListener, DocumentListener, LayoutManager2, UIResource

Handles updates from various places. If the model is changed, this class unregisters as a listener to the old model and registers with the new model. If the document model changes, the change is forwarded to the root view. If the focus accelerator changes, a new keystroke is registered to request focus.


Field Summary
private  Hashtable constraints
          The "layout constraints" for the LayoutManager2 implementation.
private  boolean i18nView
           
 
Constructor Summary
(package private) BasicTextUI.UpdateHandler()
           
 
Method Summary
 void addLayoutComponent(Component comp, Object constraint)
          Adds the specified component to the layout, using the specified constraint object.
 void addLayoutComponent(String name, Component comp)
          Adds the specified component with the specified name to the layout.
(package private)  Shape calculateViewPosition(Shape alloc, View v)
          Find the Shape representing the given view.
 void changedUpdate(DocumentEvent e)
          The change notification.
 float getLayoutAlignmentX(Container target)
          Returns the alignment along the x axis.
 float getLayoutAlignmentY(Container target)
          Returns the alignment along the y axis.
 void insertUpdate(DocumentEvent e)
          The insert notification.
 void invalidateLayout(Container target)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 void layoutContainer(Container parent)
          Lays out the container in the specified panel.
 Dimension maximumLayoutSize(Container target)
          Returns the maximum size of this component.
 Dimension minimumLayoutSize(Container parent)
          Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.
 Dimension preferredLayoutSize(Container parent)
          Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          This method gets called when a bound property is changed.
 void removeLayoutComponent(Component comp)
          Removes the specified component from the layout.
 void removeUpdate(DocumentEvent e)
          The remove notification.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constraints

private Hashtable constraints
The "layout constraints" for the LayoutManager2 implementation. These are View objects for those components that are represented by a View in the View tree.


i18nView

private boolean i18nView
Constructor Detail

BasicTextUI.UpdateHandler

BasicTextUI.UpdateHandler()
Method Detail

propertyChange

public final void propertyChange(java.beans.PropertyChangeEvent evt)
This method gets called when a bound property is changed. We are looking for document changes on the editor.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

insertUpdate

public final void insertUpdate(DocumentEvent e)
The insert notification. Gets sent to the root of the view structure that represents the portion of the model being represented by the editor. The factory is added as an argument to the update so that the views can update themselves in a dynamic (not hardcoded) way.

Specified by:
insertUpdate in interface DocumentListener
Parameters:
e - The change notification from the currently associated document.
See Also:
DocumentListener.insertUpdate(javax.swing.event.DocumentEvent)

removeUpdate

public final void removeUpdate(DocumentEvent e)
The remove notification. Gets sent to the root of the view structure that represents the portion of the model being represented by the editor. The factory is added as an argument to the update so that the views can update themselves in a dynamic (not hardcoded) way.

Specified by:
removeUpdate in interface DocumentListener
Parameters:
e - The change notification from the currently associated document.
See Also:
DocumentListener.removeUpdate(javax.swing.event.DocumentEvent)

changedUpdate

public final void changedUpdate(DocumentEvent e)
The change notification. Gets sent to the root of the view structure that represents the portion of the model being represented by the editor. The factory is added as an argument to the update so that the views can update themselves in a dynamic (not hardcoded) way.

Specified by:
changedUpdate in interface DocumentListener
Parameters:
e - The change notification from the currently associated document.
See Also:
DocumentListener#changeUpdate

addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)
Adds the specified component with the specified name to the layout.

Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name - the component name
comp - the component to be added

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Removes the specified component from the layout.

Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
comp - the component to be removed

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
parent - the component to be laid out
See Also:
minimumLayoutSize(java.awt.Container)

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
parent - the component to be laid out
See Also:
preferredLayoutSize(java.awt.Container)

layoutContainer

public void layoutContainer(Container parent)
Lays out the container in the specified panel. This is implemented to position all components that were added with a View object as a constraint. The current allocation of the associated View is used as the location of the component.

A read-lock is acquired on the document to prevent the view tree from being modified while the layout process is active.

Specified by:
layoutContainer in interface LayoutManager
Parameters:
parent - the component which needs to be laid out

calculateViewPosition

Shape calculateViewPosition(Shape alloc,
                            View v)
Find the Shape representing the given view.


addLayoutComponent

public void addLayoutComponent(Component comp,
                               Object constraint)
Adds the specified component to the layout, using the specified constraint object. We only store those components that were added with a constraint that is of type View.

Specified by:
addLayoutComponent in interface LayoutManager2
Parameters:
comp - the component to be added
constraint - where/how the component is added to the layout.

maximumLayoutSize

public Dimension maximumLayoutSize(Container target)
Returns the maximum size of this component.

Specified by:
maximumLayoutSize in interface LayoutManager2
See Also:
Component.getMinimumSize(), Component.getPreferredSize(), LayoutManager

getLayoutAlignmentX

public float getLayoutAlignmentX(Container target)
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentX in interface LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(Container target)
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentY in interface LayoutManager2

invalidateLayout

public void invalidateLayout(Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Specified by:
invalidateLayout in interface LayoutManager2