ucar.unidata.ui.drawing
Class Glyph

java.lang.Object
  extended by ucar.unidata.ui.drawing.Glyph
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
LineGlyph, PolyGlyph, RectangleGlyph

public abstract class Glyph
extends Object
implements Cloneable

Base (abstract) class for representing things that are drawn on the screen. Holds some basic attributes (but no positional attrs) and has a facility for recreating itself via xml.


Field Summary
static String ATTR_BGCOLOR
          _more_
static String ATTR_CHILDREN
          _more_
static String ATTR_CLASS
          _more_
static String ATTR_COLOR
          _more_
static String ATTR_FILL
          _more_
static String ATTR_HEIGHT
          _more_
static String ATTR_IMAGE
          _more_
static String ATTR_LINEWIDTH
          _more_
static String ATTR_PARENT
          _more_
static String ATTR_PTS
          _more_
static String ATTR_STRETCHY
          _more_
static String ATTR_TEXT
          _more_
static String ATTR_TYPE
          _more_
static String ATTR_WIDTH
          _more_
 int baseline
          _more_
static int H_SEL_WIDTH
          _more_
static Color highlightColor
          _more_
static Hashtable idToGlyph
          _more_
static int MIN_DISTANCE_TO_STRETCH
          Some global consts
static String PT_CENTER
          _more_
static String PT_H_LEFT
          _more_
static String PT_H_MIDDLE
          _more_
static String PT_H_RIGHT
          _more_
static String PT_LL
          _more_
static String PT_LM
          _more_
static String PT_LR
          _more_
static String PT_ML
          _more_
static String PT_MM
          _more_
static String PT_MR
          _more_
static String PT_P1
          _more_
static String PT_P2
          _more_
static String PT_PREFIX
          _more_
static String PT_UL
          _more_
static String PT_UM
          _more_
static String PT_UR
          _more_
static String PT_V_LOWER
          _more_
static String PT_V_MIDDLE
          _more_
static String PT_V_UPPER
          _more_
static String[] RECTPOINTNAMES
          _more_
static String[] RECTPOINTS
          _more_
static int SEL_WIDTH
          _more_
static String TAG_GLYPH
          _more_
 boolean underline
          _more_
 String url
          _more_
 
Constructor Summary
Glyph()
          _more_
 
Method Summary
 void boundsChanged()
          Hook for when the size or position of this glyph is changed
 boolean canStretch()
          _more_
protected  Object clone()
          _more_
abstract  double distance(int x, int y)
          _more_
static double distance(int x1, int y1, int x2, int y2)
          Utility method for distance between two points
 void doRemove()
          _more_
static String flipY(String pt)
          _more_
 String getAttrs()
          _more_
 Color getBackground()
          _more_
 Color getBackground(Color dflt)
          _more_
 boolean getBeingCreated()
          _more_
abstract  Rectangle getBounds()
          _more_
 CanvasCommand getCreateCommand(DisplayCanvas canvas, AWTEvent event, int x, int y)
          _more_
static Cursor getCursor(String rectPoint)
          _more_
 boolean getFilled()
          _more_
 Color getForeground()
          _more_
 String getId()
          _more_
 int getLineWidth()
          _more_
 CanvasCommand getMoveCommand(DisplayCanvas canvas, AWTEvent event, int x, int y)
          _more_
 boolean getPersistent()
          _more_
static Point2D getPointOnRect(String pt, Rectangle2D r)
          _more_
static Point2D getPointOnRect(String pt, Rectangle2D r, Point2D point)
          _more_
static String getRectPointName(String rectPoint)
          _more_
 Rectangle getRepaintBounds()
          _more_
 String getStretchPoint(int x, int y)
          _more_
static String getStretchPoint(RectangularShape r, int x, int y)
          _more_
 boolean getStretchy()
          _more_
 String getXml()
          Return the string used to recreate me
 void initDone()
          _more_
 String makeAttr(String name, String value)
          _more_
abstract  void moveBy(int x, int y)
          _more_
abstract  void moveTo(int x, int y)
          _more_
 void notifyChange()
          _more_
 void paint(Graphics g, DisplayCanvas c)
          _more_
 void paintHighlight(Graphics g, DisplayCanvas c)
          _more_
 void paintSelection(Graphics g, DisplayCanvas c)
          By default paint little black rectangles at the corners and the sides
static void paintSelectionPoints(Graphics g, RectangularShape r, int size)
          By default paint little black rectangles at the corners and the sides
 boolean pickable()
          _more_
 void processAttrs(String s)
          A Glyph can write out a persistent copy of itself as a set of attribute/value pairs.
 void setAttr(String name, String value)
          set my named atttribute to value
 void setBackground(Color c)
          _more_
 void setBeingCreated(boolean b)
          _more_
 void setFilled(boolean c)
          _more_
 void setForeground(Color c)
          _more_
 void setId(String newId)
          _more_
 void setLineWidth(int value)
          _more_
 void setParent(CompositeGlyph newParent)
          _more_
 void setPoints(int[] p, int cnt)
          Hook for setting points from the attribute line
 void setStretchy(boolean b)
          _more_
 String stretchTo(int x, int y, String pt, boolean correct)
          _more_
static String stretchTo(Rectangle bounds, int x, int y, String pt)
          _more_
static String stretchTo(Rectangle bounds, int x, int y, String pt, boolean correct, boolean symetric, boolean equalSides)
          _more_
static Rectangle toRect(RectangularShape r)
          _more_
 Point transformOutput(DisplayCanvas canvas, Point r)
          _more_
 Rectangle transformOutput(DisplayCanvas canvas, Rectangle r)
          _more_
 int transformOutputX(DisplayCanvas canvas, int x)
          _more_
 int transformOutputY(DisplayCanvas canvas, int x)
          _more_
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_GLYPH

public static final String TAG_GLYPH
_more_

See Also:
Constant Field Values

ATTR_CLASS

public static final String ATTR_CLASS
_more_

See Also:
Constant Field Values

PT_CENTER

public static final String PT_CENTER
_more_

See Also:
Constant Field Values

PT_V_UPPER

public static final String PT_V_UPPER
_more_

See Also:
Constant Field Values

PT_V_MIDDLE

public static final String PT_V_MIDDLE
_more_

See Also:
Constant Field Values

PT_V_LOWER

public static final String PT_V_LOWER
_more_

See Also:
Constant Field Values

PT_H_LEFT

public static final String PT_H_LEFT
_more_

See Also:
Constant Field Values

PT_H_MIDDLE

public static final String PT_H_MIDDLE
_more_

See Also:
Constant Field Values

PT_H_RIGHT

public static final String PT_H_RIGHT
_more_

See Also:
Constant Field Values

PT_UL

public static final String PT_UL
_more_

See Also:
Constant Field Values

PT_UM

public static final String PT_UM
_more_

See Also:
Constant Field Values

PT_UR

public static final String PT_UR
_more_

See Also:
Constant Field Values

PT_ML

public static final String PT_ML
_more_

See Also:
Constant Field Values

PT_MM

public static final String PT_MM
_more_

See Also:
Constant Field Values

PT_MR

public static final String PT_MR
_more_

See Also:
Constant Field Values

PT_LL

public static final String PT_LL
_more_

See Also:
Constant Field Values

PT_LM

public static final String PT_LM
_more_

See Also:
Constant Field Values

PT_LR

public static final String PT_LR
_more_

See Also:
Constant Field Values

RECTPOINTS

public static final String[] RECTPOINTS
_more_


RECTPOINTNAMES

public static final String[] RECTPOINTNAMES
_more_


PT_PREFIX

public static final String PT_PREFIX
_more_

See Also:
Constant Field Values

PT_P1

public static final String PT_P1
_more_

See Also:
Constant Field Values

PT_P2

public static final String PT_P2
_more_

See Also:
Constant Field Values

ATTR_CHILDREN

public static final String ATTR_CHILDREN
_more_

See Also:
Constant Field Values

ATTR_COLOR

public static final String ATTR_COLOR
_more_

See Also:
Constant Field Values

ATTR_BGCOLOR

public static final String ATTR_BGCOLOR
_more_

See Also:
Constant Field Values

ATTR_FILL

public static final String ATTR_FILL
_more_

See Also:
Constant Field Values

ATTR_HEIGHT

public static final String ATTR_HEIGHT
_more_

See Also:
Constant Field Values

ATTR_IMAGE

public static final String ATTR_IMAGE
_more_

See Also:
Constant Field Values

ATTR_LINEWIDTH

public static final String ATTR_LINEWIDTH
_more_

See Also:
Constant Field Values

ATTR_PARENT

public static final String ATTR_PARENT
_more_

See Also:
Constant Field Values

ATTR_PTS

public static final String ATTR_PTS
_more_

See Also:
Constant Field Values

ATTR_STRETCHY

public static final String ATTR_STRETCHY
_more_

See Also:
Constant Field Values

ATTR_TEXT

public static final String ATTR_TEXT
_more_

See Also:
Constant Field Values

ATTR_TYPE

public static final String ATTR_TYPE
_more_

See Also:
Constant Field Values

ATTR_WIDTH

public static final String ATTR_WIDTH
_more_

See Also:
Constant Field Values

idToGlyph

public static Hashtable idToGlyph
_more_


MIN_DISTANCE_TO_STRETCH

public static final int MIN_DISTANCE_TO_STRETCH
Some global consts

See Also:
Constant Field Values

SEL_WIDTH

public static final int SEL_WIDTH
_more_

See Also:
Constant Field Values

H_SEL_WIDTH

public static final int H_SEL_WIDTH
_more_

See Also:
Constant Field Values

highlightColor

public static final Color highlightColor
_more_


underline

public boolean underline
_more_


url

public String url
_more_


baseline

public int baseline
_more_

Constructor Detail

Glyph

public Glyph()
_more_

Method Detail

getCursor

public static Cursor getCursor(String rectPoint)
_more_

Parameters:
rectPoint - _more_
Returns:
_more_

getRectPointName

public static String getRectPointName(String rectPoint)
_more_

Parameters:
rectPoint -
Returns:
_more_

paintSelectionPoints

public static void paintSelectionPoints(Graphics g,
                                        RectangularShape r,
                                        int size)
By default paint little black rectangles at the corners and the sides

Parameters:
g - The graphics to paint into
r - The rectangle to decorate
size - Box size

flipY

public static String flipY(String pt)
_more_

Parameters:
pt -
Returns:
_more_

getPointOnRect

public static Point2D getPointOnRect(String pt,
                                     Rectangle2D r)
_more_

Parameters:
pt -
r -
Returns:
_more_

toRect

public static Rectangle toRect(RectangularShape r)
_more_

Parameters:
r - _more_
Returns:
_more_

getStretchPoint

public static String getStretchPoint(RectangularShape r,
                                     int x,
                                     int y)
_more_

Parameters:
r - _more_
x -
y -
Returns:
_more_

getPointOnRect

public static Point2D getPointOnRect(String pt,
                                     Rectangle2D r,
                                     Point2D point)
_more_

Parameters:
pt - The point spec
r - The rectangle
point - The point to set
Returns:
_more_

stretchTo

public static String stretchTo(Rectangle bounds,
                               int x,
                               int y,
                               String pt)
_more_

Parameters:
bounds -
x -
y -
pt -
Returns:
_more_

stretchTo

public static String stretchTo(Rectangle bounds,
                               int x,
                               int y,
                               String pt,
                               boolean correct,
                               boolean symetric,
                               boolean equalSides)
_more_

Parameters:
bounds - _more_
x -
y -
pt -
correct -
symetric - _more_
equalSides - _more_
Returns:
_more_

getStretchy

public boolean getStretchy()
_more_

Returns:
_more_

setStretchy

public void setStretchy(boolean b)
_more_

Parameters:
b -

setBeingCreated

public void setBeingCreated(boolean b)
_more_

Parameters:
b -

getBeingCreated

public boolean getBeingCreated()
_more_

Returns:
_more_

initDone

public void initDone()
_more_


setId

public void setId(String newId)
_more_

Parameters:
newId -

getId

public String getId()
_more_

Returns:
_more_

doRemove

public void doRemove()
_more_


setParent

public void setParent(CompositeGlyph newParent)
_more_

Parameters:
newParent -

pickable

public boolean pickable()
_more_

Returns:
_more_

notifyChange

public void notifyChange()
_more_


getCreateCommand

public CanvasCommand getCreateCommand(DisplayCanvas canvas,
                                      AWTEvent event,
                                      int x,
                                      int y)
_more_

Parameters:
canvas -
event -
x -
y -
Returns:
_more_

getMoveCommand

public CanvasCommand getMoveCommand(DisplayCanvas canvas,
                                    AWTEvent event,
                                    int x,
                                    int y)
_more_

Parameters:
canvas -
event -
x -
y -
Returns:
_more_

clone

protected Object clone()
                throws CloneNotSupportedException
_more_

Overrides:
clone in class Object
Returns:
_more_
Throws:
CloneNotSupportedException

getPersistent

public boolean getPersistent()
_more_

Returns:
_more_

canStretch

public boolean canStretch()
_more_

Returns:
_more_

boundsChanged

public void boundsChanged()
Hook for when the size or position of this glyph is changed


setPoints

public void setPoints(int[] p,
                      int cnt)
Hook for setting points from the attribute line

Parameters:
p -
cnt -

setForeground

public void setForeground(Color c)
_more_

Parameters:
c -

getForeground

public Color getForeground()
_more_

Returns:
_more_

setBackground

public void setBackground(Color c)
_more_

Parameters:
c -

getBackground

public Color getBackground()
_more_

Returns:
_more_

getBackground

public Color getBackground(Color dflt)
_more_

Parameters:
dflt -
Returns:
_more_

setLineWidth

public void setLineWidth(int value)
_more_

Parameters:
value -

getLineWidth

public int getLineWidth()
_more_

Returns:
_more_

setFilled

public void setFilled(boolean c)
_more_

Parameters:
c -

getFilled

public boolean getFilled()
_more_

Returns:
_more_

processAttrs

public void processAttrs(String s)
A Glyph can write out a persistent copy of itself as a set of attribute/value pairs. This method parses the line of attr/values of the form: ATTR=VALUE;ATTR=VALUE;

Parameters:
s -

setAttr

public void setAttr(String name,
                    String value)
set my named atttribute to value

Parameters:
name -
value -

getXml

public String getXml()
Return the string used to recreate me

Returns:
_more_

makeAttr

public String makeAttr(String name,
                       String value)
_more_

Parameters:
name -
value -
Returns:
_more_

getAttrs

public String getAttrs()
_more_

Returns:
_more_

paint

public void paint(Graphics g,
                  DisplayCanvas c)
_more_

Parameters:
g -
c -

paintSelection

public void paintSelection(Graphics g,
                           DisplayCanvas c)
By default paint little black rectangles at the corners and the sides

Parameters:
g -
c -

paintHighlight

public void paintHighlight(Graphics g,
                           DisplayCanvas c)
_more_

Parameters:
g -
c -

distance

public abstract double distance(int x,
                                int y)
_more_

Parameters:
x -
y -
Returns:
_more_

moveBy

public abstract void moveBy(int x,
                            int y)
_more_

Parameters:
x -
y -

moveTo

public abstract void moveTo(int x,
                            int y)
_more_

Parameters:
x -
y -

getBounds

public abstract Rectangle getBounds()
_more_

Returns:
_more_

getRepaintBounds

public Rectangle getRepaintBounds()
_more_

Returns:
_more_

getStretchPoint

public String getStretchPoint(int x,
                              int y)
_more_

Parameters:
x -
y -
Returns:
_more_

stretchTo

public String stretchTo(int x,
                        int y,
                        String pt,
                        boolean correct)
_more_

Parameters:
x -
y -
pt -
correct -
Returns:
_more_

distance

public static double distance(int x1,
                              int y1,
                              int x2,
                              int y2)
Utility method for distance between two points

Parameters:
x1 -
y1 -
x2 -
y2 -
Returns:
_more_

transformOutputX

public int transformOutputX(DisplayCanvas canvas,
                            int x)
_more_

Parameters:
canvas -
x -
Returns:
_more_

transformOutputY

public int transformOutputY(DisplayCanvas canvas,
                            int x)
_more_

Parameters:
canvas -
x -
Returns:
_more_

transformOutput

public Rectangle transformOutput(DisplayCanvas canvas,
                                 Rectangle r)
_more_

Parameters:
canvas -
r -
Returns:
_more_

transformOutput

public Point transformOutput(DisplayCanvas canvas,
                             Point r)
_more_

Parameters:
canvas -
r -
Returns:
_more_