javax.swing.text.html
Class BlockView

java.lang.Object
  extended by javax.swing.text.View
      extended by javax.swing.text.CompositeView
          extended by javax.swing.text.BoxView
              extended by javax.swing.text.html.BlockView
All Implemented Interfaces:
SwingConstants
Direct Known Subclasses:
ListView

public class BlockView
extends BoxView


Field Summary
 
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
BlockView(Element elem, int axis)
          Creates a new view that represents an html box.
 
Method Summary
protected  SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements r)
          Calculates the requirements along the major axis.
protected  SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r)
          Calculates the requirements along the minor axis.
 void changedUpdate(DocumentEvent ev, Shape a, ViewFactory f)
          Gives notification from the document that attributes were changed in a location that this view is responsible for.
 float getAlignment(int axis)
          Gets the alignment.
 AttributeSet getAttributes()
          Fetches the attributes to use when painting.
 float getMaximumSpan(int axis)
          Determines the maximum span along the axis.
 float getMinimumSpan(int axis)
          Determines the minimum span along the axis.
 float getPreferredSpan(int axis)
          Determines the preferred span along the axis.
 int getResizeWeight(int axis)
          Gets the resize weight.
protected  StyleSheet getStyleSheet()
          Gets the default style sheet.
protected  void layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
          Overridden to perform additional CSS layout (absolute/relative positioning).
protected  void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
          Lays out the box along the minor axis (the axis that is perpendicular to the axis that it represents).
 void paint(Graphics g, Shape a)
          Paints using the given graphics configuration and shape.
 void replace(int offset, int length, View[] views)
          Overridden to fetch additional CSS layout information.
 void setParent(View parent)
          Creates the parent view for this.
protected  void setPropertiesFromAttributes()
          Updates any cached values that come from attributes.
 
Methods inherited from class javax.swing.text.BoxView
baselineLayout, baselineRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAxis, getChildAllocation, getHeight, getOffset, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, modelToView, paintChild, preferenceChanged, setAxis, setSize, viewToModel
 
Methods inherited from class javax.swing.text.CompositeView
getBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, getViewIndexAtPosition, loadChildren, modelToView, setInsets, setParagraphInsets
 
Methods inherited from class javax.swing.text.View
append, breakView, createFragment, dump, forwardUpdateToView, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, insertUpdate, isVisible, modelToView, remove, removeAll, removeUpdate, updateChildren, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockView

public BlockView(Element elem,
                 int axis)
Creates a new view that represents an html box. This can be used for a number of elements.

Parameters:
elem - - the element to create a view for
axis - - either View.X_AXIS or View.Y_AXIS
Method Detail

setParent

public void setParent(View parent)
Creates the parent view for this. It is called before any other methods, if the parent view is working properly. Implemented to forward to the superclass and call setPropertiesFromAttributes to set the paragraph properties.

Overrides:
setParent in class CompositeView
Parameters:
parent - - the new parent, or null if the view is being removed from a parent it was added to.

calculateMajorAxisRequirements

protected SizeRequirements calculateMajorAxisRequirements(int axis,
                                                          SizeRequirements r)
Calculates the requirements along the major axis. This is implemented to call the superclass and then adjust it if the CSS width or height attribute is specified and applicable.

Overrides:
calculateMajorAxisRequirements in class BoxView
Parameters:
axis - - the axis to check the requirements for.
r - - the SizeRequirements. If null, one is created.
Returns:
the new SizeRequirements object.

calculateMinorAxisRequirements

protected SizeRequirements calculateMinorAxisRequirements(int axis,
                                                          SizeRequirements r)
Calculates the requirements along the minor axis. This is implemented to call the superclass and then adjust it if the CSS width or height attribute is specified and applicable.

Overrides:
calculateMinorAxisRequirements in class BoxView
Parameters:
axis - - the axis to check the requirements for.
r - - the SizeRequirements. If null, one is created.
Returns:
the new SizeRequirements object.

layoutMinorAxis

protected void layoutMinorAxis(int targetSpan,
                               int axis,
                               int[] offsets,
                               int[] spans)
Lays out the box along the minor axis (the axis that is perpendicular to the axis that it represents). The results of the layout are placed in the given arrays which are the allocations to the children along the minor axis.

Overrides:
layoutMinorAxis in class BoxView
Parameters:
targetSpan - - the total span given to the view, also used to layout the children.
axis - - the minor axis
offsets - - the offsets from the origin of the view for all the child views. This is a return value and is filled in by this function.
spans - - the span of each child view. This is a return value and is filled in by this function.

layoutMajorAxis

protected void layoutMajorAxis(int targetSpan,
                               int axis,
                               int[] offsets,
                               int[] spans)
Overridden to perform additional CSS layout (absolute/relative positioning).

Overrides:
layoutMajorAxis in class BoxView
Parameters:
targetSpan - the (inner) span of the BoxView in which to layout the children
axis - the axis along which the layout is performed
offsets - the array that holds the offsets of the children on exit
spans - the array that holds the spans of the children on exit

paint

public void paint(Graphics g,
                  Shape a)
Paints using the given graphics configuration and shape. This delegates to the css box painter to paint the border and background prior to the interior.

Overrides:
paint in class BoxView
Parameters:
g - - Graphics configuration
a - - the Shape to render into.

getAttributes

public AttributeSet getAttributes()
Fetches the attributes to use when painting.

Overrides:
getAttributes in class View
Returns:
the attributes of this model.

getResizeWeight

public int getResizeWeight(int axis)
                    throws IllegalArgumentException
Gets the resize weight.

Overrides:
getResizeWeight in class BoxView
Parameters:
axis - - the axis to get the resize weight for.
Returns:
the resize weight.
Throws:
IllegalArgumentException - - for an invalid axis

getAlignment

public float getAlignment(int axis)
Gets the alignment.

Overrides:
getAlignment in class BoxView
Parameters:
axis - - the axis to get the alignment for.
Returns:
the alignment.

changedUpdate

public void changedUpdate(DocumentEvent ev,
                          Shape a,
                          ViewFactory f)
Gives notification from the document that attributes were changed in a location that this view is responsible for.

Overrides:
changedUpdate in class View
Parameters:
ev - - the change information
a - - the current shape of the view
f - - the factory to use to rebuild if the view has children.

getPreferredSpan

public float getPreferredSpan(int axis)
                       throws IllegalArgumentException
Determines the preferred span along the axis.

Overrides:
getPreferredSpan in class BoxView
Parameters:
axis - - the view to get the preferred span for.
Returns:
the span the view would like to be painted into >=0/ The view is usually told to paint into the span that is returned, although the parent may choose to resize or break the view.
Throws:
IllegalArgumentException - - for an invalid axis

getMinimumSpan

public float getMinimumSpan(int axis)
                     throws IllegalArgumentException
Determines the minimum span along the axis.

Overrides:
getMinimumSpan in class BoxView
Parameters:
axis - - the axis to get the minimum span for.
Returns:
the span the view would like to be painted into >=0/ The view is usually told to paint into the span that is returned, although the parent may choose to resize or break the view.
Throws:
IllegalArgumentException - - for an invalid axis

getMaximumSpan

public float getMaximumSpan(int axis)
                     throws IllegalArgumentException
Determines the maximum span along the axis.

Overrides:
getMaximumSpan in class BoxView
Parameters:
axis - - the axis to get the maximum span for.
Returns:
the span the view would like to be painted into >=0/ The view is usually told to paint into the span that is returned, although the parent may choose to resize or break the view.
Throws:
IllegalArgumentException - - for an invalid axis

setPropertiesFromAttributes

protected void setPropertiesFromAttributes()
Updates any cached values that come from attributes.


getStyleSheet

protected StyleSheet getStyleSheet()
Gets the default style sheet.

Returns:
the style sheet

replace

public void replace(int offset,
                    int length,
                    View[] views)
Overridden to fetch additional CSS layout information.

Overrides:
replace in class BoxView
Parameters:
offset - the start offset from where to remove children
length - the number of children to remove
views - the views that replace the removed children