/*
* 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.
*/
/**
* Extends the multi-line plain text view to be suitable
* for a single-line editor view. If the view is
* allocated extra space, the field must adjust for it.
* If the hosting component is a JTextField, this view
* will manage the ranges of the associated BoundedRangeModel
* and will adjust the horizontal allocation to match the
* current visibility settings of the JTextField.
*
* @author Timothy Prinzing
* @see View
*/
/**
* Constructs a new FieldView wrapped on an element.
*
* @param elem the element
*/
super(elem);
}
/**
* Fetches the font metrics associated with the component hosting
* this view.
*
* @return the metrics
*/
Component c = getContainer();
return c.getFontMetrics(c.getFont());
}
/**
* Adjusts the allocation given to the view
* to be a suitable allocation for a text field.
* If the view has been allocated more than the
* preferred span vertically, the allocation is
* changed to be centered vertically. Horizontally
* the view is adjusted according to the horizontal
* alignment property set on the associated JTextField
* (if that is the type of the hosting component).
*
* @param a the allocation given to the view, which may need
* to be adjusted.
* @return the allocation that the superclass should use.
*/
if (a != null) {
}
// horizontal adjustments
Component c = getContainer();
if (c instanceof JTextField) {
}
max, false);
// horizontally align the interior
if(Utilities.isLeftToRight(c)) {
}
}
}
else {
}
}
}
switch (align) {
case SwingConstants.CENTER:
break;
case SwingConstants.RIGHT:
break;
}
} else {
// adjust the allocation to match the bounded range.
}
}
return bounds;
}
return null;
}
/**
* Update the visibility model with the associated JTextField
* (if there is one) to reflect the current visibility as a
* result of changes to the document model. The bounded
* range properties are updated. If the view hasn't yet been
* shown the extent will be zero and we just set it to be full
* until determined otherwise.
*/
void updateVisibilityModel() {
Component c = getContainer();
if (c instanceof JTextField) {
}
}
}
// --- View methods -------------------------------------------
/**
* Renders using the given rendering surface and area on that surface.
* The view may need to do layout and create child views to enable
* itself to render into the given allocation.
*
* @param g the rendering surface to use
* @param a the allocated region to render into
*
* @see View#paint
*/
super.paint(g, a);
}
/**
* Adjusts <code>a</code> based on the visible region and returns it.
*/
return adjustAllocation(a);
}
/**
* Determines the preferred span for this view along an
* axis.
*
* @param axis may be either View.X_AXIS or View.Y_AXIS
* @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.
*/
switch (axis) {
int width;
try {
Component c = getContainer();
getLeftSideBearing((c instanceof JComponent) ?
}
else {
firstLineOffset = 0;
}
} catch (BadLocationException bl) {
width = 0;
}
return width + firstLineOffset;
default:
return super.getPreferredSpan(axis);
}
}
/**
* Determines the resizability of the view along the
* given axis. A value of 0 or less is not resizable.
*
* @param axis View.X_AXIS or View.Y_AXIS
* @return the weight -> 1 for View.X_AXIS, else 0
*/
return 1;
}
return 0;
}
/**
* Provides a mapping from the document model coordinate space
* to the coordinate space of the view mapped to it.
*
* @param pos the position to convert >= 0
* @param a the allocated region to render into
* @return the bounding box of the given position
* @exception BadLocationException if the given position does not
* represent a valid location in the associated document
* @see View#modelToView
*/
}
/**
* Provides a mapping from the view coordinate space to the logical
* coordinate space of the model.
*
* @param fx the X coordinate >= 0.0f
* @param fy the Y coordinate >= 0.0f
* @param a the allocated region to render into
* @return the location within the model that best represents the
* given point in the view
* @see View#viewToModel
*/
}
/**
* Gives notification that something was inserted into the document
* in a location that this view is responsible for.
*
* @param changes the change information from the associated document
* @param a the current allocation of the view
* @param f the factory to use to rebuild if the view has children
* @see View#insertUpdate
*/
}
/**
* Gives notification that something was removed from the document
* in a location that this view is responsible for.
*
* @param changes the change information from the associated document
* @param a the current allocation of the view
* @param f the factory to use to rebuild if the view has children
* @see View#removeUpdate
*/
}
}