2362N/A * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A View that tries to flow it's children into some 0N/A * partially constrained space. This can be used to 0N/A * build things like paragraphs, pages, etc. The 0N/A * flow is made up of the following pieces of functionality. 0N/A * <li>A logical set of child views, which as used as a 0N/A * layout pool from which a physical view is formed. 0N/A * <li>A strategy for translating the logical view to 0N/A * a physical (flowed) view. 0N/A * <li>Constraints for the strategy to work against. 0N/A * <li>A physical structure, that represents the flow. 0N/A * The children of this view are where the pieces of 0N/A * of the logical views are placed to create the flow. 0N/A * @author Timothy Prinzing 0N/A * Constructs a FlowView for the given element. 0N/A * @param elem the element that this view is responsible for 0N/A * @param axis may be either View.X_AXIS or View.Y_AXIS 0N/A * Fetches the axis along which views should be 0N/A * flowed. By default, this will be the axis 0N/A * orthogonal to the axis along which the flow 0N/A * rows are tiled (the axis of the default flow 0N/A * rows themselves). This is typically used 0N/A * by the <code>FlowStrategy</code>. 0N/A * Fetch the constraining span to flow against for 0N/A * the given child index. This is called by the 0N/A * FlowStrategy while it is updating the flow. 0N/A * A flow can be shaped by providing different values 0N/A * for the row constraints. By default, the entire 0N/A * span inside of the insets along the flow axis 0N/A * @param index the index of the row being updated. 0N/A * This should be a value >= 0 and < getViewCount(). 0N/A * @see #getFlowStart 0N/A * Fetch the location along the flow axis that the 0N/A * flow span will start at. This is called by the 0N/A * FlowStrategy while it is updating the flow. 0N/A * A flow can be shaped by providing different values 0N/A * for the row constraints. 0N/A * @param index the index of the row being updated. 0N/A * This should be a value >= 0 and < getViewCount(). 0N/A * Create a View that should be used to hold a 0N/A * a rows worth of children in a flow. This is 0N/A * called by the FlowStrategy when new children 0N/A * are added or removed (i.e. rows are added or 0N/A * removed) in the process of updating the flow. 0N/A // ---- BoxView methods ------------------------------------- 0N/A * Loads all of the children to initialize the view. 0N/A * This is called by the <code>setParent</code> method. 0N/A * This is reimplemented to not load any children directly 0N/A * (as they are created in the process of formatting). 0N/A * If the layoutPool variable is null, an instance of 0N/A * LogicalView is created to represent the logical view 0N/A * that is used in the process of formatting. 0N/A * @param f the view factory 0N/A // This synthetic insertUpdate call gives the strategy a chance 0N/A * Fetches the child view index representing the given position in 0N/A * @param pos the position >= 0 0N/A * @return index of the view representing the given position, or 0N/A * -1 if no view represents that position 0N/A * Lays out the children. If the span along the flow 0N/A * axis has changed, layout is marked as invalid which 0N/A * which will cause the superclass behavior to recalculate 0N/A * the layout along the box axis. The FlowStrategy.layout 0N/A * method will be called to rebuild the flow rows as 0N/A * appropriate. If the height of this view changes 0N/A * (determined by the perferred size along the box axis), 0N/A * a preferenceChanged is called. Following all of that, 0N/A * the normal box layout of the superclass is performed. 0N/A * @param width the width to lay out against >= 0. This is 0N/A * the width inside of the inset area. 0N/A * @param height the height to lay out against >= 0 This 0N/A * is the height inside of the inset area. 0N/A // repair the flow if necessary 0N/A // PENDING(shannonh) 0N/A // Temporary fix for 4250847 0N/A // Can be removed when TraversalContext is added 0N/A //nb idk 12/12/2001 host should not be equal to null. We need to add assertion here 0N/A * Calculate equirements along the minor axis. This 0N/A * is implemented to forward the request to the logical 0N/A * view by calling getMinimumSpan, getPreferredSpan, and 0N/A * getMaximumSpan on it. 0N/A // Don't include insets, Box.getXXXSpan will include them. 0N/A // ---- View methods ---------------------------------------------------- 0N/A * Gives notification that something was inserted into the document 0N/A * in a location that this view is responsible for. 0N/A * @param changes the change information from the associated document 0N/A * @param a the current allocation of the view 0N/A * @param f the factory to use to rebuild if the view has children 0N/A * @see View#insertUpdate 0N/A * Gives notification that something was removed from the document 0N/A * in a location that this view is responsible for. 0N/A * @param changes the change information from the associated document 0N/A * @param a the current allocation of the view 0N/A * @param f the factory to use to rebuild if the view has children 0N/A * @see View#removeUpdate 0N/A * Gives notification from the document that attributes were changed 0N/A * in a location that this view is responsible for. 0N/A * @param changes the change information from the associated document 0N/A * @param a the current allocation of the view 0N/A * @param f the factory to use to rebuild if the view has children 0N/A * @see View#changedUpdate 0N/A /** {@inheritDoc} */ 0N/A // --- variables ----------------------------------------------- 0N/A * Default constraint against which the flow is 0N/A * These are the views that represent the child elements 0N/A * of the element this view represents (The logical view 0N/A * to translate to a physical view). These are not 0N/A * directly children of this view. These are either 0N/A * placed into the rows directly or used for the purpose 0N/A * of breaking into smaller chunks, to form the physical 0N/A * The behavior for keeping the flow updated. By 0N/A * default this is a singleton shared by all instances 0N/A * of FlowView (FlowStrategy is stateless). Subclasses 0N/A * can create an alternative strategy, which might keep 0N/A * Strategy for maintaining the physical form 0N/A * of the flow. The default implementation is 0N/A * completely stateless, and recalculates the 0N/A * entire flow if the layout is invalid on the 0N/A * given FlowView. Alternative strategies can 0N/A * be implemented by subclassing, and might 0N/A * perform incrementatal repair to the layout 0N/A * or alternative breaking behavior. 339N/A // shouldn't happen since offset is inside view bounds 0N/A * Gives notification that something was inserted into the document 0N/A * in a location that the given flow view is responsible for. The 0N/A * strategy should update the appropriate changed region (which 0N/A * depends upon the strategy used for repair). 0N/A * @param e the change information from the associated document 0N/A * @param alloc the current allocation of the view inside of the insets. 0N/A * This value will be null if the view has not yet been displayed. 0N/A * @see View#insertUpdate 0N/A // FlowView.loadChildren() makes a synthetic call into this, 0N/A // passing null as e 0N/A * Gives notification that something was removed from the document 0N/A * in a location that the given flow view is responsible for. 0N/A * @param e the change information from the associated document 0N/A * @param alloc the current allocation of the view inside of the insets. 0N/A * @see View#removeUpdate 0N/A * Gives notification from the document that attributes were changed 0N/A * in a location that this view is responsible for. 0N/A * @param fv the <code>FlowView</code> containing the changes 0N/A * @param e the <code>DocumentEvent</code> describing the changes 0N/A * done to the Document 0N/A * @param alloc Bounds of the View 0N/A * @see View#changedUpdate 0N/A * This method gives flow strategies access to the logical 0N/A * view of the FlowView. 0N/A * Update the flow on the given FlowView. By default, this causes 0N/A * all of the rows (child views) to be rebuilt to match the given 0N/A * constraints for each row. This is called by a FlowView.layout 0N/A * to update the child views in the flow. 0N/A * @param fv the view to reflow 0N/A // In some cases there's no view at position damageStart, so 0N/A // step back and search again. See 6452106 for details. 0N/A * Creates a row of views that will fit within the 0N/A * layout span of the row. This is called by the layout method. 0N/A * This is implemented to fill the row by repeatedly calling 0N/A * the createView method until the available span has been 0N/A * exhausted, a forced break was encountered, or the createView 0N/A * method returned null. If the remaining span was exhaused, 0N/A * the adjustRow method will be called to perform adjustments 0N/A * to the row to try and make it fit into the given span. 0N/A * @param rowIndex the index of the row to fill in with views. The 0N/A * row is assumed to be empty on entry. 0N/A * @param pos The current position in the children of 0N/A * this views element from which to start. 0N/A * @return the position to start the next row 0N/A }
else if (n ==
0) {
0N/A // if the view does not break, and it is the only view 0N/A // in a row, use the whole view 0N/A // row is too long, and we may break 0N/A * Adjusts the given row if possible to fit within the 0N/A * layout span. By default this will try to find the 0N/A * highest break weight possible nearest the end of 0N/A * the row. If a forced break is encountered, the 0N/A * break will be positioned there. 0N/A * @param rowIndex the row to adjust to the current layout 0N/A * @param desiredSpan the current layout span >= 0 0N/A * @param x the location r starts at. 0N/A for (
int i =
0; i < n; i++) {
0N/A // it's a forced break, so there is 0N/A // no point in searching further. 0N/A // there is nothing that can be broken, leave 0N/A // it in it's current state. 0N/A // Break the best candidate view, and patch up the row. 0N/A * Creates a view that can be used to represent the current piece 0N/A * of the flow. This can be either an entire view from the 0N/A * logical view, or a fragment of the logical view. 0N/A * @param fv the view holding the flow 0N/A * @param startOffset the start location for the view being created 0N/A * @param spanLeft the about of span left to fill in the row 0N/A * @param rowIndex the row the view will be placed into 0N/A // Get the child view that contains the given starting position 0N/A // return the entire view 0N/A // return a fragment. 0N/A * This class can be used to represent a logical view for 0N/A * a flow. It keeps the children updated to reflect the state 0N/A * of the model, gives the logical child views access to the 0N/A * view hierarchy, and calculates a preferred span. It doesn't 0N/A * Fetches the attributes to use when rendering. This view 0N/A * isn't directly responsible for an element so it returns 0N/A * the outer classes attributes. 0N/A * Determines the preferred span for this view along an 0N/A * @param axis may be either View.X_AXIS or View.Y_AXIS 0N/A * @return the span the view would like to be rendered into. 0N/A * Typically the view is told to render into the span 0N/A * that is returned, although there is no guarantee. 0N/A * The parent may choose to resize or break the view. 0N/A * @see View#getPreferredSpan 0N/A for (
int i =
0; i < n; i++) {
0N/A * Determines the minimum span for this view along an 0N/A * axis. The is implemented to find the minimum unbreakable 0N/A * @param axis may be either View.X_AXIS or View.Y_AXIS 0N/A * @return the span the view would like to be rendered into. 0N/A * Typically the view is told to render into the span 0N/A * that is returned, although there is no guarantee. 0N/A * The parent may choose to resize or break the view. 0N/A * @see View#getPreferredSpan 0N/A for (
int i =
0; i < n; i++) {
0N/A * Forward the DocumentEvent to the given child view. This 0N/A * is implemented to reparent the child to the logical view 0N/A * (the children may have been parented by a row in the flow 0N/A * if they fit without breaking) and then execute the superclass 0N/A * @param v the child view to forward the event to. 0N/A * @param e the change information from the associated document 0N/A * @param a the current allocation of the view 0N/A * @param f the factory to use to rebuild if the view has children 0N/A * @see #forwardUpdate 0N/A // The following methods don't do anything useful, they 0N/A // simply keep the class from being abstract. 0N/A * Renders using the given rendering surface and area on that 0N/A * surface. This is implemented to do nothing, the logical 0N/A * view is never visible. 0N/A * @param g the rendering surface to use 0N/A * @param allocation the allocated region to render into 0N/A * Tests whether a point lies before the rectangle range. 0N/A * Implemented to return false, as hit detection is not 0N/A * performed on the logical view. 0N/A * @param x the X coordinate >= 0 0N/A * @param y the Y coordinate >= 0 0N/A * @param alloc the rectangle 0N/A * @return true if the point is before the specified range 0N/A * Tests whether a point lies after the rectangle range. 0N/A * Implemented to return false, as hit detection is not 0N/A * performed on the logical view. 0N/A * @param x the X coordinate >= 0 0N/A * @param y the Y coordinate >= 0 0N/A * @param alloc the rectangle 0N/A * @return true if the point is after the specified range 0N/A * Fetches the child view at the given point. 0N/A * Implemented to return null, as hit detection is not 0N/A * performed on the logical view. 0N/A * @param x the X coordinate >= 0 0N/A * @param y the Y coordinate >= 0 0N/A * @param alloc the parent's allocation on entry, which should 0N/A * be changed to the child's allocation on exit 0N/A * @return the child view 0N/A * Returns the allocation for a given child. 0N/A * Implemented to do nothing, as the logical view doesn't 0N/A * perform layout on the children. 0N/A * @param index the index of the child, >= 0 && < getViewCount() 0N/A * @param a the allocation to the interior of the box on entry, 0N/A * and the allocation of the child view at the index on exit.