[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model/constraints OffsetConstraint.java,1.1
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-02-13 21:16:56
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/constraints In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28219/src/net/sourceforge/bprocessor/model/constraints Modified Files: OffsetConstraint.java Log Message: LayoutManager added to attributeview OffsetConstraint implements Parametric Index: OffsetConstraint.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/constraints/OffsetConstraint.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OffsetConstraint.java 30 Jan 2006 15:20:31 -0000 1.1 --- OffsetConstraint.java 13 Feb 2006 21:16:47 -0000 1.2 *************** *** 10,28 **** import java.util.HashSet; import java.util.Iterator; import java.util.Set; import net.sourceforge.bprocessor.model.Constraint; import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; /** ! * @author henryml ! * ! * TODO To change the template for this generated type comment go to ! * Window - Preferences - Java - Code Style - Code Templates */ ! public class OffsetConstraint extends Constraint { /** The offset */ private double offset; --- 10,29 ---- import java.util.HashSet; import java.util.Iterator; + import java.util.LinkedList; + import java.util.List; import java.util.Set; + import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Constraint; import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Edge; + import net.sourceforge.bprocessor.model.Parametric; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; /** ! * OffsetConstraint */ ! public class OffsetConstraint extends Constraint implements Parametric { /** The offset */ private double offset; *************** *** 93,98 **** Set vertices = new HashSet(); - // List vertices = slave.getVertices(); - // vertices.remove(0); collect(slave, vertices); Iterator iter = vertices.iterator(); --- 94,97 ---- *************** *** 119,121 **** --- 118,160 ---- } } + + /** + * Set attributes + * @param attributes The attributes + */ + public void setAttributes(List attributes) { + Iterator iter = attributes.iterator(); + while (iter.hasNext()) { + Attribute current = (Attribute) iter.next(); + if (current.getName().equals("Offset")) { + Double offset = (Double) current.getValue(); + this.offset = offset.doubleValue(); + update(this); + Surface slave = (Surface) getSlave(); + slave.changed(); + } + } + } + + /** + * Get attributes + * @return The attributes + */ + public List getAttributes() { + LinkedList attributes = new LinkedList(); + Surface master = (Surface) getMaster(); + Surface slave = (Surface) getSlave(); + attributes.add(new Attribute("Master", master.getName())); + attributes.add(new Attribute("Slave", slave.getName())); + attributes.add(new Attribute("Offset", new Double(offset))); + return attributes; + } + + /** + * Return general name + * @return General name + */ + public String getGeneralName() { + return "Offset Constraint"; + } } |