void logInAs(int type) throws SQLException {

    if (type == 1) {
      parentFrame.goAdminPanel(resultSet.getString("full_name"));
      parentFrame.setTitle("Admin");

    } else if (type == 2) {
      parentFrame.goGateKeeperPanel(resultSet.getString("full_name"));
      parentFrame.setTitle("Gate Keeper");
    } else if (type == 3) {
      parentFrame.setTitle("Dining Manager");
      parentFrame.goDiningManagerPanel(resultSet.getString("full_name"));
    }
  }
예제 #2
0
 @Override
 public final Object showModal(final IClient parent, final Object... params) {
   //        labFrame.setTitle(String.format("%s %s %s",
   //            (String) params[1], (String) params[2], (String) params[3]));
   labFrame.setTitle("Лабораторные исследования");
   JDialog dialog = prepareModal(parent);
   labFrame.fillPatient(
       (int) params[0],
       (String) params[1],
       (String) params[2],
       (String) params[3],
       (int) params[4]);
   dialog.setVisible(true);
   disposeModal();
   return null;
 }
예제 #3
0
  @Override
  public void display(GLAutoDrawable drawable) {

    gl = drawable.getGL().getGL2();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();

    // desenha ou nao a bounding sphere de cada objeto
    if (InputHandler.getInstance().isKeyPressed(KeyEvent.VK_B)) { // tecla B
      BoundingVolume.isVisible = !BoundingVolume.isVisible;
    }
    // habilita ou nao fog
    if (InputHandler.getInstance().isKeyPressed(KeyEvent.VK_F)) { // tecla F
      fogEnabled = !fogEnabled;
      if (fogEnabled) gl.glEnable(GL2.GL_FOG);
      else gl.glDisable(GL2.GL_FOG);
    }

    // atualiza camera
    camera.update();
    // atualiza objetos
    {
      Iterator<SceneObject> it = Scene.getInstance().getSceneObjectsIterator();
      while (it.hasNext()) {
        SceneObject so = it.next();
        // animacao da porta
        if (so.getName().contains("door")) {
          if (Collision.collide(
              camera.getSceneObject().getBoundingSphere(), so.getBoundingSphere()))
            so.setAnimating(true);
          else so.setAnimating(false);
        }

        so.update();
      }
    }

    glu.gluLookAt(
        FPCamera.position.x,
        FPCamera.position.y,
        FPCamera.position.z,
        FPCamera.position.x + FPCamera.look.x,
        FPCamera.position.y + FPCamera.look.y,
        FPCamera.position.z + FPCamera.look.z,
        FPCamera.up.x,
        FPCamera.up.y,
        FPCamera.up.z);

    if (FPCamera.changed) { // se direcao da camera mudar
      FPCamera.changed = false;

      frustum.generate(drawable); // gera o frustum

      Scene.getInstance().clearVisibleObjectsList();

      Iterator<SceneObject> it = Scene.getInstance().getSceneObjectsIterator();
      while (it.hasNext()) {
        SceneObject so = it.next();
        if (frustum.sphereInFrustum(so.getBoundingSphere()))
          Scene.getInstance().addVisibleObject(so);
      }

      //            System.out.println("Renderable objects: "+ Scene.getInstance().getSize());
      //            System.out.println(FPCamera.position);
    }

    // desenha objetos
    {
      Iterator<SceneObject> it = Scene.getInstance().getVisibleObjectsIterator();
      SceneObject so;
      while (it.hasNext()) {
        so = it.next();

        if (so.getName().contains("lake")) {
          gl.glPushAttrib(GL2.GL_ENABLE_BIT);
          gl.glEnable(GL.GL_BLEND);
          gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE);
          so.draw(drawable);
          gl.glPopAttrib();
          continue;
        }
        so.draw(drawable);
      }
    }

    //        int e = gl.glGetError();
    //        if(e != GL.GL_NO_ERROR) {
    //            System.err.println("Erro: "+ gl.glGetString(e));
    //        }
    // calculo do fps
    ++frame;
    long time = System.currentTimeMillis();
    elapsed = time - timebase;
    if (elapsed > 1000) {
      long fps = frame * 1000 / (time - timebase);
      timebase = time;
      frame = 0;

      String str = "FPS: " + fps;
      mainFrame.setTitle(str);
    }

    // gl.glFlush();
  }
예제 #4
0
  /**
   * Open the application of a full-path configuration
   *
   * @param path The full-path configuration file
   */
  public void openApp(String path) {

    // Application
    App newApp = null;
    // Application name
    String appName = null;
    // Application configuration file
    String appFileName = null;
    // Application directory full-path
    String appDir = null;
    // Application engine
    AppEngine engine = AppEngine.getInstance();

    // Get the configuration file full path
    if (path.equals("")) {
      MessageUtils.displayError("Please select an configuration file.");
      return;
    }

    // Load application name
    try {
      appName = engine.preloadAppDef(path);
    } catch (Exception e) {
      AppStatusbar.getInstance()
          .changeMessage(
              "The application is not loaded. Make sure the configuration file is correct.");
      return;
    }

    // Load application other information
    try {
      appFileName = path.substring(path.lastIndexOf(File.separator) + 1);
      appDir = path.substring(0, path.lastIndexOf(File.separator));
    } catch (Exception e) {
      AppStatusbar.getInstance().changeMessage("Can not obtain configuration file and directory.");
      return;
    }

    // Create an new application to represent it
    newApp = engine.appManager.newApp();
    newApp.setAppDir(appDir);
    newApp.setAppFileName(appFileName);
    newApp.setAppName(appName);
    newApp.setDirty(false);
    try {
      engine.appManager.initApp(newApp);
    } catch (Exception e) {
      MessageUtils.error(
          DefineAppWindow.class,
          "onOK",
          new sim.util.SimException(
              "LOAD-APPLICATION-INIT-001A", "Can not initialize application.", e));
      return;
    }
    engine.appManager.setCurrentApp(newApp);

    // Load the application configuration
    sim.core.AppLoader.loadAppFromFile(path, true);

    // Setup recent files
    sim.ui.menus.MainMenuBar.getInstance(null, null).getRecentFilesHandler().add(path);
    sim.ui.menus.MainMenuBar.getInstance(null, null).getRecentFilesHandler().updateProperties();

    try {

      // Update title
      owner.setTitle(appName + " - " + path);
      // Dispose this window
      DefineAppWindow.this.setVisible(false);
      DefineAppWindow.this.dispose();
    } catch (Exception e) {
    }
  }
예제 #5
0
  /**
   * Create a new application.
   *
   * @param appName Application name
   * @param appDir Application directory
   * @param imgDir Image directory
   */
  public void createNewApp(String appName, String appDir, String imgDir) {
    // Application
    App newApp = null;
    // Application configuration file
    String appFileName = null;
    // Application resource directory name
    String appResourceDir = null;
    // Application engine
    AppEngine engine = AppEngine.getInstance();

    // Application name
    if (appName == null || (appName.trim()).equals("")) {
      MessageUtils.displayError(this, "The application name should be set!");
      return;
    }

    // Application directory
    if (appDir == null || (appDir.trim()).equals("")) {
      MessageUtils.displayError(this, "The application directory should be set!");
      return;
    }
    // Make the appName conforms to the OS
    String title = appName;
    title = title.replace('?', '_');
    title = title.replace(':', '_');
    title = title.replace('\\', '_');
    title = title.replace('/', '_');
    title = title.replace('*', '_');
    title = title.replace('\"', '_');
    title = title.replace('<', '_');
    title = title.replace('>', '_');
    title = title.replace('|', '_');
    title = title.replace(' ', '_');
    title = title.replace('\t', '_');
    // Try the name "appName.xml" first
    StringBuffer full = new StringBuffer();
    full.append(appDir);
    full.append(File.separator);
    full.append(title);
    appFileName = full.toString() + ".xml";
    File configFile = new File(appFileName);
    if (configFile.exists()) {
      // Get a unique name
      SimpleDateFormat formatter = new SimpleDateFormat("_MM_dd_yy_hh_mm_ss");
      String formatted = formatter.format(new Date());
      full.append(formatted);
      // The default name of the configuration file, can be changed
      // manually
      appFileName = full.toString() + ".xml";
      // New configuration file
      configFile = new File(appFileName);
    }
    try {
      boolean created = configFile.createNewFile();
      if (!created) {
        throw new RuntimeException("The file name '" + appFileName + "' already exists.");
      }
    } catch (Exception ioe) {
      MessageUtils.displayError(
          this,
          "Can not create the configuration file. You can empty the selected application directory to continue.");
      return;
    }

    // Get the app file name
    appFileName = appFileName.substring(appFileName.lastIndexOf(File.separator) + 1);

    // Application resource directory
    if (imgDir != null && !(imgDir.trim()).equals("")) {
      // Resource directory name
      appResourceDir = imgDir;
      // Create the resource directory.
      File resourceFile = new File(appDir + File.separator + imgDir);
      try {
        resourceFile.mkdir();
      } catch (Exception ioe) {
        MessageUtils.displayError(
            this,
            "Can not create the resource directory. The directory name should be valid accoding to the target operating system.");
        return;
      }
    }

    // Create an new application to represent it
    newApp = engine.appManager.newApp();
    newApp.setAppDir(appDir);
    newApp.setAppFileName(appFileName);
    newApp.setAppName(appName);
    newApp.setDirty(true);
    if (appResourceDir != null) {
      newApp.setAppResourceDir(appResourceDir);
    }
    try {
      engine.appManager.initApp(newApp);
    } catch (Exception e) {
      MessageUtils.error(
          this,
          "onOK",
          new sim.util.SimException(
              "LOAD-APPLICATION-INIT-001A", "Can not initialize application.", e));
      return;
    }
    engine.appManager.setCurrentApp(newApp);

    // Prepare the background image and relative path for the simulation
    // environment
    engine.system.env.resetToApp();

    AppStatusbar.getInstance().changeMessage("A new application is created successfully.");
    AppStatusbar.getInstance().changeAppStatus("App created");

    // Save the application information to external file --- Added on
    // 04092009
    new sim.core.AppTask().run();

    // Update title
    owner.setTitle(appName + " - " + configFile.getAbsolutePath());

    // Setup recent files
    sim.ui.menus.MainMenuBar.getInstance(null, null)
        .getRecentFilesHandler()
        .add(configFile.getAbsolutePath());
    sim.ui.menus.MainMenuBar.getInstance(null, null).getRecentFilesHandler().updateProperties();

    try {
      // Dispose this window
      DefineAppWindow.this.setVisible(false);
      DefineAppWindow.this.dispose();
    } catch (Exception e) {
    }
  }