BlockView (Java 2 Platform SE 5.0) (original) (raw)
javax.swing.text.html
Class BlockView
java.lang.Object
javax.swing.text.View
javax.swing.text.CompositeView
javax.swing.text.BoxView
javax.swing.text.html.BlockView
All Implemented Interfaces:
Direct Known Subclasses:
public class BlockView
extends BoxView
A view implementation to display a block (as a box) with CSS specifications.
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](../../../../javax/swing/text/html/BlockView.html#BlockView%28javax.swing.text.Element, int%29)(Element elem, int axis) Creates a new view that represents an html box. |
Method Summary | |
---|---|
protected SizeRequirements | [calculateMajorAxisRequirements](../../../../javax/swing/text/html/BlockView.html#calculateMajorAxisRequirements%28int, javax.swing.SizeRequirements%29)(int axis,SizeRequirements r) Calculate the requirements of the block along the major axis (i.e. |
protected SizeRequirements | [calculateMinorAxisRequirements](../../../../javax/swing/text/html/BlockView.html#calculateMinorAxisRequirements%28int, javax.swing.SizeRequirements%29)(int axis,SizeRequirements r) Calculate the requirements of the block along the minor axis (i.e. |
void | [changedUpdate](../../../../javax/swing/text/html/BlockView.html#changedUpdate%28javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29)(DocumentEvent changes,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 rendering. |
float | getMaximumSpan(int axis) Determines the maximum span for this view along an axis. |
float | getMinimumSpan(int axis) Determines the minimum span for this view along an axis. |
float | getPreferredSpan(int axis) Determines the preferred span for this view along an axis. |
int | getResizeWeight(int axis) Gets the resize weight. |
protected StyleSheet | getStyleSheet() |
protected void | [layoutMinorAxis](../../../../javax/swing/text/html/BlockView.html#layoutMinorAxis%28int, int, int[], int[]%29)(int targetSpan, int axis, int[] offsets, int[] spans) Perform layout for the minor axis of the box (i.e. |
void | [paint](../../../../javax/swing/text/html/BlockView.html#paint%28java.awt.Graphics, java.awt.Shape%29)(Graphics g,Shape allocation) Renders using the given rendering surface and area on that surface. |
void | setParent(View parent) Establishes the parent view for this view. |
protected void | setPropertiesFromAttributes() Update any cached values that come from attributes. |
Methods inherited from class javax.swing.text.BoxView |
---|
[baselineLayout](../../../../javax/swing/text/BoxView.html#baselineLayout%28int, int, int[], int[]%29), [baselineRequirements](../../../../javax/swing/text/BoxView.html#baselineRequirements%28int, javax.swing.SizeRequirements%29), [childAllocation](../../../../javax/swing/text/BoxView.html#childAllocation%28int, java.awt.Rectangle%29), [flipEastAndWestAtEnds](../../../../javax/swing/text/BoxView.html#flipEastAndWestAtEnds%28int, javax.swing.text.Position.Bias%29), [forwardUpdate](../../../../javax/swing/text/BoxView.html#forwardUpdate%28javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29), getAxis, [getChildAllocation](../../../../javax/swing/text/BoxView.html#getChildAllocation%28int, java.awt.Shape%29), getHeight, [getOffset](../../../../javax/swing/text/BoxView.html#getOffset%28int, int%29), [getSpan](../../../../javax/swing/text/BoxView.html#getSpan%28int, int%29), [getViewAtPoint](../../../../javax/swing/text/BoxView.html#getViewAtPoint%28int, int, java.awt.Rectangle%29), getWidth, [isAfter](../../../../javax/swing/text/BoxView.html#isAfter%28int, int, java.awt.Rectangle%29), isAllocationValid, [isBefore](../../../../javax/swing/text/BoxView.html#isBefore%28int, int, java.awt.Rectangle%29), isLayoutValid, [layout](../../../../javax/swing/text/BoxView.html#layout%28int, int%29), layoutChanged, [layoutMajorAxis](../../../../javax/swing/text/BoxView.html#layoutMajorAxis%28int, int, int[], int[]%29), [modelToView](../../../../javax/swing/text/BoxView.html#modelToView%28int, java.awt.Shape, javax.swing.text.Position.Bias%29), [paintChild](../../../../javax/swing/text/BoxView.html#paintChild%28java.awt.Graphics, java.awt.Rectangle, int%29), [preferenceChanged](../../../../javax/swing/text/BoxView.html#preferenceChanged%28javax.swing.text.View, boolean, boolean%29), [replace](../../../../javax/swing/text/BoxView.html#replace%28int, int, javax.swing.text.View[]%29), setAxis, [setSize](../../../../javax/swing/text/BoxView.html#setSize%28float, float%29), [viewToModel](../../../../javax/swing/text/BoxView.html#viewToModel%28float, float, java.awt.Shape, javax.swing.text.Position.Bias[]%29) |
Methods inherited from class javax.swing.text.CompositeView |
---|
getBottomInset, getInsideAllocation, getLeftInset, [getNextEastWestVisualPositionFrom](../../../../javax/swing/text/CompositeView.html#getNextEastWestVisualPositionFrom%28int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[]%29), [getNextNorthSouthVisualPositionFrom](../../../../javax/swing/text/CompositeView.html#getNextNorthSouthVisualPositionFrom%28int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[]%29), [getNextVisualPositionFrom](../../../../javax/swing/text/CompositeView.html#getNextVisualPositionFrom%28int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[]%29), getRightInset, getTopInset, getView, [getViewAtPosition](../../../../javax/swing/text/CompositeView.html#getViewAtPosition%28int, java.awt.Rectangle%29), getViewCount, [getViewIndex](../../../../javax/swing/text/CompositeView.html#getViewIndex%28int, javax.swing.text.Position.Bias%29), getViewIndexAtPosition, loadChildren, [modelToView](../../../../javax/swing/text/CompositeView.html#modelToView%28int, javax.swing.text.Position.Bias, int, javax.swing.text.Position.Bias, java.awt.Shape%29), [setInsets](../../../../javax/swing/text/CompositeView.html#setInsets%28short, short, short, short%29), setParagraphInsets |
Methods inherited from class javax.swing.text.View |
---|
append, [breakView](../../../../javax/swing/text/View.html#breakView%28int, int, float, float%29), [createFragment](../../../../javax/swing/text/View.html#createFragment%28int, int%29), [forwardUpdateToView](../../../../javax/swing/text/View.html#forwardUpdateToView%28javax.swing.text.View, javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29), [getBreakWeight](../../../../javax/swing/text/View.html#getBreakWeight%28int, float, float%29), getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, [getToolTipText](../../../../javax/swing/text/View.html#getToolTipText%28float, float, java.awt.Shape%29), getViewFactory, [getViewIndex](../../../../javax/swing/text/View.html#getViewIndex%28float, float, java.awt.Shape%29), [insert](../../../../javax/swing/text/View.html#insert%28int, javax.swing.text.View%29), [insertUpdate](../../../../javax/swing/text/View.html#insertUpdate%28javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29), isVisible, [modelToView](../../../../javax/swing/text/View.html#modelToView%28int, java.awt.Shape%29), remove, removeAll, [removeUpdate](../../../../javax/swing/text/View.html#removeUpdate%28javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29), [updateChildren](../../../../javax/swing/text/View.html#updateChildren%28javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, javax.swing.text.ViewFactory%29), [updateLayout](../../../../javax/swing/text/View.html#updateLayout%28javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, java.awt.Shape%29), [viewToModel](../../../../javax/swing/text/View.html#viewToModel%28float, float, java.awt.Shape%29) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, [wait](../../../../java/lang/Object.html#wait%28long, int%29) |
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)
Establishes the parent view for this view. This is guaranteed to be called before any other methods if the parent view is functioning properly.
This is implemented to forward to the superclass as well as call thesetPropertiesFromAttributes() method to set the paragraph properties from the css attributes. The call is made at this time to ensure the ability to resolve upward through the parents view attributes.
Overrides:
[setParent](../../../../javax/swing/text/CompositeView.html#setParent%28javax.swing.text.View%29)
in class [CompositeView](../../../../javax/swing/text/CompositeView.html "class in javax.swing.text")
Parameters:
parent
- the new parent, or null if the view is being removed from a parent it was previously added to
calculateMajorAxisRequirements
protected SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements r)
Calculate the requirements of the block along the major axis (i.e. the axis along with it tiles). This is implemented to provide the superclass behavior and then adjust it if the CSS width or height attribute is specified and applicable to the axis.
Overrides:
[calculateMajorAxisRequirements](../../../../javax/swing/text/BoxView.html#calculateMajorAxisRequirements%28int, javax.swing.SizeRequirements%29)
in class [BoxView](../../../../javax/swing/text/BoxView.html "class in javax.swing.text")
Parameters:
axis
- the axis being studied
r
- the SizeRequirements
object; if null
one will be created
Returns:
the newly initialized SizeRequirements
object
See Also:
calculateMinorAxisRequirements
protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r)
Calculate the requirements of the block along the minor axis (i.e. the axis orthoginal to the axis along with it tiles). This is implemented to provide the superclass behavior and then adjust it if the CSS width or height attribute is specified and applicable to the axis.
Overrides:
[calculateMinorAxisRequirements](../../../../javax/swing/text/BoxView.html#calculateMinorAxisRequirements%28int, javax.swing.SizeRequirements%29)
in class [BoxView](../../../../javax/swing/text/BoxView.html "class in javax.swing.text")
Parameters:
axis
- the axis being studied
r
- the SizeRequirements
object; if null
one will be created
Returns:
the newly initialized SizeRequirements
object
See Also:
layoutMinorAxis
protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
Perform layout for the minor axis of the box (i.e. the axis orthoginal to the axis that it represents). The results of the layout should be placed in the given arrays which represent the allocations to the children along the minor axis.
Overrides:
[layoutMinorAxis](../../../../javax/swing/text/BoxView.html#layoutMinorAxis%28int, int, int[], int[]%29)
in class [BoxView](../../../../javax/swing/text/BoxView.html "class in javax.swing.text")
Parameters:
targetSpan
- the total span given to the view, which whould be used to layout the childre.
axis
- the axis being layed out
offsets
- the offsets from the origin of the view for each of the child views; this is a return value and is filled in by the implementation of this method
spans
- the span of each child view; this is a return value and is filled in by the implementation of this method
paint
public void paint(Graphics g, Shape allocation)
Renders using the given rendering surface and area on that surface. This is implemented to delegate to the css box painter to paint the border and background prior to the interior.
Overrides:
[paint](../../../../javax/swing/text/BoxView.html#paint%28java.awt.Graphics, java.awt.Shape%29)
in class [BoxView](../../../../javax/swing/text/BoxView.html "class in javax.swing.text")
Parameters:
g
- the rendering surface to use
allocation
- the allocated region to render into
See Also:
[View.paint(java.awt.Graphics, java.awt.Shape)](../../../../javax/swing/text/View.html#paint%28java.awt.Graphics, java.awt.Shape%29)
getAttributes
public AttributeSet getAttributes()
Fetches the attributes to use when rendering. This is implemented to multiplex the attributes specified in the model with a StyleSheet.
Overrides:
[getAttributes](../../../../javax/swing/text/View.html#getAttributes%28%29)
in class [View](../../../../javax/swing/text/View.html "class in javax.swing.text")
getResizeWeight
public int getResizeWeight(int axis)
Gets the resize weight.
Overrides:
[getResizeWeight](../../../../javax/swing/text/BoxView.html#getResizeWeight%28int%29)
in class [BoxView](../../../../javax/swing/text/BoxView.html "class in javax.swing.text")
Parameters:
axis
- may be either X_AXIS or Y_AXIS
Returns:
the weight
Throws:
[IllegalArgumentException](../../../../java/lang/IllegalArgumentException.html "class in java.lang")
- for an invalid axis
getAlignment
public float getAlignment(int axis)
Gets the alignment.
Overrides:
[getAlignment](../../../../javax/swing/text/BoxView.html#getAlignment%28int%29)
in class [BoxView](../../../../javax/swing/text/BoxView.html "class in javax.swing.text")
Parameters:
axis
- may be either X_AXIS or Y_AXIS
Returns:
the alignment
changedUpdate
public void changedUpdate(DocumentEvent changes, Shape a, ViewFactory f)
Description copied from class: [View](../../../../javax/swing/text/View.html#changedUpdate%28javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29)
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:
- 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.
- forwardUpdate is called to forward the DocumentEvent to the appropriate child views.
- updateLayout is called to give the view a chance to either repair its layout, to reschedule layout, or do nothing.
Overrides:
[changedUpdate](../../../../javax/swing/text/View.html#changedUpdate%28javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29)
in class [View](../../../../javax/swing/text/View.html "class in javax.swing.text")
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.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)](../../../../javax/swing/text/View.html#changedUpdate%28javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29)
getPreferredSpan
public float getPreferredSpan(int axis)
Determines the preferred span for this view along an axis.
Overrides:
[getPreferredSpan](../../../../javax/swing/text/BoxView.html#getPreferredSpan%28int%29)
in class [BoxView](../../../../javax/swing/text/BoxView.html "class in javax.swing.text")
Parameters:
axis
- may be either View.X_AXIS
or View.Y_AXIS
Returns:
the span the view would like to be rendered into >= 0; typically the view is told to render into the span that is returned, although there is no guarantee; the parent may choose to resize or break the view
Throws:
[IllegalArgumentException](../../../../java/lang/IllegalArgumentException.html "class in java.lang")
- for an invalid axis type
See Also:
getMinimumSpan
public float getMinimumSpan(int axis)
Determines the minimum span for this view along an axis.
Overrides:
[getMinimumSpan](../../../../javax/swing/text/BoxView.html#getMinimumSpan%28int%29)
in class [BoxView](../../../../javax/swing/text/BoxView.html "class in javax.swing.text")
Parameters:
axis
- may be either View.X_AXIS
or View.Y_AXIS
Returns:
the span the view would like to be rendered into >= 0; typically the view is told to render into the span that is returned, although there is no guarantee; the parent may choose to resize or break the view
Throws:
[IllegalArgumentException](../../../../java/lang/IllegalArgumentException.html "class in java.lang")
- for an invalid axis type
See Also:
getMaximumSpan
public float getMaximumSpan(int axis)
Determines the maximum span for this view along an axis.
Overrides:
[getMaximumSpan](../../../../javax/swing/text/BoxView.html#getMaximumSpan%28int%29)
in class [BoxView](../../../../javax/swing/text/BoxView.html "class in javax.swing.text")
Parameters:
axis
- may be either View.X_AXIS
or View.Y_AXIS
Returns:
the span the view would like to be rendered into >= 0; typically the view is told to render into the span that is returned, although there is no guarantee; the parent may choose to resize or break the view
Throws:
[IllegalArgumentException](../../../../java/lang/IllegalArgumentException.html "class in java.lang")
- for an invalid axis type
See Also:
setPropertiesFromAttributes
protected void setPropertiesFromAttributes()
Update any cached values that come from attributes.
getStyleSheet
protected StyleSheet getStyleSheet()
Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.