[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Operation.java, 1.1, 1.2 Command.jav
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-10-19 08:28:40
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5482/src/net/sourceforge/bprocessor/model Modified Files: Operation.java Command.java Log Message: cube command Index: Operation.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Operation.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Operation.java 18 Oct 2007 11:54:40 -0000 1.1 --- Operation.java 19 Oct 2007 08:28:36 -0000 1.2 *************** *** 11,21 **** * */ ! public class Operation { /** ! * Retruns the name of this Operation ! * @return the name of this Operation */ ! public String name() { ! return "!"; ! } } --- 11,18 ---- * */ ! public abstract class Operation { /** ! * */ ! public abstract void perform(); } Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Command.java 18 Oct 2007 11:54:40 -0000 1.3 --- Command.java 19 Oct 2007 08:28:36 -0000 1.4 *************** *** 8,11 **** --- 8,12 ---- package net.sourceforge.bprocessor.model; + import java.util.Collection; import java.util.LinkedList; import java.util.List; *************** *** 20,23 **** --- 21,30 ---- public List<Attribute> getAttributes() { List<Attribute> attributes = new LinkedList(); + attributes.add(new Attribute("!", new Operation() { + @Override + public void perform() { + evaluate(); + } + })); return attributes; } *************** *** 25,29 **** /** {@inheritDoc} */ public String getGeneralName() { ! return "Command"; } --- 32,36 ---- /** {@inheritDoc} */ public String getGeneralName() { ! return "Create Cube"; } *************** *** 31,33 **** --- 38,80 ---- public void setAttributes(List<Attribute> attributes) { } + + private List list(Object ...objects) { + List result = new LinkedList(); + for (Object object : objects) { + result.add(object); + } + return result; + } + + /** + * + */ + public void evaluate() { + double w = 1; + double h = 1; + double d = 1; + double x = -w / 2; + double y = -h / 2; + double z = -d / 2; + Vertex v0 = new Vertex(x, y, z); + Vertex v1 = new Vertex(x + w, y, z); + Vertex v2 = new Vertex(x + w, y + h, z); + Vertex v3 = new Vertex(x, y + h, z); + + Edge e0 = new Edge(v0, v1); + Edge e1 = new Edge(v1, v2); + Edge e2 = new Edge(v2, v3); + Edge e3 = new Edge(v3, v0); + + Surface s0 = new Surface(list(e0, e1, e2, e3)); + Collection<Surface> sides = new LinkedList(); + Surface top = s0.extrusion(d, sides); + Space world = Project.getInstance().world(); + world.insert(s0); + for (Surface current : sides) { + world.insert(current); + } + world.insert(top); + Project.getInstance().changed(world); + } } |