コード例 #1
0
 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);
 }
コード例 #2
0
 @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;
 }
コード例 #3
0
ファイル: EditableACM.java プロジェクト: tuura/workcraft-1.0
 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);
 }
コード例 #4
0
ファイル: EditableACM.java プロジェクト: tuura/workcraft-1.0
  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);
  }
コード例 #5
0
 public void register(WorkCraftServer server) throws DuplicateIdException {
   server.registerObject(this, id);
   for (BasicEditable n : children) n.register(server);
 }
コード例 #6
0
 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);
 }
コード例 #7
0
 public void update(Mat4x4 matView) {
   transform.updateTransformCache(matView);
   for (BasicEditable n : children) {
     n.update(transform.getViewToLocalMatrix());
   }
 }
コード例 #8
0
 public void addChild(BasicEditable child) {
   children.add(child);
   child.setParent(this);
 }
コード例 #9
0
 public void setParent(BasicEditable parent) {
   this.parent = parent;
   this.ownerDocument = parent.getOwnerDocument();
 }
コード例 #10
0
 public BasicEditable getTopParent(GroupNode root) {
   return (parent == root) ? this : parent.getTopParent(root);
 }
コード例 #11
0
 public int compareTo(BasicEditable other) {
   if (zOrder == other.getZOrder()) {
     return this.hashCode() - other.hashCode();
   }
   return zOrder - other.getZOrder();
 }