// EdgeButton.java Copyright (c) 2004 brising.com import java.awt.Color; import java.awt.Point; import java.awt.event.ActionEvent; import javax.swing.SwingUtilities; /** I am a button on the edge of the button matrix. I generate Photons and display the results of their travels. */ public class EdgeButton extends GameButton { // INSTANCE VARIABLES ///////////////////////////////////////////////////////// Point hpDirection; Point hpLocation; // CONSTRUCTORS /////////////////////////////////////////////////////////////// public EdgeButton ( Point apLocation, Point apDirection ) { hpLocation = apLocation; hpDirection = apDirection; } // PUBLIC INSTANCE METHODS //////////////////////////////////////////////////// /** Fire a Photon. */ public void actionPerformed ( ActionEvent aoActionEvent ) { SwingUtilities.invokeLater (new Photon (hpLocation ,hpDirection, (GamePanel)getParent()) ); } /** What is my default background color? */ public Color getBackgroundDefault ( ) { return Color.lightGray; } /** How many points do I subtract from the game's score when I change color? */ public int getScore ( ) { return 1; } /** Indicate that a Photon started here. */ public void initiate ( ) { if (hasBackgroundDefault()) changeScore(); setBackground(Color.green); } /** Indicate that a Photon stopped here. */ public void terminate ( ) { if (hasBackgroundDefault()) changeScore(); setBackground(Color.red); } }