uk.ac.starlink.xdoc.fig
Class Anchor

java.lang.Object
  extended by uk.ac.starlink.xdoc.fig.Anchor

public abstract class Anchor
extends Object

Utility for positioning things in the graphics context.

Since:
18 Sep 2007
Author:
Mark Taylor

Field Summary
static Color BG
          Background colour.
static Anchor CENTRE
           
static Anchor EAST
           
static Anchor NORTH
           
static Anchor NORTH_EAST
           
static Anchor NORTH_WEST
           
static Anchor SOUTH
           
static Anchor SOUTH_EAST
           
static Anchor SOUTH_WEST
           
static Anchor WEST
           
 
Constructor Summary
Anchor()
           
 
Method Summary
static Anchor createFractionAnchor(float xfrac, float yfrac)
          Returns an anchor defined by fractional amounts along each edge of a box.
 Rectangle drawString(Graphics g, String text, int x, int y, boolean clearBg)
          Positions a string relative to the given reference point, optionally clearing the background first.
abstract  Point getPoint(Rectangle box)
          Returns the position of this anchor point in a given rectangle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BG

public static final Color BG
Background colour.


CENTRE

public static final Anchor CENTRE

WEST

public static final Anchor WEST

EAST

public static final Anchor EAST

NORTH

public static final Anchor NORTH

SOUTH

public static final Anchor SOUTH

NORTH_WEST

public static final Anchor NORTH_WEST

SOUTH_WEST

public static final Anchor SOUTH_WEST

NORTH_EAST

public static final Anchor NORTH_EAST

SOUTH_EAST

public static final Anchor SOUTH_EAST
Constructor Detail

Anchor

public Anchor()
Method Detail

getPoint

public abstract Point getPoint(Rectangle box)
Returns the position of this anchor point in a given rectangle.

Parameters:
box - rectangle
Returns:
position of this anchor point in box

drawString

public Rectangle drawString(Graphics g,
                            String text,
                            int x,
                            int y,
                            boolean clearBg)
Positions a string relative to the given reference point, optionally clearing the background first.

Parameters:
g - graphics context
text - string to draw
x - reference point X coordinate
y - reference point Y coordinate
clearBg - true iff you want to clear the background for the text to the background colour (white) before painting the text

createFractionAnchor

public static Anchor createFractionAnchor(float xfrac,
                                          float yfrac)
Returns an anchor defined by fractional amounts along each edge of a box.

Parameters:
xfrac - left-right amount (0-1)
yfrac - top-bottom amount (0-1)
Returns:
new anchor


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.