//****************************************************************************
// CLASS NAME:	PetriComponent.java
//
// AUTHOR:	Rick Brink
//		rick@mail.csh.rit.edu
//		http://www.csh.rit.edu/~rick
//
// VERSION:	1.1
//
// HISTORY:	4/16/96		Initial Version
//         10/06/96     Changed setCoordinates to translateCoordinates
//
// COPYRIGHT INFORMATION:
//
// This program and the Java source is in the public domain.
// Permission to use, copy, modify, and distribute this software
// and its documentation for NON-COMMERCIAL purposes and
// without fee is hereby granted.
//
//    Copyright 1996
//
//    Rick Brink
//    1266 Brighton-Henrietta Townline Rd.
//    Rochester, NY 14623
//
// DISCLAIMER:
//
// The author claims no responsibility for any damage, direct or indirect,
// to any harware or software as a result of using this program.
//****************************************************************************

/**
  * A class representing a generic Component in a Petri Net diagram.
  * This class contains common variables and methods for all
  * Petri Net Components, and should be subclassed to add additional
  * functionality.
  *
  * @see Arc
  * @see Caption
  * @see Place
  * @see Token
  * @see Transition
  *
  * @version 1.0 July 3, 1996
  *
  * @author  Rick Brink
**/
class PetriComponent extends Object {
    /** X coordinate of the Component **/
    private protected int xCoordinate_;

    /** Y coordinate of the Component **/
    private protected int yCoordinate_;

    /** Whether or not the Component is currently selected **/
    private protected boolean selected_;

    /** Size of the squares defining the select box **/
    private protected final int SELECT_SIZE = 5;

    /**
      * Translate the coordinates of the component
      * to be (xCoordinate_ + xTranslate, yCoordinate_ + yTranslate)
    **/
    public void translateCoordinates(int xTranslate, int yTranslate) {
        xCoordinate_ += xTranslate;
        yCoordinate_ += yTranslate;
    }

    /**
      * Set the component to be either selected or not selected
    **/
    public void setSelected(boolean select) {
        selected_ = select;
    }

    /**
      * Toggle whether or not the Component is selected.
    **/
    public void toggleSelected() {
        if (selected_) {
            selected_ = false;
        }
        else {
            selected_ = true;
        }
    }

    /**
      * Return whether or not the Component is selected.
    **/
    public boolean isSelected() {
        return(selected_);
    }

    /**
      * Get the value of the X coordinate
    **/
    public int getXCoordinate() {
        return (xCoordinate_);
    }

    /**
      * Get the value of the Y coordinate
    **/
    public int getYCoordinate() {
        return (yCoordinate_);
    }
}
