[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model LibraryObj.java, NONE, 1.1 Space.jav
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-11-12 14:15:20
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16947/src/net/sourceforge/bprocessor/model Modified Files: Space.java Command.java Project.java Added Files: LibraryObj.java Log Message: Removed lock from space, and created a LibraryObj to encapsulate the union spaces for the library. Made changes acording to that in the treeview. --- NEW FILE: LibraryObj.java --- //--------------------------------------------------------------------------------- // $Id: LibraryObj.java,v 1.1 2007/11/12 14:15:22 rimestad 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.io.File; import java.util.LinkedList; import java.util.List; /** * @author rimestad * A object pointing to a lib file */ public class LibraryObj implements Parametric { private File file; private Space space = null; private byte useableLevels = 0; private boolean isLocked = false; private String name; private String author; private String version; /** * The default constructor * @param usableLvls the levels where obj can be used incoded into a byte * @param f the file that represents this library object * @param s the space (union) this lib obj encapsulate */ public LibraryObj(byte usableLvls, File f, Space s) { file = f; useableLevels = usableLvls; space = s; name = s.getName(); } /** * Constructor for persistence */ public LibraryObj() { } /** * Get the file this lib obj represents * @return the file */ public File getFile() { return file; } /** * Set the file this lib obj points to * @param f The file */ void setFile(File f) { file = f; } /** * Return a byte with the usable levelnumber bit set * @return a byte with some set bits */ public byte getUseLevel() { return useableLevels; } /** * A getter for the space (union) this lib obj points to * @return The Space */ public Space getSpace() { return space; } /** * A setter for space in this lib obj * @param s the space */ void setSpace(Space s) { space = s; } /** * @return the isLocked */ public boolean isLocked() { return isLocked; } /** * @param isLocked the isLocked to set */ public void setLocked(boolean isLocked) { this.isLocked = isLocked; } /** * {@inheritDoc} */ public String getGeneralName() { return "Library Object"; } /** * {@inheritDoc} */ public List<Attribute> getAttributes() { List<Attribute> att = new LinkedList<Attribute>(); att.add(new Attribute("name", getName())); att.add(new Attribute("levels", new Selector<String>(getLevelStrings()))); att.add(new Attribute("geometry", getSpace())); att.add(new Attribute("Locked", isLocked())); att.add(new Attribute("File", getFile().getAbsoluteFile())); att.add(new Attribute("Author", getAuthor())); att.add(new Attribute("Version", getVersion())); return att; } private List<String> getLevelStrings() { List<String> strings = new LinkedList<String>(); int lvl = Space.SPACE_LEVEL; for (int i = 0; i < Space.PART_LEVEL; i++) { if ((useableLevels & (1 >> i)) == (1 >> i)) { strings.add(Space.levelToString(lvl)); } lvl++; } return strings; } /** * {@inheritDoc} */ public void setAttributes(List<Attribute> attributes) { } /** * Getter for name * @return The name */ public String getName() { return name; } /** * @return the author */ public String getAuthor() { return author; } /** * @param author the author to set */ public void setAuthor(String author) { this.author = author; } /** * @return the version */ public String getVersion() { return version; } /** * @param version the version to set */ public void setVersion(String version) { this.version = version; } } Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.205 retrieving revision 1.206 diff -C2 -d -r1.205 -r1.206 *** Space.java 9 Nov 2007 13:58:42 -0000 1.205 --- Space.java 12 Nov 2007 14:15:22 -0000 1.206 *************** *** 65,71 **** private int type; - /** Tell if the space is finished and therefore cannot be edited */ - private boolean locked; - /** If the constructionspace is transparent */ private boolean transparent; --- 65,68 ---- *************** *** 2819,2838 **** /** - * Tell if the space is locked or not - * @return the locked - */ - public boolean isLocked() { - return locked; - } - - /** - * Set a lock on the space to tell that it is finish - * @param locked the locked to set - */ - public void setLocked(boolean locked) { - this.locked = locked; - } - - /** * Getter for anchor * @return The anchor --- 2816,2819 ---- Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Command.java 12 Nov 2007 08:05:25 -0000 1.24 --- Command.java 12 Nov 2007 14:15:22 -0000 1.25 *************** *** 801,859 **** } } - - /** - * a command for instanciating a union - * @author rimestad - */ - public static class Instance extends Command { - private Space space; - /** - * Create a instance - * @param s the space to instanciate - */ - public Instance(Space s) { - space = s; - parameters.put(new Attribute("scale", 1.0)); - } - - /** {@inheritDoc} */ - @Override - public void evaluate() { - Project proj = Project.getInstance(); - Space world = proj.getActiveSpace(); - double scale = parameters.getDouble("scale"); - Space instance = new Space(space.getName() + " instance ", space.getType(), false); - instance.setProto(space); - world.add(instance); - } - } - - /** - * a command for instanciating a union - * @author rimestad - */ - public static class Duplicate extends Command { - private Space space; - /** - * Create a duplicate - * @param s the space to duplicate - */ - public Duplicate(Space s) { - space = s; - parameters.put(new Attribute("scale", 1.0)); - } - - /** {@inheritDoc} */ - @Override - public void evaluate() { - Project proj = Project.getInstance(); - Space world = proj.getActiveSpace(); - double scale = parameters.getDouble("scale"); - Space created = space.copy(); - for (Vertex v : created.collect()) { - v.scale(scale); - } - world.add(created); - } - } } --- 801,803 ---- Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.139 retrieving revision 1.140 diff -C2 -d -r1.139 -r1.140 *** Project.java 6 Nov 2007 19:00:43 -0000 1.139 --- Project.java 12 Nov 2007 14:15:22 -0000 1.140 *************** *** 121,125 **** private long nextMaterialId; ! private List<Space> catalog; /** --- 121,125 ---- private long nextMaterialId; ! private List<LibraryObj> catalog; /** *************** *** 157,161 **** redoStack = new Stack(); copyBuffer = new LinkedList(); ! catalog = new LinkedList<Space>(); resetCam(); observers = new LinkedList(); --- 157,161 ---- redoStack = new Stack(); copyBuffer = new LinkedList(); ! catalog = new LinkedList<LibraryObj>(); resetCam(); observers = new LinkedList(); *************** *** 1044,1057 **** * @return the list of spaces */ ! public List<Space> getCatalogObjects() { return catalog; } /** ! * Add a catalog spaces to til list of catalog objects ! * @param s the space object to add */ ! public void addCalalogObject(Space s) { ! catalog.add(s); } } --- 1044,1057 ---- * @return the list of spaces */ ! public List<LibraryObj> getCatalogObjects() { return catalog; } /** ! * Add a lib obj to til list of lib objects ! * @param lo the library object to add */ ! public void addCalalogObject(LibraryObj lo) { ! catalog.add(lo); } } |