javax.swing.text
Class FieldView

java.lang.Object
  extended by javax.swing.text.View
      extended by javax.swing.text.PlainView
          extended by javax.swing.text.FieldView
All Implemented Interfaces:
SwingConstants, TabExpander
Direct Known Subclasses:
PasswordView

public class FieldView
extends PlainView


Field Summary
 
Fields inherited from class javax.swing.text.PlainView
metrics
 
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
FieldView(Element elem)
           
 
Method Summary
protected  Shape adjustAllocation(Shape shape)
          Vertically centers the single line of text within the bounds of the input shape.
 void changedUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
          This method is called when attributes were changed in the Document in a location that this view is responsible for.
protected  FontMetrics getFontMetrics()
           
 float getPreferredSpan(int axis)
          Returns the preferred span along the specified axis.
 int getResizeWeight(int axis)
          Returns the resize weight of this view.
 void insertUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
          This method is called when something is inserted into the Document that this View is displaying.
 Shape modelToView(int pos, Shape a, Position.Bias bias)
          Maps a position in the document into the coordinate space of the View.
 void paint(Graphics g, Shape s)
           
 void removeUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
          This method is called when something is removed from the Document that this View is displaying.
 int viewToModel(float fx, float fy, Shape a, Position.Bias[] bias)
          Maps coordinates from the View's space into a position in the document model.
 
Methods inherited from class javax.swing.text.PlainView
damageLineRange, drawLine, drawSelectedText, drawUnselectedText, getLineBuffer, getTabSize, lineToRect, nextTabStop, updateDamage, updateMetrics
 
Methods inherited from class javax.swing.text.View
append, breakView, createFragment, dump, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getNextVisualPositionFrom, getParent, getStartOffset, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, replace, setParent, setSize, updateChildren, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldView

public FieldView(Element elem)
Method Detail

getFontMetrics

protected FontMetrics getFontMetrics()

adjustAllocation

protected Shape adjustAllocation(Shape shape)
Vertically centers the single line of text within the bounds of the input shape. The returned Rectangle is centered vertically within shape and has a height of the preferred span along the Y axis. Horizontal adjustment is done according to the horizontalAligment property of the component that is rendered.

Parameters:
shape - the shape within which the line is beeing centered

getPreferredSpan

public float getPreferredSpan(int axis)
Description copied from class: View
Returns the preferred span along the specified axis. Normally the view is rendered with the span returned here if that is possible.

Overrides:
getPreferredSpan in class PlainView
Parameters:
axis - the axis
Returns:
the preferred span along the specified axis

getResizeWeight

public int getResizeWeight(int axis)
Description copied from class: View
Returns the resize weight of this view. A value of 0 or less means this view is not resizeable. Positive values make the view resizeable. The default implementation returns 0 unconditionally.

Overrides:
getResizeWeight in class View
Parameters:
axis - the axis
Returns:
the resizability of this view along the specified axis

modelToView

public Shape modelToView(int pos,
                         Shape a,
                         Position.Bias bias)
                  throws BadLocationException
Description copied from class: View
Maps a position in the document into the coordinate space of the View. The output rectangle usually reflects the font height but has a width of zero.

Overrides:
modelToView in class PlainView
Parameters:
pos - the position of the character in the model
a - the area that is occupied by the view
bias - either Position.Bias.Forward or Position.Bias.Backward depending on the preferred direction bias. If null this defaults to Position.Bias.Forward
Returns:
a rectangle that gives the location of the document position inside the view coordinate space
Throws:
BadLocationException - if pos is invalid

paint

public void paint(Graphics g,
                  Shape s)
Overrides:
paint in class PlainView

insertUpdate

public void insertUpdate(DocumentEvent ev,
                         Shape shape,
                         ViewFactory vf)
Description copied from class: PlainView
This method is called when something is inserted into the Document that this View is displaying.

Overrides:
insertUpdate in class PlainView
Parameters:
ev - the DocumentEvent for the changes.
shape - the allocation of the View
vf - the ViewFactory used to rebuild

removeUpdate

public void removeUpdate(DocumentEvent ev,
                         Shape shape,
                         ViewFactory vf)
Description copied from class: PlainView
This method is called when something is removed from the Document that this View is displaying.

Overrides:
removeUpdate in class PlainView
Parameters:
ev - the DocumentEvent for the changes.
shape - the allocation of the View
vf - the ViewFactory used to rebuild

changedUpdate

public void changedUpdate(DocumentEvent ev,
                          Shape shape,
                          ViewFactory vf)
Description copied from class: PlainView
This method is called when attributes were changed in the Document in a location that this view is responsible for.

Overrides:
changedUpdate in class PlainView
Parameters:
ev - the DocumentEvent that describes the change
shape - the shape of the view
vf - the ViewFactory for creating child views

viewToModel

public int viewToModel(float fx,
                       float fy,
                       Shape a,
                       Position.Bias[] bias)
Description copied from class: PlainView
Maps coordinates from the View's space into a position in the document model.

Overrides:
viewToModel in class PlainView
Parameters:
fx - the x coordinate in the view space
fy - the y coordinate in the view space
a - the allocation of this View
bias - the bias to use
Returns:
the position in the document that corresponds to the screen coordinates x, y