APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing.text.html

pack-priv Class HRuleView

extends View
Class Inheritance
Imports
java.awt.*, javax.swing.event.DocumentEvent, javax.swing.text.*, java.util.Enumeration, java.lang.Integer

A view implementation to display an html horizontal rule.
Authors
Timothy Prinzing, Sara Swanson

Field Summary

Modifier and TypeField and Description
private int
private AttributeSet
attr

View Attributes.

private float
private float
private String
private float
private int
private static final int
private static final int
private float
private CSS.LengthValue
Inherited from javax.swing.text.View:
BadBreakWeightExcellentBreakWeightForcedBreakWeightGoodBreakWeightX_AXISY_AXIS

Constructor Summary

AccessConstructor and Description
public
HRuleView(Element
the element to create a view for
elem
)

Creates a new view that represents an <hr> element.

Method Summary

Modifier and TypeMethod and Description
public View
breakView(int axis, int offset, float pos, float len)

Overrides javax.swing.text.View.breakView.

Tries to break this view on the given axis.

public void
changedUpdate(DocumentEvent changes, Shape a, ViewFactory f)

Overrides javax.swing.text.View.changedUpdate.

Gives notification from the document that attributes were changed in a location that this view is responsible for.

public AttributeSet
getAttributes()

Overrides javax.swing.text.View.getAttributes.

Fetches the attributes to use when rendering.

public int

Returns:

the weight, which should be a value between ForcedBreakWeight and BadBreakWeight.
getBreakWeight
(int
may be either View.X_AXIS or View.Y_AXIS
axis
,
float
the potential location of the start of the broken view (greater than or equal to zero). This may be useful for calculating tab positions.
pos
,
float
specifies the relative length from pos where a potential break is desired. The value must be greater than or equal to zero.
len
)

Overrides javax.swing.text.View.getBreakWeight.

Determines how attractive a break opportunity in this view is.

private float
public float

Returns:

the desired span
getPreferredSpan
(int
may be either X_AXIS or Y_AXIS
axis
)

Implements abstract javax.swing.text.View.getPreferredSpan.

Calculates the desired shape of the rule...

public int

Returns:

the weight
getResizeWeight
(int
may be either X_AXIS or Y_AXIS
axis
)

Overrides javax.swing.text.View.getResizeWeight.

Gets the resize weight for the axis.

public Shape

Returns:

the bounding box of the given position
modelToView
(int
the position to convert
pos
,
Shape
the allocated region to render into
a
,
Position.Bias b)

Implements abstract javax.swing.text.View.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

public void
paint(Graphics
the graphics context
g
,
Shape
the allocation region for the view
a
)

Implements abstract javax.swing.text.View.paint.

Paints the view.

protected void
setPropertiesFromAttributes()

Update any cached values that come from attributes.

public int

Returns:

the location within the model that best represents the given point of view
viewToModel
(float
the X coordinate
x
,
float
the Y coordinate
y
,
Shape
the allocated region to render into
a
,
Position.Bias[] bias)

Implements abstract javax.swing.text.View.viewToModel.

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Inherited from javax.swing.text.View:
appendcreateFragmentforwardUpdateforwardUpdateToViewgetAlignmentgetChildAllocationgetContainergetDocumentgetElementgetEndOffsetgetGraphicsgetMaximumSpangetMinimumSpangetNextVisualPositionFromgetParentgetStartOffsetgetToolTipTextgetViewgetViewCountgetViewFactorygetViewIndexgetViewIndexinsertinsertUpdateisVisiblemodelToViewmodelToViewpreferenceChangedremoveremoveAllremoveUpdatereplacesetParentsetSizeupdateChildrenupdateLayoutviewToModel

Field Detail

alignmentback to summary
private int alignment
attrback to summary
private AttributeSet attr

View Attributes.

bottomMarginback to summary
private float bottomMargin
leftMarginback to summary
private float leftMargin
noshadeback to summary
private String noshade
rightMarginback to summary
private float rightMargin
sizeback to summary
private int size
SPACE_ABOVEback to summary
private static final int SPACE_ABOVE
SPACE_BELOWback to summary
private static final int SPACE_BELOW
topMarginback to summary
private float topMargin
widthValueback to summary
private CSS.LengthValue widthValue

Constructor Detail

HRuleViewback to summary
public HRuleView(Element elem)

Creates a new view that represents an <hr> element.

Parameters
elem:Element

the element to create a view for

Method Detail

breakViewback to summary
public View breakView(int axis, int offset, float pos, float len)

Overrides javax.swing.text.View.breakView.

Doc from javax.swing.text.View.breakView.

Tries to break this view on the given axis. This is called by views that try to do formatting of their children. For example, a view of a paragraph will typically try to place its children into row and views representing chunks of text can sometimes be broken down into smaller pieces.

This is implemented to return the view itself, which represents the default behavior on not being breakable. If the view does support breaking, the starting offset of the view returned should be the given offset, and the end offset should be less than or equal to the end offset of the view being broken.

changedUpdateback to summary
public void changedUpdate(DocumentEvent changes, Shape a, ViewFactory f)

Overrides javax.swing.text.View.changedUpdate.

Doc from javax.swing.text.View.changedUpdate.

Gives notification from the document that attributes were changed in a location that this view is responsible for. To reduce the burden to subclasses, this functionality is spread out into the following calls that subclasses can reimplement:

  1. updateChildren is called if there were any changes to the element this view is responsible for. If this view has child views that are represent the child elements, then this method should do whatever is necessary to make sure the child views correctly represent the model.
  2. forwardUpdate is called to forward the DocumentEvent to the appropriate child views.
  3. updateLayout is called to give the view a chance to either repair its layout, to reschedule layout, or do nothing.
getAttributesback to summary
public AttributeSet getAttributes()

Overrides javax.swing.text.View.getAttributes.

Fetches the attributes to use when rendering. This is implemented to multiplex the attributes specified in the model with a StyleSheet.

getBreakWeightback to summary
public int getBreakWeight(int axis, float pos, float len)

Overrides javax.swing.text.View.getBreakWeight.

Determines how attractive a break opportunity in this view is. This is implemented to request a forced break.

Parameters
axis:int

may be either View.X_AXIS or View.Y_AXIS

pos:float

the potential location of the start of the broken view (greater than or equal to zero). This may be useful for calculating tab positions.

len:float

specifies the relative length from pos where a potential break is desired. The value must be greater than or equal to zero.

Returns:int

the weight, which should be a value between ForcedBreakWeight and BadBreakWeight.

getLengthback to summary
private float getLength(CSS.Attribute key, AttributeSet a)
getPreferredSpanback to summary
public float getPreferredSpan(int axis)

Implements abstract javax.swing.text.View.getPreferredSpan.

Calculates the desired shape of the rule... this is basically the preferred size of the border.

Parameters
axis:int

may be either X_AXIS or Y_AXIS

Returns:float

the desired span

See Also
View#getPreferredSpan
getResizeWeightback to summary
public int getResizeWeight(int axis)

Overrides javax.swing.text.View.getResizeWeight.

Gets the resize weight for the axis. The rule is: rigid vertically and flexible horizontally.

Parameters
axis:int

may be either X_AXIS or Y_AXIS

Returns:int

the weight

modelToViewback to summary
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException

Implements abstract javax.swing.text.View.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

Parameters
pos:int

the position to convert

a:Shape

the allocated region to render into

Returns:Shape

the bounding box of the given position

Exceptions
BadLocationException:
if the given position does not represent a valid location in the associated document
See Also
View#modelToView
paintback to summary
public void paint(Graphics g, Shape a)

Implements abstract javax.swing.text.View.paint.

Paints the view.

Parameters
g:Graphics

the graphics context

a:Shape

the allocation region for the view

See Also
View#paint
setPropertiesFromAttributesback to summary
protected void setPropertiesFromAttributes()

Update any cached values that come from attributes.

viewToModelback to summary
public int viewToModel(float x, float y, Shape a, Position.Bias[] bias)

Implements abstract javax.swing.text.View.viewToModel.

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Parameters
x:float

the X coordinate

y:float

the Y coordinate

a:Shape

the allocated region to render into

Returns:int

the location within the model that best represents the given point of view

See Also
View#viewToModel