Example #1
0
  /**
   * <b>refreshWindow()</b></br> <i>Updates window boundaries, sets the current panel, and turns the
   * Window visible. A general method used to update things pertaining to the Window that the
   * WindowManager cares for.</i></br>
   *
   * @version Slap 0.1
   */
  public void refreshWindow() {

    LOG.setSubSection("Refresh");

    if (CURRENT_PANEL != null) {

      WINDOW.repaint();
      LOG.log("Current panel exists. Setting up information.");

      if (CURRENT_PANEL.getTrackProgress() == true) {

        LOG.log("Progress tracking turned on, setting next panel.");
        setTrackProgress(true);
        setNextPanel(CURRENT_PANEL.getNextPanelName());

      } else {
        LOG.log("Progress tracking turned off.");
        setTrackProgress(false);
      }

      LOG.log("Setting current panel.");
      WINDOW.setCurrentPanel(CURRENT_PANEL);

      if (BOUND_HEIGHT != WINDOW.getBoundLength() || BOUND_WIDTH != WINDOW.getBoundWidth()) {
        LOG.log("Forcing window visiblity to false to update boundaries.");
        WINDOW.setVisible(false);
        LOG.log("Updating boundaries.");
        WINDOW.setBoundaries(BOUND_HEIGHT, BOUND_WIDTH);

        try {
          SwingUtilities.invokeAndWait(
              new Runnable() {
                @Override
                public void run() {
                  WINDOW.updateBoundaries();
                }
              });
        } catch (Exception ex) {
          ex.printStackTrace();
        }
      }

      LOG.log("Applying window attributes.");
      WINDOW.setTitle(TITLE);
      LOG.log("Forcing window visibility to true.");
      WINDOW.setVisible(true);

      LOG.log("Forcing window to move to centered position.");
      WINDOW.setLocationRelativeTo(null);
      LOG.log("Repainting window.");
      WINDOW.repaint();

    } else {
      LOG.log("No current panel, window cannot be refreshed.");
    }

    LOG.useSubSection(false);
  }
Example #2
0
  /**
   * <b>setNextPanel()</b></br> <i>Sets the panel that will become the current panel after the
   * current panel is "done."</i></br>
   *
   * @version Slap 0.1
   * @param identifier name of the panel to be added once progress is done.
   */
  public void setNextPanel(String identifier) {

    if (PANELS.containsKey(identifier) == false) {

      LOG.setSubSection("Warning");
      LOG.log(
          "HashMap does not contain a panel with specified name." + " Allowing addition. anyways.");
      LOG.useSubSection(false);
    }

    NEXT_PANEL_NAME = identifier;
  }
Example #3
0
  /**
   * <b>addPanel()</b></br> <i>Removes a panel from the HashMap. Cannot remove a panel while it is
   * the current panel of the entire Window Manager.</i></br>
   *
   * @version Slap 0.1
   * @param identifier name of the panel to be removed.
   */
  public void removePanel(String identifier) {

    if (CURRENT_PANEL_NAME == identifier) {

      LOG.setSubSection("Error");
      LOG.log("Denied the attempt to remove a panel that is currently in use.");
      LOG.useSubSection(false);

    } else {

      LOG.log("Removing panel \"" + identifier + "\"");
      PANELS.remove(identifier);
    }
  }
Example #4
0
  /**
   * <b>setCurrentPanel()</b></br> <i>Sets the overall current panel object. Window must be
   * refreshed to actually change the panel that the Window displays.</i></br>
   *
   * @version Slap 0.1
   * @param name string name of panel from the panel map to be set as the current panel.
   */
  public void setCurrentPanel(String name) {

    if (PANELS.containsKey(name)) {

      LOG.log("Setting current panel to \"" + name + "\".");
      CURRENT_PANEL = PANELS.get(name);
      CURRENT_PANEL_NAME = name;

    } else {

      LOG.setSubSection("Error");
      LOG.log("Attempted current panel does not exist in the HashMap.");
      LOG.useSubSection(false);
    }
  }
Example #5
0
  public WindowManager() {

    LOG = new Log();
    LOG.setSection("WindowManager");
    LOG.useSubSection(false);

    LOG.log("Measuring screen.");

    DIM_SCREEN = Toolkit.getDefaultToolkit().getScreenSize();
    SCREEN_HEIGHT = DIM_SCREEN.height;
    SCREEN_WIDTH = DIM_SCREEN.width;

    LOG.log("Creating HashMaps.");

    PANELS = new HashMap<String, WindowPanel>();
    createWindow();
    refreshWindow();
  }