abbot.tester
Class ComponentLocation

java.lang.Object
  extended by abbot.tester.ComponentLocation
Direct Known Subclasses:
JGraphLocation, JListLocation, JTabbedPaneLocation, JTableHeaderLocation, JTableLocation, JTreeLocation, ListLocation

public class ComponentLocation
extends Object

Provides encapsulation of a visible Component-relative location. "Visible" in this context means currently accessible by the pointer (possibly via scrolling). A hidden node in a collapsed tree path would not be considered visible.

This class the specifics of location so that ComponentTester primitives (ComponentTester.actionClick(Component,ComponentLocation), ComponentTester.actionShowPopupMenu(Component,ComponentLocation), etc) may be directed to specific elements of substructure on a Component (list rows, tree paths, table cells, substructure values, etc.).

Classes derived from ComponentLocation should provide constructors for each type of location indication, e.g. value, index, and Point. The toString() method should provide an encoded String suitable for use by the parse(String) method, which must convert the String encoding back into a proper ComponentLocation.

By convention, Point locations are specified with (x,y) notation. Indexed locations should use square brackets, e.g. [i] or [r,c] and value locations should use a quoted String, e.g. '"cuckoo for cocoa puffs"'. The specific syntax allowed will vary by specific ComponentLocation type. The base ComponentLocation implementation supports only the explicit (x,y) notation.

Recorders should use the String value by default for consistency. The special value CENTER is provided to indicate the center of a Component.

The method badFormat(String) should provide usage-like information indicating the acceptable forms of input for this class.

See Also:
JListLocation, JTreeLocation, JTableLocation

Field Summary
static String CENTER
          Special ComponentLocation encoding which represents the center of the component.
 
Constructor Summary
ComponentLocation()
          Create a simple location which represents the center of a component.
ComponentLocation(Point where)
          Create a simple location.
 
Method Summary
protected  String badFormat(String encoded)
           
protected  String encodeIndex(int index)
           
protected  String encodeValue(String value)
           
 boolean equals(Object o)
          Returns whether the given object is an equivalent ComponentLocation.
 Rectangle getBounds(Component c)
          Convert the abstract location into a concrete area, relative to the given Component.
 Point getPoint(Component c)
          Convert the abstract location into a concrete one.
protected  boolean isIndex(String encoded)
          Returns whether the given (trimmed) String is an encoded index.
protected  boolean isValue(String encoded)
          Returns whether the given (trimmed) String is an encoded value.
 ComponentLocation parse(String encoded)
          Convert the given encoding into the proper location.
protected  int parseIndex(String encoded)
          Extract the encoded index.
protected  String parseValue(String encoded)
          Extract the encoded value.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CENTER

public static final String CENTER
Special ComponentLocation encoding which represents the center of the component.

See Also:
Constant Field Values
Constructor Detail

ComponentLocation

public ComponentLocation()
Create a simple location which represents the center of a component.


ComponentLocation

public ComponentLocation(Point where)
Create a simple location.

Method Detail

getPoint

public Point getPoint(Component c)
               throws LocationUnavailableException
Convert the abstract location into a concrete one. Returns a Point relative to the given Component.

Throws:
LocationUnavailableException

getBounds

public Rectangle getBounds(Component c)
                    throws LocationUnavailableException
Convert the abstract location into a concrete area, relative to the given Component. If a point has been specified, returns a 1x1 rectangle, otherwise returns the a rectangle at (0, 0) of the Component's size.

Throws:
LocationUnavailableException

equals

public boolean equals(Object o)
Returns whether the given object is an equivalent ComponentLocation.

Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

badFormat

protected String badFormat(String encoded)

encodeIndex

protected String encodeIndex(int index)

isIndex

protected boolean isIndex(String encoded)
Returns whether the given (trimmed) String is an encoded index.


parseIndex

protected int parseIndex(String encoded)
Extract the encoded index.


encodeValue

protected String encodeValue(String value)

isValue

protected boolean isValue(String encoded)
Returns whether the given (trimmed) String is an encoded value.


parseValue

protected String parseValue(String encoded)
Extract the encoded value.


parse

public ComponentLocation parse(String encoded)
Convert the given encoding into the proper location. Allowed formats: (x, y)



Copyright © 2002-2008 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge