[Bprocessor-commit] facade/src/net/sourceforge/bprocessor/facade/modellor WindowModellor.java, NON
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-08-21 14:18:04
|
Update of /cvsroot/bprocessor/facade/src/net/sourceforge/bprocessor/facade/modellor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19841/src/net/sourceforge/bprocessor/facade/modellor Added Files: WindowModellor.java Log Message: Added window modellor to the facade project and registred it via the main class. It is not done yet, just comitting to be able to work at home --- NEW FILE: WindowModellor.java --- //--------------------------------------------------------------------------------- // $Id: WindowModellor.java,v 1.1 2006/08/21 14:17:55 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.facade.modellor; import java.util.Collection; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Iterator; import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.modellor.Modellor; /** A modellor to make windows */ public class WindowModellor extends Modellor { /** The width of the frame */ private double framewidth = 0.1; /** The depth of the frame */ private double framedepth = 0.075; /** The offset in the window */ private double offset = 0; /** The number of vertical sprosses */ private int verticalSprosses = 0; /** The number of horizontal sprosses */ private int horizontalSprosses = 0; /** The used space */ private Space space; /** The bound surface */ private Surface surface; /** The created bounding */ private Surface opposite; /** * the constructor */ public WindowModellor() { } /** * the constructor * @param s The space this modellor makes * @param sur The surface in the given space is use as base */ public WindowModellor(Space s, Surface sur) { space = s; surface = sur; } /** * @see net.sourceforge.bprocessor.model.Modellor#update(Object) */ public void update(Object entity) { if (entity == space || entity == surface) { drawWindow(); } } /** Draw the window */ public void drawWindow() { Space frame = new Space("Frame", Space.CONSTRUCTION, true); space.add(frame); } /** * @see net.sourceforge.bprocessor.model.Modellor#newInstance(Space) */ public Modellor newInstance(Space s) { if (s.getSurfaces().size() == 1) { Surface sur = (Surface)s.getSurfaces().iterator().next(); opposite = sur.extrude(framedepth, new HashSet()); } return new WindowModellor(s, (Surface)s.getSurfaces().iterator().next()); } /** * @see net.sourceforge.bprocessor.model.Entity#delete() */ public void delete() { Collection added = space.getElements(); Iterator iter = added.iterator(); while (iter.hasNext()) { Space s = (Space)iter.next(); s.delete(); } if (opposite != null) { Collection surs = space.getSurfaces(); iter = surs.iterator(); while (iter.hasNext()) { Surface cur = (Surface)iter.next(); if (cur != surface) { cur.delete(); } } } space.setModellor(null); } /** * @see net.sourceforge.bprocessor.model.Parametric#setAttributes(List) */ public void setAttributes(List attributes) { framewidth = ((Double)((Attribute)attributes.get(1)).getValue()).doubleValue(); framedepth = ((Double)((Attribute)attributes.get(2)).getValue()).doubleValue(); offset = ((Double)((Attribute)attributes.get(3)).getValue()).doubleValue(); Iterator sit = Project.getInstance().getSurfaces().iterator(); Object value = ((Attribute)attributes.get(4)).getValue(); while (sit.hasNext()) { Project.getInstance().checkpoint(); Surface s = (Surface)sit.next(); if (s.getName().equals(value)) { surface = s; } } update(this); } /** * @see net.sourceforge.bprocessor.model.Parametric#getAttributes() */ public List getAttributes() { List res = new LinkedList(); res.add(new Attribute("Name", getName(), false)); res.add(new Attribute("Framewidth", new Double(framewidth))); res.add(new Attribute("Framedepth", new Double(framedepth))); res.add(new Attribute("Offset", new Double(offset))); res.add(new Attribute("Surface", surface)); return res; } /** * @see net.sourceforge.bprocessor.model.Entity#getName() */ public String getName() { return "Window-" + id; } /** * @see net.sourceforge.bprocessor.model.Parametric#getGeneralName() */ public String getGeneralName() { return "Window modellor"; } } |