[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool SpaceTool.java,1.3,1.4
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-01-11 13:50:22
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29131/src/net/sourceforge/bprocessor/gl/tool Modified Files: SpaceTool.java Log Message: Added OffsetConstraint (no implementation yet) Index: SpaceTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SpaceTool.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SpaceTool.java 11 Jan 2006 13:24:17 -0000 1.3 --- SpaceTool.java 11 Jan 2006 13:50:10 -0000 1.4 *************** *** 12,15 **** --- 12,16 ---- import java.awt.event.ActionListener; import java.awt.event.MouseEvent; + import java.util.Collection; import java.util.HashSet; import java.util.Iterator; *************** *** 23,26 **** --- 24,29 ---- import net.sourceforge.bprocessor.gl.GLView; + import net.sourceforge.bprocessor.model.Constraint; + import net.sourceforge.bprocessor.model.Constraints; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Space; *************** *** 84,88 **** offsetItem.addActionListener(new MenuAction() { public void actionPerformed(ActionEvent event) { ! log.info("OffsetConstraint should be added to selection here"); } } --- 87,91 ---- offsetItem.addActionListener(new MenuAction() { public void actionPerformed(ActionEvent event) { ! addOffsetConstraint(selection); } } *************** *** 92,95 **** --- 95,147 ---- } + + /** + * The OffsetConstraint maintains a distance between surfaces + * TODO move to model + */ + public class OffsetConstraint extends Constraint { + /** + * Constructor for OffsetConstraint + * @param master The master + * @param slave The slave + */ + public OffsetConstraint(Surface master, Surface slave) { + super(master, slave); + log.info("initialize offset " + master + " -> " + slave); + } + + /** + * Update + * @param entity The changed entity + */ + public void update(Object entity) { + log.info("maintain offset " + entity); + } + } + + /** + * Add offset constraint to objects + * @param objects The objects + */ + protected void addOffsetConstraint(Collection objects) { + if (objects.size() == 2) { + Iterator iter = objects.iterator(); + Object arg1 = iter.next(); + Object arg2 = iter.next(); + Surface master = null; + Surface slave = null; + if (arg1 instanceof Surface) { + master = (Surface) arg1; + } + if (arg2 instanceof Surface) { + slave = (Surface) arg2; + } + if (master != null && slave != null) { + OffsetConstraint constraint = new OffsetConstraint(master, slave); + Constraints.getInstance().add(constraint); + } + } + } + /** * Creates the correct type popup menu. |