Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model/modellor Modellor.java, NONE, 1.1 p
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-08-10 13:13:31
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/modellor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21531/src/net/sourceforge/bprocessor/model/modellor Added Files: Modellor.java package.html LayerModellor.java Log Message: made own package for modellors and made them appear in the popupmenu in databaseview --- NEW FILE: package.html --- <body> Defines the package that contains the modellor in the model </body> --- NEW FILE: LayerModellor.java --- //--------------------------------------------------------------------------------- // $Id: LayerModellor.java,v 1.1 2006/08/10 13:13:26 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.modellor; 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.Space; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; /** * Modellor */ public class LayerModellor extends Modellor { /** Default */ private static final long serialVersionUID = 1L; /** The default layer thickness */ private static final double STD_THICKNESS = 0.3; /** The space */ private Space space; /** The surface */ private Surface surface; /** The distance */ private double distance; /** * Constructor for LayerModellor * @param space The space to contain the layer * @param surface The surface to extrude * @param distance The distance of the xtrusion */ public LayerModellor(Space space, Surface surface, double distance) { super(); this.space = space; this.surface = surface; this.distance = distance; } /** * Empty Constructor */ public LayerModellor() { // TODO Auto-generated constructor stub } /** * Update the geometry. * @param entity The changed entity */ public void update(Object entity) { space.clear(); Surface bottom = surface.copy(space); if (surface.getBackDomain() == space) { bottom.flip(); } for (int i = 0; i < 3; i++) { Set sides = new HashSet(); bottom = bottom.extrude(distance, sides); bottom.flip(); } } /** * Return null as center * @return Null */ public Vertex center() { return null; } /** * Return name * @return Name */ public String getName() { return "Layer Modellor"; } /** * 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("Thickness")) { Double thickness = (Double) current.getValue(); distance = thickness.doubleValue(); space.changed(); } else if (current.getName().equals("Surface")) { Iterator it = space.getEnvelope().iterator(); Surface chosen = null; while (it.hasNext()) { Surface cur = (Surface)it.next(); if (cur.getName().equalsIgnoreCase((String)current.getValue())) { chosen = cur; } } if (chosen != null) { surface = chosen; } } } } /** * Get attributes * @return The attributes */ public List getAttributes() { LinkedList attributes = new LinkedList(); attributes.add(new Attribute("Name", "Layer 1")); attributes.add(new Attribute("Classification", "?")); attributes.add(new Attribute("Specification", "?")); attributes.add(new Attribute("Surface", surface.getName())); attributes.add(new Attribute("Thickness", new Double(distance))); attributes.add(new Attribute("Top Offset", new Double(0))); attributes.add(new Attribute("Bottom Offset", new Double(0))); return attributes; } /** * Delete the entity */ public void delete() { space.clear(); } /** @see net.sourceforge.bprocessor.model.modellor.Modellor#newInstance(Space) */ public Modellor newInstance(Space s) { Iterator iter = s.getEnvelope().iterator(); if (iter.hasNext()) { Surface sur = (Surface)iter.next(); return new LayerModellor(s, sur, STD_THICKNESS); } else { return null; } } } --- NEW FILE: Modellor.java --- //--------------------------------------------------------------------------------- // $Id: Modellor.java,v 1.1 2006/08/10 13:13:25 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.modellor; import java.util.Collection; import java.util.LinkedList; import net.sourceforge.bprocessor.model.Entity; import net.sourceforge.bprocessor.model.Observer; import net.sourceforge.bprocessor.model.Parametric; import net.sourceforge.bprocessor.model.Space; /** * The modellor interface, can generate surfaces from parameters * established at the creation of the Modellor. */ public abstract class Modellor extends Entity implements Observer, Parametric { /** The registered modellors */ private static LinkedList modellors; static { modellors = new LinkedList(); } /** * Register a modellor to the possible choices of modellors * @param m The modellor */ public static void registerModellor(Modellor m) { modellors.add(m); } /** * Return a list of all the registered modellors * @return A collection of the modellors */ public static Collection getRegisteredModellors() { return modellors; } /** * Remove all registered modellors */ public static void clearModellors() { modellors.clear(); } /** * De-register a modellor from the system * @param m The modellor to remove from the registry * @return True if it succedes */ public static boolean removeModellor(Modellor m) { return modellors.remove(m); } /** * Generate a list of surfaces. * @param entity Changed entity */ public abstract void update(Object entity); /** * @see net.sourceforge.bprocessor.model.Parametric#getGeneralName() */ public String getGeneralName() { return "Modellor"; } /** * Create a new instance of the modellor, based on a space * @param s The space the modellor should reside in * @return The created modellor object for the given space */ public abstract Modellor newInstance(Space s); } |