megamek.client.ui.swing.util
Class StraightArrowPolygon

java.lang.Object
  extended by java.awt.Polygon
      extended by megamek.client.ui.swing.util.StraightArrowPolygon
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable

public class StraightArrowPolygon
extends java.awt.Polygon

This class calculates and stores points of polygon shaped as straight arrow. Minimum required arguments are two Point elements - start and end of arrow.

Special feature of this class is last boolean argument. It defines if it will be full shaped arrow or left half only. Private Polygon hotArea contains same points as an arrow itself except when arrow is changed to halved hotArea stays if full arrow shape. It was done in order to get only one tooltip for two arrows in case of mutual attack.

Author:
Slava Zipunov (zipp32)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.awt.Polygon
bounds, npoints, xpoints, ypoints
 
Constructor Summary
StraightArrowPolygon(java.awt.Point startPoint, java.awt.Point endPoint, boolean halved)
          Short constructor.
StraightArrowPolygon(java.awt.Point startPoint, java.awt.Point endPoint, int width, boolean halved)
          One more constructor
StraightArrowPolygon(java.awt.Point startPoint, java.awt.Point endPoint, int width, int headWidth, boolean halved)
          I know, it is annoying, but another constructor
StraightArrowPolygon(java.awt.Point startPoint, java.awt.Point endPoint, int headLength, int headWidth, int arrowWidthAtHead, int tailWidth, int tailLength, boolean halved)
          Most extencive constructor with all paremeters given
 
Method Summary
 boolean contains(double x, double y)
           
 boolean contains(int x, int y)
           
 boolean contains(java.awt.Point p)
           
 void translate(int deltaX, int deltaY)
           
 
Methods inherited from class java.awt.Polygon
addPoint, contains, contains, contains, getBoundingBox, getBounds, getBounds2D, getPathIterator, getPathIterator, inside, intersects, intersects, invalidate, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StraightArrowPolygon

public StraightArrowPolygon(java.awt.Point startPoint,
                            java.awt.Point endPoint,
                            int headLength,
                            int headWidth,
                            int arrowWidthAtHead,
                            int tailWidth,
                            int tailLength,
                            boolean halved)
Most extencive constructor with all paremeters given


StraightArrowPolygon

public StraightArrowPolygon(java.awt.Point startPoint,
                            java.awt.Point endPoint,
                            boolean halved)
Short constructor. Two points and boolean value.


StraightArrowPolygon

public StraightArrowPolygon(java.awt.Point startPoint,
                            java.awt.Point endPoint,
                            int width,
                            boolean halved)
One more constructor


StraightArrowPolygon

public StraightArrowPolygon(java.awt.Point startPoint,
                            java.awt.Point endPoint,
                            int width,
                            int headWidth,
                            boolean halved)
I know, it is annoying, but another constructor

Method Detail

contains

public boolean contains(int x,
                        int y)
Overrides:
contains in class java.awt.Polygon

contains

public boolean contains(java.awt.Point p)
Overrides:
contains in class java.awt.Polygon

contains

public boolean contains(double x,
                        double y)
Specified by:
contains in interface java.awt.Shape
Overrides:
contains in class java.awt.Polygon

translate

public void translate(int deltaX,
                      int deltaY)
Overrides:
translate in class java.awt.Polygon