ch.sahits.game.graphic.display.util
Class ClickablePolygons

java.lang.Object
  extended by ch.sahits.game.graphic.display.util.ClickablePolygons

public class ClickablePolygons
extends Object

This class represents an ordered list of poligons. With each polygon is an action associated that is executed if clicked inside the polygon.

Author:
Andi Hotz, (c) Sahits GmbH, 2011 Created on Nov 23, 2011

Field Summary
private  Rectangle area
           
private  List<ClickablePolygon> polygons
           
 
Constructor Summary
ClickablePolygons()
           
 
Method Summary
 void add(NamedPolygon polygon, Runnable action)
          Add a new polygon to the list
private  ClickablePolygon findPolygon(Point p)
          Find the first polygon that has the point inside it.
 void testAndExecute(Point p)
          Find the polygon that contains the point and if such a polygon exists execute its action
private  void updateArea(Polygon polygon)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

polygons

private List<ClickablePolygon> polygons

area

private Rectangle area
Constructor Detail

ClickablePolygons

public ClickablePolygons()
Method Detail

add

public void add(NamedPolygon polygon,
                Runnable action)
Add a new polygon to the list

Parameters:
polygon -
action -

updateArea

private void updateArea(Polygon polygon)

testAndExecute

public void testAndExecute(Point p)
Find the polygon that contains the point and if such a polygon exists execute its action

Parameters:
p -

findPolygon

private ClickablePolygon findPolygon(Point p)
Find the first polygon that has the point inside it.

Parameters:
p -
Returns:


Copyright © 2011 Sahits GmbH. All Rights Reserved.