Beispiel #1
0
 public void resetUI() {
   this.remove(manager);
   manager = PanelManager.createNewInstance(this);
   this.add(manager);
   revalidate();
   repaint();
 }
Beispiel #2
0
  /**
   * Creates a new FlowClient
   *
   * @throws IOException
   */
  private FlowClient() {
    // loads things
    super("Flow");

    // sets the icon in the task bar
    try {
      this.setIconImage(ImageIO.read(ClassLoader.getSystemResource("images/icon.png")));
    } catch (IOException e) {
      JOptionPane.showConfirmDialog(
          this,
          "Window icon not found",
          "Missing Image",
          JOptionPane.DEFAULT_OPTION,
          JOptionPane.ERROR_MESSAGE);
    }

    // Sets up communications with the server
    Communicator.initComms(JOptionPane.showInputDialog(null, "TEMP: ENTER IP", "127.0.0.1"));

    // Creates a new PanelManager
    manager = PanelManager.createNewInstance(this);
    this.add(manager);

    // JFrame setup
    this.setResizable(true);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // Logs off the client when the "big red X" is pressed
    Runtime.getRuntime()
        .addShutdownHook(
            new Thread(
                new Runnable() {

                  @Override
                  public void run() {
                    // Generates a new data packet and sends to server
                    Data logOff = new Data("end_session");
                    UUID sessionID = Communicator.getSessionID();
                    if (sessionID == null) return;
                    Communicator.killAsync();
                    Communicator.communicate(logOff);
                  }
                }));
    this.setSize(
        (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() * 0.8),
        (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() * 0.8));
    this.setLocation(
        (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() * 0.1),
        (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() * 0.1));
    this.setVisible(true);
  }
  /** Construct the panel's GUI. */
  private void initGUI() {
    PanelManager mainPanelManager = new PanelManager(this);
    PanelManager destPanelManager = new PanelManager("Destination");
    PanelManager regionPanelManager = new PanelManager("Process");

    ButtonGroup destinationGroup = new ButtonGroup();
    ButtonGroup imageVOIGroup = new ButtonGroup();

    newImageRadio = WidgetFactory.buildRadioButton("New image", true, destinationGroup);
    destPanelManager.add(newImageRadio);
    replaceImageRadio = WidgetFactory.buildRadioButton("Replace image", false, destinationGroup);
    destPanelManager.addOnNextLine(replaceImageRadio);

    // Only if the image is unlocked can it be replaced.
    if (srcImage.getLockStatus() == ModelStorageBase.UNLOCKED) {
      replaceImageRadio.setEnabled(true);
      if (ViewUserInterface.getReference().doForceInPlace()) {
        replaceImageRadio.setSelected(true);
        newImageRadio.setEnabled(false);
      }
    } else {
      replaceImageRadio.setEnabled(false);
    }

    wholeImageRadio = WidgetFactory.buildRadioButton("Whole image", true, imageVOIGroup);
    regionPanelManager.add(wholeImageRadio);
    voiRegionsRadio = WidgetFactory.buildRadioButton("VOI region(s)", false, imageVOIGroup);
    regionPanelManager.addOnNextLine(voiRegionsRadio);

    mainPanelManager.add(destPanelManager.getPanel());
    mainPanelManager.add(regionPanelManager.getPanel());
  }