コード例 #1
0
 public void setInput(Input input) throws IOException {
   super.setInput(input);
   Object stuff;
   XStream xstr = XStreamFactory.forVersion(0.2);
   try {
     stuff = xstr.fromXML(input.getReader());
   } catch (Exception e) {
     xstr = XStreamFactory.forVersion(0.1);
     try {
       System.out.println("trying to read JRS v0.1");
       stuff = xstr.fromXML(input.copy().getReader());
       System.out.println("JRS v0.1 success.");
     } catch (Exception e2) {
       throw new IOException("illegal JRS file");
     }
   }
   if (stuff instanceof JrScene) {
     read = (JrScene) stuff;
     root = read.getSceneRoot();
   } else {
     if (stuff instanceof SceneGraphComponent) root = (SceneGraphComponent) stuff;
     else {
       root = new SceneGraphComponent();
       root.setName("jrs");
       SceneGraphUtility.addChildNode(root, (SceneGraphNode) stuff);
     }
   }
 }
コード例 #2
0
 @Override
 public void setContent(SceneGraphNode node) {
   boolean fire = getContentNode() != node;
   if (getContentNode() != null) {
     SceneGraphUtility.removeChildNode(scalingComponent, getContentNode());
   }
   setContentNode(node);
   if (getContentNode() != null) {
     SceneGraphUtility.addChildNode(scalingComponent, getContentNode());
     alignContent();
   }
   if (fire) {
     ContentChangedEvent cce = new ContentChangedEvent(ChangeEventType.ContentChanged);
     cce.node = node;
     fireContentChanged(cce);
   }
 }
コード例 #3
0
 private SceneGraphComponent wrap(SceneGraphNode node) {
   if (node instanceof SceneGraphComponent) return (SceneGraphComponent) node;
   SceneGraphComponent wrap = new SceneGraphComponent("wrapper");
   SceneGraphUtility.addChildNode(wrap, node);
   return wrap;
 }