org.placelab.util.swt
Class Glyph

java.lang.Object
  extended byorg.placelab.util.swt.Glyph
Direct Known Subclasses:
GlyphBeacon, GlyphComposite, GlyphImage, GlyphLabel, GlyphLine, GlyphPoly, GlyphRectangle, GlyphReticle, ParticleFilterVisualizer, RegionGlyph

public abstract class Glyph
extends java.lang.Object


Field Summary
static int ANCHOR_C
           
static int ANCHOR_E
           
static int ANCHOR_N
           
static int ANCHOR_NE
           
static int ANCHOR_NW
           
static int ANCHOR_S
           
static int ANCHOR_SE
           
static int ANCHOR_SW
           
static int ANCHOR_W
           
static int DISPOSED
           
static int IGNORE_TRANSPARENCY
           
static int MOUSE_EVENTS
           
protected  boolean needsTransformRedraw
           
static int NONE
           
protected  AffineTransform transform
           
protected  org.eclipse.swt.graphics.Image transformedImage
           
protected  int transparency
           
static int VISIBLE
           
protected  double zoom
           
 
Constructor Summary
Glyph(GlyphComposite parent, int style)
           
Glyph(GlyphHolder holder, int style)
           
 
Method Summary
 void addListener(int eventType, org.eclipse.swt.widgets.Listener handler)
           
 void addMouseListener(org.eclipse.swt.events.MouseListener listener)
           
 void addPaintListener(org.eclipse.swt.events.PaintListener listener)
           
 boolean areMouseEventsEnabled()
           
 void dispose()
           
 void enableMouseEvents(boolean enable)
           
protected  void enter(org.eclipse.swt.events.MouseEvent e)
           
 org.eclipse.swt.graphics.Rectangle getBounds()
           
protected abstract  org.eclipse.swt.graphics.Rectangle getBoundsImpl()
           
 int getCloseEnough()
           
 boolean getFlag(int flag)
           
 GlyphHolder getHolder()
           
 org.eclipse.swt.graphics.Point getLocation()
          Gets the location that the Glyph is currently at, translated to account for zoom
protected  org.eclipse.swt.graphics.Color getMaskColor()
          Because swt cannot draw into an image and leave the pixels in the image not drawn on in a transparent state and make the other pixels opaque, Glyphs must set a mask color which stands for transparent.
protected  boolean getNeedsTransformRedraw()
          Return true here if your glyph needs to have its transform image recalculated That is, if its changed anywhere that will matter, return true.
 org.eclipse.swt.graphics.Point getOriginalLocation()
          Gets the location that the Glyph is set to for a zoom of 1.0
 GlyphComposite getParent()
           
 AffineTransform getTransform()
           
 int getTransparency()
           
 double getZoom()
           
 void handleMouseEvent(int eventType, org.eclipse.swt.events.MouseEvent e)
           
 boolean isDisposed()
           
 boolean isVisible()
           
protected  void leave(org.eclipse.swt.events.MouseEvent e)
           
 void moveAbove(Glyph glyph)
           
 void moveBelow(Glyph glyph)
           
 void notifyListeners(int eventType, org.eclipse.swt.widgets.Event event)
           
 void paint(org.eclipse.swt.events.PaintEvent e, GlyphGC gc)
          If you want to do your own drawing for the AffineTransform (for instance, your glyph is a vector graphic thats easily drawn transformed, override this and handle for the transform yourself).
protected  void paintImpl(org.eclipse.swt.events.PaintEvent e, GlyphGC gc)
          Implement this if you don't want to worry about AffineTransforms.
 Glyph pickGlyphAt(int x, int y, boolean checkMouseEnabled)
           
 boolean pointInside(int x, int y)
           
 boolean pointInside(org.eclipse.swt.graphics.Point p)
           
protected abstract  boolean pointInsideImpl(int x, int y)
          Return if the point is inside your glyph without the AffineTransform applied
 void redraw(org.eclipse.swt.graphics.Rectangle invalidate)
           
 void removeListener(int eventType, org.eclipse.swt.widgets.Listener handler)
           
 void resetFlag(int flag)
           
 void setCloseEnough(int c)
           
 void setCursor(org.eclipse.swt.graphics.Cursor cursor)
           
 void setFlag(int flag)
           
 void setLocation(org.eclipse.swt.graphics.Point loc)
           
protected  void setNeedsTransformRedraw(boolean flag)
           
 void setTransform(AffineTransform aTransform)
           
 void setTransparency(int newTransparency)
           
 void setVisible(boolean visible)
           
 void setZoom(double z)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANCHOR_NW

public static final int ANCHOR_NW
See Also:
Constant Field Values

ANCHOR_N

public static final int ANCHOR_N
See Also:
Constant Field Values

ANCHOR_NE

public static final int ANCHOR_NE
See Also:
Constant Field Values

ANCHOR_E

public static final int ANCHOR_E
See Also:
Constant Field Values

ANCHOR_SE

public static final int ANCHOR_SE
See Also:
Constant Field Values

ANCHOR_S

public static final int ANCHOR_S
See Also:
Constant Field Values

ANCHOR_SW

public static final int ANCHOR_SW
See Also:
Constant Field Values

ANCHOR_W

public static final int ANCHOR_W
See Also:
Constant Field Values

ANCHOR_C

public static final int ANCHOR_C
See Also:
Constant Field Values

NONE

public static final int NONE
See Also:
Constant Field Values

DISPOSED

public static final int DISPOSED
See Also:
Constant Field Values

VISIBLE

public static final int VISIBLE
See Also:
Constant Field Values

MOUSE_EVENTS

public static final int MOUSE_EVENTS
See Also:
Constant Field Values

IGNORE_TRANSPARENCY

public static final int IGNORE_TRANSPARENCY
See Also:
Constant Field Values

transform

protected AffineTransform transform

needsTransformRedraw

protected boolean needsTransformRedraw

transformedImage

protected org.eclipse.swt.graphics.Image transformedImage

transparency

protected int transparency

zoom

protected double zoom
Constructor Detail

Glyph

public Glyph(GlyphComposite parent,
             int style)

Glyph

public Glyph(GlyphHolder holder,
             int style)
Method Detail

setFlag

public void setFlag(int flag)

resetFlag

public void resetFlag(int flag)

getFlag

public boolean getFlag(int flag)

isDisposed

public boolean isDisposed()

getHolder

public GlyphHolder getHolder()

getParent

public GlyphComposite getParent()

setCloseEnough

public void setCloseEnough(int c)

getCloseEnough

public int getCloseEnough()

setTransparency

public void setTransparency(int newTransparency)

getTransparency

public int getTransparency()
Returns:
a value between 0 and 255

setTransform

public void setTransform(AffineTransform aTransform)

getTransform

public AffineTransform getTransform()

setZoom

public void setZoom(double z)

getZoom

public double getZoom()

setLocation

public void setLocation(org.eclipse.swt.graphics.Point loc)

getOriginalLocation

public org.eclipse.swt.graphics.Point getOriginalLocation()
Gets the location that the Glyph is set to for a zoom of 1.0

Returns:
the unzoomed location

getLocation

public org.eclipse.swt.graphics.Point getLocation()
Gets the location that the Glyph is currently at, translated to account for zoom

Returns:
the zoom translated location

dispose

public void dispose()

addListener

public void addListener(int eventType,
                        org.eclipse.swt.widgets.Listener handler)

removeListener

public void removeListener(int eventType,
                           org.eclipse.swt.widgets.Listener handler)

notifyListeners

public void notifyListeners(int eventType,
                            org.eclipse.swt.widgets.Event event)

addPaintListener

public void addPaintListener(org.eclipse.swt.events.PaintListener listener)

addMouseListener

public void addMouseListener(org.eclipse.swt.events.MouseListener listener)

paint

public void paint(org.eclipse.swt.events.PaintEvent e,
                  GlyphGC gc)
If you want to do your own drawing for the AffineTransform (for instance, your glyph is a vector graphic thats easily drawn transformed, override this and handle for the transform yourself).


paintImpl

protected void paintImpl(org.eclipse.swt.events.PaintEvent e,
                         GlyphGC gc)
Implement this if you don't want to worry about AffineTransforms. Your graphics will be rasterized and have an AffineTransform applied to them


getMaskColor

protected org.eclipse.swt.graphics.Color getMaskColor()
Because swt cannot draw into an image and leave the pixels in the image not drawn on in a transparent state and make the other pixels opaque, Glyphs must set a mask color which stands for transparent. You may return null if you don't need any areas masked out.


getNeedsTransformRedraw

protected boolean getNeedsTransformRedraw()
Return true here if your glyph needs to have its transform image recalculated That is, if its changed anywhere that will matter, return true. If it hasn't, return false and you get the cached image so we don't waste a bunch of time transforming images, which is not fast I might add.


setNeedsTransformRedraw

protected void setNeedsTransformRedraw(boolean flag)

handleMouseEvent

public void handleMouseEvent(int eventType,
                             org.eclipse.swt.events.MouseEvent e)

pickGlyphAt

public Glyph pickGlyphAt(int x,
                         int y,
                         boolean checkMouseEnabled)

redraw

public void redraw(org.eclipse.swt.graphics.Rectangle invalidate)

setVisible

public void setVisible(boolean visible)

isVisible

public boolean isVisible()

enableMouseEvents

public void enableMouseEvents(boolean enable)

areMouseEventsEnabled

public boolean areMouseEventsEnabled()

getBounds

public org.eclipse.swt.graphics.Rectangle getBounds()

pointInside

public boolean pointInside(int x,
                           int y)

getBoundsImpl

protected abstract org.eclipse.swt.graphics.Rectangle getBoundsImpl()
Returns:
your bounds without having the AffineTransform applied to them

pointInsideImpl

protected abstract boolean pointInsideImpl(int x,
                                           int y)
Return if the point is inside your glyph without the AffineTransform applied


pointInside

public boolean pointInside(org.eclipse.swt.graphics.Point p)

moveAbove

public void moveAbove(Glyph glyph)

moveBelow

public void moveBelow(Glyph glyph)

setCursor

public void setCursor(org.eclipse.swt.graphics.Cursor cursor)

enter

protected void enter(org.eclipse.swt.events.MouseEvent e)

leave

protected void leave(org.eclipse.swt.events.MouseEvent e)