javax.swing.text.html

Class BlockView

Implemented Interfaces:
SwingConstants
Known Direct 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, calculateMajorAxisRequirements, calculateMinorAxisRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAlignment, getAxis, getChildAllocation, getHeight, getMaximumSpan, getMinimumSpan, getOffset, getPreferredSpan, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, layoutMajorAxis, layoutMinorAxis, modelToView, paint, paintChild, preferenceChanged, replace, setAxis, setSize, viewToModel

Methods inherited from class javax.swing.text.CompositeView

childAllocation, flipEastAndWestAtEnds, getBottomInset, getChildAllocation, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPoint, getViewAtPosition, getViewCount, getViewIndex, getViewIndexAtPosition, isAfter, isBefore, loadChildren, modelToView, modelToView, replace, setInsets, setParagraphInsets, setParent, viewToModel

Methods inherited from class javax.swing.text.View

append, breakView, changedUpdate, createFragment, dump, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getNextVisualPositionFrom, getParent, getPreferredSpan, getResizeWeight, getStartOffset, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, insertUpdate, isVisible, modelToView, modelToView, modelToView, paint, preferenceChanged, remove, removeAll, removeUpdate, replace, setParent, setSize, updateChildren, updateLayout, viewToModel, viewToModel

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

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 Details

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 interface 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 interface BoxView
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.
Overrides:
changedUpdate in interface 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.

getAlignment

public float getAlignment(int axis)
Gets the alignment.
Overrides:
getAlignment in interface BoxView
Parameters:
axis - - the axis to get the alignment for.
Returns:
the alignment.

getAttributes

public AttributeSet getAttributes()
Fetches the attributes to use when painting.
Overrides:
getAttributes in interface View
Returns:
the attributes of this model.

getMaximumSpan

public float getMaximumSpan(int axis)
            throws IllegalArgumentException
Determines the maximum span along the axis.
Overrides:
getMaximumSpan in interface 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

getMinimumSpan

public float getMinimumSpan(int axis)
            throws IllegalArgumentException
Determines the minimum span along the axis.
Overrides:
getMinimumSpan in interface 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

getPreferredSpan

public float getPreferredSpan(int axis)
            throws IllegalArgumentException
Determines the preferred span along the axis.
Overrides:
getPreferredSpan in interface 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

getResizeWeight

public int getResizeWeight(int axis)
            throws IllegalArgumentException
Gets the resize weight.
Overrides:
getResizeWeight in interface BoxView
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).
Overrides:
layoutMajorAxis in interface BoxView

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 interface 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.

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 interface BoxView
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.
Overrides:
replace in interface BoxView

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 interface CompositeView
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.

BlockView.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.