childAllocation
protected abstract 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.
index
- the index of the child View
a
- the allocation of this CompositeView
before the
call, the allocation of the child on exit
flipEastAndWestAtEnds
protected boolean flipEastAndWestAtEnds(int pos,
Position.Bias bias)
Determines if the next view in horinzontal direction is located to
the east or west of the view at position pos
. Usually
the View
s are laid out from the east to the west, so
we unconditionally return false
here. Subclasses that
support bidirectional text may wish to override this method.
pos
- the position in the documentbias
- the bias to be applied to pos
true
if the next View
is located
to the EAST, false
otherwise
getBottomInset
protected short getBottomInset()
Returns the bottom inset of this CompositeView
.
- the bottom inset of this
CompositeView
getChildAllocation
public Shape getChildAllocation(int index,
Shape a)
Returns the allocation for the specified child View
.
- getChildAllocation in interface View
index
- the index of the child viewa
- the allocation for this view
- the allocation for the specified child
View
getInsideAllocation
protected Rectangle getInsideAllocation(Shape a)
Returns the allocation that is given to this
CompositeView
minus this
CompositeView
's insets.
Also this translates from an immutable allocation to a mutable allocation
that is typically reused and further narrowed, like in
childAllocation(int,Rectangle)
.
a
- the allocation given to this CompositeView
- the allocation that is given to this
CompositeView
minus this CompositeView
's insets or
null
if a was null
getLeftInset
protected short getLeftInset()
Returns the left inset of this CompositeView
.
- the left inset of this
CompositeView
getNextEastWestVisualPositionFrom
protected int getNextEastWestVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
Returns the next model location that is visible in east or west
direction.
This is used to determine the
placement of the caret when navigating around the document with
the arrow keys.
pos
- the model position to start search fromb
- the bias for pos
a
- the allocated region for this viewdirection
- the direction from the current position, can be one of
the following:
biasRet
- the bias of the return value gets stored here
- the position inside the model that represents the next visual
location
getNextNorthSouthVisualPositionFrom
protected int getNextNorthSouthVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
Returns the next model location that is visible in north or south
direction.
This is used to determine the
placement of the caret when navigating around the document with
the arrow keys.
pos
- the model position to start search fromb
- the bias for pos
a
- the allocated region for this viewdirection
- the direction from the current position, can be one of
the following:
biasRet
- the bias of the return value gets stored here
- the position inside the model that represents the next visual
location
getRightInset
protected short getRightInset()
Returns the right inset of this CompositeView
.
- the right inset of this
CompositeView
getTopInset
protected short getTopInset()
Returns the top inset of this CompositeView
.
- the top inset of this
CompositeView
getView
public View getView(int n)
Returns the child view at index n
.
- getView in interface View
n
- the index of the requested child view
- the child view at index
n
getViewAtPoint
protected abstract View getViewAtPoint(int x,
int y,
Rectangle r)
Returns the child View
at the specified location.
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
getViewAtPosition
protected View getViewAtPosition(int pos,
Rectangle a)
Returns the child View
that contains the given model
position. The given Rectangle
gives the parent's allocation
and is changed to the child's allocation on exit.
pos
- the model position to query the child View
fora
- the parent allocation on entry and the child allocation on exit
- the child view at the given model position
getViewIndex
public int getViewIndex(int pos,
Position.Bias b)
Returns the index of the child view that represents the specified
model location.
- getViewIndex in interface View
pos
- the model location for which to determine the child view indexb
- the bias to be applied to pos
- the index of the child view that represents the specified
model location
getViewIndexAtPosition
protected int getViewIndexAtPosition(int pos)
Returns the index of the child View
for the given model
position.
pos
- the model position for whicht the child View
is
queried
- the index of the child
View
for the given model
position
isAfter
protected abstract 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.
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
isBefore
protected abstract 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.
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
loadChildren
protected void loadChildren(ViewFactory f)
Loads the child views of this
CompositeView
. This method
is called from
setParent(View)
to initialize the child views of
this composite view.
f
- the view factory to use for creating new child views
modelToView
public Shape modelToView(int pos,
Shape a,
Position.Bias bias)
throws BadLocationException
Maps a position in the document into the coordinate space of the View.
The output rectangle usually reflects the font height but has a width
of zero.
- modelToView in interface View
pos
- the position of the character in the modela
- the area that is occupied by the viewbias
- either Position.Bias.Forward
or
Position.Bias.Backward
depending on the preferred
direction bias. If null
this defaults to
Position.Bias.Forward
- a rectangle that gives the location of the document position
inside the view coordinate space
modelToView
public Shape modelToView(int p1,
Position.Bias b1,
int p2,
Position.Bias b2,
Shape a)
throws BadLocationException
Maps a region in the document into the coordinate space of the View.
- modelToView in interface View
p1
- the beginning position inside the documentb1
- the direction bias for the beginning positionp2
- the end position inside the documentb2
- the direction bias for the end positiona
- the area that is occupied by the view
- a rectangle that gives the span of the document region
inside the view coordinate space
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.
- replace in interface View
offset
- the start offset from where to remove childrenlength
- the number of children to removeviews
- the views that replace the removed children
setInsets
protected void setInsets(short t,
short l,
short b,
short r)
Sets the insets of this CompositeView
.
t
- the top insetl
- the left insetb
- the bottom insetr
- the right inset
setParent
public void setParent(View parent)
Sets the parent of this
View
.
In addition to setting the parent, this calls
loadChildren(ViewFactory)
, if
this
View
does not already have its children initialized.
- setParent in interface View
parent
- the parent to set
viewToModel
public int viewToModel(float x,
float y,
Shape a,
Position.Bias[] b)
Maps coordinates from the View
's space into a position
in the document model.
- viewToModel in interface View
x
- the x coordinate in the view space, x >= 0y
- the y coordinate in the view space, y >= 0a
- the allocation of this View
b
- the bias to use
- the position in the document that corresponds to the screen
coordinates
x, y
>= 0
CompositeView.java -- An abstract view that manages child views
Copyright (C) 2005, 2006 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.