/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A view implementation to display a block (as a box)
* with CSS specifications.
*
* @author Timothy Prinzing
*/
/**
* Creates a new view that represents an
* html box. This can be used for a number
* of elements.
*
* @param elem the element to create a view for
* @param axis either View.X_AXIS or View.Y_AXIS
*/
}
/**
* Establishes the parent view for this view. This is
* guaranteed to be called before any other methods if the
* parent view is functioning properly.
* <p>
* This is implemented
* to forward to the superclass as well as call the
* {@link #setPropertiesFromAttributes()}
* 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.
*
* @param parent the new parent, or null if the view is
* being removed from a parent it was previously added
* to
*/
}
}
/**
* 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.
*/
if (r == null) {
r = new SizeRequirements();
}
r = super.calculateMajorAxisRequirements(axis, r);
}
else {
// right value.
getTopInset() + getBottomInset();
}
return 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.
*/
if (r == null) {
r = new SizeRequirements();
}
/*
* The requirements were not directly specified by attributes, so
* compute the aggregate of the requirements of the children. The
* children that have a percentage value specified will be treated
* as completely stretchable since that child is not limited in any
* way.
*/
/*
int min = 0;
long pref = 0;
int max = 0;
int n = getViewCount();
for (int i = 0; i < n; i++) {
View v = getView(i);
min = Math.max((int) v.getMinimumSpan(axis), min);
pref = Math.max((int) v.getPreferredSpan(axis), pref);
if (
max = Math.max((int) v.getMaximumSpan(axis), max);
}
r.preferred = (int) pref;
r.minimum = min;
r.maximum = max;
*/
r = super.calculateMinorAxisRequirements(axis, r);
}
else {
// right value.
getTopInset() + getBottomInset();
}
/*
* Set the alignment based upon the CSS properties if it is
* specified. For X_AXIS this would be text-align, for
* Y_AXIS this would be vertical-align.
*/
if (o != null) {
r.alignment = 0.5f;
r.alignment = 1.0f;
} else {
r.alignment = 0.0f;
}
}
}
// Y_AXIS TBD
return r;
}
return cssWidth.isPercentage();
}
} else {
return cssHeight.isPercentage();
}
}
return false;
}
/**
* Adjust the given requirements to the CSS width or height if
* it is specified along the applicable axis. Return true if the
* size is exactly specified, false if the span is not specified
* in an attribute or the size specified is a percentage.
*/
return true;
}
} else {
return true;
}
}
return false;
}
/**
* Performs layout for the minor axis of the box (i.e. the
* axis orthoginal to the axis that it represents). The results
* of the layout (the offset and span for each children) are
* placed in the given arrays which represent the allocations to
* the children along the minor axis.
*
* @param targetSpan the total span given to the view, which
* whould be used to layout the childre.
* @param axis the axis being layed out
* @param 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
* @param spans the span of each child view; this is a return
* value and is filled in by the implementation of this method
*/
int n = getViewCount();
for (int i = 0; i < n; i++) {
int max;
// check for percentage span
AttributeSet a = v.getAttributes();
// bound the span to the percentage specified
} else {
}
// assign the offset and span for the child
if (max < targetSpan) {
// can't make the child this wide, align it
} else {
// make it the target width, or as small as it can get.
offsets[i] = 0;
}
}
}
/**
* 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.
*
* @param g the rendering surface to use
* @param allocation the allocated region to render into
* @see View#paint
*/
super.paint(g, a);
}
/**
* Fetches the attributes to use when rendering. This is
* implemented to multiplex the attributes specified in the
* model with a StyleSheet.
*/
}
return attr;
}
/**
* Gets the resize weight.
*
* @param axis may be either X_AXIS or Y_AXIS
* @return the weight
* @exception IllegalArgumentException for an invalid axis
*/
switch (axis) {
return 1;
return 0;
default:
}
}
/**
* Gets the alignment.
*
* @param axis may be either X_AXIS or Y_AXIS
* @return the alignment
*/
switch (axis) {
return 0;
if (getViewCount() == 0) {
return 0;
}
return a;
default:
}
}
super.changedUpdate(changes, a, f);
getEndOffset()) {
}
}
/**
* Determines the preferred span for this view along an
* axis.
*
* @param axis may be either <code>View.X_AXIS</code>
* or <code>View.Y_AXIS</code>
* @return 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
* @exception IllegalArgumentException for an invalid axis type
*/
return super.getPreferredSpan(axis);
}
/**
* Determines the minimum span for this view along an
* axis.
*
* @param axis may be either <code>View.X_AXIS</code>
* or <code>View.Y_AXIS</code>
* @return 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
* @exception IllegalArgumentException for an invalid axis type
*/
return super.getMinimumSpan(axis);
}
/**
* Determines the maximum span for this view along an
* axis.
*
* @param axis may be either <code>View.X_AXIS</code>
* or <code>View.Y_AXIS</code>
* @return 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
* @exception IllegalArgumentException for an invalid axis type
*/
return super.getMaximumSpan(axis);
}
/**
* Update any cached values that come from attributes.
*/
protected void setPropertiesFromAttributes() {
// update attributes
// Reset the painter
}
}
return doc.getStyleSheet();
}
/**
* Constrains <code>want</code> to fit in the minimum size specified
* by <code>min</code>.
*/
}
}
}