[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Constraint.java,NONE,1.1
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-01-10 10:45:31
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11616/src/net/sourceforge/bprocessor/model Added Files: Constraint.java Log Message: Added a constraint class --- NEW FILE: Constraint.java --- //--------------------------------------------------------------------------------- // $Id: Constraint.java,v 1.1 2006/01/10 10:45:21 henryml Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import java.util.Collection; import java.util.LinkedList; /** * The Constraint has a master and a slave, which are * geometric entities. * The constraint depends on the both the master and the slave, * but only the slave depends on the constraint. * The constraint are not supposed to change the master. A change * to the master will make the constraint change the slave. A * change to a slave will make the constraint update it's own internal * state. */ public abstract class Constraint implements Observer { /** The master */ private Entity master; /** The slave */ private Entity slave; /** * Constructor for Constraint. */ public Constraint() { super(); } /** * Constructor for Constraint * @param master The master * @param slave The slave */ public Constraint(Entity master, Entity slave) { this(); this.master = master; this.slave = slave; } /** * Set the master * @param master The master */ public void setMaster(Entity master) { this.master = master; } /** * Return the master * @return The master */ public Entity getMaster() { return master; } /** * Set the slave * @param slave The slave */ public void setSlave(Entity slave) { this.slave = slave; } /** * Return the slave * @return The slave */ public Entity getSlave() { return slave; } /** * Return true if this Constraint depends on the entity * @param entity The entity * @return True of this Constraints depends on the entity */ public boolean depends(Entity entity) { return (entity == master) || (entity == slave); } /** * Return collection of entities depending on this Constraint * @return Collecton of depending entities */ public Collection depending() { Collection entities = new LinkedList(); entities.add(slave); return entities; } } |