public class JTreeLocation extends ComponentLocation
JTree
.
A row index or a String
ified TreePath
(i.e. each
TreePath
component is a String
) or a TreePath
of Object
may be used to indicate the location. Note that if a
TreePath
is used, the entire path leading up to the designated
node must be viewable at the time the location is used.CENTER
Constructor and Description |
---|
JTreeLocation()
Create an uninitialized JTreeLocation.
|
JTreeLocation(int row)
Create a JTreeLocation corresponding to the given row, by index.
|
JTreeLocation(int row,
boolean inExpansion)
Create a JTreeLocation corresponding to the given row, by index.
|
JTreeLocation(Point p) |
JTreeLocation(TreePath treePath)
Create a JTreeLocation corresponding to the given TreePath.
|
JTreeLocation(TreePath treePath,
boolean inExpansion)
Create a JTreeLocation corresponding to the given TreePath.
|
Modifier and Type | Method and Description |
---|---|
protected String |
badFormat(String encoded) |
boolean |
equals(Object o)
Returns whether the given object is an equivalent
ComponentLocation . |
static TreePath |
findMatchingPath(JTree tree,
TreePath path)
|
Rectangle |
getBounds(Component c)
Convert the abstract location into a concrete area, relative
to the given
Component . |
(package private) TreePath |
getPath(JTree tree)
Return the path represented by this JTree location.
|
Point |
getPoint(Component c)
Return a concrete point for the abstract location.
|
(package private) int |
getRow(JTree tree)
Return the row represented by this JTree location.
|
boolean |
isInExpansion() |
ComponentLocation |
parse(String encoded)
Convert the given encoding into the proper location.
|
protected Point |
pathToPoint(JTree tree,
TreePath path)
Convert the given path to an x, y coordinate.
|
protected Point |
rowToPoint(JTree tree,
int row)
Convert the given row to an x, y coordinate.
|
void |
setInExpansion(boolean in) |
String |
toString() |
encodeIndex, encodeValue, isIndex, isValue, parseIndex, parseValue
public JTreeLocation()
Point
will return the default location.public JTreeLocation(int row)
public JTreeLocation(int row, boolean inExpansion)
public JTreeLocation(TreePath treePath)
Object.toString()
is not usable; if that is all that is
available, refer to the row number instead.public JTreeLocation(TreePath treePath, boolean inExpansion)
Object.toString()
is not usable; if that is all that is
available, refer to the row number instead.public JTreeLocation(Point p)
public void setInExpansion(boolean in)
public boolean isInExpansion()
protected Point rowToPoint(JTree tree, int row)
LocationUnavailableException
- if the row is not visible.protected Point pathToPoint(JTree tree, TreePath path)
LocationUnavailableException
- if any part of the path is
hidden.TreePath getPath(JTree tree)
int getRow(JTree tree)
public Point getPoint(Component c)
getPoint
in class ComponentLocation
public Rectangle getBounds(Component c)
ComponentLocation
Component
. If a point has
been specified, returns a 1x1 rectangle, otherwise returns the
a rectangle at (0, 0) of the Component's size.getBounds
in class ComponentLocation
public boolean equals(Object o)
ComponentLocation
ComponentLocation
.equals
in class ComponentLocation
public String toString()
toString
in class ComponentLocation
public ComponentLocation parse(String encoded)
ComponentLocation
parse
in class ComponentLocation
protected String badFormat(String encoded)
badFormat
in class ComponentLocation
public static TreePath findMatchingPath(JTree tree, TreePath path)
TreePath
(which may be composed of objects, string
representations of objects, or regular expressions), return the
equivalent TreePath
for the given JTree
constructed
from objects from the tree's model.
For each element, Object.equals(java.lang.Object)
is attempted first (a
null
pattern matches everything), followed by a comparison
of the pattern as a String
(via Object.toString()
). The
pattern may be a regular expression bounded by forward slashes.
LocationUnavailableException
- if no matching path is found.
Abbot is hosted on