javax.swing.text
Class BoxView
- SwingConstants
An implementation of
CompositeView
that arranges its children in
a box along one axis. This is comparable to how the
BoxLayout
works, but for
View
children.
BOTTOM , CENTER , EAST , HORIZONTAL , LEADING , LEFT , NEXT , NORTH , NORTH_EAST , NORTH_WEST , PREVIOUS , RIGHT , SOUTH , SOUTH_EAST , SOUTH_WEST , TOP , TRAILING , VERTICAL , WEST |
BoxView(Element element, int axis) - Creates a new
BoxView for the given
Element and axis.
|
protected SizeRequirements | baselineRequirements(int axis, SizeRequirements sr) - Calculates the size requirements for this
BoxView along
the specified axis.
|
protected SizeRequirements | calculateMajorAxisRequirements(int axis, SizeRequirements sr) - Calculates the size requirements of this
BoxView along
its major axis, that is the axis specified in the constructor.
|
protected SizeRequirements | calculateMinorAxisRequirements(int axis, SizeRequirements sr) - Calculates the size requirements of this
BoxView along
its minor axis, that is the axis opposite to the axis specified in the
constructor.
|
protected void | childAllocation(int index, Rectangle a) - Computes the allocation for a child
View .
|
int | getAxis() - Returns the axis along which this
BoxView is laid out.
|
int | getHeight() - Return the current height of the box.
|
float | getMaximumSpan(int axis)
|
float | getPreferredSpan(int axis) - Returns the preferred span of the content managed by this
View along the specified axis .
|
protected View | getViewAtPoint(int x, int y, Rectangle r) - Returns the child
View at the specified location.
|
int | getWidth() - Return the current width of the box.
|
protected boolean | isAfter(int x, int y, Rectangle r) - Returns
true if the specified point lies after the
given Rectangle , false otherwise.
|
protected boolean | isAllocationValid() - Returns
true if the cached allocations for the children
are still valid, false otherwise.
|
protected boolean | isBefore(int x, int y, Rectangle r) - Returns
true if the specified point lies before the
given Rectangle , false otherwise.
|
protected boolean | isLayoutValid(int axis) - Returns
true if the layout along the specified
axis is valid, false otherwise.
|
protected void | layout(int width, int height) - Lays out the children of this
BoxView with the specified
bounds.
|
void | layoutChanged(int axis) - Marks the layout along the specified axis as invalid.
|
protected void | layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans) - Performs the layout along the major axis of a
BoxView .
|
protected void | layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans) - Performs the layout along the minor axis of a
BoxView .
|
void | paint(Graphics g, Shape a) - Renders the
Element that is associated with this
View .
|
protected void | paintChild(Graphics g, Rectangle alloc, int index) - Paints the child
View at the specified index .
|
void | replace(int offset, int length, View views) - Replaces child views by some other child views.
|
void | setAxis(int axis) - Sets the axis along which this
BoxView is laid out.
|
void | setSize(float width, float height) - Sets the size of the view.
|
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 |
append , breakView , changedUpdate , createFragment , forwardUpdate , forwardUpdateToView , getAlignment , getAttributes , getBreakWeight , getChildAllocation , getContainer , getDocument , getElement , getEndOffset , getGraphics , getMaximumSpan , getMinimumSpan , getParent , getPreferredSpan , getResizeWeight , getStartOffset , getToolTipText , getView , getViewCount , getViewFactory , getViewIndex , getViewIndex , insert , insertUpdate , isVisible , modelToView , modelToView , paint , preferenceChanged , remove , removeAll , removeUpdate , replace , setParent , setSize , updateChildren , updateLayout , viewToModel |
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
BoxView
public BoxView(Element element,
int axis)
Creates a new
BoxView
for the given
Element
and axis. Valid values for the axis are
View.X_AXIS
and
View.Y_AXIS
.
element
- the element that is rendered by this BoxViewaxis
- the axis along which the box is laid out
baselineRequirements
protected SizeRequirements baselineRequirements(int axis,
SizeRequirements sr)
Calculates the size requirements for this BoxView
along
the specified axis.
axis
- the axis that is examinedsr
- the SizeRequirements
object to hold the result,
if null
, a new one is created
- the size requirements for this
BoxView
along
the specified axis
calculateMajorAxisRequirements
protected SizeRequirements calculateMajorAxisRequirements(int axis,
SizeRequirements sr)
Calculates the size requirements of this BoxView
along
its major axis, that is the axis specified in the constructor.
axis
- the axis that is examinedsr
- the SizeRequirements
object to hold the result,
if null
, a new one is created
- the size requirements for this
BoxView
along
the specified axis
calculateMinorAxisRequirements
protected SizeRequirements calculateMinorAxisRequirements(int axis,
SizeRequirements sr)
Calculates the size requirements of this BoxView
along
its minor axis, that is the axis opposite to the axis specified in the
constructor.
axis
- the axis that is examinedsr
- the SizeRequirements
object to hold the result,
if null
, a new one is created
- the size requirements for this
BoxView
along
the specified axis
childAllocation
protected void childAllocation(int index,
Rectangle a)
Computes the allocation for a child View
. The parameter
a
stores the allocation of this CompositeView
and is then adjusted to hold the allocation of the child view.
- childAllocation in interface CompositeView
index
- the index of the child View
a
- the allocation of this CompositeView
before the
call, the allocation of the child on exit
getAxis
public int getAxis()
Returns the axis along which this BoxView
is laid out.
- the axis along which this
BoxView
is laid out
getHeight
public int getHeight()
Return the current height of the box. This is the last allocated height.
- the current height of the box
getPreferredSpan
public float getPreferredSpan(int axis)
Returns the preferred span of the content managed by this
View
along the specified axis
.
- getPreferredSpan in interface View
axis
- the axis
- the preferred span of this
View
.
getViewAtPoint
protected View getViewAtPoint(int x,
int y,
Rectangle r)
Returns the child View
at the specified location.
- getViewAtPoint in interface CompositeView
x
- the X coordinatey
- the Y coordinater
- the inner allocation of this BoxView
on entry,
the allocation of the found child on exit
- the child
View
at the specified location
getWidth
public int getWidth()
Return the current width of the box. This is the last allocated width.
- the current width of the box
isAfter
protected boolean isAfter(int x,
int y,
Rectangle r)
Returns true
if the specified point lies after the
given Rectangle
, false
otherwise.
"After" is typically defined as being to the right or below.
- isAfter in interface CompositeView
x
- the X coordinate of the pointy
- the Y coordinate of the pointr
- the rectangle to test the point against
true
if the specified point lies after the
given Rectangle
, false
otherwise
isAllocationValid
protected boolean isAllocationValid()
Returns true
if the cached allocations for the children
are still valid, false
otherwise.
true
if the cached allocations for the children
are still valid, false
otherwise
isBefore
protected boolean isBefore(int x,
int y,
Rectangle r)
Returns true
if the specified point lies before the
given Rectangle
, false
otherwise.
"Before" is typically defined as being to the left or above.
- isBefore in interface CompositeView
x
- the X coordinate of the pointy
- the Y coordinate of the pointr
- the rectangle to test the point against
true
if the specified point lies before the
given Rectangle
, false
otherwise
isLayoutValid
protected boolean isLayoutValid(int axis)
Returns
true
if the layout along the specified
axis
is valid,
false
otherwise.
Valid values for the axis are
View.X_AXIS
and
View.Y_AXIS
.
axis
- the axis
true
if the layout along the specified
axis
is valid, false
otherwise
layout
protected void layout(int width,
int height)
Lays out the children of this BoxView
with the specified
bounds.
width
- the width of the allocated region for the children (that
is the inner allocation of this BoxView
height
- the height of the allocated region for the children (that
is the inner allocation of this BoxView
layoutChanged
public void layoutChanged(int axis)
Marks the layout along the specified axis as invalid. This is triggered
automatically when any of the child view changes its preferences
via
preferenceChanged(View,boolean,boolean)
.
The layout will be updated the next time when
setSize()
is
called, typically from within the
paint()
method.
Valid values for the axis are
View.X_AXIS
and
View.Y_AXIS
.
axis
- an int
value
layoutMajorAxis
protected void layoutMajorAxis(int targetSpan,
int axis,
int[] offsets,
int[] spans)
Performs the layout along the major axis of a BoxView
.
targetSpan
- the (inner) span of the BoxView
in which
to layout the childrenaxis
- the axis along which the layout is performedoffsets
- the array that holds the offsets of the children on exit
layoutMinorAxis
protected void layoutMinorAxis(int targetSpan,
int axis,
int[] offsets,
int[] spans)
Performs the layout along the minor axis of a BoxView
.
targetSpan
- the (inner) span of the BoxView
in which
to layout the childrenaxis
- the axis along which the layout is performedoffsets
- the array that holds the offsets of the children on exit
paint
public void paint(Graphics g,
Shape a)
Renders the Element
that is associated with this
View
.
- paint in interface View
g
- the Graphics
context to render toa
- the allocated region for the Element
paintChild
protected void paintChild(Graphics g,
Rectangle alloc,
int index)
Paints the child View
at the specified index
.
This method modifies the actual values in alloc
so make
sure you have a copy of the original values if you need them.
g
- the Graphics
context to paint toalloc
- the allocated region for the child to paint intoindex
- the index of the child to be painted
#childAllocation}
replace
public void replace(int offset,
int length,
View views)
Replaces child views by some other child views. If there are no views to
remove (length == 0
), the result is a simple insert, if
there are no children to add (view == null
) the result
is a simple removal.
In addition this invalidates the layout and resizes the internal cache
for the child allocations. The old children's cached allocations can
still be accessed (although they are not guaranteed to be valid), and
the new children will have an initial offset and span of 0.
- replace in interface CompositeView
offset
- the start offset from where to remove childrenlength
- the number of children to removeviews
- the views that replace the removed children
setAxis
public void setAxis(int axis)
Sets the axis along which this
BoxView
is laid out.
Valid values for the axis are
View.X_AXIS
and
View.Y_AXIS
.
axis
- the axis along which this BoxView
is laid out
setSize
public void setSize(float width,
float height)
Sets the size of the view. If the actual size has changed, the layout
is updated accordingly.
- setSize in interface View
width
- the new widthheight
- the new height
BoxView.java -- An composite view
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.