package pipe.dataLayer; import java.awt.Color; import java.awt.Shape; import java.awt.Point; import java.awt.geom.*; import java.awt.Rectangle; import javax.swing.JLabel; import java.awt.event.*; import java.awt.Graphics; /** * PetriNetObject - Petri-Net Object Class - Abstract * @see
* @version 1.0 * @author James D Bloom */ public abstract class PetriNetObject extends JLabel implements MouseListener, MouseMotionListener { /** Id */ protected String id = null; /** Color of PetriNetObject*/ protected Color color = null; /** Name Label for displaying name*/ public NameLabel pnname; /** when a pnobject has an arc attached to it we don't allow it to move */ private boolean movable = true; /** * Modifies coordinates implemented by all Place, Transition, Arc * * @param startX Start X-axis Position * @param startY Start Y-axis Position * @param endX End X-axis Position * @param endY End Y-axis Position */ public abstract void modify(double startX, double startY, double endX, double endY); /** * Create PetriNetObject * * @param idInput Input Id * @param colorInput Input Color */ public PetriNetObject(String idInput, Color colorInput){ id = idInput; } public PetriNetObject(String label) { super(label); } /** * Create PetriNetObject * * @param colorInput Color value for color */ public PetriNetObject(Color colorInput){ color = colorInput; } /** * Create PetriNetObject * */ public PetriNetObject(){ } /** * Set color * * @param colorInput Color value for color */ public void setColor(Color colorInput){ color = colorInput; } /** * Get color * * @return Color value for color */ public Color getColor(){ return color; } /** * Set id * * @param idInput String value for id; */ public void setId(String idInput) { id = idInput; } /** * Get id returns null if value not yet entered * * @return String value for id; */ public String getId() { return id; } /* These can be implemented fully in the subclasses if necessary */ public void mouseDragged(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseMoved(MouseEvent e) {} public void mouseClicked(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void mousePressed(MouseEvent e) {} public abstract void updateSize(MouseEvent e); public void paintComponent(Graphics g) { super.paintComponent(g); } /** * Returns Name Label - is used by GuiView * @return PetriNetObject's Name Label (Model View Controller Design Pattern) */ public NameLabel getNameLabel(){ return pnname; } /** * Set PetriNetObject's is movable status * @param canMove boolean value setting whether object is movable (Model View Controller Design Pattern) */ public void setMovable(boolean canMove) { movable = canMove; } /** * Returns whether PetriNetObject is movable * @return boolean value for whether PetriNetObject is movable (Model View Controller Design Pattern) */ public boolean getMovable() { return movable; } }