public BasicEditable(BasicEditable parent) throws UnsupportedComponentException { this.zOrder = 0; this.children = new TreeSet<BasicEditable>(); transform = new TransformNode(this); boundingBox = new BoundingBox(); parent.addChild(this); parent.getOwnerDocument().addComponent(this, true); }
@Override public Object saveState() { HashMap<String, Object> componentStates = new HashMap<String, Object>(); LinkedList<BasicEditable> lst = new LinkedList<BasicEditable>(); getComponents(lst); for (BasicEditable bn : lst) componentStates.put(bn.getId(), ((SDFSNode) bn).saveState()); return componentStates; }
public void fromXmlDom(Element element) throws DuplicateIdException { NodeList nl = element.getElementsByTagName("ACM"); Element ne = (Element) nl.item(0); setCapacity(Integer.parseInt(ne.getAttribute("capacity"))); setBlockReading(Boolean.parseBoolean(ne.getAttribute("blockReading"))); setBlockWriting(Boolean.parseBoolean(ne.getAttribute("blockWriting"))); super.fromXmlDom(element); }
public void draw(Painter p) { p.setTransform(transform.getLocalToViewMatrix()); p.setShapeMode(ShapeMode.FILL); if (selected) p.setFillColor(selectedACMOutlineColor); else p.setFillColor(ACMOutlineColor); p.drawCircle(radius, null); if (selected) p.setFillColor(selectedACMColor); else p.setFillColor(ACMColor); p.drawCircle(innerRadius, null); if (selected) p.setLineColor(selectedACMOutlineColor); else p.setLineColor(ACMOutlineColor); float L = -radius, R = radius; if (blockWriting) L *= 0.6f; if (blockReading) R *= 0.6f; p.setLineMode(LineMode.SOLID); p.setLineWidth(0.01f); p.drawLine(L, 0.0f, R, 0.0f); p.setLineWidth(0.004f); if (blockWriting) p.drawLine(L, -radius * 0.75f, L, radius * 0.75f); if (blockReading) p.drawLine(R, -radius * 0.75f, R, radius * 0.75f); String n = Integer.toString(countValidTokens()); float h = radius * 0.8f; Vec2 v = new Vec2(0, radius * 0.2f); transform.getLocalToViewMatrix().transform(v); p.setTextColor(validTokenColor); p.drawString(n, v, h, TextAlign.CENTER); n = Integer.toString(capacity - countValidTokens()); h = radius * 0.8f; v = new Vec2(0, -radius * 0.7f); transform.getLocalToViewMatrix().transform(v); p.setTextColor(invalidTokenColor); p.drawString(n, v, h, TextAlign.CENTER); super.draw(p); }
public void register(WorkCraftServer server) throws DuplicateIdException { server.registerObject(this, id); for (BasicEditable n : children) n.register(server); }
private void recTraceChildren(BasicEditable n, int level) { for (int i = 0; i < level; i++) System.out.print(' '); System.out.println(n.getId()); for (BasicEditable cn : n.getChildren()) recTraceChildren(cn, level + 1); }
public void update(Mat4x4 matView) { transform.updateTransformCache(matView); for (BasicEditable n : children) { n.update(transform.getViewToLocalMatrix()); } }
public void addChild(BasicEditable child) { children.add(child); child.setParent(this); }
public void setParent(BasicEditable parent) { this.parent = parent; this.ownerDocument = parent.getOwnerDocument(); }
public BasicEditable getTopParent(GroupNode root) { return (parent == root) ? this : parent.getTopParent(root); }
public int compareTo(BasicEditable other) { if (zOrder == other.getZOrder()) { return this.hashCode() - other.hashCode(); } return zOrder - other.getZOrder(); }