Ejemplo n.º 1
0
  /** Method that loads all necessary information and initiates the views, the keyhandlers etc. */
  public void loadProgramDataFromPdb() {
    // Extract nucleotide information
    rnaSequence3D = new RNASequence(getModel().getPdbfile());

    // Extract base-sequence and compute watson-crick bonds
    getModel().setSequence(rnaSequence3D.extractString());
    getModel().setBonds(rnaSequence3D.computeWCBonds());

    // Init selection Model
    initSelectionModel();

    // Init the Views
    initPrimaryView();
    initSecondaryView();
    initTertiaryView();

    // init focus selection listener
    initSelectionListener();
    selectionFocusBinding();

    // init keyhandler
    if (keyPressedEventHandler != null)
      scene.removeEventFilter(KeyEvent.KEY_PRESSED, keyPressedEventHandler);
    initKeyEventHandler();
    scene.addEventFilter(KeyEvent.KEY_PRESSED, keyPressedEventHandler);
  }
Ejemplo n.º 2
0
  @Test
  public void testDepthBufferInitializedInConstructor() {
    Group g = new Group();
    Scene scene = new Scene(g, 100, 100, true);

    assertTrue(scene.isDepthBuffer());
  }
Ejemplo n.º 3
0
 public void playScene(int sceneNumber) {
   Scene scene = scenes.get(sceneNumber);
   if (scene != null) {
     scene.setupScene();
     processScene(scene);
   }
 }
Ejemplo n.º 4
0
 public void objectClear() {
   for (int i = 0; i < _scene.children().size(); i++) {
     Object3d o = _scene.children().get(i);
     if (o.animationEnabled()) ((AnimationObject3d) o).pause();
     o.isVisible(false);
   }
 }
Ejemplo n.º 5
0
  public void objectPointChanged(
      int found_markers, int[] ar_code_index, float[][] resultf, float[] cameraRHf) {

    synchronized (this) {
      this.found_markers = found_markers;
      for (int i = 0; i < MARKER_MAX; i++) {
        this.ar_code_index[i] = ar_code_index[i];
        System.arraycopy(resultf[i], 0, this.resultf[i], 0, 16);
      }
      System.arraycopy(cameraRHf, 0, this.cameraRHf, 0, 16);
    }

    objectClear();

    for (int i = 0; i < MARKER_MAX; i++) {

      if (ar_code_index[i] > (_scene.children().size() - 1)) continue;

      Log.i("min3D Render", "Draw Model number:" + ar_code_index[i]);
      Object3d o = _scene.children().get(ar_code_index[i]);
      if (!o.isVisible()) {
        if (o.animationEnabled()) ((AnimationObject3d) o).play();
        o.isVisible(true);
        o.matrix(resultf[i]);
      }
    }
  }
Ejemplo n.º 6
0
  /** @param media insert this scene into the projects scene list at index */
  public void setScene(int projectIndex, Scene scene) {
    scene.setProjectIndex(projectIndex);
    scene.setProjectId(getId());
    scene.save();

    mSceneCount = Math.max((projectIndex + 1), mSceneCount);
  }
Ejemplo n.º 7
0
 public static void switchState(GameState newState) {
   Scene newScene = null;
   switch (newState) {
     case INTRO:
       newScene = new IntroScene();
       break;
     case TITLE:
       newScene = new TitleScene();
       break;
     case HOW_TO_PLAY:
       newScene = new HowToPlayScene();
       break;
     case PLAY:
       newScene = new PlayScene();
       break;
     case GAME_OVER:
       newScene = new GameOverScene();
       break;
     case WIN:
       newScene = new WinScene();
       break;
   }
   if (!scenes.empty()) {
     scenes.pop().dispose();
   }
   newScene.create();
   scenes.push(newScene);
 }
Ejemplo n.º 8
0
  public BranchGroup createSceneGraph(URL url) {

    try {
      Loader loader = new com.sun.j3d.loaders.objectfile.ObjectFile();
      Scene scene = loader.load(url);
      BranchGroup bg = scene.getSceneGroup();
      System.out.println(bg);
      TransformGroup[] views = scene.getViewGroups();
      if (views != null) {
        for (int i = 0; i < views.length; i++) {
          System.out.print(views[i]);
        }
        if (views.length > 0) viewStart = views[0];
      }
      return bg;
    } catch (Exception ex) {
      // in case there was a problem, print the stack out
      ex.printStackTrace();
      // System.out.println(ex);
      add("South", new Label(ex.toString()));
      System.out.println("URL: " + url);
      BranchGroup bg = new BranchGroup();
      bg.addChild(new ColorCube());
      System.out.println(bg);
      return bg;
    }
  }
Ejemplo n.º 9
0
  @Test
  public void testSceneSizeSetWithClipOnRoot() {
    Group g = new Group();

    Rectangle clip = new Rectangle();
    clip.setX(20);
    clip.setY(20);
    clip.setWidth(150);
    clip.setHeight(150);

    g.setClip(clip);

    Rectangle r = new Rectangle();

    r.setX(20);
    r.setY(20);
    g.getChildren().add(r);
    r.setWidth(200);
    r.setHeight(200);

    Scene scene = new Scene(g);
    stage.setScene(scene);

    assertEquals(170, (int) scene.getWidth());
    assertEquals(170, (int) scene.getHeight());
  }
Ejemplo n.º 10
0
  @Test
  public void testRootInitializedInConstructor() {
    Group g = new Group();
    Scene scene = new Scene(g);

    assertEquals(g, scene.getRoot());
    assertEquals(scene, g.getScene());
  }
Ejemplo n.º 11
0
 /**
  * Gets the content size for the specified page.
  *
  * @param page the page number.
  * @return the content size.
  */
 public Rectangle2D getContentSize(final int page) {
   Rectangle2D content = scene.getContentSize();
   return new Rectangle2D.Double(
       content.getX(),
       (page - 1) * perPage * scene.getScalingFactor(),
       content.getWidth(),
       perPage * scene.getScalingFactor());
 }
Ejemplo n.º 12
0
 @Test
 public void testSetCamera() {
   Camera camera = new PerspectiveCamera();
   Scene scene = new Scene(new Group(camera));
   scene.setCamera(camera);
   assertEquals(scene.getCamera(), camera);
   scene.setCamera(camera);
 }
Ejemplo n.º 13
0
 @Override
 void activated() {
   if (QuestList.getQuest("TutorialQuest").getStage() == 1) {
     QuestList.getQuest("TutorialQuest").setStage(2);
     Scene s = new TutorialTalkScene(gamedata, gametext);
     s.start();
   }
 }
Ejemplo n.º 14
0
 @Test(expected = IllegalArgumentException.class)
 public void subSceneAndSceneCannotShareCamera() {
   SubScene sub = new SubScene(new Group(), 100, 100);
   Scene scene = new Scene(new Group(sub), 300, 200);
   Camera cam = new ParallelCamera();
   sub.setCamera(cam);
   scene.setCamera(cam);
 }
Ejemplo n.º 15
0
 @Test(expected = IllegalArgumentException.class)
 public void scenesCannotShareCamera() {
   Scene scene = new Scene(new Group(), 300, 200);
   Scene scene2 = new Scene(new Group(), 300, 200);
   Camera cam = new ParallelCamera();
   scene.setCamera(cam);
   scene2.setCamera(cam);
 }
Ejemplo n.º 16
0
  @Override
  public void render() {
    float dt = Gdx.app.getGraphics().getDeltaTime();

    // we use a copy of the scene reference because the actual scene may change during update
    Scene s = scene;
    s.update(dt);
    s.render();
  }
Ejemplo n.º 17
0
 public Scene getScene(long id) {
   for (Iterator iter = this.scenes.iterator(); iter.hasNext(); ) {
     Scene scene = (Scene) iter.next();
     if (scene.getId() == id) {
       return scene;
     }
   }
   return null;
 }
Ejemplo n.º 18
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);
    grid.setVgap(10);
    grid.setHgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    Scene sc = new Scene(grid, 500, 500);

    String css = Main.class.getResource("Login.css").toExternalForm();
    //        System.out.println(css);
    sc.getStylesheets().add(css);

    Text scenetitle = new Text("Welcome");
    //        scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
    grid.add(scenetitle, 0, 0, 1, 1);

    Label userName = new Label("User Name:");
    grid.add(userName, 0, 1);

    TextField userTextField = new TextField("Мудак");
    grid.add(userTextField, 1, 1);

    Label pw = new Label("Password:"******"Sign in");
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(btn);
    grid.add(hbBtn, 1, 4);

    final Text actiontarget = new Text();
    grid.add(actiontarget, 1, 6);

    btn.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            //                actiontarget.setFill(Color.FIREBRICK);
            actiontarget.setText("Pressed");
          }
        });

    //        grid.setGridLinesVisible(true);

    scenetitle.setId("welc");
    actiontarget.setId("act");

    primaryStage.setScene(sc);
    primaryStage.setTitle("Hello World");
    primaryStage.show();
  }
Ejemplo n.º 19
0
 public Scene getSceneByName(String name) {
   for (Iterator iter = this.scenes.iterator(); iter.hasNext(); ) {
     Scene scene = (Scene) iter.next();
     if (scene.getName().equals(name)) {
       return scene;
     }
   }
   return null;
 }
Ejemplo n.º 20
0
 /**
  * Create a new PageableScene.
  *
  * @param scene the scene.
  * @param paper the paper.
  * @param perPage the number of scene units per page.
  */
 public PageableScene(final Scene scene, final Paper paper, final double perPage) {
   this(
       scene,
       paper,
       scene.getContentSize().getY() / scene.getScalingFactor(),
       perPage,
       true,
       true);
 }
Ejemplo n.º 21
0
  @Test(expected = IllegalArgumentException.class)
  public void testSetIllegalCameraFromSubScene() {
    Camera camera = new PerspectiveCamera();

    SubScene subScene = new SubScene(new Group(camera), 150, 150);
    Scene scene = new Scene(new Group());

    subScene.setCamera(camera);
    scene.setCamera(camera);
  }
Ejemplo n.º 22
0
  @Test
  public void testRootUpdatedWhenAddedToScene() {
    Scene scene = new Scene(new Group());

    Group g = new Group();
    scene.setRoot(g);

    assertEquals(g, scene.getRoot());
    assertEquals(scene, g.getScene());
  }
Ejemplo n.º 23
0
  @Test(expected = IllegalArgumentException.class)
  public void testSetIllegalCameraFromOtherScene() {
    Camera camera = new PerspectiveCamera();

    Scene scene1 = new Scene(new Group(camera));
    Scene scene2 = new Scene(new Group());

    scene1.setCamera(camera);
    scene2.setCamera(camera);
  }
Ejemplo n.º 24
0
 public static void restart() {
   dispose();
   for (Scene scene : new ArrayList<Scene>(scenes)) {
     scenes.remove(scene);
     scene.end();
   }
   if (profiler.scene != null) profiler.scene.end();
   init();
   scenes.add(firstScene);
 }
Ejemplo n.º 25
0
  public static void main(String[] args) {
    final Scene scene = new Scene();

    LayerWidget layer = new LayerWidget(scene);
    scene.addChild(layer);

    Widget nodeWidget = new Widget(scene);
    nodeWidget.setBorder(BorderFactory.createLineBorder(1, Color.RED));
    nodeWidget.setPreferredLocation(new Point(100, 100));
    layer.addChild(nodeWidget);

    final Widget deferredWidget = new Widget(scene);
    deferredWidget.setLayout(LayoutFactory.createCardLayout(deferredWidget));
    deferredWidget.setBorder(BorderFactory.createLineBorder(1, Color.BLUE));
    nodeWidget.addChild(deferredWidget);

    final Widget label = new LabelWidget(scene, "Click me to add ComponentWidget");
    label.setBorder(BorderFactory.createLineBorder(1, Color.GREEN));
    deferredWidget.addChild(label);
    LayoutFactory.setActiveCard(deferredWidget, label);

    label
        .getActions()
        .addAction(
            ActionFactory.createEditAction(
                new EditProvider() {
                  public void edit(Widget widget) {
                    ComponentWidget component =
                        new ComponentWidget(scene, new JButton("This is the new ComponentWidget"));
                    component.setBorder(BorderFactory.createLineBorder(1, Color.GREEN));
                    deferredWidget.addChild(component);
                    LayoutFactory.setActiveCard(deferredWidget, component);
                  }
                }));

    scene
        .getActions()
        .addAction(
            ActionFactory.createEditAction(
                new EditProvider() {
                  public void edit(Widget widget) {
                    LayoutFactory.setActiveCard(deferredWidget, label);
                  }
                }));

    // to force the boundary
    //        nodeWidget.setPreferredBounds (new Rectangle (0, 0, 70, 30));
    //        nodeWidget.setPreferredSize (new Dimension (70, 30));
    nodeWidget.setLayout(LayoutFactory.createOverlayLayout());
    nodeWidget.setCheckClipping(true);
    //

    SceneSupport.show(scene);
  }
Ejemplo n.º 26
0
 static Band createSubset(Band sourceBand, Scene targetScene, ProductSubsetDef subsetDef) {
   final Band targetBand =
       new Band(
           sourceBand.getName(),
           sourceBand.getDataType(),
           targetScene.getRasterWidth(),
           targetScene.getRasterHeight());
   ProductUtils.copyRasterDataNodeProperties(sourceBand, targetBand);
   targetBand.setSourceImage(getSourceImage(subsetDef, sourceBand));
   return targetBand;
 }
Ejemplo n.º 27
0
 /**
  * Sets the number of scene units visible per page.
  *
  * @param perPage the number of scene units visible per page.
  */
 public void setPerPage(final double perPage) {
   this.perPage = perPage;
   double content = paper.getPrintableHeight();
   if (renderHeader) {
     content -= scene.getHeaderSize().getHeight();
   }
   if (renderFooter) {
     content -= scene.getFooterSize().getHeight();
   }
   scene.setScalingFactor(content / perPage);
 }
Ejemplo n.º 28
0
 @Test
 public void shouldBeAbleToSetCameraTwiceToScene() {
   Scene scene = new Scene(new Group(), 300, 200);
   Camera cam = new ParallelCamera();
   try {
     scene.setCamera(cam);
     scene.setCamera(cam);
   } catch (IllegalArgumentException e) {
     fail("It didn't allow to 'share' camera with myslef");
   }
 }
Ejemplo n.º 29
0
 public void nextScene() {
   if (currentSceneIndex < scenes.size() - 1) {
     currentSceneIndex++;
     Scene scene = scenes.get(currentSceneIndex);
     scene.setupScene();
     processScene(scene);
   } else {
     // do it accurately!
     // may be I should add loopback mode?
     // after the last scene there should be the first?
   }
 }
Ejemplo n.º 30
0
  @Test
  public void testDefaultCameraUpdatesPG() {
    Scene scene = new Scene(new Group(), 300, 200);
    stage.setScene(scene);
    Toolkit.getToolkit().firePulse();
    Camera cam = scene.getEffectiveCamera();

    cam.setNearClip(20);
    Toolkit.getToolkit().firePulse();
    NGCamera camera = ((StubScene) scene.impl_getPeer()).getCamera();
    assertEquals(20, camera.getNearClip(), 0.00001);
  }