コード例 #1
0
 @Override
 public void stopBehavior() {
   Enumeration<MenuItem> children = ((Group) displayedMenuItems.getChild(0)).getAllChildren();
   while (children.hasMoreElements()) {
     MenuItem child = (MenuItem) children.nextElement();
     child.behavior.setEnable(false);
   }
 }
コード例 #2
0
ファイル: Java3DViewer.java プロジェクト: alexeyivanov/FEM
  public void draw(DrawModel d) {
    view.detach();
    rotation.removeAllChildren();
    drawModel = d;
    if (drawModel.getPicture() == null) return;
    Integer i = 0;
    for (VisualShape v : drawModel.getPicture()) {
      TransformGroup shapeGroup = new TransformGroup();
      rotation.addChild(shapeGroup);
      BranchGroup faces = v.getFaces2(BranchGroup.class);
      BranchGroup edges = v.getEdges2(BranchGroup.class);
      BranchGroup text = v.getText2(BranchGroup.class);
      if (faces == null && edges == null) continue;
      i++;
      if (faces != null) {
        faces.detach();
        rotation.addChild(faces);
        faces.setPickable(true);
        faces.setUserData(v);
        faces.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
        faces.setName(i.toString());
      }
      if (edges != null) {
        edges.detach();
        rotation.addChild(edges);
        edges.setPickable(true);
        edges.setUserData(v);
        edges.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
        edges.setName(i.toString());
      }

      if (text != null) {
        text.detach();
        rotation.addChild(text);
        text.setPickable(false);
        if (text instanceof BranchGroup) {
          BranchGroup bg = (BranchGroup) text;
          for (int j = 0; j < bg.numChildren(); j++) {
            Node child = bg.getChild(j);
            if (child instanceof TransformGroup) {
              TransformGroup tg = (TransformGroup) child;
              tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
              tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
              textLabels.add(tg);
            }
          }
        }

        //        		edges.setUserData(v);
        //        		edges.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
        //         		edges.setName(i.toString());
      }
    }
    root.addChild(view);
  }