javax.swing.plaf.basic
Class BasicTextFieldUI.I18nFieldView

java.lang.Object
  extended byjavax.swing.text.View
      extended byjavax.swing.text.CompositeView
          extended byjavax.swing.text.BoxView
              extended byjavax.swing.text.FlowView
                  extended byjavax.swing.text.ParagraphView
                      extended byjavax.swing.plaf.basic.BasicTextFieldUI.I18nFieldView
All Implemented Interfaces:
SwingConstants, TabExpander
Enclosing class:
BasicTextFieldUI

static class BasicTextFieldUI.I18nFieldView
extends ParagraphView

A field view that support bidirectional text via the support provided by ParagraphView.


Nested Class Summary
 
Nested classes inherited from class javax.swing.text.ParagraphView
 
Nested classes inherited from class javax.swing.text.FlowView
FlowView.FlowStrategy
 
Field Summary
 
Fields inherited from class javax.swing.text.ParagraphView
firstLineIndent
 
Fields inherited from class javax.swing.text.FlowView
layoutPool, layoutSpan, strategy
 
Fields inherited from class javax.swing.text.BoxView
 
Fields inherited from class javax.swing.text.CompositeView
 
Fields inherited from class javax.swing.text.View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
(package private) BasicTextFieldUI.I18nFieldView(Element elem)
           
 
Method Summary
(package private)  Shape adjustAllocation(Shape a)
          Adjusts the allocation given to the view to be a suitable allocation for a text field.
 int getFlowSpan(int index)
          Fetch the constraining span to flow against for the given child index.
 int getResizeWeight(int axis)
          Determines the resizability of the view along the given axis.
 void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f)
          Gives notification that something was inserted into the document in a location that this view is responsible for.
(package private) static boolean isLeftToRight(Component c)
           
 Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
          Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
 Shape modelToView(int pos, Shape a, Position.Bias b)
          Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
 void paint(Graphics g, Shape a)
          Renders using the given rendering surface and area on that surface.
 void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f)
          Gives notification that something was removed from the document in a location that this view is responsible for.
protected  void setJustification(int j)
          Sets the type of justification.
(package private)  void updateVisibilityModel()
          Update the visibility model with the associated JTextField (if there is one) to reflect the current visibility as a result of changes to the document model.
 int viewToModel(float fx, float fy, Shape a, Position.Bias[] bias)
          Provides a mapping from the view coordinate space to the logical coordinate space of the model.
 
Methods inherited from class javax.swing.text.ParagraphView
adjustRow, breakView, changedUpdate, createRow, findOffsetToCharactersInString, flipEastAndWestAtEnds, getAlignment, getBreakWeight, getClosestPositionTo, getFlowStart, getLayoutView, getLayoutViewCount, getNextNorthSouthVisualPositionFrom, getPartialSize, getTabBase, getTabSet, nextTabStop, setFirstLineIndent, setLineSpacing, setPropertiesFromAttributes
 
Methods inherited from class javax.swing.text.FlowView
calculateMinorAxisRequirements, getFlowAxis, getViewIndexAtPosition, layout, loadChildren
 
Methods inherited from class javax.swing.text.BoxView
baselineLayout, baselineRequirements, calculateMajorAxisRequirements, childAllocation, forwardUpdate, getAxis, getChildAllocation, getHeight, getMaximumSpan, getMinimumSpan, getOffset, getPreferredSpan, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layoutChanged, layoutMajorAxis, layoutMinorAxis, paintChild, preferenceChanged, replace, setAxis, setSize
 
Methods inherited from class javax.swing.text.CompositeView
getBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, setInsets, setParagraphInsets, setParent
 
Methods inherited from class javax.swing.text.View
append, breakView, createFragment, forwardUpdateToView, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, remove, removeAll, updateChildren, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicTextFieldUI.I18nFieldView

BasicTextFieldUI.I18nFieldView(Element elem)
Method Detail

getFlowSpan

public int getFlowSpan(int index)
Fetch the constraining span to flow against for the given child index. There is no limit for a field since it scrolls, so this is implemented to return Integer.MAX_VALUE.

Overrides:
getFlowSpan in class ParagraphView
Parameters:
index - the index of the view being queried
Returns:
the constraining span for the given view at index

setJustification

protected void setJustification(int j)
Description copied from class: ParagraphView
Sets the type of justification.

Overrides:
setJustification in class ParagraphView
Parameters:
j - one of the following values:
  • StyleConstants.ALIGN_LEFT
  • StyleConstants.ALIGN_CENTER
  • StyleConstants.ALIGN_RIGHT

isLeftToRight

static boolean isLeftToRight(Component c)

adjustAllocation

Shape adjustAllocation(Shape a)
Adjusts the allocation given to the view to be a suitable allocation for a text field. If the view has been allocated more than the preferred span vertically, the allocation is changed to be centered vertically. Horizontally the view is adjusted according to the horizontal alignment property set on the associated JTextField (if that is the type of the hosting component).

Parameters:
a - the allocation given to the view, which may need to be adjusted.
Returns:
the allocation that the superclass should use.

updateVisibilityModel

void updateVisibilityModel()
Update the visibility model with the associated JTextField (if there is one) to reflect the current visibility as a result of changes to the document model. The bounded range properties are updated. If the view hasn't yet been shown the extent will be zero and we just set it to be full until determined otherwise.


paint

public void paint(Graphics g,
                  Shape a)
Renders using the given rendering surface and area on that surface. The view may need to do layout and create child views to enable itself to render into the given allocation.

Overrides:
paint in class ParagraphView
Parameters:
g - the rendering surface to use
a - the allocated region to render into
See Also:
View.paint(java.awt.Graphics, java.awt.Shape)

getResizeWeight

public int getResizeWeight(int axis)
Determines the resizability of the view along the given axis. A value of 0 or less is not resizable.

Overrides:
getResizeWeight in class BoxView
Parameters:
axis - View.X_AXIS or View.Y_AXIS
Returns:
the weight -> 1 for View.X_AXIS, else 0

modelToView

public Shape modelToView(int pos,
                         Shape a,
                         Position.Bias b)
                  throws BadLocationException
Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

Overrides:
modelToView in class BoxView
Parameters:
pos - the position to convert >= 0
a - the allocated region to render into
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)

modelToView

public Shape modelToView(int p0,
                         Position.Bias b0,
                         int p1,
                         Position.Bias b1,
                         Shape a)
                  throws BadLocationException
Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

Overrides:
modelToView in class CompositeView
Parameters:
p0 - the position to convert >= 0
b0 - the bias toward the previous character or the next character represented by p0, in case the position is a boundary of two views.
p1 - the position to convert >= 0
b1 - the bias toward the previous character or the next character represented by p1, in case the position is a boundary of two views.
a - the allocated region to render into
Returns:
the bounding box of the given position is returned
Throws:
BadLocationException - if the given position does not represent a valid location in the associated document
IllegalArgumentException - for an invalid bias argument
See Also:
View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])

viewToModel

public int viewToModel(float fx,
                       float fy,
                       Shape a,
                       Position.Bias[] bias)
Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Overrides:
viewToModel in class BoxView
Parameters:
fx - the X coordinate >= 0.0f
fy - the Y coordinate >= 0.0f
a - the allocated region to render into
Returns:
the location within the model that best represents the given point in the view
See Also:
View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])

insertUpdate

public void insertUpdate(DocumentEvent changes,
                         Shape a,
                         ViewFactory f)
Gives notification that something was inserted into the document in a location that this view is responsible for.

Overrides:
insertUpdate in class FlowView
Parameters:
changes - the change information from the associated document
a - the current allocation of the view
f - the factory to use to rebuild if the view has children
See Also:
View.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)

removeUpdate

public void removeUpdate(DocumentEvent changes,
                         Shape a,
                         ViewFactory f)
Gives notification that something was removed from the document in a location that this view is responsible for.

Overrides:
removeUpdate in class FlowView
Parameters:
changes - the change information from the associated document
a - the current allocation of the view
f - the factory to use to rebuild if the view has children
See Also:
View.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)