javax.swing.text.html

Class BlockView

public class BlockView extends BoxView

Constructor Summary
BlockView(Element elem, int axis)
Creates a new view that represents an html box.
Method Summary
protected SizeRequirementscalculateMajorAxisRequirements(int axis, SizeRequirements r)
Calculates the requirements along the major axis.
protected SizeRequirementscalculateMinorAxisRequirements(int axis, SizeRequirements r)
Calculates the requirements along the minor axis.
voidchangedUpdate(DocumentEvent ev, Shape a, ViewFactory f)
Gives notification from the document that attributes were changed in a location that this view is responsible for.
floatgetAlignment(int axis)
Gets the alignment.
AttributeSetgetAttributes()
Fetches the attributes to use when painting.
floatgetMaximumSpan(int axis)
Determines the maximum span along the axis.
floatgetMinimumSpan(int axis)
Determines the minimum span along the axis.
floatgetPreferredSpan(int axis)
Determines the preferred span along the axis.
intgetResizeWeight(int axis)
Gets the resize weight.
protected StyleSheetgetStyleSheet()
Gets the default style sheet.
protected voidlayoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
Overridden to perform additional CSS layout (absolute/relative positioning).
protected voidlayoutMinorAxis(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).
voidpaint(Graphics g, Shape a)
Paints using the given graphics configuration and shape.
voidreplace(int offset, int length, View[] views)
Overridden to fetch additional CSS layout information.
voidsetParent(View parent)
Creates the parent view for this.
protected voidsetPropertiesFromAttributes()
Updates any cached values that come from attributes.

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

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.

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.

Parameters: axis - the axis to check the requirements for. r - the SizeRequirements. If null, one is created.

Returns: the new SizeRequirements object.

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.

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

getAlignment

public float getAlignment(int axis)
Gets the alignment.

Parameters: axis - the axis to get the alignment for.

Returns: the alignment.

getAttributes

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

Returns: the attributes of this model.

getMaximumSpan

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

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

getMinimumSpan

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

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

getPreferredSpan

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

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

getResizeWeight

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

Parameters: axis - the axis to get the resize weight for.

Returns: the resize weight.

Throws: IllegalArgumentException - for an invalid axis

getStyleSheet

protected StyleSheet getStyleSheet()
Gets the default style sheet.

Returns: the style sheet

layoutMajorAxis

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

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.

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.

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.

Parameters: g - Graphics configuration a - the Shape to render into.

replace

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

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.

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

setPropertiesFromAttributes

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