/**
   * Adds contact entry labels.
   *
   * @param nameLabelGridWidth the grid width of the contact entry name label
   */
  private void addLabels(int nameLabelGridWidth) {
    remove(nameLabel);
    remove(rightLabel);
    remove(displayDetailsLabel);

    if (treeNode != null && !(treeNode instanceof GroupNode))
      constraints.insets = new Insets(0, 0, V_GAP, H_GAP);
    else constraints.insets = new Insets(0, 0, 0, H_GAP);

    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.weightx = 1f;
    constraints.weighty = 0f;
    constraints.gridheight = 1;
    constraints.gridwidth = nameLabelGridWidth;
    this.add(nameLabel, constraints);

    constraints.anchor = GridBagConstraints.NORTHEAST;
    constraints.fill = GridBagConstraints.VERTICAL;
    constraints.gridx = nameLabelGridWidth + 1;
    constraints.gridy = 0;
    constraints.gridheight = 3;
    constraints.weightx = 0f;
    constraints.weighty = 1f;
    this.add(rightLabel, constraints);

    if (treeNode != null && treeNode instanceof ContactNode) {
      constraints.anchor = GridBagConstraints.WEST;
      constraints.fill = GridBagConstraints.NONE;
      constraints.gridx = 1;
      constraints.gridy = 1;
      constraints.weightx = 1f;
      constraints.weighty = 0f;
      constraints.gridwidth = nameLabelGridWidth;
      constraints.gridheight = 1;

      this.add(displayDetailsLabel, constraints);
    } else if (treeNode != null && treeNode instanceof GroupNode) {
      constraints.anchor = GridBagConstraints.WEST;
      constraints.fill = GridBagConstraints.NONE;
      constraints.gridx = 1;
      constraints.gridy = 1;
      constraints.weightx = 1f;
      constraints.weighty = 0f;
      constraints.gridwidth = nameLabelGridWidth;
      constraints.gridheight = 1;

      this.add(displayDetailsLabel, constraints);
    }
  }
Beispiel #2
0
  // Initializing this component.
  private void jbInit() {
    callStackTable.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            callStackTable_focusGained(e);
          }

          public void focusLost(FocusEvent e) {
            callStackTable_focusLost(e);
          }
        });
    callStackTable.setTableHeader(null);
    callStackTable.setDefaultRenderer(callStackTable.getColumnClass(0), getCellRenderer());
    scrollPane = new JScrollPane(callStackTable);
    setVisibleRows(DEFAULT_VISIBLE_ROWS);
    scrollPane.setLocation(0, 27);
    setBorder(BorderFactory.createEtchedBorder());
    // this.setLayout(null);
    this.setLayout(new GridBagLayout());
    nameLbl.setText("Call Stack");
    nameLbl.setBounds(new Rectangle(3, 4, 70, 23));
    nameLbl.setFont(Utilities.labelsFont);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 7;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.PAGE_END;
    c.gridx = 0;
    c.gridy = 2;
    this.add(scrollPane, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0.0;
    c.gridwidth = 3;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 0, 0, 0);
    this.add(nameLbl, c);
  }
Beispiel #3
0
 private void add(Component c, GridBagConstraints gbc, int x, int y, int w, int h) {
   gbc.gridx = x;
   gbc.gridy = y;
   gbc.gridwidth = w;
   gbc.gridheight = h;
   getContentPane().add(c, gbc);
 }
Beispiel #4
0
  public void insert(Container cont, GridBagLayout gbl, int x, int y) {
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = x;
    gbc.gridy = y;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.fill = GridBagConstraints.NONE;

    gbl.setConstraints(name, gbc);
    cont.add(name);

    gbc.gridx = x + 1;
    gbc.weightx = 10;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    gbl.setConstraints(scroll, gbc);
    cont.add(scroll);

    gbc.gridx = x + 2;
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;

    gbl.setConstraints(field, gbc);
    cont.add(field);
  }
  private int addButton(SIPCommButton button, int gridX, int xBounds, boolean isLast) {
    lastAddedButton = button;

    constraints.insets = new Insets(0, 0, V_GAP, 0);
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = gridX;
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0f;
    constraints.weighty = 0f;
    this.add(button, constraints);

    int yBounds =
        TOP_BORDER
            + BOTTOM_BORDER
            + 2 * V_GAP
            + ComponentUtils.getStringSize(nameLabel, nameLabel.getText()).height
            + ComponentUtils.getStringSize(displayDetailsLabel, displayDetailsLabel.getText())
                .height;

    button.setBounds(xBounds, yBounds, BUTTON_WIDTH, BUTTON_HEIGHT);

    button.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    setButtonBg(button, gridX, isLast);

    return button.getWidth();
  }
  public static void addToGridBag(
      GridBagLayout grid,
      Container cont,
      Component comp,
      int x,
      int y,
      int gw,
      int gh,
      double wx,
      double wy,
      int fill,
      int anchor) {
    // now the constraints
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = x;
    gbc.gridy = y;
    gbc.weightx = wx;
    gbc.weighty = wy;
    gbc.fill = fill;
    gbc.gridwidth = gw;
    gbc.gridheight = gh;
    gbc.anchor = anchor;

    cont.add(comp);
    grid.setConstraints(comp, gbc);
  }
Beispiel #7
0
 public static void addComponent(
     Container container,
     Component component,
     int gridx,
     int gridy,
     int gridwidth,
     int gridheight,
     int fill,
     int anchor)
     throws AWTException {
   LayoutManager lm = container.getLayout();
   if (!(lm instanceof GridBagLayout)) {
     throw new AWTException("Invalid layout" + lm);
   } else {
     GridBagConstraints gbc = new GridBagConstraints();
     gbc.gridx = gridx;
     gbc.gridy = gridy;
     gbc.gridwidth = gridwidth;
     gbc.gridheight = gridheight;
     gbc.fill = fill;
     gbc.anchor = anchor;
     ((GridBagLayout) lm).setConstraints(component, gbc);
     container.add(component);
   }
 }
  /** Creates the panel with the optional components. */
  private void _setupOptionsPanel(JComponent[] components) {
    JPanel mainButtons = new JPanel();
    JPanel emptyPanel = new JPanel();
    GridBagLayout gbLayout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    mainButtons.setLayout(gbLayout);

    for (JComponent b : components) {
      mainButtons.add(b);
    }
    mainButtons.add(emptyPanel);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;

    for (JComponent b : components) {
      gbLayout.setConstraints(b, c);
    }

    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.SOUTH;
    c.gridheight = GridBagConstraints.REMAINDER;
    c.weighty = 1.0;

    gbLayout.setConstraints(emptyPanel, c);

    _optionsPanel.add(mainButtons, BorderLayout.CENTER);
  }
    public void addForDisplay(CTalkativeTextPane pane, LabelPair<String, String> lp) {
      GridBagLayout gridbag = (GridBagLayout) getLayout();
      labelPair = lp;
      label = new JLabel(labelPair.getSingular(), JLabel.LEFT);
      pane.getDocument().addDocumentListener(this);

      GridBagConstraints c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = 0;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.weightx = 0.1;
      c.weighty = 0.1;
      c.anchor = GridBagConstraints.LINE_START;
      c.insets = new Insets(0, 20, 0, 00);
      gridbag.setConstraints(pane, c);
      add(pane);

      c = new GridBagConstraints();
      c.gridx = 1;
      c.gridy = 0;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.weightx = 0.1;
      c.weighty = 0.1;
      c.anchor = GridBagConstraints.LINE_START;
      c.insets = new Insets(0, 0, 0, 20);
      gridbag.setConstraints(label, c);
      add(label);

      JPanel filler = new JPanel();
      filler.setBackground(white);
      c = new GridBagConstraints();
      c.gridx = 2;
      c.gridy = 0;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.weightx = 0.8;
      c.weighty = 0.8;
      c.fill = GridBagConstraints.BOTH;
      c.anchor = GridBagConstraints.LINE_END;
      gridbag.setConstraints(filler, c);
      add(filler);

      filler = null;
      c = null;
    }
Beispiel #10
0
  private void setupWindowAndListeners() {
    // Initialize Objects
    title = new JLabel("Coordinated Behavior Tree", JLabel.CENTER);
    treeScroller = new JScrollPane();
    treeNodes = new Vector<PBTreeNode>();
    treeView = new JTree(treeNodes);
    stratView = new JList();
    formView = new JList();
    roleView = new JList();
    subRoleView = new JList();

    // Setup our display selection drop down list
    selectorList = new Vector<String>();
    selectorList.add(PBTREE_ID);
    selectorList.add(STRAT_ID);
    selectorList.add(FORM_ID);
    selectorList.add(ROLE_ID);
    selectorList.add(SUBROLE_ID);
    displaySelector = new JComboBox(selectorList);
    displaySelector.addActionListener(this);
    treeScroller.getViewport().setView(treeView);
    treeMode = PBTREE_ID;
    treeScroller.setFocusable(false);
    treeScroller.addMouseListener(this);
    subRoleView.addMouseListener(this);

    // Setup Layout
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);

    // Add Items
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(title, c);
    c.gridheight = 2;
    add(title);

    gridbag.setConstraints(displaySelector, c);
    add(displaySelector);

    c.gridheight = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(treeScroller, c);
    add(treeScroller);
  }
 public header() {
   super();
   JLabel name = new JLabel("Welcome MR. ANAND");
   JLabel counter = new JLabel("SONGS REMAINING : 50");
   setLayout(new GridBagLayout());
   GridBagConstraints cc = new GridBagConstraints();
   // setPreferredSize(new Dimension(100,20));
   cc.insets = new Insets(3, 3, 3, 3);
   cc.gridx = 0;
   cc.gridy = 0;
   cc.gridwidth = 5;
   cc.gridheight = 1;
   add(name, cc);
   cc.gridx = 5;
   cc.gridy = 0;
   cc.gridwidth = 2;
   cc.gridheight = 1;
   add(counter, cc);
 }
 // For setting the gridbagconstraints for this application
 public static void setConstraints(GridBagConstraints c, int fill, int col, int row) {
   c.fill = fill;
   c.weightx = 1.0;
   c.weighty = 1.0;
   c.gridx = col;
   c.gridy = row;
   c.gridwidth = 1;
   c.gridheight = 1;
   Insets insets = new Insets(5, 5, 5, 5);
   c.insets = insets;
 }
 protected GridBagConstraints createConstraints(int x, int y) {
   GridBagConstraints c = new GridBagConstraints();
   c.gridx = x;
   c.gridy = y;
   c.gridwidth = 2;
   c.gridheight = 1;
   c.ipadx = 1;
   c.weightx = 0.5;
   c.weighty = 0.5;
   c.fill = GridBagConstraints.BOTH;
   c.anchor = GridBagConstraints.CENTER;
   return c;
 }
Beispiel #14
0
  private static JPanel createTextFieldAndListPanel(
      String label, JTextField textField, JList list) {
    GridBagLayout layout = new GridBagLayout();
    JPanel panel = new JPanel(layout);

    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = cons.gridy = 0;
    cons.gridwidth = cons.gridheight = 1;
    cons.fill = GridBagConstraints.BOTH;
    cons.weightx = 1.0f;

    JLabel _label = new JLabel(jEdit.getProperty(label));
    layout.setConstraints(_label, cons);
    panel.add(_label);

    cons.gridy = 1;
    Component vs = Box.createVerticalStrut(6);
    layout.setConstraints(vs, cons);
    panel.add(vs);

    cons.gridy = 2;
    layout.setConstraints(textField, cons);
    panel.add(textField);

    cons.gridy = 3;
    vs = Box.createVerticalStrut(6);
    layout.setConstraints(vs, cons);
    panel.add(vs);

    cons.gridy = 4;
    cons.gridheight = GridBagConstraints.REMAINDER;
    cons.weighty = 1.0f;
    JScrollPane scroller = new JScrollPane(list);
    layout.setConstraints(scroller, cons);
    panel.add(scroller);

    return panel;
  }
 /**
  * This method adds the panels to the window and organises them using a GridBagLayout and a
  * JLayeredPane.
  */
 private void populateFrame(Container frame) {
   frame.setLayout(new GridBagLayout());
   GridBagConstraints layoutConstraints = new GridBagConstraints();
   JLayeredPane dungeonArea = new JLayeredPane();
   dungeonArea.setPreferredSize(new Dimension(448, 448));
   dungeonArea.add(dungeonPanel, JLayeredPane.DEFAULT_LAYER);
   // the DungeonPanel is added underneath
   dungeonArea.add(dungeonPanelOverlay, JLayeredPane.PALETTE_LAYER);
   // the mostly transparent DungeonPanelOverlay is added on top in the same position
   layoutConstraints.gridx = 0;
   layoutConstraints.gridy = 0;
   layoutConstraints.gridwidth = 7;
   layoutConstraints.gridheight = 7;
   frame.add(dungeonArea, layoutConstraints);
   layoutConstraints.gridx = 7;
   layoutConstraints.gridwidth = 1;
   frame.add(serverSettings, layoutConstraints);
   layoutConstraints.gridx = 0;
   layoutConstraints.gridy = 7;
   layoutConstraints.gridwidth = 8;
   layoutConstraints.gridheight = 1;
   frame.add(chatPanel, layoutConstraints);
 }
  /*
   * helper class to initialize empty spaces
   * @param int x - column of button
   * @param int y - row of button
   * @param Dimension btnSize - sets the size of the button
   */
  public void createBlankButtons(int x, int y, Dimension btnSize) {
    String output = "";
    Font clueFont = new Font("Arial", Font.PLAIN, 8);

    // initialize next myButton
    btn[activeMyButtons] = new myButton();
    String toolTip = ("" + activeMyButtons);
    btn[activeMyButtons].setDefaultToolTipText(toolTip);
    btn[activeMyButtons].setToolTipText(toolTip);

    // get next available myButton and assign current position
    btn[activeMyButtons].positionX = x;
    btn[activeMyButtons].positionY = y;
    btn[activeMyButtons].button = activeMyButtons;
    btn[activeMyButtons].setPreferredSize(btnSize);
    btn[activeMyButtons].setFont(clueFont);

    // assign GridBagConstraints for //position
    cons.gridx = x;
    cons.gridy = y;
    cons.gridwidth = 1;
    cons.gridheight = 1;
    cons.ipadx = 0;
    cons.ipady = 0;

    // determine position and set alternating color
    if (((x % 2 == 0) && (y % 2 == 0)) || ((x % 2 != 0) && (y % 2 != 0))) {
      btn[activeMyButtons].setBackground(new Color(152, 86, 112));
      btn[activeMyButtons].setDefaultColor(new Color(152, 86, 112));
    } else {

      btn[activeMyButtons].setBackground(new Color(128, 48, 82));
      btn[activeMyButtons].setDefaultColor(new Color(128, 48, 82));
    }

    btn[activeMyButtons].setOpaque(true);
    btn[activeMyButtons].setBorderPainted(false);

    // add button to boardPanel
    this.add(btn[activeMyButtons], cons);
    btn[activeMyButtons].addActionListener(new myActionListener());
    validate();

    // pass output to setOutput()
    output = "activeMyButtons: " + activeMyButtons + " " + btn[activeMyButtons].getDefaultColor();
    // setOutput(output);

    activeMyButtons++;
  }
Beispiel #17
0
  // Put the controls on the screen
  private void placeControls() {
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(layout);

    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0.5;
    c.gridwidth = 1;
    c.gridheight = 1;

    c.gridx = 0;
    c.gridy = 0;
    c.gridheight = 1;
    layout.setConstraints(startMeasureLabel, c);
    add(startMeasureLabel);

    c.gridx = 1;
    c.gridy = 0;
    c.gridheight = 1;
    layout.setConstraints(startMeasureEdit, c);
    add(startMeasureEdit);

    c.gridx = 0;
    c.gridy = 1;
    c.gridheight = 1;
    layout.setConstraints(measureCountLabel, c);
    add(measureCountLabel);

    c.gridx = 1;
    c.gridy = 1;
    c.gridheight = 1;
    layout.setConstraints(measureCountEdit, c);
    add(measureCountEdit);

    c.gridx = 0;
    c.gridy = 3;
    c.gridheight = 1;
    layout.setConstraints(okButton, c);
    add(okButton);
    okButton.addActionListener(this);

    c.gridx = 1;
    c.gridy = 3;
    c.gridheight = 1;
    add(cancelButton);
    layout.setConstraints(cancelButton, c);

    cancelButton.addActionListener(this);
  }
Beispiel #18
0
  private static JComponent makeUI() {
    // final JProgressBar progressBar = new JProgressBar(SwingConstants.VERTICAL);
    final JProgressBar progressBar = new JProgressBar();
    progressBar.setOpaque(false);
    progressBar.setUI(new GradientPalletProgressBarUI());

    GridBagConstraints c = new GridBagConstraints();
    JPanel p = new JPanel(new GridBagLayout());
    p.setBorder(BorderFactory.createEmptyBorder(32, 8, 0, 8));

    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridy = 0;

    c.gridx = 0;
    c.insets = new Insets(0, 0, 0, 4);
    c.weightx = 1d;
    c.fill = GridBagConstraints.HORIZONTAL;
    p.add(progressBar, c);

    c.gridx = 1;
    c.weightx = 0d;
    p.add(
        new JButton(
            new AbstractAction("Start") {
              @Override
              public void actionPerformed(ActionEvent e) {
                final JButton b = (JButton) e.getSource();
                b.setEnabled(false);
                SwingWorker<Void, Void> worker =
                    new Task() {
                      @Override
                      public void done() {
                        if (b.isDisplayable()) {
                          b.setEnabled(true);
                        }
                      }
                    };
                worker.addPropertyChangeListener(new ProgressListener(progressBar));
                worker.execute();
              }
            }),
        c);
    return p;
  }
 // For setting the gridbagconstraints for this application
 public static void setConstraints(
     GridBagConstraints c,
     int fill,
     double wx,
     double wy,
     int gx,
     int gy,
     int gw,
     int gh,
     int ins) {
   c.fill = fill;
   c.weightx = (float) wx;
   c.weighty = (float) wy;
   c.gridx = gx;
   c.gridy = gy;
   c.gridwidth = gw;
   c.gridheight = gh;
   Insets insets = new Insets(ins, ins, ins, ins);
   c.insets = insets;
 }
  /**
   * Messaged from installComponents to create a Container containing the body of the message. The
   * icon is the created by calling <code>addIcon</code>.
   */
  protected Container createMessageArea() {
    JPanel top = new JPanel();
    Border topBorder = (Border) DefaultLookup.get(optionPane, this, "OptionPane.messageAreaBorder");
    if (topBorder != null) {
      top.setBorder(topBorder);
    }
    top.setLayout(new BorderLayout());

    /* Fill the body. */
    Container body = new JPanel(new GridBagLayout());
    Container realBody = new JPanel(new BorderLayout());

    body.setName("OptionPane.body");
    realBody.setName("OptionPane.realBody");

    if (getIcon() != null) {
      JPanel sep = new JPanel();
      sep.setName("OptionPane.separator");
      sep.setPreferredSize(new Dimension(15, 1));
      realBody.add(sep, BorderLayout.BEFORE_LINE_BEGINS);
    }
    realBody.add(body, BorderLayout.CENTER);

    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = cons.gridy = 0;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cons.gridheight = 1;
    cons.anchor =
        DefaultLookup.getInt(
            optionPane, this, "OptionPane.messageAnchor", GridBagConstraints.CENTER);
    cons.insets = new Insets(0, 0, 3, 0);

    addMessageComponents(body, cons, getMessage(), getMaxCharactersPerLineCount(), false);
    top.add(realBody, BorderLayout.CENTER);

    addIcon(top);
    return top;
  }
  /**
   * Initializes the display details component for the given <tt>UIContact</tt>.
   *
   * @param displayDetails the display details to show
   */
  private void initDisplayDetails(String displayDetails) {
    remove(displayDetailsLabel);
    displayDetailsLabel.setText("");

    if (displayDetails != null && displayDetails.length() > 0) {
      // Replace all occurrences of new line with slash.
      displayDetails = Html2Text.extractText(displayDetails);
      displayDetails = displayDetails.replaceAll("\n|<br>|<br/>", " / ");

      displayDetailsLabel.setText(displayDetails);
    }

    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.weightx = 1f;
    constraints.weighty = 0f;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;

    this.add(displayDetailsLabel, constraints);
  }
Beispiel #22
0
  protected void populateDialog(JDialog dlg) {
    dlg.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dlg.setResizable(false);
    dlg.setSize(new Dimension(350, 135));
    dlg.setTitle("New TurboVNC Connection");

    dlg.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            if (VncViewer.nViewers == 1) {
              if (cc.viewer instanceof VncViewer) {
                ((VncViewer) cc.viewer).exit(1);
              }
            } else {
              ret = false;
              endDialog();
            }
          }
        });

    dlg.getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = 1;
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.ipadx = 0;
    gbc.ipady = 0;
    gbc.weightx = 1;
    gbc.weighty = 1;

    dlg.getContentPane().add(topPanel, gbc);
    dlg.getContentPane().add(buttonPanel);
    dlg.pack();
  }
Beispiel #23
0
  public void init() {
    d = getSize();
    resize(d.width, d.height);
    GridBagLayout g = new GridBagLayout();
    setLayout(g);
    GridBagConstraints gC = new GridBagConstraints();

    // first row
    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 0, 10, 0);
    gC.gridy = 0;
    gC.gridwidth = 5;
    gC.fill = GridBagConstraints.BOTH;
    txt = new JTextField();
    txt.setHorizontalAlignment(JTextField.RIGHT);
    txt.setEditable(false);
    g.setConstraints(txt, gC);
    add(txt);

    // second row
    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 0, 5, 0);
    gC.gridy = 1;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    b7 = new JButton("7");
    b7.setForeground(Color.BLACK);
    b7.addActionListener(new setLabelText_ActionListener());
    g.setConstraints(b7, gC);
    add(b7);

    gC = new GridBagConstraints();
    gC.fill = GridBagConstraints.HORIZONTAL;
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 1;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    b8 = new JButton("8");
    b8.setForeground(Color.BLACK);
    b8.addActionListener(new setLabelText_ActionListener());
    g.setConstraints(b8, gC);
    add(b8);

    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 1;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    b9 = new JButton("9");
    b9.setForeground(Color.BLACK);
    b9.addActionListener(new setLabelText_ActionListener());
    g.setConstraints(b9, gC);
    add(b9);

    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 1;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    bAdd = new JButton("+");
    bAdd.setForeground(Color.BLUE);
    bAdd.addActionListener(new setOperator_ActionListener());
    g.setConstraints(bAdd, gC);
    add(bAdd);

    // third row
    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 0, 5, 0);
    gC.gridy = 2;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    b4 = new JButton("4");
    b4.setForeground(Color.BLACK);
    b4.addActionListener(new setLabelText_ActionListener());
    g.setConstraints(b4, gC);
    add(b4);

    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 2;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    b5 = new JButton("5");
    b5.setForeground(Color.BLACK);
    b5.addActionListener(new setLabelText_ActionListener());
    g.setConstraints(b5, gC);
    add(b5);

    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 2;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    b6 = new JButton("6");
    b6.setForeground(Color.BLACK);
    b6.addActionListener(new setLabelText_ActionListener());
    g.setConstraints(b6, gC);
    add(b6);

    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 2;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    bDec = new JButton("-");
    bDec.setForeground(Color.BLUE);
    bDec.addActionListener(new setOperator_ActionListener());
    g.setConstraints(bDec, gC);
    add(bDec);

    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 1;
    gC.gridwidth = 1;
    gC.gridheight = 2;
    gC.fill = GridBagConstraints.BOTH;
    bC = new JButton("C");
    bC.setForeground(Color.RED);
    bC.addActionListener(new setOperator_ActionListener());
    g.setConstraints(bC, gC);
    add(bC);

    // fourth row
    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 0, 5, 0);
    gC.gridy = 3;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    b1 = new JButton("1");
    b1.setForeground(Color.BLACK);
    b1.addActionListener(new setLabelText_ActionListener());
    g.setConstraints(b1, gC);
    add(b1);

    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 3;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    b2 = new JButton("2");
    b2.setForeground(Color.BLACK);
    b2.addActionListener(new setLabelText_ActionListener());
    g.setConstraints(b2, gC);
    add(b2);

    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 3;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    b3 = new JButton("3");
    b3.setForeground(Color.BLACK);
    b3.addActionListener(new setLabelText_ActionListener());
    g.setConstraints(b3, gC);
    add(b3);

    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 3;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    bMul = new JButton("*");
    bMul.setForeground(Color.BLUE);
    bMul.addActionListener(new setOperator_ActionListener());
    g.setConstraints(bMul, gC);
    add(bMul);

    // fifth row
    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 0, 5, 0);
    gC.gridy = 4;
    gC.gridwidth = 2;
    gC.fill = GridBagConstraints.BOTH;
    b0 = new JButton("0");
    b0.setForeground(Color.BLACK);
    b0.addActionListener(new setLabelText_ActionListener());
    g.setConstraints(b0, gC);
    add(b0);

    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 4;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    bPoint = new JButton(".");
    bPoint.setForeground(Color.BLACK);
    bPoint.addActionListener(new setLabelText_ActionListener());
    g.setConstraints(bPoint, gC);
    add(bPoint);

    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 4;
    gC.gridwidth = 1;
    gC.fill = GridBagConstraints.BOTH;
    bDiv = new JButton("/");
    bDiv.setForeground(Color.BLUE);
    bDiv.addActionListener(new setOperator_ActionListener());
    g.setConstraints(bDiv, gC);
    add(bDiv);

    gC = new GridBagConstraints();
    gC.insets = new Insets(0, 5, 5, 0);
    gC.gridy = 3;
    gC.gridwidth = 1;
    gC.gridheight = 2;
    gC.fill = GridBagConstraints.BOTH;
    bCal = new JButton("=");
    bCal.addActionListener(new setOperator_ActionListener());
    bCal.setForeground(Color.RED);
    g.setConstraints(bCal, gC);
    add(bCal);
  }
  // Here some legacy code makes use of generics. They are tested, so there
  // is no risk of an actual error, but Java issues a warning.
  @SuppressWarnings("unchecked")
  public DialogParameters(
      JFrame parent, Vector<ParameterDescription> vec, boolean strict, Vector<LayerDesc> layers) {
    super(parent, Globals.messages.getString("Param_opt"), true);

    keyb1 = new OSKeybPanel(KEYBMODES.GREEK);
    keyb2 = new OSKeybPanel(KEYBMODES.MISC);
    keyb1.setField(this);
    keyb2.setField(this);
    keyb.addTab("Greek", keyb1);
    keyb.addTab("Misc", keyb2);
    keyb.setVisible(false);
    v = vec;

    int ycount = 0;

    // We create dynamically all the needed elements.
    // For this reason, we work on arrays of the potentially useful Swing
    // objects.

    jtf = new JTextField[MAX_ELEMENTS];
    jcb = new JCheckBox[MAX_ELEMENTS];
    jco = new JComboBox[MAX_ELEMENTS];

    active = false;
    addComponentListener(this);

    GridBagLayout bgl = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    Container contentPane = getContentPane();
    contentPane.setLayout(bgl);
    boolean extStrict = strict;

    ParameterDescription pd;

    int top = 0;

    JLabel lab;

    tc = 0;
    cc = 0;
    co = 0;

    // We process all parameter passed. Depending on its type, a
    // corresponding interface element will be created.
    // A symmetrical operation is done when validating parameters.

    for (ycount = 0; ycount < v.size(); ++ycount) {
      if (ycount > MAX) break;

      pd = (ParameterDescription) v.elementAt(ycount);

      // We do not need to store label objects, since we do not need
      // to retrieve data from them.

      lab = new JLabel(pd.description);
      constraints.weightx = 100;
      constraints.weighty = 100;
      constraints.gridx = 1;
      constraints.gridy = ycount;
      constraints.gridwidth = 1;
      constraints.gridheight = 1;

      // The first element needs a little bit more space at the top.
      if (ycount == 0) top = 10;
      else top = 0;

      // Here we configure the grid layout

      constraints.insets = new Insets(top, 20, 0, 6);

      constraints.fill = GridBagConstraints.VERTICAL;
      constraints.anchor = GridBagConstraints.EAST;
      lab.setEnabled(!(pd.isExtension && extStrict));

      if (!(pd.parameter instanceof Boolean)) contentPane.add(lab, constraints);

      constraints.anchor = GridBagConstraints.WEST;
      constraints.insets = new Insets(top, 0, 0, 0);
      constraints.fill = GridBagConstraints.HORIZONTAL;

      // Now, depending on the type of parameter we create interface
      // elements and we populate the dialog.

      if (pd.parameter instanceof PointG) {
        jtf[tc] = new JTextField(10);
        jtf[tc].setText("" + ((PointG) (pd.parameter)).x);
        constraints.weightx = 100;
        constraints.weighty = 100;
        constraints.gridx = 2;
        constraints.gridy = ycount;
        constraints.gridwidth = 1;
        constraints.gridheight = 1;
        // Disable FidoCadJ extensions in the strict compatibility mode
        jtf[tc].setEnabled(!(pd.isExtension && extStrict));

        contentPane.add(jtf[tc++], constraints);

        jtf[tc] = new JTextField(10);
        jtf[tc].setText("" + ((PointG) (pd.parameter)).y);
        constraints.weightx = 100;
        constraints.weighty = 100;
        constraints.gridx = 3;
        constraints.gridy = ycount;
        constraints.gridwidth = 1;
        constraints.gridheight = 1;
        constraints.insets = new Insets(top, 6, 0, 20);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        jtf[tc].setEnabled(!(pd.isExtension && extStrict));
        contentPane.add(jtf[tc++], constraints);
      } else if (pd.parameter instanceof String) {
        jtf[tc] = new JTextField(24);
        jtf[tc].setText((String) (pd.parameter));
        // If we have a String text field in the first position, its
        // contents should be evidenced, since it is supposed to be
        // the most important field (e.g. for the AdvText primitive)
        if (ycount == 0) jtf[tc].selectAll();
        constraints.weightx = 100;
        constraints.weighty = 100;
        constraints.gridx = 2;
        constraints.gridy = ycount;
        constraints.gridwidth = 2;
        constraints.gridheight = 1;
        constraints.insets = new Insets(top, 0, 0, 20);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        jtf[tc].setEnabled(!(pd.isExtension && extStrict));

        contentPane.add(jtf[tc++], constraints);

      } else if (pd.parameter instanceof Boolean) {
        jcb[cc] = new JCheckBox(pd.description);
        jcb[cc].setSelected(((Boolean) (pd.parameter)).booleanValue());
        constraints.weightx = 100;
        constraints.weighty = 100;
        constraints.gridx = 2;
        constraints.gridy = ycount;
        constraints.gridwidth = 2;
        constraints.gridheight = 1;
        constraints.insets = new Insets(top, 0, 0, 20);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        jcb[cc].setEnabled(!(pd.isExtension && extStrict));
        contentPane.add(jcb[cc++], constraints);
      } else if (pd.parameter instanceof Integer) {
        jtf[tc] = new JTextField(24);
        jtf[tc].setText(((Integer) pd.parameter).toString());
        constraints.weightx = 100;
        constraints.weighty = 100;
        constraints.gridx = 2;
        constraints.gridy = ycount;
        constraints.gridwidth = 2;
        constraints.gridheight = 1;
        constraints.insets = new Insets(top, 0, 0, 20);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        jtf[tc].setEnabled(!(pd.isExtension && extStrict));
        contentPane.add(jtf[tc++], constraints);
      } else if (pd.parameter instanceof Float) {
        // TODO.
        // WARNING: (DB) this is supposed to be temporary. In fact, I
        // am planning to upgrade some of the parameters from int
        // to float. But for a few months, the users should not be
        // aware of that, even if the internal representation is
        // slowing being adapted.
        jtf[tc] = new JTextField(24);
        int dummy = java.lang.Math.round((Float) pd.parameter);
        jtf[tc].setText("" + dummy);
        constraints.weightx = 100;
        constraints.weighty = 100;
        constraints.gridx = 2;
        constraints.gridy = ycount;
        constraints.gridwidth = 2;
        constraints.gridheight = 1;
        constraints.insets = new Insets(top, 0, 0, 20);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        jtf[tc].setEnabled(!(pd.isExtension && extStrict));
        contentPane.add(jtf[tc++], constraints);
      } else if (pd.parameter instanceof FontG) {
        GraphicsEnvironment gE;
        gE = GraphicsEnvironment.getLocalGraphicsEnvironment();
        String[] s = gE.getAvailableFontFamilyNames();
        jco[co] = new JComboBox();

        for (int i = 0; i < s.length; ++i) {
          jco[co].addItem(s[i]);
          if (s[i].equals(((FontG) pd.parameter).getFamily())) jco[co].setSelectedIndex(i);
        }
        constraints.weightx = 100;
        constraints.weighty = 100;
        constraints.gridx = 2;
        constraints.gridy = ycount;
        constraints.gridwidth = 2;
        constraints.gridheight = 1;
        constraints.insets = new Insets(top, 0, 0, 20);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        jco[co].setEnabled(!(pd.isExtension && extStrict));
        contentPane.add(jco[co++], constraints);
      } else if (pd.parameter instanceof LayerInfo) {
        jco[co] = new JComboBox(new Vector<LayerDesc>(layers));
        jco[co].setSelectedIndex(((LayerInfo) pd.parameter).layer);
        jco[co].setRenderer(new LayerCellRenderer());

        constraints.weightx = 100;
        constraints.weighty = 100;
        constraints.gridx = 2;
        constraints.gridy = ycount;
        constraints.gridwidth = 2;
        constraints.gridheight = 1;
        constraints.insets = new Insets(top, 0, 0, 20);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        jco[co].setEnabled(!(pd.isExtension && extStrict));
        contentPane.add(jco[co++], constraints);

      } else if (pd.parameter instanceof ArrowInfo) {
        jco[co] = new JComboBox<ArrowInfo>();
        jco[co].addItem(new ArrowInfo(0));
        jco[co].addItem(new ArrowInfo(1));
        jco[co].addItem(new ArrowInfo(2));
        jco[co].addItem(new ArrowInfo(3));

        jco[co].setSelectedIndex(((ArrowInfo) pd.parameter).style);
        jco[co].setRenderer(new ArrowCellRenderer());

        constraints.weightx = 100;
        constraints.weighty = 100;
        constraints.gridx = 2;
        constraints.gridy = ycount;
        constraints.gridwidth = 2;
        constraints.gridheight = 1;
        constraints.insets = new Insets(top, 0, 0, 20);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        jco[co].setEnabled(!(pd.isExtension && extStrict));
        contentPane.add(jco[co++], constraints);

      } else if (pd.parameter instanceof DashInfo) {

        jco[co] = new JComboBox<DashInfo>();

        for (int k = 0; k < Globals.dashNumber; ++k) {
          jco[co].addItem(new DashInfo(k));
        }

        jco[co].setSelectedIndex(((DashInfo) pd.parameter).style);
        jco[co].setRenderer(new DashCellRenderer());

        constraints.weightx = 100;
        constraints.weighty = 100;
        constraints.gridx = 2;
        constraints.gridy = ycount;
        constraints.gridwidth = 2;
        constraints.gridheight = 1;
        constraints.insets = new Insets(top, 0, 0, 20);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        jco[co].setEnabled(!(pd.isExtension && extStrict));
        contentPane.add(jco[co++], constraints);
      }
    }
    // Put the OK and Cancel buttons and make them active.
    JButton ok = new JButton(Globals.messages.getString("Ok_btn"));
    JButton cancel = new JButton(Globals.messages.getString("Cancel_btn"));
    JButton keybd = new JButton("\u00B6\u2211\u221A"); // phylum
    keybd.setFocusable(false);
    keybd.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // If at this point, the keyboard is not visible, this means
            // that it will become visible in a while. It is better to
            // resize first and then show up the keyboard.
            if (keyb.isVisible()) {
              MIN_WIDTH = 400;
              MIN_HEIGHT = 350;
            } else {
              MIN_WIDTH = 400;
              MIN_HEIGHT = 500;
            }
            // setSize(MIN_WIDTH, MIN_HEIGHT);
            keyb.setVisible(!keyb.isVisible());
            pack();
          }
        });

    constraints.gridx = 0;
    constraints.gridy = ycount++;
    constraints.gridwidth = 4;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.EAST;
    constraints.insets = new Insets(6, 20, 20, 20);

    // Put the OK and Cancel buttons and make them active.
    Box b = Box.createHorizontalBox();
    b.add(keybd); // phylum

    b.add(Box.createHorizontalGlue());
    ok.setPreferredSize(cancel.getPreferredSize());

    if (Globals.okCancelWinOrder) {
      b.add(ok);
      b.add(Box.createHorizontalStrut(12));
      b.add(cancel);

    } else {
      b.add(cancel);
      b.add(Box.createHorizontalStrut(12));
      b.add(ok);
    }
    // b.add(Box.createHorizontalStrut(12));
    contentPane.add(b, constraints);

    constraints.gridx = 0;
    constraints.gridy = ycount;
    constraints.gridwidth = 4;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.EAST;
    constraints.insets = new Insets(6, 20, 20, 20);

    contentPane.add(keyb, constraints);

    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            try {
              int ycount;
              ParameterDescription pd;
              tc = 0;
              cc = 0;
              co = 0;

              // Here we read all the contents of the interface and we
              // update the contents of the parameter description array.

              for (ycount = 0; ycount < v.size(); ++ycount) {
                if (ycount > MAX) break;
                pd = (ParameterDescription) v.elementAt(ycount);

                if (pd.parameter instanceof PointG) {
                  ((PointG) (pd.parameter)).x = Integer.parseInt(jtf[tc++].getText());
                  ((PointG) (pd.parameter)).y = Integer.parseInt(jtf[tc++].getText());
                } else if (pd.parameter instanceof String) {
                  pd.parameter = jtf[tc++].getText();
                } else if (pd.parameter instanceof Boolean) {
                  pd.parameter = Boolean.valueOf(jcb[cc++].isSelected());
                } else if (pd.parameter instanceof Integer) {
                  pd.parameter = Integer.valueOf(Integer.parseInt(jtf[tc++].getText()));
                } else if (pd.parameter instanceof Float) {
                  pd.parameter = Float.valueOf(Float.parseFloat(jtf[tc++].getText()));
                } else if (pd.parameter instanceof FontG) {
                  pd.parameter = new FontG((String) jco[co++].getSelectedItem());
                } else if (pd.parameter instanceof LayerInfo) {
                  pd.parameter = new LayerInfo(jco[co++].getSelectedIndex());
                } else if (pd.parameter instanceof ArrowInfo) {
                  pd.parameter = new ArrowInfo(jco[co++].getSelectedIndex());
                } else if (pd.parameter instanceof DashInfo) {
                  pd.parameter = new DashInfo(jco[co++].getSelectedIndex());
                }
              }
            } catch (NumberFormatException E) {
              // Error detected. Probably, the user has entered an
              // invalid string when FidoCadJ was expecting a numerical
              // input.

              JOptionPane.showMessageDialog(
                  null,
                  Globals.messages.getString("Format_invalid"),
                  "",
                  JOptionPane.INFORMATION_MESSAGE);
              return;
            }

            active = true;
            // Globals.activeWindow.setEnabled(true);
            setVisible(false);
            keyb.setVisible(false);
          }
        });
    cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            // Globals.activeWindow.setEnabled(true);
            setVisible(false);
            keyb.setVisible(false);
          }
        });
    // Here is an action in which the dialog is closed

    AbstractAction cancelAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            // Globals.activeWindow.setEnabled(true);
            setVisible(false);
            keyb.setVisible(false);
          }
        };
    DialogUtil.addCancelEscape(this, cancelAction);

    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            // Globals.activeWindow.setEnabled(true);
            keyb.setVisible(false);
          }
        });

    pack();
    DialogUtil.center(this);
    getRootPane().setDefaultButton(ok);
  }
  /**
   * Initializes the GUI by creating the components, placing them in the dialog, and displaying
   * them.
   */
  private void init() {
    setForeground(Color.black);

    setTitle("Nonlocal Means Filter");

    JPanel mainPanel;
    mainPanel = new JPanel();
    mainPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    mainPanel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 1;
    gbc.insets = new Insets(3, 3, 3, 3);
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    paramPanel = new JPanel(new GridBagLayout());
    paramPanel.setForeground(Color.black);
    paramPanel.setBorder(buildTitledBorder("Parameters"));
    mainPanel.add(paramPanel, gbc);

    GridBagConstraints gbc2 = new GridBagConstraints();
    gbc2.gridwidth = 1;
    gbc2.gridheight = 1;
    gbc2.anchor = GridBagConstraints.WEST;
    gbc2.weightx = 1;
    gbc2.insets = new Insets(3, 3, 3, 3);
    gbc2.gridx = 0;
    gbc2.gridy = 0;
    gbc2.fill = GridBagConstraints.HORIZONTAL;

    labelSearchWindowSide = createLabel("Search window side (odd)");

    paramPanel.add(labelSearchWindowSide, gbc2);

    gbc2.gridx = 1;
    textSearchWindowSide = createTextField("15");
    paramPanel.add(textSearchWindowSide, gbc2);

    gbc2.gridx = 0;
    gbc2.gridy = 1;
    labelSimilarityWindowSide = createLabel("Similarity window side (odd) ");
    paramPanel.add(labelSimilarityWindowSide, gbc2);

    gbc2.gridx = 1;
    textSimilarityWindowSide = createTextField("7");
    paramPanel.add(textSimilarityWindowSide, gbc2);

    gbc2.gridx = 0;
    gbc2.gridy = 2;
    labelNoiseStandardDeviation = createLabel("Noise standard deviation ");
    paramPanel.add(labelNoiseStandardDeviation, gbc2);

    gbc2.gridx = 1;
    textNoiseStandardDeviation = createTextField("10.0");
    paramPanel.add(textNoiseStandardDeviation, gbc2);

    gbc2.gridx = 0;
    gbc2.gridy = 3;
    labelDegree = createLabel("Degree of filtering ");
    labelDegree.setEnabled(doRician);
    paramPanel.add(labelDegree, gbc2);

    gbc2.gridx = 1;
    textDegree = createTextField("1.414");
    textDegree.setEnabled(doRician);
    paramPanel.add(textDegree, gbc2);

    gbc2.gridx = 0;
    gbc2.gridy = 4;
    doRicianCheckBox = new JCheckBox("Deal with Rician noise in MRI");
    doRicianCheckBox.setFont(serif12);
    doRicianCheckBox.setSelected(false);
    doRicianCheckBox.addActionListener(this);
    paramPanel.add(doRicianCheckBox, gbc2);

    if (image.getNDims() > 2) {
      gbc2.gridx = 0;
      gbc2.gridy = 5;
      gbc2.gridwidth = 2;

      image25DCheckBox = new JCheckBox("Process each slice independently (2.5D)");
      image25DCheckBox.setFont(serif12);
      paramPanel.add(image25DCheckBox, gbc2);
      image25DCheckBox.setSelected(false);
    } // if (image.getNDims > 2)

    JPanel outputOptPanel = new JPanel(new GridLayout(1, 2));
    destinationPanel = new JPanel(new BorderLayout());
    destinationPanel.setForeground(Color.black);
    destinationPanel.setBorder(buildTitledBorder("Destination"));
    outputOptPanel.add(destinationPanel);

    destinationGroup = new ButtonGroup();
    newImage = new JRadioButton("New image", true);
    newImage.setBounds(10, 16, 120, 25);
    newImage.setFont(serif12);
    destinationGroup.add(newImage);
    destinationPanel.add(newImage, BorderLayout.NORTH);

    replaceImage = new JRadioButton("Replace image", false);
    replaceImage.setFont(serif12);
    destinationGroup.add(replaceImage);
    destinationPanel.add(replaceImage, BorderLayout.CENTER);

    // Only if the image is unlocked can it be replaced.
    if (image.getLockStatus() == ModelStorageBase.UNLOCKED) {
      replaceImage.setEnabled(true);
    } else {
      replaceImage.setEnabled(false);
    }

    gbc.gridx = 0;
    gbc.gridy = 1;
    mainPanel.add(outputOptPanel, gbc);

    mainDialogPanel.add(mainPanel, BorderLayout.CENTER);
    mainDialogPanel.add(buildButtons(), BorderLayout.SOUTH);

    getContentPane().add(mainDialogPanel);

    pack();
    setResizable(true);
    // setVisible(true);

    System.gc();
  }
Beispiel #26
0
  /**
   * Standard constructor: it needs the parent frame.
   *
   * @param parent the dialog's parent
   */
  public DialogPrint(JFrame parent) {
    super(400, 350, parent, Globals.messages.getString("Print_dlg"), true);
    addComponentListener(this);
    export = false;

    // Ensure that under MacOSX >= 10.5 Leopard, this dialog will appear
    // as a document modal sheet

    getRootPane().putClientProperty("apple.awt.documentModalSheet", Boolean.TRUE);

    GridBagLayout bgl = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    Container contentPane = getContentPane();
    contentPane.setLayout(bgl);

    constraints.insets.right = 30;

    JLabel empty = new JLabel("  ");
    constraints.weightx = 100;
    constraints.weighty = 100;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    contentPane.add(empty, constraints); // Add "   " label

    JLabel empty1 = new JLabel("  ");
    constraints.weightx = 100;
    constraints.weighty = 100;
    constraints.gridx = 3;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    contentPane.add(empty1, constraints); // Add "   " label

    mirror_CB = new JCheckBox(Globals.messages.getString("Mirror"));
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.WEST;
    contentPane.add(mirror_CB, constraints); // Add Print Mirror cb

    fit_CB = new JCheckBox(Globals.messages.getString("FitPage"));
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.WEST;
    contentPane.add(fit_CB, constraints); // Add Fit to page cb

    bw_CB = new JCheckBox(Globals.messages.getString("B_W"));
    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.WEST;
    contentPane.add(bw_CB, constraints); // Add BlackWhite cb

    landscape_CB = new JCheckBox(Globals.messages.getString("Landscape"));
    constraints.gridx = 1;
    constraints.gridy = 3;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.WEST;
    contentPane.add(landscape_CB, constraints); // Add landscape cb

    // Put the OK and Cancel buttons and make them active.
    JButton ok = new JButton(Globals.messages.getString("Ok_btn"));
    JButton cancel = new JButton(Globals.messages.getString("Cancel_btn"));

    constraints.gridx = 0;
    constraints.gridy = 4;
    constraints.gridwidth = 4;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.EAST;

    // Put the OK and Cancel buttons and make them active.
    Box b = Box.createHorizontalBox();
    b.add(Box.createHorizontalGlue());
    ok.setPreferredSize(cancel.getPreferredSize());

    if (Globals.okCancelWinOrder) {
      b.add(ok);
      b.add(Box.createHorizontalStrut(12));
      b.add(cancel);

    } else {
      b.add(cancel);
      b.add(Box.createHorizontalStrut(12));
      b.add(ok);
    }

    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            export = true;
            setVisible(false);
          }
        });
    cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            setVisible(false);
          }
        });
    // Here is an action in which the dialog is closed

    AbstractAction cancelAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        };
    contentPane.add(b, constraints); // Add OK/cancel dialog

    DialogUtil.addCancelEscape(this, cancelAction);
    pack();
    DialogUtil.center(this);
    getRootPane().setDefaultButton(ok);
  }
  /*
   * main constructor
   * @param debug - boolean for debug mode
   */
  public boardPanel(boolean debug) {
    // initial constructor
    super();
    debugBoardPanel = debug;

    // continue defining boardPanel
    this.setLayout(new GridBagLayout());
    cons.fill = GridBagConstraints.BOTH;
    cons.insets = new Insets(0, 0, 0, 0);
    cons.anchor = GridBagConstraints.FIRST_LINE_START;
    this.setVisible(true);

    // button preferred size
    Dimension btnSize = new Dimension(25, 25);

    // top row
    // ------------------------------------------------------------------------------------------
    // spa
    btnSpa = new JButton("Spa");
    allRooms[0] = btnSpa;
    btnSpa.setPreferredSize(btnSize);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.gridwidth = 5;
    cons.gridheight = 5;
    btnSpa.setBackground(defaultRoomColor);
    btnSpa.setOpaque(true);
    btnSpa.setBorderPainted(false);
    btnSpa.addActionListener(new myActionListener());
    this.add(btnSpa, cons);

    // space buttons
    for (int y = 0; y < 5; y++) {
      for (int x = 5; x < 10; x++) {
        createBlankButtons(x, y, btnSize);
      }
    }

    // theater
    btnTheater = new JButton("Theater");
    allRooms[1] = btnTheater;
    btnTheater.setPreferredSize(btnSize);
    cons.gridx = 10;
    cons.gridy = 0;
    cons.gridwidth = 5;
    cons.gridheight = 5;
    btnTheater.setOpaque(true);
    btnTheater.setBorderPainted(false);
    btnTheater.setBackground(defaultRoomColor);
    btnTheater.addActionListener(new myActionListener());
    this.add(btnTheater, cons);

    // space buttons
    for (int y = 0; y < 5; y++) {
      for (int x = 15; x < 20; x++) {
        createBlankButtons(x, y, btnSize);
      }
    }

    // Living Room
    btnLivingRoom = new JButton("Living Room");
    allRooms[2] = btnLivingRoom;
    btnLivingRoom.setPreferredSize(btnSize);
    cons.gridx = 20;
    cons.gridy = 0;
    cons.gridwidth = 5;
    cons.gridheight = 5;
    btnLivingRoom.setBackground(defaultRoomColor);
    btnLivingRoom.setOpaque(true);
    btnLivingRoom.setBorderPainted(false);
    btnLivingRoom.addActionListener(new myActionListener());
    this.add(btnLivingRoom, cons);

    // space buttons
    for (int y = 0; y < 5; y++) {
      for (int x = 25; x < 30; x++) {
        createBlankButtons(x, y, btnSize);
      }
    }

    // observatory
    btnObservatory = new JButton("Observatory");
    allRooms[3] = btnObservatory;
    btnObservatory.setPreferredSize(btnSize);
    cons.gridx = 30;
    cons.gridy = 0;
    cons.gridwidth = 5;
    cons.gridheight = 5;
    btnObservatory.setBackground(defaultRoomColor);
    btnObservatory.setOpaque(true);
    btnObservatory.setBorderPainted(false);
    btnObservatory.addActionListener(new myActionListener());
    this.add(btnObservatory, cons);

    // top to middle spaces
    // ------------------------------------------------------------------------------------------

    // space buttons
    for (int y = 5; y < 10; y++) {
      for (int x = 0; x < 35; x++) {
        createBlankButtons(x, y, btnSize);
      }
    }

    // middle row
    // ------------------------------------------------------------------------------------------

    // Patio
    btnPatio = new JButton("Patio");
    allRooms[4] = btnPatio;
    btnPatio.setPreferredSize(btnSize);
    cons.gridx = 0;
    cons.gridy = 10;
    cons.gridwidth = 5;
    cons.gridheight = 5;
    btnPatio.setBackground(defaultRoomColor);
    btnPatio.setOpaque(true);
    btnPatio.setBorderPainted(false);
    btnPatio.addActionListener(new myActionListener());
    this.add(btnPatio, cons);

    // space buttons
    for (int y = 10; y < 15; y++) {
      for (int x = 5; x < 10; x++) {
        createBlankButtons(x, y, btnSize);
      }
    }

    // pool
    btnPool = new JButton("Pool");
    allRooms[5] = btnPool;
    btnPool.setPreferredSize(btnSize);
    cons.gridx = 10;
    cons.gridy = 10;
    cons.gridwidth = 15;
    cons.gridheight = 5;
    btnPool.setBackground(defaultPoolColor);
    btnPool.setOpaque(true);
    btnPool.setBorderPainted(false);
    btnPool.addActionListener(new myActionListener());
    this.add(btnPool, cons);

    // space buttons
    for (int y = 10; y < 15; y++) {
      for (int x = 25; x < 30; x++) {
        createBlankButtons(x, y, btnSize);
      }
    }

    // Hall
    btnHall = new JButton("Hall");
    allRooms[6] = btnHall;
    btnHall.setPreferredSize(btnSize);
    cons.gridx = 30;
    cons.gridy = 10;
    cons.gridwidth = 5;
    cons.gridheight = 5;
    btnHall.setBackground(defaultRoomColor);
    btnHall.setOpaque(true);
    btnHall.setBorderPainted(false);
    btnHall.addActionListener(new myActionListener());
    this.add(btnHall, cons);

    // middle to bottom spaces
    // ------------------------------------------------------------------------------------------

    // space buttons
    for (int y = 15; y < 20; y++) {
      for (int x = 0; x < 35; x++) {
        createBlankButtons(x, y, btnSize);
      }
    }

    // bottom row
    // ------------------------------------------------------------------------------------------

    // Kitchen
    btnKitchen = new JButton("Kitchen");
    allRooms[7] = btnKitchen;
    btnKitchen.setPreferredSize(btnSize);
    cons.gridx = 0;
    cons.gridy = 20;
    cons.gridwidth = 5;
    cons.gridheight = 5;
    btnKitchen.setBackground(defaultRoomColor);
    btnKitchen.setOpaque(true);
    btnKitchen.setBorderPainted(false);
    btnKitchen.addActionListener(new myActionListener());
    this.add(btnKitchen, cons);

    // space buttons
    for (int y = 20; y < 25; y++) {
      for (int x = 5; x < 10; x++) {
        createBlankButtons(x, y, btnSize);
      }
    }

    // dining room
    btnDiningRoom = new JButton("Dining Room");
    allRooms[8] = btnDiningRoom;
    btnPool.setPreferredSize(btnSize);
    cons.gridx = 10;
    cons.gridy = 20;
    cons.gridwidth = 15;
    cons.gridheight = 5;
    btnDiningRoom.setBackground(defaultRoomColor);
    btnDiningRoom.setOpaque(true);
    btnDiningRoom.setBorderPainted(false);
    btnDiningRoom.addActionListener(new myActionListener());
    this.add(btnDiningRoom, cons);

    // space buttons
    for (int y = 20; y < 25; y++) {
      for (int x = 25; x < 30; x++) {
        createBlankButtons(x, y, btnSize);
      }
    }

    // Guest House
    btnGuestHouse = new JButton("Guest House");
    allRooms[9] = btnGuestHouse;
    btnGuestHouse.setPreferredSize(btnSize);
    cons.gridx = 30;
    cons.gridy = 20;
    cons.gridwidth = 5;
    cons.gridheight = 5;
    btnGuestHouse.setBackground(defaultRoomColor);
    btnGuestHouse.setOpaque(true);
    btnGuestHouse.setBorderPainted(false);
    btnGuestHouse.addActionListener(new myActionListener());
    this.add(btnGuestHouse, cons);

    // textArea
    // ------------------------------------------------------------------------------------------

    // create textarea for output
    cons.gridx = 0;
    cons.gridy = 25;
    cons.gridwidth = 35;
    this.add(jsp, cons);
  }
  private void makeGUI() {
    // Set Frames properties
    this.setTitle("Search And Edit Student");
    this.setSize(700, 500);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    // Add components to panel_1
    FlowLayout layout = new FlowLayout();
    layout.setAlignment(FlowLayout.LEFT);
    panel_1.setLayout(layout);
    panel_1.add(searchcombobox);
    panel_1.add(searchtextfield);
    panel_1.add(searchbutton);
    panel_1.add(allfieldcheckbox);
    panel_1.setBackground(Color.WHITE);

    // Add panel_1 to frame
    this.add(panel_1, BorderLayout.PAGE_START);

    // Add components to panel_2
    panel_2.add(totalstudentlabel);
    panel_2.setBackground(Color.WHITE);

    // Add panel_2 to frame
    this.add(panel_2, BorderLayout.PAGE_END);

    // Add components to panel_3
    panel_3.setLayout(new GridLayout(1, 0));

    // Design panel_5
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;

    panel_5.setLayout(gbl);

    c.gridx = 0;
    c.gridy = 0;
    c.gridheight = 4;
    c.gridwidth = GridBagConstraints.REMAINDER;
    panel_5.add(panel_3, c);

    c.gridx = 0;
    c.gridy = 5;
    c.gridheight = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    panel_5.add(panel_4, c);

    // Add components to panel_4
    panel_4.setLayout(new GridLayout(1, 2));
    panel_4.add(panel_6); // Lower Left
    panel_4.add(panel_7); // Lower Right

    // Design panel 6
    SpringLayout sl = new SpringLayout();
    panel_6.setLayout(sl);

    sl.putConstraint(SpringLayout.WEST, feespayedlabel, 2, SpringLayout.WEST, panel_6);
    sl.putConstraint(SpringLayout.NORTH, feespayedlabel, 2, SpringLayout.NORTH, panel_6);

    sl.putConstraint(SpringLayout.WEST, addfeestextfield, 2, SpringLayout.EAST, feespayedlabel);
    sl.putConstraint(SpringLayout.NORTH, addfeestextfield, 2, SpringLayout.NORTH, panel_6);

    sl.putConstraint(SpringLayout.WEST, addfeesbutton, 2, SpringLayout.EAST, addfeestextfield);
    sl.putConstraint(SpringLayout.NORTH, addfeesbutton, 2, SpringLayout.NORTH, panel_6);

    sl.putConstraint(SpringLayout.WEST, feesduelabel, 2, SpringLayout.WEST, panel_6);
    sl.putConstraint(SpringLayout.NORTH, feesduelabel, 2, SpringLayout.SOUTH, addfeesbutton);

    sl.putConstraint(SpringLayout.WEST, totalfeeslabel, 2, SpringLayout.WEST, panel_6);
    sl.putConstraint(SpringLayout.NORTH, totalfeeslabel, 2, SpringLayout.SOUTH, feesduelabel);

    sl.putConstraint(SpringLayout.WEST, coursecombobox, 2, SpringLayout.WEST, panel_6);
    sl.putConstraint(SpringLayout.NORTH, coursecombobox, 3, SpringLayout.SOUTH, totalfeeslabel);

    sl.putConstraint(SpringLayout.WEST, spinner, 2, SpringLayout.EAST, coursecombobox);
    sl.putConstraint(SpringLayout.NORTH, spinner, 3, SpringLayout.SOUTH, totalfeeslabel);

    sl.putConstraint(SpringLayout.WEST, addcoursebutton, 2, SpringLayout.WEST, panel_6);
    sl.putConstraint(SpringLayout.NORTH, addcoursebutton, 3, SpringLayout.SOUTH, coursecombobox);

    panel_6.add(feespayedlabel);
    panel_6.add(addfeestextfield);
    panel_6.add(addfeesbutton);
    panel_6.add(feesduelabel);
    panel_6.add(totalfeeslabel);
    panel_6.add(coursecombobox);
    panel_6.add(spinner);
    panel_6.add(addcoursebutton);

    // Set panel 7 layout
    panel_7.setLayout(new GridLayout(1, 0));
    panel_7.setBackground(Color.WHITE);

    // Add panel_5 to frame
    this.add(panel_5);

    update();

    // Show frame
    this.validate();
    this.setVisible(true);
  }
  /** Sets up the GUI (panels, buttons, etc) and displays it on the screen. */
  private void init() {
    DecimalFormat df;
    int xUnits;
    String unitStr;
    String distStr;
    setForeground(Color.black);
    setTitle("Center Distances version 2  07/14/08");

    df = new DecimalFormat("0.000E0");

    GridBagConstraints gbc = new GridBagConstraints();
    int yPos = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 1;
    gbc.insets = new Insets(3, 3, 3, 3);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 0;
    gbc.gridy = yPos++;

    JPanel mainPanel = new JPanel(new GridBagLayout());
    mainPanel.setForeground(Color.black);
    mainPanel.setBorder(buildTitledBorder("Input parameters"));

    blueMinLabel = new JLabel("Minimum number of blue pixels per nucleus");
    blueMinLabel.setForeground(Color.black);
    blueMinLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(blueMinLabel, gbc);

    blueMinText = new JTextField(5);
    if (image.getNDims() == 2) {
      blueMinText.setText("1000");
    } else {
      blueMinText.setText("20000");
    }
    blueMinText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(blueMinText, gbc);

    redMinLabel = new JLabel("Minimum red pixel count");
    redMinLabel.setForeground(Color.black);
    redMinLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(redMinLabel, gbc);

    redMinText = new JTextField(5);
    redMinText.setText("50");
    redMinText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(redMinText, gbc);

    redFractionLabel = new JLabel("Fraction of red pixels to consider");
    redFractionLabel.setForeground(Color.black);
    redFractionLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(redFractionLabel, gbc);

    redFractionText = new JTextField(5);
    redFractionText.setText("0.15");
    redFractionText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(redFractionText, gbc);

    xUnits = image.getFileInfo(0).getUnitsOfMeasure()[0];
    if (xUnits != Unit.UNKNOWN_MEASURE.getLegacyNum()) {
      unitStr = (Unit.getUnitFromLegacyNum(xUnits)).toString();
      greenMergingLabel = new JLabel("Green merging radius around peak (" + unitStr + ")");
    } else {
      greenMergingLabel = new JLabel("Green merging radius around peak");
    }
    greenMergingLabel.setForeground(Color.black);
    greenMergingLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(greenMergingLabel, gbc);

    if (image.getNDims() == 2) {
      // mergingDistance = 8.0f * image.getFileInfo(0).getResolutions()[0];
      mergingDistance = 0.0f;
    } else {
      // mergingDistance = 4.0f * image.getFileInfo(0).getResolutions()[0];
      mergingDistance = 0.0f;
    }
    distStr = df.format(mergingDistance);
    greenMergingText = new JTextField(10);
    greenMergingText.setText(distStr);
    greenMergingText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(greenMergingText, gbc);

    greenMinLabel = new JLabel("Minimum green pixel count");
    greenMinLabel.setForeground(Color.black);
    greenMinLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(greenMinLabel, gbc);

    greenMinText = new JTextField(5);
    greenMinText.setText("10");
    greenMinText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(greenMinText, gbc);

    greenFractionLabel = new JLabel("Fraction of green pixels to consider");
    greenFractionLabel.setForeground(Color.black);
    greenFractionLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(greenFractionLabel, gbc);

    greenFractionText = new JTextField(5);
    greenFractionText.setText("0.01");
    greenFractionText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(greenFractionText, gbc);

    greenRegionsLabel = new JLabel("Green regions per cell");
    greenRegionsLabel.setForeground(Color.black);
    greenRegionsLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(greenRegionsLabel, gbc);

    JPanel buttonPanel = new JPanel(new GridBagLayout());

    greenGroup = new ButtonGroup();

    oneButton = new JRadioButton("1", false);
    oneButton.setForeground(Color.black);
    oneButton.setFont(serif12);
    greenGroup.add(oneButton);
    gbc.gridx = 0;
    gbc.gridy = 0;
    buttonPanel.add(oneButton, gbc);

    twoButton = new JRadioButton("2", true);
    twoButton.setForeground(Color.black);
    twoButton.setFont(serif12);
    greenGroup.add(twoButton);
    gbc.gridx = 1;
    gbc.gridy = 0;
    buttonPanel.add(twoButton, gbc);

    threeButton = new JRadioButton("3", false);
    threeButton.setForeground(Color.black);
    threeButton.setFont(serif12);
    greenGroup.add(threeButton);
    gbc.gridx = 2;
    gbc.gridy = 0;
    buttonPanel.add(threeButton, gbc);

    fourButton = new JRadioButton("4", false);
    fourButton.setForeground(Color.black);
    fourButton.setFont(serif12);
    greenGroup.add(fourButton);
    gbc.gridx = 3;
    gbc.gridy = 0;
    buttonPanel.add(fourButton, gbc);

    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(buttonPanel, gbc);

    twoBox = new JCheckBox("Use 2 top gray levels in green segmentation", true);
    twoBox.setForeground(Color.black);
    twoBox.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos++;
    mainPanel.add(twoBox, gbc);

    blueValueLabel =
        new JLabel("Fraction of blue transition from image min to max at nucleus boundary");
    blueValueLabel.setForeground(Color.black);
    blueValueLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(blueValueLabel, gbc);

    blueValueText = new JTextField(5);
    blueValueText.setText("0.15");
    blueValueText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(blueValueText, gbc);

    blueSmoothBox = new JCheckBox("Smooth blue VOI contours with AlgorithmBSmooth", true);
    blueSmoothBox.setForeground(Color.black);
    blueSmoothBox.setFont(serif12);
    blueSmoothBox.addActionListener(this);
    gbc.gridx = 0;
    gbc.gridy = yPos++;
    mainPanel.add(blueSmoothBox, gbc);

    interpolationLabel = new JLabel("Number of interpolation points determined by divisor (> 1.0)");
    interpolationLabel.setForeground(Color.black);
    interpolationLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(interpolationLabel, gbc);

    interpolationText = new JTextField(5);
    interpolationText.setText("24.0");
    interpolationText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(interpolationText, gbc);

    getContentPane().add(mainPanel, BorderLayout.CENTER);
    getContentPane().add(buildButtons(), BorderLayout.SOUTH);

    pack();
    setVisible(true);
    setResizable(false);
    System.gc();
  } // end init()
Beispiel #30
0
import java.applet.*;