PamView
Class PamSymbol

java.lang.Object
  extended by PamView.PamSymbol
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, javax.swing.Icon
Direct Known Subclasses:
CustomSymbol, Vessel

public class PamSymbol
extends java.lang.Object
implements java.io.Serializable, javax.swing.Icon, java.lang.Cloneable

Standard symbols for Pamguard graphics. A number of shapes are available, most of which can have a fill colour and a line colour. They may be created anywhere in Pamguard code using new PamSymbol(...) and can also be created and configured using a PamSymbolDialog to chose the symbol type, colours, line thicknesses, etc. A selection of drawing routines allow you to draw them on plots with varying sizes at any location.

Author:
Doug Gillespie
See Also:
PamSymbolDialog, PanelOverlayDraw, Serialized Form

Nested Class Summary
private  class PamSymbol.KeyPanel
           
 
Field Summary
private static double[] diax
           
private static double[] diay
           
private  java.awt.Polygon drawnPolygon
          The last polygon used for drawing.
private  boolean fill
           
private  java.awt.Color fillColor
           
private  int height
           
private static double[] hexx
           
private static double[] hexy
           
static int ICON_HORIZONTAL_CENTRE
           
static int ICON_HORIZONTAL_FILL
           
static int ICON_HORIZONTAL_LEFT
           
static int ICON_HORIZONTAL_RIGHT
           
static int ICON_STYLE_LINE
           
static int ICON_STYLE_SYMBOL
           
static int ICON_VERTICAL_BOTTOM
           
static int ICON_VERTICAL_FILL
           
static int ICON_VERTICAL_MIDDLE
           
static int ICON_VERTICAL_TOP
           
private  int iconHorizontalAlignment
           
private  int iconStyle
           
private  int iconVerticalAlignment
           
private  java.awt.Color lineColor
           
private  float lineThickness
           
private static double[] pentx
           
private static double[] penty
           
static long serialVersionUID
           
private static double[] sqx
           
private static double[] sqy
           
private  int symbol
           
static int SYMBOL_CIRCLE
           
static int SYMBOL_CROSS
           
static int SYMBOL_CROSS2
           
static int SYMBOL_CUSTOMPOLYGON
           
static int SYMBOL_DIAMOND
           
static int SYMBOL_DOUBLETRIANGLEL
           
static int SYMBOL_DOUBLETRIANGLER
           
static int SYMBOL_HEXAGRAM
           
static int SYMBOL_LINESEGMENT
           
static int SYMBOL_LINESTART
           
static int SYMBOL_NONE
           
static int SYMBOL_PENTAGRAM
           
static int SYMBOL_POINT
           
static int SYMBOL_REGIONSTART
           
static int SYMBOL_SQUARE
           
static int SYMBOL_STAR
           
static int SYMBOL_TRIANGLED
           
static int SYMBOL_TRIANGLEL
           
static int SYMBOL_TRIANGLER
           
static int SYMBOL_TRIANGLEU
           
private static double[] trdx
           
private static double[] trdy
           
private static double[] trlx
           
private static double[] trly
           
private static double[] trrx
           
private static double[] trry
           
private static double[] trux
           
private static double[] truy
           
private  int width
           
 
Constructor Summary
PamSymbol()
          Simplest constructor creates a PamSymbol with default attributes.
PamSymbol(int symbol, int width, int height, boolean fill, java.awt.Color fillColor, java.awt.Color lineColor)
          Creates a PamSymbol with a given shape, size, colour, etc.
 
Method Summary
 PamSymbol clone()
           
 java.awt.Rectangle draw(java.awt.Graphics g, java.awt.Point pt)
          Draw the symbbol at a given point using it's preset size.
 java.awt.Rectangle draw(java.awt.Graphics g, java.awt.Point pt, double w, double h, boolean fill, float lineThickness, java.awt.Color fillColor, java.awt.Color lineColor)
          Draw the symbol using a complete new set of parameters.
 void draw(java.awt.Graphics g, java.awt.Point pt, int width, int height)
          Draw the symbol at a given point using a new width and height.
static java.awt.Rectangle drawArrow(java.awt.Graphics g, double x1, double y1, double x2, double y2, double headSize, double headAngle, boolean doubleEnded)
           
static java.awt.Rectangle drawArrow(java.awt.Graphics g, int x1, int y1, int x2, int y2, int headSize)
           
private  void drawScaledPolygon(java.awt.Graphics2D g2d, java.awt.Point pt, int np, double halfWidth, double halfHeight, double[] px, double[] py, boolean fill, java.awt.Color fillColor, java.awt.Color lineColor)
          Does the actual drawing work.
 java.awt.Polygon getDrawnPolygon()
           
 java.awt.Color getFillColor()
           
 int getHeight()
           
 int getIconHeight()
          Returns the icon's height.
 int getIconHorizontalAlignment()
           
 int getIconStyle()
           
 int getIconVerticalAlignment()
           
 int getIconWidth()
          Returns the icon's width.
 java.awt.Color getLineColor()
           
 float getLineThickness()
           
 int getSymbol()
           
 char getTextCode()
           
static char getTextCode(int symbol)
          Get a text code for a symbol
 int getWidth()
           
 double[] getXPoints()
           
 double[] getYPoints()
           
static int interpretTextCode(java.lang.String textCode)
          Convert a single character text code into a symbol type
 boolean isFill()
           
 boolean isSolidShape()
           
 PamKeyItem makeKeyItem(java.lang.String text)
          Create a small JPanel to incorporate into a key.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
           
 void setFill(boolean fill)
           
 void setFillColor(java.awt.Color fillColor)
           
 void setHeight(int height)
           
 void setIconHorizontalAlignment(int hAlignment)
           
 void setIconStyle(int iconStyle)
           
 void setIconVerticalAlignment(int iconVerticalAlignment)
           
 void setLineColor(java.awt.Color lineColor)
           
 void setLineThickness(float lineThickness)
           
private  void setSquareDrawnPolygon(int x1, int y1, int x2, int y2)
          Called to set a square drawn polygon when drawing shapes which didn't actually use the polygon draw function.
 void setSymbol(int symbol)
           
 void setWidth(int width)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

SYMBOL_NONE

public static final int SYMBOL_NONE
See Also:
Constant Field Values

SYMBOL_REGIONSTART

public static final int SYMBOL_REGIONSTART
See Also:
Constant Field Values

SYMBOL_LINESTART

public static final int SYMBOL_LINESTART
See Also:
Constant Field Values

SYMBOL_LINESEGMENT

public static final int SYMBOL_LINESEGMENT
See Also:
Constant Field Values

SYMBOL_CROSS

public static final int SYMBOL_CROSS
See Also:
Constant Field Values

SYMBOL_CROSS2

public static final int SYMBOL_CROSS2
See Also:
Constant Field Values

SYMBOL_SQUARE

public static final int SYMBOL_SQUARE
See Also:
Constant Field Values

SYMBOL_TRIANGLEU

public static final int SYMBOL_TRIANGLEU
See Also:
Constant Field Values

SYMBOL_CIRCLE

public static final int SYMBOL_CIRCLE
See Also:
Constant Field Values

SYMBOL_DIAMOND

public static final int SYMBOL_DIAMOND
See Also:
Constant Field Values

SYMBOL_POINT

public static final int SYMBOL_POINT
See Also:
Constant Field Values

SYMBOL_STAR

public static final int SYMBOL_STAR
See Also:
Constant Field Values

SYMBOL_TRIANGLED

public static final int SYMBOL_TRIANGLED
See Also:
Constant Field Values

SYMBOL_TRIANGLEL

public static final int SYMBOL_TRIANGLEL
See Also:
Constant Field Values

SYMBOL_TRIANGLER

public static final int SYMBOL_TRIANGLER
See Also:
Constant Field Values

SYMBOL_PENTAGRAM

public static final int SYMBOL_PENTAGRAM
See Also:
Constant Field Values

SYMBOL_HEXAGRAM

public static final int SYMBOL_HEXAGRAM
See Also:
Constant Field Values

SYMBOL_CUSTOMPOLYGON

public static final int SYMBOL_CUSTOMPOLYGON
See Also:
Constant Field Values

SYMBOL_DOUBLETRIANGLEL

public static final int SYMBOL_DOUBLETRIANGLEL
See Also:
Constant Field Values

SYMBOL_DOUBLETRIANGLER

public static final int SYMBOL_DOUBLETRIANGLER
See Also:
Constant Field Values

ICON_STYLE_SYMBOL

public static final int ICON_STYLE_SYMBOL
See Also:
Constant Field Values

ICON_STYLE_LINE

public static final int ICON_STYLE_LINE
See Also:
Constant Field Values

iconStyle

private int iconStyle

sqx

private static final double[] sqx

sqy

private static final double[] sqy

diax

private static final double[] diax

diay

private static final double[] diay

trux

private static final double[] trux

truy

private static final double[] truy

trdx

private static final double[] trdx

trdy

private static final double[] trdy

trrx

private static final double[] trrx

trry

private static final double[] trry

trlx

private static final double[] trlx

trly

private static final double[] trly

pentx

private static final double[] pentx

penty

private static final double[] penty

hexx

private static final double[] hexx

hexy

private static final double[] hexy

symbol

private int symbol

width

private int width

height

private int height

lineThickness

private float lineThickness

fill

private boolean fill

fillColor

private java.awt.Color fillColor

lineColor

private java.awt.Color lineColor

drawnPolygon

private transient java.awt.Polygon drawnPolygon
The last polygon used for drawing.


ICON_HORIZONTAL_LEFT

public static final int ICON_HORIZONTAL_LEFT
See Also:
Constant Field Values

ICON_HORIZONTAL_CENTRE

public static final int ICON_HORIZONTAL_CENTRE
See Also:
Constant Field Values

ICON_HORIZONTAL_RIGHT

public static final int ICON_HORIZONTAL_RIGHT
See Also:
Constant Field Values

ICON_HORIZONTAL_FILL

public static final int ICON_HORIZONTAL_FILL
See Also:
Constant Field Values

iconHorizontalAlignment

private int iconHorizontalAlignment

ICON_VERTICAL_TOP

public static final int ICON_VERTICAL_TOP
See Also:
Constant Field Values

ICON_VERTICAL_MIDDLE

public static final int ICON_VERTICAL_MIDDLE
See Also:
Constant Field Values

ICON_VERTICAL_BOTTOM

public static final int ICON_VERTICAL_BOTTOM
See Also:
Constant Field Values

ICON_VERTICAL_FILL

public static final int ICON_VERTICAL_FILL
See Also:
Constant Field Values

iconVerticalAlignment

private int iconVerticalAlignment
Constructor Detail

PamSymbol

public PamSymbol()
Simplest constructor creates a PamSymbol with default attributes. You will probably only use this constructor if you plan to subsequently modify it with PamSymbolDialog

See Also:
PamSymbolDialog

PamSymbol

public PamSymbol(int symbol,
                 int width,
                 int height,
                 boolean fill,
                 java.awt.Color fillColor,
                 java.awt.Color lineColor)
Creates a PamSymbol with a given shape, size, colour, etc.

Parameters:
symbol - Symbol type
width - Width of symbol in pixels
height - Height of symbol in pixels
fill - true if the symbol is to be filled, false if the shape should be hollow
fillColor - fill colour (required fill to be true)
lineColor - line colour
Method Detail

interpretTextCode

public static int interpretTextCode(java.lang.String textCode)
Convert a single character text code into a symbol type

Parameters:
textCode - text code
Returns:
symbol type

getTextCode

public char getTextCode()
Returns:
the text code for this symbol

getTextCode

public static char getTextCode(int symbol)
Get a text code for a symbol

Parameters:
symbol - symbol type
Returns:
text code

draw

public java.awt.Rectangle draw(java.awt.Graphics g,
                               java.awt.Point pt)
Draw the symbbol at a given point using it's preset size.

Parameters:
g - graphics component to draw on
pt - x,y coordinate to draw centre of symbol at

draw

public void draw(java.awt.Graphics g,
                 java.awt.Point pt,
                 int width,
                 int height)
Draw the symbol at a given point using a new width and height.

Parameters:
g - graphics component to draw on
pt - x,y coordinate to draw centre of symbol at
width - width for drawing symbol (overrides preset width)
height - height for drawing symbol (overrides prest height)

draw

public java.awt.Rectangle draw(java.awt.Graphics g,
                               java.awt.Point pt,
                               double w,
                               double h,
                               boolean fill,
                               float lineThickness,
                               java.awt.Color fillColor,
                               java.awt.Color lineColor)
Draw the symbol using a complete new set of parameters.

Parameters:
g - graphics component to draw on
pt - x,y coordinate to draw centre of symbol at
w - width for drawing symbol (overrides preset width)
h - height for drawing symbol (overrides prest height)
fill - true if the symbol is to be filled, false for hollow
lineThickness - outer line thickness
fillColor - fill colour
lineColor - line colour
Returns:
a rectangle giving an outer boud of the shape (can be used to invaldiate a graphic for redrawing).

setSquareDrawnPolygon

private void setSquareDrawnPolygon(int x1,
                                   int y1,
                                   int x2,
                                   int y2)
Called to set a square drawn polygon when drawing shapes which didn't actually use the polygon draw function.

Parameters:
x1 -
y1 -
x2 -
y2 -

getDrawnPolygon

public java.awt.Polygon getDrawnPolygon()
Returns:
the last drawn polygon

drawScaledPolygon

private void drawScaledPolygon(java.awt.Graphics2D g2d,
                               java.awt.Point pt,
                               int np,
                               double halfWidth,
                               double halfHeight,
                               double[] px,
                               double[] py,
                               boolean fill,
                               java.awt.Color fillColor,
                               java.awt.Color lineColor)
Does the actual drawing work.


paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface javax.swing.Icon

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isSolidShape

public boolean isSolidShape()
Returns:
true if the symbol is a solid shape - e.g. is true for a circle, but false for a cross.

getIconWidth

public int getIconWidth()
Returns the icon's width.

Specified by:
getIconWidth in interface javax.swing.Icon
Returns:
an int specifying the fixed width of the icon.

getIconHeight

public int getIconHeight()
Returns the icon's height.

Specified by:
getIconHeight in interface javax.swing.Icon
Returns:
an int specifying the fixed height of the icon.

isFill

public boolean isFill()

setFill

public void setFill(boolean fill)

getFillColor

public java.awt.Color getFillColor()

setFillColor

public void setFillColor(java.awt.Color fillColor)

getHeight

public int getHeight()

setHeight

public void setHeight(int height)

getLineColor

public java.awt.Color getLineColor()

setLineColor

public void setLineColor(java.awt.Color lineColor)

getSymbol

public int getSymbol()

setSymbol

public void setSymbol(int symbol)

getWidth

public int getWidth()

setWidth

public void setWidth(int width)

getLineThickness

public float getLineThickness()

setLineThickness

public void setLineThickness(float lineThickness)

makeKeyItem

public PamKeyItem makeKeyItem(java.lang.String text)
Create a small JPanel to incorporate into a key. The component will contain a small panel on the left with a symbol drawn in it and a panel on the right with the text as a JLabel.

Parameters:
text -
Returns:
Java component to include in a key

clone

public PamSymbol clone()
Overrides:
clone in class java.lang.Object

drawArrow

public static java.awt.Rectangle drawArrow(java.awt.Graphics g,
                                           int x1,
                                           int y1,
                                           int x2,
                                           int y2,
                                           int headSize)

drawArrow

public static java.awt.Rectangle drawArrow(java.awt.Graphics g,
                                           double x1,
                                           double y1,
                                           double x2,
                                           double y2,
                                           double headSize,
                                           double headAngle,
                                           boolean doubleEnded)

getXPoints

public double[] getXPoints()

getYPoints

public double[] getYPoints()

getIconStyle

public int getIconStyle()
Returns:
the iconStyle

setIconStyle

public void setIconStyle(int iconStyle)
Parameters:
iconStyle - the iconStyle to set

setIconHorizontalAlignment

public void setIconHorizontalAlignment(int hAlignment)
Parameters:
hAlignment - the icon horizontal alignment

getIconVerticalAlignment

public int getIconVerticalAlignment()
Returns:
the iconVerticalAlignment

setIconVerticalAlignment

public void setIconVerticalAlignment(int iconVerticalAlignment)
Parameters:
iconVerticalAlignment - the iconVerticalAlignment to set

getIconHorizontalAlignment

public int getIconHorizontalAlignment()
Returns:
the iconHorizontalAlignment