Пример #1
0
  /**
   * Constructs a ClutoTree diaplay which is initialized with tableModel as the data model, and the
   * given selection model.
   *
   * @param clutoSolution The clustering solution
   * @param tableContext The context which manages views and selections.
   * @param tableModel the data model for the parallel coordinate display
   */
  public ClutoTree(ClutoSolution clutoSolution, TableContext tableContext, TableModel tableModel) {
    ctx = tableContext;
    tm = tableModel;
    lsm = ctx.getRowSelectionModel(tm);

    // labelModel
    int ncol = tm.getColumnCount();
    for (int i = 0; i < ncol; i++) {
      labelModel.addElement(tm.getColumnName(i));
    }

    setLayout(new BorderLayout());
    btnP = new JToolBar();
    add(btnP, BorderLayout.NORTH);
    labelChoice.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              labelColumn = 0;
              String ln = (String) e.getItem();
              if (ln != null) {
                for (int c = 0; c < tm.getColumnCount(); c++) {
                  if (ln.equals(tm.getColumnName(c))) {
                    labelColumn = c;
                    break;
                  }
                }
              }
              graph.invalidate();
              validate();
              repaint();
            }
          }
        });
    btnP.add(labelChoice);

    graph = new SimpleGraph();
    graph.getGraphDisplay().setOpaque(true);
    graph.getGraphDisplay().setBackground(Color.white);
    graph.getGraphDisplay().setGridColor(new Color(220, 220, 220));
    graph.showGrid(false);
    graph.showAxis(BorderLayout.WEST, false);
    graph.showAxis(BorderLayout.EAST, true);
    graph.getAxisDisplay(BorderLayout.EAST).setZoomable(true);
    graph.getAxisDisplay(BorderLayout.EAST).setAxisLabeler(labeler);
    ((LinearAxis) graph.getYAxis()).setTickIncrement(-1.);
    graph.getAxisDisplay(BorderLayout.SOUTH).setZoomable(true);
    gs = new GraphSegments();
    gs.setColor(Color.blue);
    idxSelColor = new IndexSelectColor(Color.cyan, null, new DefaultListSelectionModel());
    gs.setIndexedColor(idxSelColor);
    graph.addGraphItem(gs);
    graph.getGraphDisplay().addMouseListener(ma);

    add(graph);
    if (lsm != null) {
      lsm.addListSelectionListener(selListener);
    }
    display(makeTree(clutoSolution));
  }
Пример #2
0
  public LicenseDialog(Component parent) {
    setTitle("Licensing information");

    pnlButtons.add(bttnOk);

    cbLang.addItem("English");
    cbLang.addItem("Eesti");

    FlowLayout fl = new FlowLayout();
    fl.setAlignment(FlowLayout.LEFT);

    pnlHeader.setLayout(fl);

    pnlHeader.add(lblLang);
    pnlHeader.add(cbLang);

    pnlMain.setLayout(new BorderLayout());
    pnlMain.add(pnlHeader, BorderLayout.NORTH);
    pnlMain.add(scrollPane, BorderLayout.CENTER);
    pnlMain.add(pnlButtons, BorderLayout.SOUTH);

    taLicenseText.setText(getLicenseText());
    taLicenseText.setCaretPosition(0);
    taLicenseText.setLineWrap(true);
    taLicenseText.setEditable(false);
    taLicenseText.setWrapStyleWord(true);

    getContentPane().add(pnlMain);
    setPreferredSize(new Dimension(500, 600));
    setLocationRelativeTo(parent);

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    bttnOk.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            if (evt.getSource() == bttnOk) {
              dispose();
            }
          } // end actionPerformed
        }); // end bttnOk Action Listener

    cbLang.addItemListener(
        new ItemListener() {
          public void itemStateChanged(final ItemEvent event) {
            if (event.getSource() == cbLang
                && event.getStateChange() == ItemEvent.SELECTED
                && cbLang.getItemCount() > 0) {
              taLicenseText.setText(getLicenseText());
              taLicenseText.setCaretPosition(0);
            }
          }
        }); // end cbLang item listener

    pack();
    setVisible(true);
  } // PortPropertiesDialog
Пример #3
0
 /**
  * Add a listener to the given combobox that will set the state to unconnected
  *
  * @param box The box to listen to.
  */
 protected void clearOnChange(final JComboBox box) {
   box.addItemListener(
       new ItemListener() {
         public void itemStateChanged(ItemEvent e) {
           if (!ignoreStateChangedEvents) {
             setState(STATE_UNCONNECTED);
           }
         }
       });
 }
Пример #4
0
 protected void createButtons(JPanel panel) {
   panel.add(new Filler(24, 20));
   JComboBox drawingChoice = new JComboBox();
   drawingChoice.addItem(fgUntitled);
   String param = getParameter("DRAWINGS");
   if (param == null) {
     param = "";
   }
   StringTokenizer st = new StringTokenizer(param);
   while (st.hasMoreTokens()) {
     drawingChoice.addItem(st.nextToken());
   }
   if (drawingChoice.getItemCount() > 1) {
     panel.add(drawingChoice);
   } else {
     panel.add(new JLabel(fgUntitled));
   }
   drawingChoice.addItemListener(
       new ItemListener() {
         public void itemStateChanged(ItemEvent e) {
           if (e.getStateChange() == ItemEvent.SELECTED) {
             loadDrawing((String) e.getItem());
           }
         }
       });
   panel.add(new Filler(6, 20));
   JButton button;
   button = new CommandButton(new DeleteCommand("Delete", this));
   panel.add(button);
   button = new CommandButton(new DuplicateCommand("Duplicate", this));
   panel.add(button);
   button = new CommandButton(new GroupCommand("Group", this));
   panel.add(button);
   button = new CommandButton(new UngroupCommand("Ungroup", this));
   panel.add(button);
   button = new JButton("Help");
   button.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           showHelp();
         }
       });
   panel.add(button);
   fUpdateButton = new JButton("Simple Update");
   fUpdateButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           if (fSimpleUpdate) {
             setBufferedDisplayUpdate();
           } else {
             setSimpleDisplayUpdate();
           }
         }
       });
 }
 public ejemplo6_javaya() {
   setLayout(null);
   combo1 = new JComboBox();
   combo1.setBounds(10, 10, 80, 20);
   add(combo1);
   combo1.addItem("rojo");
   combo1.addItem("vede");
   combo1.addItem("azul");
   combo1.addItem("amarillo");
   combo1.addItem("negro");
   combo1.addItemListener(this);
 }
Пример #6
0
 private void addPainter(myjava.gui.syntax.Painter painter) {
   EntryListPanel newPanel = new EntryListPanel(painter);
   listPanelSet.add(newPanel);
   centerPanel.add(newPanel, painter.getName());
   painterComboBox.removeItemListener(painterChangeListener);
   painterComboBox.removeAllItems();
   for (EntryListPanel p : listPanelSet) {
     painterComboBox.addItem(p.getPainter());
   }
   removedPainters.remove(painter);
   painterComboBox.addItemListener(painterChangeListener);
 }
Пример #7
0
 public CapabilitiesTest(GraphicsDevice dev) {
   super(dev.getDefaultConfiguration());
   addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent ev) {
           System.exit(0);
         }
       });
   initComponents(getContentPane());
   GraphicsConfiguration[] gcs = dev.getConfigurations();
   for (int i = 0; i < gcs.length; i++) {
     gcSelection.addItem(new GCWrapper(gcs[i], i));
   }
   gcSelection.addItemListener(this);
   gcChanged();
 }
Пример #8
0
  DropdownImp() {
    b.setOpaque(false);

    b.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent ie) {
            if (ie.getStateChange() != ItemEvent.SELECTED
                && onSelectionChange != null
                && !selecting) {
              getInterface().getOwner().getCallbackHandler().callHandleErrors(onSelectionChange);
            }
          }
        });
    add(b);
  }
Пример #9
0
  private void _setUpEvents() {
    mHeadingComboBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent itemEvent) {
            if (itemEvent.getStateChange() == ItemEvent.SELECTED) {
              String key = itemEvent.getItem().toString();
              Integer fontSize = HEADING_LIST.get(key);

              Font cFont = mTextEditor.getFont();
              Font font = new Font(cFont.getFamily(), cFont.getStyle(), fontSize);
              _applyFontStyleForSelection(font);
            }
          }
        });
    mTextEditor.addKeyListener(
        new KeyListener() {
          public void keyTyped(KeyEvent keyEvent) {}

          public void keyPressed(KeyEvent keyEvent) {}

          public void keyReleased(KeyEvent keyEvent) {
            if (keyEvent.isControlDown() && keyEvent.getKeyCode() == KeyEvent.VK_B) {
              Font font = new Font(mTextEditor.getFont().getFamily(), Font.BOLD, 12);
              _applyFontStyleForSelection(font);
              CharArrayWriter caw = new CharArrayWriter();
              try {
                mTextEditor.write(caw);
                MutableAttributeSet set = mTextEditor.getInputAttributes();
                Enumeration e = set.getAttributeNames();
                while (e.hasMoreElements()) {
                  try {
                    StyleConstants.FontConstants at =
                        (StyleConstants.FontConstants) e.nextElement();

                  } catch (Exception ex) {
                    ex.printStackTrace();
                  }
                }
                System.out.println(caw.toString());
              } catch (IOException e) {
                e.printStackTrace(); // To change body of catch statement use File | Settings |
                // File Templates.
              }
            }
          }
        });
  }
Пример #10
0
  public AddNewUser() {
    super("Add New User", true, false, true, true);
    msg = new JOptionPane();
    rand = new RandomPassword();
    ec = new EasyCrypt();
    db = new ExecDb();
    AddNewUserLayout customLayout = new AddNewUserLayout();

    getContentPane().setFont(new Font("Helvetica", Font.PLAIN, 12));
    getContentPane().setLayout(customLayout);

    accType = new JComboBox();
    accType.addItem("Student");
    accType.addItem("Teacher");
    accType.addItem("Officer");
    getContentPane().add(accType);

    accTxt = new JTextField("");
    getContentPane().add(accTxt);

    label_1 = new JLabel("Add new user account", JLabel.CENTER);
    getContentPane().add(label_1);

    label_2 = new JLabel("Account Type : ");
    getContentPane().add(label_2);

    label_3 = new JLabel("Account ID : ");
    getContentPane().add(label_3);

    button_1 = new JButton("ADD");
    getContentPane().add(button_1);

    button_2 = new JButton("CLOSE");
    getContentPane().add(button_2);

    passTxt = new JTextField("");
    passTxt.setEditable(false);
    getContentPane().add(passTxt);

    label_4 = new JLabel("Random Password : ");
    getContentPane().add(label_4);

    setSize(getPreferredSize());
    accType.addItemListener(this);
    button_1.addActionListener(this);
    button_2.addActionListener(this);
  }
Пример #11
0
  /**
   * This method is used to add a listner for a combobox to choose the type of the parameters of an
   * {@link ObixObject} in the GUI.
   *
   * @param parameterComboBox The combobox to which the listener is added.
   * @param paramUnitLabelxPosition The x position of the unit label of the parameter.
   * @param paramUnitLabelyPosition The y position of the unit label of the parameter.
   * @param parameterUnitLabel The unit label of the parameter.
   * @param parameterUnitTextField The unit textfield of the parameter.
   * @param pane The pane to which sates are added.
   * @param paramAddStateButton The button which is used to add states to the pane.
   * @param vbox The vbox in which the states are added.
   */
  private void addParameterBoxListener(
      JComboBox parameterComboBox,
      int paramUnitLabelxPosition,
      int paramUnitLabelyPosition,
      JLabel parameterUnitLabel,
      JTextField parameterUnitTextField,
      Container pane,
      JButton paramAddStateButton,
      Box vbox) {
    parameterComboBox.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            GridBagConstraints cTemp = new GridBagConstraints();
            cTemp.gridx = paramUnitLabelxPosition + 1;
            cTemp.gridy = paramUnitLabelyPosition;
            if (parameterComboBox.getSelectedItem().equals("&colibri;StateParameter")) {
              parameterUnitLabel.setEnabled(false);
              parameterUnitTextField.setEnabled(false);
              // stateDescriptionPanel.add(vBox1);
              pane.add(paramAddStateButton, cTemp);
              vbox.repaint();
              vbox.revalidate();
              cTemp.gridx++;
              pane.add(vbox, cTemp);
            } else {
              pane.remove(paramAddStateButton);

              Iterator<StateRepresentation> iter = listOfStateRepresentations.iterator();
              while (iter.hasNext()) {
                StateRepresentation s = iter.next();
                if (paramAddStateButton.equals(s.getAddButton())) {
                  vbox.removeAll();
                  pane.remove(s.getContainerVBox());
                  iter.remove();
                  s.getParameter().getStateDescriptions().clear();
                }
              }
              parameterUnitLabel.setEnabled(true);
              parameterUnitTextField.setEnabled(true);
            }
            pane.revalidate();
            pane.repaint();
          }
        });
  }
Пример #12
0
  private void initToolbar() {
    JToolBar tbTraceFilters = new JToolBar();
    tbTraceFilters.setFloatable(false);
    tbTraceFilters.setRollover(true);

    tbTraceFilters.add(new JLabel("Min time:"));
    txtMinTime = new JTextField(4);
    tbTraceFilters.add(txtMinTime);

    JButton btnFilterByTime = new JButton(new FilterByTimeAction());
    btnFilterByTime.setFocusable(false);
    btnFilterByTime.setToolTipText("Filter by trace execution time");
    tbTraceFilters.add(btnFilterByTime);

    tbTraceFilters.addSeparator();

    btnFilterErrors = new JToggleButton(new FilterByErrorAction());
    btnFilterErrors.setFocusable(false);
    btnFilterErrors.setToolTipText("Show only traces with errors");
    tbTraceFilters.add(btnFilterErrors);

    tbTraceFilters.addSeparator();

    cmbTraceType = new JComboBox();
    cmbTraceType.addItem("*");

    cmbTraceType.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              String item = (String) e.getItem();
              traceLabel = "*".equals(item) ? null : item;
              tbmTraces.setDataSet(dataSet, traceFilter);
            }
          }
        });

    tbTraceFilters.add(cmbTraceType);

    add(tbTraceFilters, BorderLayout.NORTH);
  }
Пример #13
0
  private void createComponents() {
    categoryLabel = new JLabel(Language.text("contrib.category"));

    categoryChooser = new JComboBox<String>();
    categoryChooser.setMaximumRowCount(20);
    categoryChooser.setFont(Toolkit.getSansFont(14, Font.PLAIN));

    updateCategoryChooser();

    categoryChooser.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            category = (String) categoryChooser.getSelectedItem();
            if (ContributionManagerDialog.ANY_CATEGORY.equals(category)) {
              category = null;
            }
            filterLibraries(category, filterField.filters);
            contributionListPanel.updateColors();
          }
        });

    filterField = new FilterField();
  }
Пример #14
0
 private void initializeGUI() {
   frame = new JFrame("bug4523758");
   tools = new JToolBar();
   frame.getContentPane().add(tools, BorderLayout.NORTH);
   combo =
       new JComboBox(
           new Object[] {"Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"});
   combo.addItemListener(
       new ItemListener() {
         public void itemStateChanged(ItemEvent event) {
           itemStateChanged = true;
           synchronized (itemLock) {
             try {
               itemLock.notifyAll();
             } catch (Exception e) {
             }
           }
         }
       });
   tools.add(combo);
   frame.setSize(250, 400);
   frame.setLocation(700, 0);
   frame.setVisible(true);
 }
Пример #15
0
  public PartitionModelPanel(final PartitionSubstitutionModel partitionModel) {

    super(12, (OSType.isMac() ? 6 : 24));

    this.model = partitionModel;

    initCodonPartitionComponents();

    PanelUtils.setupComponent(nucSubstCombo);
    nucSubstCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setNucSubstitutionModel((NucModelType) nucSubstCombo.getSelectedItem());
          }
        });
    nucSubstCombo.setToolTipText("<html>Select the type of nucleotide substitution model.</html>");

    PanelUtils.setupComponent(aaSubstCombo);
    aaSubstCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            AminoAcidModelType type = (AminoAcidModelType) aaSubstCombo.getSelectedItem();
            model.setAaSubstitutionModel(type);
            citationText.setText(type.getCitation().toString());
          }
        });
    aaSubstCombo.setToolTipText("<html>Select the type of amino acid substitution model.</html>");

    PanelUtils.setupComponent(binarySubstCombo);
    binarySubstCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setBinarySubstitutionModel((BinaryModelType) binarySubstCombo.getSelectedItem());
            useAmbiguitiesTreeLikelihoodCheck.setSelected(
                binarySubstCombo.getSelectedItem() == BinaryModelType.BIN_COVARION);
            useAmbiguitiesTreeLikelihoodCheck.setEnabled(
                binarySubstCombo.getSelectedItem() != BinaryModelType.BIN_COVARION);
          }
        });
    binarySubstCombo.setToolTipText("<html>Select the type of binary substitution model.</html>");

    PanelUtils.setupComponent(useAmbiguitiesTreeLikelihoodCheck);
    useAmbiguitiesTreeLikelihoodCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setUseAmbiguitiesTreeLikelihood(useAmbiguitiesTreeLikelihoodCheck.isSelected());
          }
        });
    useAmbiguitiesTreeLikelihoodCheck.setToolTipText(
        "<html>Detemine useAmbiguities in &lt treeLikelihood &gt .</html>");

    PanelUtils.setupComponent(frequencyCombo);
    frequencyCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setFrequencyPolicy((FrequencyPolicyType) frequencyCombo.getSelectedItem());
          }
        });
    frequencyCombo.setToolTipText(
        "<html>Select the policy for determining the base frequencies.</html>");

    PanelUtils.setupComponent(heteroCombo);
    heteroCombo.setToolTipText(
        "<html>Select the type of site-specific rate<br>heterogeneity model.</html>");
    heteroCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {

            boolean gammaHetero =
                heteroCombo.getSelectedIndex() == 1 || heteroCombo.getSelectedIndex() == 3;

            model.setGammaHetero(gammaHetero);
            model.setInvarHetero(
                heteroCombo.getSelectedIndex() == 2 || heteroCombo.getSelectedIndex() == 3);

            if (gammaHetero) {
              gammaCatLabel.setEnabled(true);
              gammaCatCombo.setEnabled(true);
            } else {
              gammaCatLabel.setEnabled(false);
              gammaCatCombo.setEnabled(false);
            }

            if (codingCombo.getSelectedIndex() != 0) {
              heteroUnlinkCheck.setEnabled(heteroCombo.getSelectedIndex() != 0);
              heteroUnlinkCheck.setSelected(heteroCombo.getSelectedIndex() != 0);
            }
          }
        });

    PanelUtils.setupComponent(gammaCatCombo);
    gammaCatCombo.setToolTipText(
        "<html>Select the number of categories to use for<br>the discrete gamma rate heterogeneity model.</html>");
    gammaCatCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {

            model.setGammaCategories(gammaCatCombo.getSelectedIndex() + 4);
          }
        });

    setYang96Button = new JButton("Use Yang96 model");
    setYang96Button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            setYang96Model();
          }
        });
    PanelUtils.setupComponent(setYang96Button);
    setYang96Button.setToolTipText(
        "<html>Sets a 3 codon-position model with independent GTR and Gamma as described in<br>"
            + "Yang (1996) <i>J Mol Evol</i> <b>42</b>: 587–596. This model is named 3' in this paper.</html>");

    setSRD06Button = new JButton("Use SRD06 model");
    setSRD06Button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            setSRD06Model();
          }
        });
    PanelUtils.setupComponent(setSRD06Button);
    setSRD06Button.setToolTipText(
        "<html>Sets the SRD06 model as described in<br>"
            + "Shapiro, Rambaut & Drummond (2006) <i>MBE</i> <b>23</b>: 7-9.</html>");

    citationText = new JTextArea(1, 40);
    citationText.setLineWrap(true);
    citationText.setWrapStyleWord(true);
    citationText.setEditable(false);
    citationText.setFont(this.getFont());
    citationText.setOpaque(false);
    AminoAcidModelType type = (AminoAcidModelType) aaSubstCombo.getSelectedItem();
    citationText.setText(type.getCitation().toString());

    dolloCheck.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            if (dolloCheck.isSelected()) {
              binarySubstCombo.setSelectedIndex(0);
              binarySubstCombo.setEnabled(false);
              useAmbiguitiesTreeLikelihoodCheck.setSelected(true);
              useAmbiguitiesTreeLikelihoodCheck.setEnabled(false);
              frequencyCombo.setEnabled(false);
              frequencyCombo.setSelectedItem(FrequencyPolicyType.EMPIRICAL);
              heteroCombo.setSelectedIndex(0);
              heteroCombo.setEnabled(false);
              model.setBinarySubstitutionModel(BinaryModelType.BIN_DOLLO);
              model.setDolloModel(true);
              DolloComponentOptions comp =
                  (DolloComponentOptions)
                      model.getOptions().getComponentOptions(DolloComponentOptions.class);
              comp.createParameters(model.getOptions());
              comp.setActive(true);

            } else {
              binarySubstCombo.setEnabled(true);
              useAmbiguitiesTreeLikelihoodCheck.setEnabled(true);
              frequencyCombo.setEnabled(true);
              heteroCombo.setEnabled(true);
              model.setBinarySubstitutionModel(
                  (BinaryModelType) binarySubstCombo.getSelectedItem());
              model.setDolloModel(false);
            }
          }
        });

    PanelUtils.setupComponent(dolloCheck);
    //        dolloCheck.addChangeListener(new ChangeListener() {
    //            public void stateChanged(ChangeEvent e) {
    //                model.setDolloModel(true);
    //            }
    //        });
    dolloCheck.setEnabled(true);
    dolloCheck.setToolTipText(
        "<html>Activates a Stochastic Dollo model as described in<br>"
            + "Alekseyenko, Lee & Suchard (2008) <i>Syst Biol</i> <b>57</b>: 772-784.</html>");

    PanelUtils.setupComponent(discreteTraitSiteModelCombo);
    discreteTraitSiteModelCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setDiscreteSubstType(
                (DiscreteSubstModelType) discreteTraitSiteModelCombo.getSelectedItem());
          }
        });

    PanelUtils.setupComponent(continuousTraitSiteModelCombo);
    continuousTraitSiteModelCombo.setToolTipText(
        "<html>Select the model of continuous random walk, either homogenous<br>"
            + "or relaxed random walk (RRW) with a choice of distributions.</html>");
    continuousTraitSiteModelCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setContinuousSubstModelType(
                (ContinuousSubstModelType) continuousTraitSiteModelCombo.getSelectedItem());
          }
        });

    PanelUtils.setupComponent(latLongCheck);
    latLongCheck.setToolTipText(
        "<html>Specify whether this is a geographical trait representing <br>"
            + "latitude and longitude. Provides appropriate statistics to log file.</html>");

    latLongCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setIsLatitudeLongitude(latLongCheck.isSelected());
          }
        });
    latLongCheck.setEnabled(false);

    PanelUtils.setupComponent(useLambdaCheck);
    useLambdaCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            ContinuousComponentOptions component =
                (ContinuousComponentOptions)
                    model.getOptions().getComponentOptions(ContinuousComponentOptions.class);
            component.setUseLambda(model, useLambdaCheck.isSelected());
          }
        });
    useLambdaCheck.setToolTipText(
        "<html>Estimate degree of phylogenetic correlation in continuous traits using <br>"
            + "a tree transform. Inspired by Pagel (1999), described in Lemey et al (2013) <i>in prep</i></html>");

    PanelUtils.setupComponent(activateBSSVS);
    activateBSSVS.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setActivateBSSVS(activateBSSVS.isSelected());
          }
        });
    activateBSSVS.setToolTipText(
        "<html>Activates Bayesian stochastic search variable selection on the rates as described in<br>"
            + "Lemey, Rambaut, Drummond & Suchard (2009) <i>PLoS Computational Biology</i> <b>5</b>: e1000520</html>");

    // ============ micro-sat ================
    microsatName.setColumns(30);
    microsatName.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            model.getMicrosatellite().setName(microsatName.getText());
          }
        });
    microsatMax.setColumns(10);
    microsatMax.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            model.getMicrosatellite().setMax(Integer.parseInt(microsatMax.getText()));
          }
        });
    microsatMin.setColumns(10);
    microsatMin.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            model.getMicrosatellite().setMin(Integer.parseInt(microsatMin.getText()));
          }
        });

    PanelUtils.setupComponent(shareMicroSatCheck);
    shareMicroSatCheck.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            model.getOptions().shareMicroSat = shareMicroSatCheck.isSelected();
            if (shareMicroSatCheck.isSelected()) {
              model.getOptions().shareMicroSat();
            } else {
              model.getOptions().unshareMicroSat();
            }
            setOptions();
          }
        });

    PanelUtils.setupComponent(rateProportionCombo);
    rateProportionCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setRatePorportion(
                (MicroSatModelType.RateProportionality) rateProportionCombo.getSelectedItem());
          }
        });
    // rateProportionCombo.setToolTipText("<html>Select the type of microsatellite substitution
    // model.</html>");
    PanelUtils.setupComponent(mutationBiasCombo);
    mutationBiasCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setMutationBias(
                (MicroSatModelType.MutationalBias) mutationBiasCombo.getSelectedItem());
          }
        });
    PanelUtils.setupComponent(phaseCombo);
    phaseCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setPhase((MicroSatModelType.Phase) phaseCombo.getSelectedItem());
          }
        });

    setupPanel();
    setOpaque(false);
  }
Пример #16
0
  public DialogStammdaten(JFrame fenster, String[][] datensatz1, String s, Methoden datenbank1) {
    super(fenster, true);
    datenbank = datenbank1;
    datensatz = datensatz1;
    p = new JPanel();
    platzhalter = new JLabel();
    text1 = new JLabel("Name");
    text2 = new JLabel("Personalnummer");
    text3 = new JLabel("Titel");
    text4 = new JLabel("Institut");
    feld = new JComboBox();
    textName = new JTextField();
    textPersonalnr = new JTextField();
    textInstitut = new JTextField();
    textTitel = new JTextField();
    menue = new JMenuBar();
    datei = new JMenu("Datei");
    aendern = new JMenuItem("Aendern");
    hinzufuegen = new JMenuItem("Hinzufuegen");
    loeschen = new JMenuItem("Loeschen");
    beenden = new JMenuItem("Beenden");
    final JDialog dialog = this;
    this.setTitle(s);
    feld = new JComboBox(ersteElemente(datensatz));
    textName.setText(datensatz[0][0]);
    textPersonalnr.setText(datensatz[0][1]);
    setzen(datensatz, feld.getSelectedIndex());

    feld.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getID() == ItemEvent.ITEM_STATE_CHANGED
                && e.getStateChange() == ItemEvent.SELECTED) {
              textName.setText((String) e.getItem());
              textPersonalnr.setText(datensatz[feld.getSelectedIndex()][1]);
              setzen(datensatz, feld.getSelectedIndex());
            }
          }
        });

    datei.addMenuListener(
        new MenuListener() {
          public void menuSelected(MenuEvent e) {
            hinzufuegen.setEnabled(false);
            aendern.setEnabled(false);
            loeschen.setEnabled(false);

            if (!geaendert(datensatz, feld.getSelectedIndex())) {
              loeschen.setEnabled(true);
            } else if (!(textName.getText().equals("") || textPersonalnr.getText().equals(""))) {
              hinzufuegen.setEnabled(true);
              aendern.setEnabled(true);
            }
          }

          public void menuDeselected(MenuEvent e) {}

          public void menuCanceled(MenuEvent e) {}
        });

    hinzufuegen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String[] daten = erstellen();
            if (hinzufuegen(daten)) {
              dispose();
            } else {
              JOptionPane.showMessageDialog(
                  dialog, "Hinzufuegen geht nicht.", "Fehler", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    aendern.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String[] daten = erstellen();
            if (aendern(datensatz[feld.getSelectedIndex()][1], daten)) {
              dispose();
            } else {
              JOptionPane.showMessageDialog(
                  dialog, "Aendern geht nicht.", "Fehler", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    loeschen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String[] daten = erstellen();
            if (loeschen(datensatz[feld.getSelectedIndex()][1])) {
              dispose();
            } else {
              JOptionPane.showMessageDialog(
                  dialog, "Loeschen geht nicht.", "Fehler", JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    beenden.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });

    datei.add(hinzufuegen);
    datei.add(aendern);
    datei.add(loeschen);
    datei.add(beenden);
    menue.add(datei);
    this.setJMenuBar(menue);

    p.setLayout(new GridLayout(2, 5));
    p.add(platzhalter);
    p.add(text1);
    p.add(text2);
    p.add(text3);
    p.add(text4);
    p.add(feld);
    p.add(textName);
    p.add(textPersonalnr);
    p.add(textTitel);
    p.add(textInstitut);
    this.setContentPane(p);

    this.pack();
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  }
Пример #17
0
  public void setUpGameSetupPanel(GameSetupListener setupListener) {
    int boardSizeMaxDigits = 3;

    class PlayerSelectionListener implements ItemListener {
      /**
       * Constructor
       *
       * @param tabs panel whose state should be changed when event fired
       */
      public PlayerSelectionListener(JPanel tabs) {
        mTabs = tabs;
      }

      public void itemStateChanged(ItemEvent e) {
        PlayerType ptype = (PlayerType) e.getItem();
        CardLayout cl = (CardLayout) mTabs.getLayout();
        assert (cl.getClass() == CardLayout.class);
        cl.show(mTabs, ptype.toString());
      }

      private JPanel mTabs;
    }

    mGameSetupDialog = new JDialog(this, true);
    mGameSetupDialog.setTitle("Game setup");
    mGameSetupDialog.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    mGameSetupDialog.setSize(DIALOG_DIM);

    Container cpane = mGameSetupDialog.getContentPane();

    cpane.setLayout(new GridBagLayout());

    JLabel playerDes = new JLabel("Configure player");

    JComboBox<BotType> botType = new JComboBox<BotType>(BotType.values());
    JComboBox<PerfMeasureType> pmType = new JComboBox<PerfMeasureType>(PerfMeasureType.values());

    JButton addCustomPM = new JButton("+");
    addCustomPM.setVisible(false);
    CustomBotListener customAdder = new CustomBotListener(addCustomPM);
    addCustomPM.addActionListener(customAdder);
    pmType.addItemListener(customAdder);

    JTextField enterPlayerName = new JTextField("name");
    enterPlayerName.selectAll();
    setupListener.setupPlayerNameInput(enterPlayerName);

    JPanel botConfigPanel = new JPanel(new GridBagLayout());
    GridBagConstraints cBotType = new GridBagConstraints();
    cBotType.gridx = 0;
    cBotType.gridy = 0;
    cBotType.gridwidth = 1;
    cBotType.gridheight = 1;
    cBotType.fill = GridBagConstraints.BOTH;

    GridBagConstraints cPerfMeasureType = (GridBagConstraints) cBotType.clone();
    cPerfMeasureType.gridy = 1;
    GridBagConstraints cCustomAdder = (GridBagConstraints) cBotType.clone();
    cCustomAdder.gridx = 1;
    botConfigPanel.add(botType, cBotType);
    botConfigPanel.add(pmType, cPerfMeasureType);
    botConfigPanel.add(addCustomPM, cCustomAdder);
    setupListener.setupCustomBotListener(customAdder);

    JPanel playerConfigPanel = new JPanel(new CardLayout());
    playerConfigPanel.add(enterPlayerName, PlayerType.HUMAN.toString());
    playerConfigPanel.add(botConfigPanel, PlayerType.BOT.toString());

    JComboBox<PlayerType> playerType = new JComboBox<PlayerType>(PlayerType.values());
    PlayerSelectionListener listenPlayerSelection = new PlayerSelectionListener(playerConfigPanel);
    playerType.addItemListener(listenPlayerSelection);
    setupListener.setupTypeInput(playerType, botType, pmType);

    JLabel boardDes = new JLabel("Configure board");
    JTextField enterWidth = new JTextField("10");
    enterWidth.setColumns(boardSizeMaxDigits);
    JTextField enterHeight = new JTextField("15");
    enterHeight.setColumns(boardSizeMaxDigits);
    setupListener.setupBoardInputs(enterWidth, enterHeight);

    JButton startGameButton = new JButton("start");
    startGameButton.addActionListener(setupListener);

    int extSpace = 5;
    GridBagConstraints cUniversal = new GridBagConstraints();
    cUniversal.gridwidth = 1;
    cUniversal.gridheight = 1;
    cUniversal.fill = GridBagConstraints.BOTH;
    cUniversal.insets = new Insets(extSpace, extSpace, extSpace, extSpace);
    cUniversal.anchor = GridBagConstraints.CENTER;

    GridBagConstraints cDesPSelect = (GridBagConstraints) cUniversal.clone();
    cDesPSelect.gridx = 0;
    cDesPSelect.gridy = 0;
    cDesPSelect.gridwidth = 2;
    cDesPSelect.gridheight = 1;

    GridBagConstraints cPTypeSelect = (GridBagConstraints) cDesPSelect.clone();
    cPTypeSelect.gridy = 1;

    GridBagConstraints cPlayerSelection = (GridBagConstraints) cDesPSelect.clone();
    cPlayerSelection.gridy = 2;

    GridBagConstraints cDesBoardConfig = (GridBagConstraints) cUniversal.clone();
    cDesBoardConfig.gridx = 0;
    cDesBoardConfig.gridy = 3;
    cDesBoardConfig.gridwidth = 2;

    GridBagConstraints cBoardWInput;
    cBoardWInput = (GridBagConstraints) cDesBoardConfig.clone();
    cBoardWInput.gridy = 4;
    cBoardWInput.gridwidth = 1;
    cBoardWInput.weightx = 0.5;

    GridBagConstraints cBoardHInput;
    cBoardHInput = (GridBagConstraints) cBoardWInput.clone();
    cBoardHInput.gridx = 1;

    GridBagConstraints cStartButton;
    cStartButton = (GridBagConstraints) cDesPSelect.clone();
    cStartButton.gridy = 5;
    cStartButton.gridwidth = 2;

    mGameSetupDialog.add(playerDes, cDesPSelect);
    mGameSetupDialog.add(playerType, cPTypeSelect);
    mGameSetupDialog.add(playerConfigPanel, cPlayerSelection);
    mGameSetupDialog.add(boardDes, cDesBoardConfig);
    mGameSetupDialog.add(enterWidth, cBoardWInput);
    mGameSetupDialog.add(enterHeight, cBoardHInput);
    mGameSetupDialog.add(startGameButton, cStartButton);
  }
Пример #18
0
  /** Display a frame for browsing issues. */
  private JPanel constructView() {
    // sort the original issues list
    final SortedList<Issue> issuesSortedList = new SortedList<Issue>(issuesEventList, null);

    // filter the sorted issues
    FilterList<Issue> filteredIssues =
        new FilterList<Issue>(issuesSortedList, filterPanel.getMatcherEditor());

    SeparatorList<Issue> separatedIssues =
        new SeparatorList<Issue>(
            filteredIssues,
            GlazedLists.beanPropertyComparator(Issue.class, "subcomponent"),
            0,
            Integer.MAX_VALUE);
    EventList<Issue> separatedIssuesProxyList =
        GlazedListsSwing.swingThreadProxyList(separatedIssues);
    // build the issues table
    issuesTableModel =
        GlazedListsSwing.eventTableModel(separatedIssuesProxyList, new IssueTableFormat());
    final TableColumnModel issuesTableColumnModel =
        new EventTableColumnModel<TableColumn>(new BasicEventList<TableColumn>());
    JSeparatorTable issuesJTable = new JSeparatorTable(issuesTableModel, issuesTableColumnModel);
    issuesJTable.setAutoCreateColumnsFromModel(true);

    issuesJTable.setSeparatorRenderer(new IssueSeparatorTableCell(separatedIssues));
    issuesJTable.setSeparatorEditor(new IssueSeparatorTableCell(separatedIssues));
    issuesSelectionModel = GlazedListsSwing.eventSelectionModel(separatedIssuesProxyList);
    issuesSelectionModel.setSelectionMode(
        ListSelection
            .MULTIPLE_INTERVAL_SELECTION_DEFENSIVE); // multi-selection best demos our awesome
                                                     // selection management
    issuesSelectionModel.addListSelectionListener(new IssuesSelectionListener());
    issuesJTable.setSelectionModel(issuesSelectionModel);
    issuesJTable.getColumnModel().getColumn(0).setPreferredWidth(150);
    issuesJTable.getColumnModel().getColumn(1).setPreferredWidth(400);
    issuesJTable.getColumnModel().getColumn(2).setPreferredWidth(300);
    issuesJTable.getColumnModel().getColumn(3).setPreferredWidth(300);
    issuesJTable.getColumnModel().getColumn(4).setPreferredWidth(250);
    issuesJTable.getColumnModel().getColumn(5).setPreferredWidth(300);
    issuesJTable.getColumnModel().getColumn(6).setPreferredWidth(300);
    issuesJTable.getColumnModel().getColumn(7).setPreferredWidth(1000);
    // turn off cell focus painting
    issuesJTable.setDefaultRenderer(
        String.class, new NoFocusRenderer(issuesJTable.getDefaultRenderer(String.class)));
    issuesJTable.setDefaultRenderer(
        Integer.class, new NoFocusRenderer(issuesJTable.getDefaultRenderer(Integer.class)));
    issuesJTable.setDefaultRenderer(
        Priority.class, new NoFocusRenderer(new PriorityTableCellRenderer()));
    LookAndFeelTweaks.tweakTable(issuesJTable);
    TableComparatorChooser.install(
        issuesJTable, issuesSortedList, TableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD);
    JScrollPane issuesTableScrollPane =
        new JScrollPane(
            issuesJTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    issuesTableScrollPane.getViewport().setBackground(UIManager.getColor("EditorPane.background"));
    issuesTableScrollPane.setBorder(BorderFactory.createEmptyBorder());

    issueDetails = new IssueDetailsComponent(filteredIssues);

    // projects
    EventList<Project> projects = Project.getProjects();
    TransformedList<Project, Project> projectsProxyList =
        GlazedListsSwing.swingThreadProxyList(projects);
    // project select combobox
    DefaultEventComboBoxModel projectsComboModel =
        new DefaultEventComboBoxModel<Project>(projectsProxyList);
    JComboBox projectsCombo = new JComboBox(projectsComboModel);
    projectsCombo.setEditable(false);
    projectsCombo.setOpaque(false);
    projectsCombo.addItemListener(new ProjectChangeListener());
    projectsComboModel.setSelectedItem(new Project(null, "Select a Java.net project..."));

    // build a label to display the number of issues in the issue table
    issueCounter = new IssueCounterLabel(filteredIssues);
    issueCounter.setHorizontalAlignment(SwingConstants.CENTER);
    issueCounter.setForeground(Color.WHITE);

    // throbber
    throbber = new JLabel(THROBBER_STATIC);
    throbber.setHorizontalAlignment(SwingConstants.RIGHT);

    // header bar
    JPanel iconBar = new GradientPanel(GLAZED_LISTS_MEDIUM_BROWN, GLAZED_LISTS_DARK_BROWN, true);
    iconBar.setLayout(new GridLayout(1, 3));
    iconBar.add(projectsCombo);
    iconBar.add(issueCounter);
    iconBar.add(throbber);
    iconBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    // assemble all data components on a common panel
    JPanel dataPanel = new JPanel();
    JComponent issueDetailsComponent = issueDetails;
    dataPanel.setLayout(new GridLayout(2, 1));
    dataPanel.add(issuesTableScrollPane);
    dataPanel.add(issueDetailsComponent);

    // draw lines between components
    JComponent filtersPanel = filterPanel.getComponent();
    filtersPanel.setBorder(BorderFactory.createEmptyBorder());
    // filtersPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1,
    // IssuesBrowser.GLAZED_LISTS_DARK_BROWN));
    issueDetailsComponent.setBorder(
        BorderFactory.createMatteBorder(1, 0, 0, 0, GLAZED_LISTS_DARK_BROWN));

    // the outermost panel to layout the icon bar with the other panels
    final JPanel mainPanel = new JPanel(new GridBagLayout());
    mainPanel.add(
        iconBar,
        new GridBagConstraints(
            0,
            0,
            2,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    mainPanel.add(
        filtersPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    mainPanel.add(
        Box.createHorizontalStrut(240),
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    mainPanel.add(
        dataPanel,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    return mainPanel;
  }
Пример #19
0
  public JComponent buildCommon() {
    String colSpec = FormLayoutUtil.getColSpec(COMMON_COL_SPEC, orientation);
    FormLayout layout = new FormLayout(colSpec, COMMON_ROW_SPEC);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    maxbuffer = new JTextField("" + configuration.getMaxMemoryBufferSize());
    maxbuffer.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(maxbuffer.getText());
              configuration.setMaxMemoryBufferSize(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug(
                  "Could not parse max memory buffer size from \"" + maxbuffer.getText() + "\"");
            }
          }
        });

    JComponent cmp =
        builder.addSeparator(
            Messages.getString("NetworkTab.5"),
            FormLayoutUtil.flip(cc.xyw(1, 1, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(
        Messages.getString("NetworkTab.6")
            .replaceAll("MAX_BUFFER_SIZE", configuration.getMaxMemoryBufferSizeStr()),
        FormLayoutUtil.flip(cc.xy(1, 3), colSpec, orientation));
    builder.add(maxbuffer, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation));

    String nCpusLabel =
        String.format(
            Messages.getString("NetworkTab.7"), Runtime.getRuntime().availableProcessors());
    builder.addLabel(nCpusLabel, FormLayoutUtil.flip(cc.xy(1, 5), colSpec, orientation));

    String[] guiCores = new String[MAX_CORES];
    for (int i = 0; i < MAX_CORES; i++) {
      guiCores[i] = Integer.toString(i + 1);
    }
    nbcores = new JComboBox(guiCores);
    nbcores.setEditable(false);
    int nbConfCores = configuration.getNumberOfCpuCores();
    if (nbConfCores > 0 && nbConfCores <= MAX_CORES) {
      nbcores.setSelectedItem(Integer.toString(nbConfCores));
    } else {
      nbcores.setSelectedIndex(0);
    }

    nbcores.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setNumberOfCpuCores(Integer.parseInt(e.getItem().toString()));
          }
        });
    builder.add(nbcores, FormLayoutUtil.flip(cc.xy(3, 5), colSpec, orientation));

    chapter_interval = new JTextField("" + configuration.getChapterInterval());
    chapter_interval.setEnabled(configuration.isChapterSupport());
    chapter_interval.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(chapter_interval.getText());
              configuration.setChapterInterval(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug(
                  "Could not parse chapter interval from \"" + chapter_interval.getText() + "\"");
            }
          }
        });

    chapter_support = new JCheckBox(Messages.getString("TrTab2.52"));
    chapter_support.setContentAreaFilled(false);
    chapter_support.setSelected(configuration.isChapterSupport());

    chapter_support.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setChapterSupport((e.getStateChange() == ItemEvent.SELECTED));
            chapter_interval.setEnabled(configuration.isChapterSupport());
          }
        });

    builder.add(chapter_support, FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation));

    builder.add(chapter_interval, FormLayoutUtil.flip(cc.xy(3, 7), colSpec, orientation));

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.3"),
            FormLayoutUtil.flip(cc.xyw(1, 11, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    channels =
        new JComboBox(
            new Object[] {
              Messages.getString("TrTab2.55"),
              Messages.getString("TrTab2.56") /*, "8 channels 7.1" */
            }); // 7.1 not supported by Mplayer :\
    channels.setEditable(false);
    if (configuration.getAudioChannelCount() == 2) {
      channels.setSelectedIndex(0);
    } else {
      channels.setSelectedIndex(1);
    }
    channels.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setAudioChannelCount(
                Integer.parseInt(e.getItem().toString().substring(0, 1)));
          }
        });

    builder.addLabel(
        Messages.getString("TrTab2.50"), FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation));
    builder.add(channels, FormLayoutUtil.flip(cc.xy(3, 13), colSpec, orientation));

    forcePCM = new JCheckBox(Messages.getString("TrTab2.27"));
    forcePCM.setContentAreaFilled(false);
    if (configuration.isMencoderUsePcm()) {
      forcePCM.setSelected(true);
    }
    forcePCM.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderUsePcm(e.getStateChange() == ItemEvent.SELECTED);
          }
        });

    builder.add(forcePCM, FormLayoutUtil.flip(cc.xyw(1, 15, 3), colSpec, orientation));

    ac3remux =
        new JCheckBox(
            Messages.getString("MEncoderVideo.32")
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    ac3remux.setContentAreaFilled(false);
    if (configuration.isRemuxAC3()) {
      ac3remux.setSelected(true);
    }
    ac3remux.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setRemuxAC3((e.getStateChange() == ItemEvent.SELECTED));
          }
        });

    builder.add(ac3remux, FormLayoutUtil.flip(cc.xyw(1, 17, 3), colSpec, orientation));

    forceDTSinPCM =
        new JCheckBox(
            Messages.getString("TrTab2.28")
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    forceDTSinPCM.setContentAreaFilled(false);
    if (configuration.isDTSEmbedInPCM()) {
      forceDTSinPCM.setSelected(true);
    }
    forceDTSinPCM.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            configuration.setDTSEmbedInPCM(forceDTSinPCM.isSelected());
            if (configuration.isDTSEmbedInPCM()) {
              JOptionPane.showMessageDialog(
                  (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                  Messages.getString("TrTab2.10"),
                  "Information",
                  JOptionPane.INFORMATION_MESSAGE);
            }
          }
        });

    builder.add(forceDTSinPCM, FormLayoutUtil.flip(cc.xyw(1, 19, 3), colSpec, orientation));

    abitrate = new JTextField("" + configuration.getAudioBitrate());
    abitrate.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(abitrate.getText());
              configuration.setAudioBitrate(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug("Could not parse audio bitrate from \"" + abitrate.getText() + "\"");
            }
          }
        });

    builder.addLabel(
        Messages.getString("TrTab2.29"), FormLayoutUtil.flip(cc.xy(1, 21), colSpec, orientation));
    builder.add(abitrate, FormLayoutUtil.flip(cc.xy(3, 21), colSpec, orientation));

    mpeg2remux =
        new JCheckBox(
            Messages.getString("MEncoderVideo.39")
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    mpeg2remux.setContentAreaFilled(false);
    if (configuration.isMencoderRemuxMPEG2()) {
      mpeg2remux.setSelected(true);
    }
    mpeg2remux.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderRemuxMPEG2((e.getStateChange() == ItemEvent.SELECTED));
          }
        });

    builder.add(mpeg2remux, FormLayoutUtil.flip(cc.xyw(1, 23, 3), colSpec, orientation));

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.4"),
            FormLayoutUtil.flip(cc.xyw(1, 25, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(
        Messages.getString("TrTab2.32"),
        FormLayoutUtil.flip(cc.xyw(1, 29, 3), colSpec, orientation));

    Object data[] =
        new Object[] {
          configuration.getMencoderMainSettings(), /* default */
          String.format(
              "keyint=5:vqscale=1:vqmin=2  /* %s */", Messages.getString("TrTab2.60")), /* great */
          String.format(
              "keyint=5:vqscale=1:vqmin=1  /* %s */",
              Messages.getString("TrTab2.61")), /* lossless */
          String.format(
              "keyint=5:vqscale=2:vqmin=3  /* %s */",
              Messages.getString("TrTab2.62")), /* good (wired) */
          String.format(
              "keyint=25:vqmax=5:vqmin=2  /* %s */",
              Messages.getString("TrTab2.63")), /* good (wireless) */
          String.format(
              "keyint=25:vqmax=7:vqmin=2  /* %s */",
              Messages.getString("TrTab2.64")), /* medium (wireless) */
          String.format(
              "keyint=25:vqmax=8:vqmin=3  /* %s */", Messages.getString("TrTab2.65")) /* low */
        };

    MyComboBoxModel cbm = new MyComboBoxModel(data);

    vq = new JComboBox(cbm);
    vq.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              String s = (String) e.getItem();
              if (s.indexOf("/*") > -1) {
                s = s.substring(0, s.indexOf("/*")).trim();
              }
              configuration.setMencoderMainSettings(s);
            }
          }
        });
    vq.getEditor()
        .getEditorComponent()
        .addKeyListener(
            new KeyListener() {
              @Override
              public void keyPressed(KeyEvent e) {}

              @Override
              public void keyTyped(KeyEvent e) {}

              @Override
              public void keyReleased(KeyEvent e) {
                vq.getItemListeners()[0].itemStateChanged(
                    new ItemEvent(vq, 0, vq.getEditor().getItem(), ItemEvent.SELECTED));
              }
            });
    vq.setEditable(true);
    builder.add(vq, FormLayoutUtil.flip(cc.xyw(1, 31, 3), colSpec, orientation));

    String help1 = Messages.getString("TrTab2.39");
    help1 += Messages.getString("TrTab2.40");
    help1 += Messages.getString("TrTab2.41");
    help1 += Messages.getString("TrTab2.42");
    help1 += Messages.getString("TrTab2.43");
    help1 += Messages.getString("TrTab2.44");

    JTextArea decodeTips = new JTextArea(help1);
    decodeTips.setEditable(false);
    decodeTips.setBorder(BorderFactory.createEtchedBorder());
    decodeTips.setBackground(new Color(255, 255, 192));
    builder.add(decodeTips, FormLayoutUtil.flip(cc.xyw(1, 41, 3), colSpec, orientation));

    disableSubs = new JCheckBox(Messages.getString("TrTab2.51"));
    disableSubs.setContentAreaFilled(false);

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.7"),
            FormLayoutUtil.flip(cc.xyw(1, 33, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.add(disableSubs, FormLayoutUtil.flip(cc.xy(1, 35), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.8"), FormLayoutUtil.flip(cc.xy(1, 37), colSpec, orientation));

    notranscode = new JTextField(configuration.getNoTranscode());
    notranscode.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            configuration.setNoTranscode(notranscode.getText());
          }
        });
    builder.add(notranscode, FormLayoutUtil.flip(cc.xy(3, 37), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.9"), FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation));

    forcetranscode = new JTextField(configuration.getForceTranscode());
    forcetranscode.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            configuration.setForceTranscode(forcetranscode.getText());
          }
        });
    builder.add(forcetranscode, FormLayoutUtil.flip(cc.xy(3, 39), colSpec, orientation));

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    return panel;
  }
Пример #20
0
  public Displayer(Player x, int num) {
    super("Player " + num + " Information");
    playernum = num;
    this.x = x;

    setSize(400, 400);
    setResizable(false);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    moneyLabel = new JLabel("Money Owned:" + x.getMoney() + "");
    jcards = new JLabel("Get out of Jail Cards Owned: " + x.getJailCards());

    propertydisplay = new JComboBox(getPropertyName());
    icon = new ImageIcon(Game.wdr + "images/tokens/monopoly_token_" + x.getToken() + ".png");
    mortgage = new JButton("Manage Mortgage");
    mortgage.addActionListener(this);
    mortgage.setActionCommand("mortgage");

    buyHouse = new JButton("Buy a House");
    buyHouse.addActionListener(this);
    buyHouse.setActionCommand("buyHouse");

    sellHouse = new JButton("Sell a House");
    sellHouse.addActionListener(this);
    sellHouse.setActionCommand("sellHouse");

    sellProperty = new JButton("Sell this Property");
    sellProperty.addActionListener(this);
    sellProperty.setActionCommand("sellProperty");

    Image img = icon.getImage();
    Image newimg = img.getScaledInstance(80, 80, java.awt.Image.SCALE_SMOOTH);
    ImageIcon newicon = new ImageIcon(newimg);
    timg = new JLabel(newicon);

    propertydisplay.addItemListener(this);

    p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
    p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
    p2.setAlignmentX(Component.RIGHT_ALIGNMENT);
    p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
    p3.setAlignmentX(Component.LEFT_ALIGNMENT);

    p2.add(timg);
    p3.add(moneyLabel);
    p3.add(jcards);

    p1.add(p2);
    p1.add(p3);

    p4.setLayout(new BoxLayout(p4, BoxLayout.Y_AXIS));
    p4.setAlignmentY(Component.CENTER_ALIGNMENT);

    p4.add(propertydisplay);
    p4.add(pr1);
    p4.add(pr2);
    p4.add(pr3);
    p4.add(pr4);
    p4.add(pr5);

    p5.setLayout(new BoxLayout(p5, BoxLayout.X_AXIS));

    p5.add(mortgage);
    p5.add(buyHouse);
    p5.add(sellHouse);

    p.add(p1);
    p.add(p4);
    p.add(p5);

    add(p);
    setVisible(true);

    timer.setActionCommand("timing");
    timer.setInitialDelay(500);
    timer.start();
  }
Пример #21
0
  /**
   * Create an AddeChooser associated with an IdvChooser
   *
   * @param mgr The chooser manager
   * @param root The chooser.xml node
   */
  public AddeChooser(IdvChooserManager mgr, Element root) {

    super(mgr, root);
    simpleMode = !getProperty(IdvChooser.ATTR_SHOWDETAILS, true);
    this.addeServers = getIdv().getIdvChooserManager().getAddeServers(getGroupType());

    serverSelector =
        new JComboBox(new Vector(addeServers)) {
          public void paint(Graphics g) {
            if (myServerTimeStamp != serverTimeStamp) {
              myServerTimeStamp = serverTimeStamp;
              Misc.runInABit(10, AddeChooser.this, "updateServerList", null);
            }
            super.paint(g);
          }
        };
    serverSelector.setEditable(true);
    serverSelector.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (!ignoreStateChangedEvents) {
              setGroups();
            }
          }
        });

    serverSelector
        .getEditor()
        .getEditorComponent()
        .addMouseListener(
            new MouseAdapter() {
              public void mouseReleased(MouseEvent e) {
                if (!SwingUtilities.isRightMouseButton(e)) {
                  return;
                }
                AddeServer server = getAddeServer();
                if (server == null) {
                  return;
                }
                List items = new ArrayList();
                if (MARK_AS_INACTIVE || server.getIsLocal()) {
                  items.add(
                      GuiUtils.makeMenuItem(
                          "Remove local server: " + server.getName(),
                          AddeChooser.this,
                          "removeServer",
                          server));
                } else {
                  items.add(new JMenuItem("Not a local server"));
                }
                JPopupMenu popup = GuiUtils.makePopupMenu(items);
                popup.show(serverSelector, e.getX(), e.getY());
              }
            });

    groupSelector = new JComboBox();
    groupSelector.setToolTipText("Right click to remove group");
    groupSelector.setEditable(true);
    groupSelector
        .getEditor()
        .getEditorComponent()
        .addMouseListener(
            new MouseAdapter() {
              public void mouseReleased(MouseEvent e) {
                if (SwingUtilities.isRightMouseButton(e)) {
                  Object selected = groupSelector.getSelectedItem();
                  if ((selected == null) || !(selected instanceof AddeServer.Group)) {
                    return;
                  }
                  AddeServer.Group group = (AddeServer.Group) selected;
                  List items = new ArrayList();
                  if (MARK_AS_INACTIVE || group.getIsLocal()) {
                    items.add(
                        GuiUtils.makeMenuItem(
                            "Remove local group: " + group.getName(),
                            AddeChooser.this,
                            "removeGroup",
                            group));
                  }

                  final AddeServer server = getAddeServer();

                  if (server != null) {
                    List groups = server.getGroupsWithType(getGroupType(), false);
                    for (int i = 0; i < groups.size(); i++) {
                      final AddeServer.Group inactiveGroup = (AddeServer.Group) groups.get(i);
                      if (inactiveGroup.getActive()) {
                        continue;
                      }
                      JMenuItem mi = new JMenuItem("Re-activate group: " + inactiveGroup);
                      items.add(mi);
                      mi.addActionListener(
                          new ActionListener() {
                            public void actionPerformed(ActionEvent ae) {
                              getIdv()
                                  .getIdvChooserManager()
                                  .activateAddeServerGroup(server, inactiveGroup);
                              setGroups();
                              groupSelector.setSelectedItem(inactiveGroup);
                            }
                          });
                    }
                  }

                  if (items.size() == 0) {
                    items.add(new JMenuItem("Not a local group"));
                  }

                  JPopupMenu popup = GuiUtils.makePopupMenu(items);
                  popup.show(groupSelector, e.getX(), e.getY());
                }
              }
            });
    loadServerState();
    setGroups();
  }
Пример #22
0
  /**
   * Конструктор
   *
   * @param mediator Посредник родитьельского окна
   */
  public ButtonToolBar(final IGuiMediator mediator) {
    this.mediator = mediator;

    try {
      locale = ((WBDrawing) mediator).getLocalizer();
    } catch (Exception e) {
      logger.debug(e.getMessage(), e);
    }

    mouseMenu = new JPopupMenu();
    imagePanel = new JPanel();
    imagePanel.setLayout(new GridLayout(4, 2));
    mouseMenu.add(imagePanel);
    imagePanel.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            System.out.println("Focus Gained");
          }

          public void focusLost(FocusEvent e) {
            mouseMenu.setVisible(false);
            System.out.println("Focus Lost");
          }
        });

    URL url = ClassLoader.getSystemResource("img/open.gif");
    Icon iconOpen = new ImageIcon(url);
    JButton btnOpen = new JButton(iconOpen);
    btnOpen.setToolTipText(locale.getString("btntoolbar.open"));
    url = ClassLoader.getSystemResource("img/save.gif");
    Icon iconSave = new ImageIcon(url);
    JButton btnSave = new JButton(iconSave);
    btnSave.setToolTipText(locale.getString("btntoolbar.save"));
    url = ClassLoader.getSystemResource("img/undo.gif");
    Icon iconUndo = new ImageIcon(url);
    btnUndo = new JButton(iconUndo);
    btnUndo.setToolTipText(locale.getString("btntoolbar.undo"));
    url = ClassLoader.getSystemResource("img/redo.gif");
    Icon iconRedo = new ImageIcon(url);
    btnRedo = new JButton(iconRedo);
    btnRedo.setToolTipText(locale.getString("btntoolbar.redo"));
    url = ClassLoader.getSystemResource("img/draw.gif");
    Icon iconDraw = new ImageIcon(url);
    btnDraw = new JToggleButton(iconDraw, true);
    btnDraw.setToolTipText(locale.getString("btntoolbar.draw"));
    url = ClassLoader.getSystemResource("img/pen.gif");
    Icon iconPen = new ImageIcon(url);
    btnPen = new JToggleButton(iconPen);
    btnPen.setToolTipText(locale.getString("btntoolbar.pen"));
    url = ClassLoader.getSystemResource("img/calibrate.gif");
    Icon iconCalibrate = new ImageIcon(url);
    btnCalibrate = new JToggleButton(iconCalibrate);
    btnCalibrate.setToolTipText(locale.getString("btntoolbar.calibration"));
    url = ClassLoader.getSystemResource("img/gridMove.gif");
    Icon iconGridMove = new ImageIcon(url);

    JToggleButton btnGrigMove = new JToggleButton(iconGridMove);
    url = ClassLoader.getSystemResource("img/hand.gif");
    Icon iconHand = new ImageIcon(url);

    JToggleButton btnHand = new JToggleButton(iconHand);
    btnHand.setToolTipText(locale.getString("btntoolbar.hand"));

    url = ClassLoader.getSystemResource("img/selTool.gif");
    Icon iconSelTool = new ImageIcon(url);
    JToggleButton btnSelTool = new JToggleButton(iconSelTool);

    url = ClassLoader.getSystemResource("img/spline.gif");
    Icon iconQuadTool = new ImageIcon(url);
    btnSpline = new JToggleButton(iconQuadTool);
    btnSpline.setToolTipText(locale.getString("btntoolbar.spline"));

    btnTools = new JToggleButton("T");

    btnTextTool = new JToggleButton("A");

    url = ClassLoader.getSystemResource("img/ruler.gif");
    Icon iconRulerTool = new ImageIcon(url);
    btnRulerTool = new JToggleButton(iconRulerTool);

    url = ClassLoader.getSystemResource("img/sendFile.gif");
    Icon iconSendFile = new ImageIcon(url);
    JToggleButton btnFileTransmit = new JToggleButton(iconSendFile);
    btnFileTransmit.setToolTipText(locale.getString("btntoolbar.fileTransmit"));
    url = ClassLoader.getSystemResource("img/nodesEdit.gif");
    Icon iconNodesEdit = new ImageIcon(url);

    JToggleButton btnNodesEdit = new JToggleButton(iconNodesEdit);
    btnNodesEdit.setToolTipText(locale.getString("btntoolbar.nodeEdit"));

    JButton btnTest = new JButton(locale.getString("btntoolbar.button.Test"));
    btnTest.setEnabled(false);
    url = ClassLoader.getSystemResource("img/send.gif");
    Icon iconSend = new ImageIcon(url);
    JButton btnSendArq = new JButton(iconSend);
    btnSendArq.setToolTipText(locale.getString("btntoolbar.send"));
    url = ClassLoader.getSystemResource("img/clear.gif");
    Icon iconClear = new ImageIcon(url);
    JButton btnClearTab = new JButton(iconClear);
    btnClearTab.setToolTipText(locale.getString("btntoolbar.clear"));

    JButton btnRequestModel = new JButton(locale.getString("btntoolbar.button.RequestModel"));
    btnRequestModel.setEnabled(false);

    JComboBox cmbTools = new JComboBox();
    cmbTools.addItem("Thick Line");

    cmbTools.addItemListener(
        new ItemListener() {

          public void itemStateChanged(ItemEvent e) {
            boolean selected = btnTools.getModel().isSelected();
            if (selected) {
              mode = getToolsMode();
              guiChanged();
            }
          }
        });

    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(btnDraw);
    buttonGroup.add(btnPen);
    buttonGroup.add(btnCalibrate);
    buttonGroup.add(btnGrigMove);
    buttonGroup.add(btnHand);
    buttonGroup.add(btnSelTool);
    buttonGroup.add(btnSpline);
    buttonGroup.add(btnTextTool);
    buttonGroup.add(btnRulerTool);
    buttonGroup.add(btnNodesEdit);
    // buttonGroup.add( btnTools );

    btnDraw.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_DRAWING;
            }
            guiChanged();
          }
        });

    btnPen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_PEN;
            }
            guiChanged();
          }
        });

    btnCalibrate.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_CALIBRATING;
            }
            guiChanged();
          }
        });

    btnGrigMove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_GRID_MOVING;
            }
            guiChanged();
          }
        });

    btnHand.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_HAND_MAP;
            }
            guiChanged();
          }
        });

    btnSelTool.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_SELECT_TOOL;
            }
            guiChanged();
          }
        });

    btnSpline.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_QUAD_TOOL;
            }
            guiChanged();
          }
        });

    btnTextTool.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_TEXT_TOOL;
            }
            guiChanged();
          }
        });

    btnRulerTool.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_RULER_TOOL;
            }
            guiChanged();
          }
        });

    btnNodesEdit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
            boolean selected = abstractButton.getModel().isSelected();
            if (selected) {
              mode = Mode.MODE_NODES_EDIT;
            }
            guiChanged();
          }
        });

    btnTools.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mode = getToolsMode();
            guiChanged();
          }
        });

    btnOpen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnOpenPressed();
          }
        });

    btnSave.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnSavePressed();
          }
        });

    btnUndo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnUndoPressed();
          }
        });

    btnRedo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnRedoPressed();
          }
        });

    btnTest.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnTestPressed();
          }
        });

    btnSendArq.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnSendModelPressed();
          }
        });

    btnSendArq.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnSendArqModelPressed();
          }
        });

    btnClearTab.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnClearTabPressed();
          }
        });

    btnRequestModel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnFileTransmitPressed();
          }
        });

    btnFileTransmit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediator.btnFileTransmitPressed();
          }
        });

    add(btnOpen);
    add(btnSave);
    //        add( btnUndo );
    //        add( btnRedo );
    addSeparator();
    // add(lblMode);

    actionButton = new JToggleButton(btnDraw.getIcon());
    actionButton.setToolTipText(btnDraw.getToolTipText());
    actionButton.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            mouseMenu.show(e.getComponent(), e.getX(), e.getY());
          }
        });
    addButton(btnDraw);
    addButton(btnPen);
    addButton(btnCalibrate);
    // add( btnGrigMove );
    addButton(btnHand);
    // add(btnSelTool);
    addButton(btnSpline);
    addButton(btnNodesEdit);
    // add( btnTextTool );
    addButton(btnRulerTool);
    // addSeparator();
    // add(cmbTools);
    add(actionButton);

    cmbScale = new JComboBox();
    cmbScale.setEditable(true);
    cmbScale.addItem("1:1000");
    cmbScale.addItem("1:2000");
    cmbScale.addItem("1:5000");
    cmbScale.addItem("1:10000");
    cmbScale.addItem("1:25000");
    cmbScale.addItem("1:50000");
    cmbScale.addItem("1:100000");
    cmbScale.setSelectedIndex(3);
    cmbScale.setToolTipText(locale.getString("btntoolbar.scale"));
    cmbScale.setPreferredSize(cmbScale.getMinimumSize());
    cmbScale.setMaximumSize(cmbScale.getMinimumSize());

    cmbScale.addItemListener(new ZoomListener());
    addSeparator();

    chbVisibleGrid = new JCheckBox();
    chbVisibleGrid.setSelected(true);
    chbVisibleGrid.setToolTipText(locale.getString("btntoolbar.grid"));
    // addSeparator();
    chbVisibleGrid.addItemListener(
        new ItemListener() {

          public void itemStateChanged(ItemEvent e) {
            guiChanged();
          }
        });
    add(btnFileTransmit);
    add(btnSendArq);
    add(btnClearTab);
    add(chbVisibleGrid);
    add(cmbScale);
    // addSeparator();
    // add( lblControl );
    // add( btnSend );
    // add( btnRequestModel );
    // add( btnTest );
  }
Пример #23
0
  public StockpileItemDialog(final Program program) {
    super(program, TabsStockpile.get().addStockpileItem(), Images.TOOL_STOCKPILE.getImage());

    ListenerClass listener = new ListenerClass();

    JLabel jItemsLabel = new JLabel(TabsStockpile.get().item());
    jItems = new JComboBox();
    AutoCompleteSupport<Item> itemAutoComplete =
        AutoCompleteSupport.install(
            jItems, EventModels.createSwingThreadProxyList(items), new ItemFilterator());
    itemAutoComplete.setStrict(true);
    itemAutoComplete.setCorrectsCase(true);
    jItems.addItemListener(listener); // Must be added after AutoCompleteSupport

    JLabel jCountMinimumLabel = new JLabel(TabsStockpile.get().countMinimum());
    jCountMinimum = new JTextField();
    jCountMinimum.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(final FocusEvent e) {
            jCountMinimum.selectAll();
          }
        });
    jCountMinimum.addCaretListener(listener);

    jCopy = new JCheckBox(TabsStockpile.get().copy());
    jCopy.setActionCommand(StockpileItemAction.COPY.name());
    jCopy.addActionListener(listener);

    jOK = new JButton(TabsStockpile.get().ok());
    jOK.setActionCommand(StockpileItemAction.OK.name());
    jOK.addActionListener(listener);
    jOK.setEnabled(false);

    jCancel = new JButton(TabsStockpile.get().cancel());
    jCancel.setActionCommand(StockpileItemAction.CANCEL.name());
    jCancel.addActionListener(listener);

    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.TRAILING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGroup(
                        layout
                            .createParallelGroup()
                            .addComponent(jItemsLabel)
                            .addComponent(jCountMinimumLabel))
                    .addGroup(
                        layout
                            .createParallelGroup()
                            .addComponent(jItems, 300, 300, 300)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(jCountMinimum, 100, 100, Short.MAX_VALUE)
                                    .addComponent(jCopy))))
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(
                        jOK, Program.BUTTONS_WIDTH, Program.BUTTONS_WIDTH, Program.BUTTONS_WIDTH)
                    .addComponent(
                        jCancel,
                        Program.BUTTONS_WIDTH,
                        Program.BUTTONS_WIDTH,
                        Program.BUTTONS_WIDTH)));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(
                        jItemsLabel,
                        Program.BUTTONS_HEIGHT,
                        Program.BUTTONS_HEIGHT,
                        Program.BUTTONS_HEIGHT)
                    .addComponent(
                        jItems,
                        Program.BUTTONS_HEIGHT,
                        Program.BUTTONS_HEIGHT,
                        Program.BUTTONS_HEIGHT))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(
                        jCountMinimumLabel,
                        Program.BUTTONS_HEIGHT,
                        Program.BUTTONS_HEIGHT,
                        Program.BUTTONS_HEIGHT)
                    .addComponent(
                        jCountMinimum,
                        Program.BUTTONS_HEIGHT,
                        Program.BUTTONS_HEIGHT,
                        Program.BUTTONS_HEIGHT)
                    .addComponent(
                        jCopy,
                        Program.BUTTONS_HEIGHT,
                        Program.BUTTONS_HEIGHT,
                        Program.BUTTONS_HEIGHT))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(
                        jOK, Program.BUTTONS_HEIGHT, Program.BUTTONS_HEIGHT, Program.BUTTONS_HEIGHT)
                    .addComponent(
                        jCancel,
                        Program.BUTTONS_HEIGHT,
                        Program.BUTTONS_HEIGHT,
                        Program.BUTTONS_HEIGHT)));
  }
Пример #24
0
  /**
   * Initialisiere die obere Leiste, in welcher Messergebnisse und Einschätzungen geladen,<br>
   * eine Formel eingegeben (berechnet oder durch ausprobieren der Platzhalter ausgewertet),<br>
   * die Bewertungsergebnisse angezeigt werden.
   */
  private void initTopPane() {
    setLayout(new BorderLayout());
    JPanel topPane = new JPanel(new GridLayout(12, 2));

    initResultSelectionPanel(topPane);
    initEstimationsSelectionPanel(topPane);

    topPane.add(new JLabel("Variables:"));
    variablesArea = new JTextArea(1, 30);
    variablesArea.setEditable(false);
    variablesArea.setLineWrap(true);
    Font fnt = new Font("Monospaced", Font.PLAIN, 11);
    variablesArea.setFont(fnt);
    topPane.add(new JScrollPane(variablesArea));

    topPane.add(new JLabel("Mode: "));
    modeCombo = new JComboBox(new String[] {"Test effort estimation", "Bug count estimation"});
    modeCombo.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent itemEvent) {
            mode =
                modeCombo.getSelectedIndex() == 0
                    ? PredictionType.TestEffort
                    : PredictionType.BugCount;
            benchmarkTableModel.setMode(mode);
            benchmarkTable.updateUI();
          }
        });
    topPane.add(modeCombo);

    topPane.add(new JLabel("Option:"));
    zeroIsInvalidCheckbox = new JCheckBox("Zero is invalid", false);
    topPane.add(zeroIsInvalidCheckbox);

    topPane.add(new JLabel("Prediction equation:"));

    JPanel equationPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    equationField = new JTextField("0");
    equationField.setColumns(35);
    equationField.getDocument().addDocumentListener(new EquationChangeListener());
    equationPanel.add(equationField);

    JButton computeBtn = new JButton("Compute");
    computeBtn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            eqtnChanged();
          }
        });
    equationPanel.add(computeBtn);

    JButton enumerateBtn = new JButton("Enumerate");
    enumerateBtn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String winner = null;
            try {
              winner =
                  Benchmark.enumerate(
                      equationField.getText(),
                      metricsData,
                      respProjs,
                      mode,
                      zeroIsInvalidCheckbox.isSelected());
            } catch (Exception e1) {
              e1.printStackTrace();
            }
            if (winner == null) {
              return;
            }

            equationField.setText(winner);
            eqtnChanged();
          }
        });
    equationPanel.add(enumerateBtn);

    topPane.add(equationPanel);

    topPane.add(new JLabel("# Correct order predictions:"));
    numCorrLbl = new JLabel("0");
    topPane.add(numCorrLbl);

    topPane.add(new JLabel("Total number of valid order estimations:"));
    numEstimationsLbl = new JLabel("0");
    topPane.add(numEstimationsLbl);

    topPane.add(new JLabel("Percentage of correct orderings:"));
    percCorrLbl = new JLabel("0%");
    topPane.add(percCorrLbl);

    topPane.add(new JLabel("# Correct order predictions weighted:"));
    weightedNumCorrLbl = new JLabel("0");
    topPane.add(weightedNumCorrLbl);

    topPane.add(new JLabel("Total weight sum of valid estimators:"));
    weightSumLbl = new JLabel("0");
    topPane.add(weightSumLbl);

    topPane.add(new JLabel("Percentage of weighted correct orderings:"));
    percWeightCorrLbl = new JLabel("0%");
    topPane.add(percWeightCorrLbl);

    add(topPane, BorderLayout.NORTH);
  }
Пример #25
0
  public SyntaxTab() {
    super(new BorderLayout(), "Syntax highlighting");
    /*
     * upper checkboxes
     */
    JPanel upper = new JPanel(new GridLayout(2, 1, 0, 0));
    upper.setOpaque(false);
    upper.add(MyPanel.wrap(highlightSyntax));
    upper.add(MyPanel.wrap(matchBracket));
    highlightSyntax.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ev) {
            SyntaxTab.this.updateComponentStatus();
          }
        });
    this.add(upper, BorderLayout.PAGE_START);
    /*
     * upper panel (painters)
     */
    painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getCurrentInstance());
    painterComboBox.setFont(f13);
    if (isMetal) painterComboBox.setBackground(Color.WHITE);
    painterComboBox.addItemListener(this.painterChangeListener);
    JButton addPainter =
        new MyButton("+") {
          {
            if (isMetal) {
              this.setPreferredSize(new Dimension(28, 28));
            }
          }

          @Override
          public void actionPerformed(ActionEvent ev) {
            String name;
            do {
              name =
                  JOptionPane.showInputDialog(
                      SyntaxTab.this, "Enter a name:", "Name", JOptionPane.QUESTION_MESSAGE);
            } while (!myjava.gui.syntax.Painter.isValidPrompt(name, SyntaxTab.this));
            if ((name != null) && (!name.isEmpty())) {
              // name is valid, neither cancelled nor pressed enter directly
              myjava.gui.syntax.Painter newPainter =
                  ((myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem()))
                      .newInstance(name);
              addPainter(newPainter);
              System.out.println("now set, should call listener");
              painterComboBox.setSelectedItem(newPainter); // auto-call ItemListener(s)
            }
          }
        };
    JButton removePainter =
        new MyButton("-") {
          {
            if (isMetal) {
              this.setPreferredSize(new Dimension(28, 28));
            }
          }

          @Override
          public void actionPerformed(ActionEvent ev) {
            myjava.gui.syntax.Painter painter =
                (myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem());
            if (painter.equals(myjava.gui.syntax.Painter.getDefaultInstance())) {
              JOptionPane.showMessageDialog(
                  SyntaxTab.this,
                  "The default painter cannot be removed.",
                  "Error",
                  JOptionPane.ERROR_MESSAGE);
            } else {
              int option =
                  JOptionPane.showConfirmDialog(
                      SyntaxTab.this,
                      "Remove painter \"" + painter.getName() + "\"?",
                      "Confirm",
                      JOptionPane.YES_NO_OPTION);
              if (option == JOptionPane.YES_OPTION) {
                // remove "painter"
                removedPainters.add(painter);
                painterComboBox.removeItemListener(painterChangeListener);
                painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getDefaultInstance());
                painterComboBox.removeItem(painter);
                for (Iterator<EntryListPanel> it = listPanelSet.iterator(); it.hasNext(); ) {
                  EntryListPanel panel = it.next();
                  if (panel.getPainter().getName().equals(painter.getName())) {
                    System.out.println("removing, then break");
                    it.remove();
                    centerPanel.remove(panel);
                    break;
                  }
                }
                painterComboBox.addItemListener(painterChangeListener);
                cardLayout.show(
                    centerPanel, myjava.gui.syntax.Painter.getDefaultInstance().getName());
              }
            }
          }
        };
    // lower part
    JPanel center = new JPanel(new BorderLayout());
    JLabel selectLabel = new MyLabel("Selected painter:");
    center.add(
        MyPanel.wrap(MyPanel.CENTER, selectLabel, painterComboBox, addPainter, removePainter),
        BorderLayout.PAGE_START);
    componentSet.addAll(Arrays.asList(selectLabel, addPainter, removePainter));
    center.add(centerPanel, BorderLayout.CENTER);
    this.add(center, BorderLayout.CENTER);
    cardLayout.show(centerPanel, myjava.gui.syntax.Painter.getCurrentInstance().getName());
  }
Пример #26
0
    public Editor(JFrame parent, Evaluator evaluator) {
      super(parent, "Structure");
      setModal(true);
      this.evaluator = evaluator;

      getContentPane().setLayout(new BorderLayout());

      // name and type
      JPanel pNameType = new JPanel(new GridLayout(2, 1));
      JPanel pName = new JPanel(new BorderLayout());
      pName.add(new JLabel("Name: "), BorderLayout.WEST);
      tfName = new JTextField(evaluator.getName());
      pName.add(tfName, BorderLayout.CENTER);
      pNameType.add(pName);
      JPanel pType = new JPanel(new BorderLayout());
      pType.add(new JLabel("Type: "), BorderLayout.WEST);
      cbType = new JComboBox(types);
      cbType.setEditable(false);
      cbType.setSelectedIndex(evaluator.type);
      cbType.addItemListener(this);
      pType.add(cbType, BorderLayout.CENTER);
      pNameType.add(pType);
      getContentPane().add(pNameType, BorderLayout.NORTH);

      // options panel
      this.clOptions = new CardLayout();
      this.pOptions = new JPanel(clOptions);

      JPanel pConstraintRoot = new JPanel(new BorderLayout());
      Box pConstraintOpts = new Box(BoxLayout.Y_AXIS);
      JPanel pDiagonals = new JPanel(new BorderLayout());
      cbDiagonals = new JCheckBox("Ignore Diagonals", evaluator.ignoreDiagonals);
      pDiagonals.add(cbDiagonals, BorderLayout.CENTER);
      pConstraintOpts.add(pDiagonals);
      JPanel pInvestment = new JPanel(new BorderLayout());
      pInvestment.add(new Label("Investments "), BorderLayout.WEST);
      cbInvestment = new JComboBox(investments);
      cbInvestment.setEditable(false);
      cbInvestment.setSelectedIndex(evaluator.investments);
      pInvestment.add(cbInvestment, BorderLayout.CENTER);
      pConstraintOpts.add(pInvestment);
      JPanel pOrganization = new JPanel(new GridLayout(2, 1));
      lOrgFileName = new JLabel("File: <none selected>");
      pOrganization.add(lOrgFileName);
      JPanel pFileChoose = new JPanel(new FlowLayout(FlowLayout.CENTER));
      JButton bFileChoose = new JButton("Choose File...");
      bFileChoose.addActionListener(this);
      bFileChoose.setActionCommand(CMD_CHOOSE_FILE);
      pFileChoose.add(bFileChoose);
      pOrganization.add(pFileChoose);
      pConstraintOpts.add(pOrganization);
      pConstraintRoot.add(pConstraintOpts, BorderLayout.NORTH);
      pOptions.add(pConstraintRoot, types[CONSTRAINT]);

      JPanel pSizeRoot = new JPanel(new BorderLayout());
      pOptions.add(pSizeRoot, types[EFFECTIVE_SIZE]);
      clOptions.first(pOptions);

      getContentPane().add(BorderLayout.CENTER, pOptions);

      // ok/cancel panel
      JOkCancelPanel okCancelPanel = new JOkCancelPanel();
      okCancelPanel.addActionListener(this);
      getContentPane().add(BorderLayout.SOUTH, okCancelPanel);

      pack();
    }
Пример #27
0
  public BookMain() {
    String[] col = {"번호", "제목", "저자"};
    String[][] row = new String[0][3];
    model =
        new DefaultTableModel(row, col) {
          // 익명의 클래스 : 변경,추가
          public boolean isCellEditable(int r, int c) {
            return false;
          }
        };
    table = new JTable(model);
    JScrollPane js = new JScrollPane(table);
    la1 = new JLabel("번호:");
    la2 = new JLabel("제목:");
    la3 = new JLabel("저자:");
    la4 = new JLabel("출판사:");
    la5 = new JLabel("가격:");

    la6 = new JLabel("Search");
    box = new JComboBox();
    box.addItem("위키북스");
    box.addItem("한빛미디어");
    box.addItem("영진출판사");
    box.addItem("대림출판사");
    tf = new JTextField(20);
    tf.setEditable(false);
    b = new JButton("전체목록");
    // <input type=text readonly>
    JPanel p = new JPanel();
    p.add(la6);
    p.add(box);
    p.add(tf);
    p.add(b);
    // 배치
    setLayout(null);
    p.setBounds(10, 15, 620, 35);
    js.setBounds(10, 55, 620, 245);
    bp.setBounds(10, 320, 300, 170);
    la1.setBounds(320, 320, 300, 30);
    la2.setBounds(320, 355, 300, 30);
    la3.setBounds(320, 390, 300, 30);
    la4.setBounds(320, 425, 300, 30);
    la5.setBounds(320, 460, 300, 30);
    add(p);
    add(js);
    add(bp);
    add(la1);
    add(la2);
    add(la3);
    add(la4);
    add(la5);

    setSize(640, 550);
    setVisible(true);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    getData();
    getData();
    table.addMouseListener(this);
    box.addItemListener(this);
    b.addMouseListener(this);
  }
Пример #28
0
  /** Initializes and binds the components related to modeling codon positions. */
  private void initCodonPartitionComponents() {

    PanelUtils.setupComponent(substUnlinkCheck);

    substUnlinkCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setUnlinkedSubstitutionModel(substUnlinkCheck.isSelected());
          }
        });
    substUnlinkCheck.setEnabled(false);
    substUnlinkCheck.setToolTipText(
        ""
            + "<html>Gives each codon position partition different<br>"
            + "substitution model parameters.</html>");

    PanelUtils.setupComponent(heteroUnlinkCheck);
    heteroUnlinkCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setUnlinkedHeterogeneityModel(heteroUnlinkCheck.isSelected());
          }
        });
    heteroUnlinkCheck.setEnabled(heteroCombo.getSelectedIndex() != 0);
    heteroUnlinkCheck.setToolTipText(
        "<html>Gives each codon position partition different<br>rate heterogeneity model parameters.</html>");

    PanelUtils.setupComponent(freqsUnlinkCheck);
    freqsUnlinkCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {
            model.setUnlinkedFrequencyModel(freqsUnlinkCheck.isSelected());
          }
        });
    freqsUnlinkCheck.setEnabled(false);
    freqsUnlinkCheck.setToolTipText(
        "<html>Gives each codon position partition different<br>nucleotide frequency parameters.</html>");

    PanelUtils.setupComponent(codingCombo);
    codingCombo.setToolTipText("<html>Select how to partition the codon positions.</html>");
    codingCombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent ev) {

            switch (codingCombo.getSelectedIndex()) {
              case 0:
                model.setCodonHeteroPattern(null);
                break;
              case 1:
                model.setCodonHeteroPattern("112");
                break;
              default:
                model.setCodonHeteroPattern("123");
                break;
            }

            if (codingCombo.getSelectedIndex() != 0) {
              // codon position partitioning
              substUnlinkCheck.setEnabled(true);
              heteroUnlinkCheck.setEnabled(heteroCombo.getSelectedIndex() != 3);
              freqsUnlinkCheck.setEnabled(true);
              substUnlinkCheck.setSelected(true);
              heteroUnlinkCheck.setSelected(heteroCombo.getSelectedIndex() != 0);
              freqsUnlinkCheck.setSelected(true);

            } else {
              substUnlinkCheck.setEnabled(false);
              substUnlinkCheck.setSelected(false);
              heteroUnlinkCheck.setEnabled(false);
              heteroUnlinkCheck.setSelected(false);
              freqsUnlinkCheck.setEnabled(false);
              freqsUnlinkCheck.setSelected(false);
            }
          }
        });
  }
  public Assi() {
    c = getContentPane();

    c.setLayout(new BorderLayout());
    c.add(pnn, BorderLayout.NORTH);
    c.add(pns, BorderLayout.SOUTH);
    c.add(pnc, BorderLayout.CENTER);
    c.add(pne, BorderLayout.EAST);

    pne.setLayout(new GridLayout(2, 1));
    pne.add(pne1);
    pne.add(pne2);
    pne1.setLayout(new FlowLayout());
    pne1.add(go);
    go.addItem("Student");
    go.addItem("Teacher");
    go.addItem("Course");
    go.addItem("Result");
    pne1.add(b6);
    pne2.setLayout(cl2);

    pns.add(b1);
    pns.add(b2);
    pns.add(b3);
    pns.add(b4);
    pns.add(b5);

    setJMenuBar(m);
    m.add(student);
    m.add(teacher);
    m.add(course);
    m.add(result);

    stu.setLayout(new GridLayout(8, 2));
    stu.add(l1);
    stu.add(t1);
    stu.add(l2);
    stu.add(t2);
    stu.add(l3);
    stu.add(t3);
    stu.add(l4);
    stu.add(t4);
    stu.add(l5);
    stu.add(t5);
    stu.add(l6);
    stu.add(t6);

    cou.setLayout(new GridLayout(4, 2));
    cou.add(l7);
    cou.add(t7);
    cou.add(l8);
    cou.add(t8);
    cou.add(l9);
    cou.add(t9);
    cou.add(l0);
    cou.add(t0);

    tea.setLayout(new GridLayout(4, 2));
    tea.add(l11);
    tea.add(t11);
    tea.add(l12);
    tea.add(t12);
    tea.add(l13);
    tea.add(t13);
    tea.add(l14);
    tea.add(t14);

    res.setLayout(new GridLayout(15, 3));
    res.add(l15);
    res.add(t15);
    res.add(l16);
    res.add(t16);
    res.add(l17);
    res.add(t17);
    res.add(lg);
    res.add(l);
    res.add(l18);
    res.add(t18);
    res.add(l19);
    res.add(t19);
    res.add(l20);
    res.add(t20);
    res.add(l21);
    res.add(t21);
    res.add(l22);
    res.add(t22);
    res.add(l23);
    res.add(t23);
    res.add(l24);
    res.add(t24);
    res.add(l25);
    res.add(t25);
    res.add(l26);
    res.add(t26);
    res.add(l27);
    res.add(t27);
    res.add(l28);
    res.add(t28);

    pnc.setLayout(cl);
    pnc.add(blk, "cblk");
    pnc.add(stu, "cstu");
    pnc.add(tea, "ctea");
    pnc.add(cou, "ccou");
    pnc.add(res, "cres");

    b1.addActionListener(this);
    b2.addActionListener(this);
    b3.addActionListener(this);
    b4.addActionListener(this);
    b5.addActionListener(this);
    b6.addActionListener(this);

    student.addActionListener(this);
    teacher.addActionListener(this);
    course.addActionListener(this);
    result.addActionListener(this);

    go.addItemListener(this);
  }
Пример #30
0
  public MyFrame(String title, Color col) {
    setTitle(title); // title is set in main method
    setSize(500, 500); // this may need changed but looks ok
    setLocationRelativeTo(null); // sets the location as the centre of the screen
    setResizable(false);

    Container c = getContentPane(); // container to hold the different panels
    c.setBackground(Color.white); // col from main
    c.setLayout(null); // no layout selected so we can place anywhere

    // add to container

    ImageIcon gameLogo =
        new ImageIcon(
            new ImageIcon(getClass().getResource("GameLogobBlank.png"))
                .getImage()
                .getScaledInstance(360, 80, java.awt.Image.SCALE_SMOOTH));
    JPanel logoPanel = new JPanel();
    JLabel logoLabel = new JLabel("", gameLogo, JLabel.CENTER);
    logoPanel.setBounds(50, 45, gameLogo.getIconWidth() + 20, gameLogo.getIconHeight() + 20);
    logoPanel.setBackground(Color.white);
    logoPanel.add(logoLabel);
    c.add(logoPanel);

    ImageIcon qubLogo =
        new ImageIcon(new ImageIcon(getClass().getResource("QUBLogo.png")).getImage());
    JPanel qubLogoPanel = new JPanel();
    JLabel qubLogoLabel = new JLabel("", qubLogo, JLabel.CENTER);
    qubLogoPanel.setBounds(15, 380, qubLogo.getIconWidth() + 10, qubLogo.getIconHeight() + 10);
    qubLogoPanel.setBackground(Color.white);
    qubLogoPanel.add(qubLogoLabel);
    c.add(qubLogoPanel);

    ImageIcon seseLogo =
        new ImageIcon(
            new ImageIcon(getClass().getResource("seseLogo.png"))
                .getImage()
                .getScaledInstance(120, 45, java.awt.Image.SCALE_SMOOTH));
    JPanel seseLogoPanel = new JPanel();
    JLabel seseLogoLabel = new JLabel("", seseLogo, JLabel.CENTER);
    seseLogoPanel.setBounds(350, 390, seseLogo.getIconWidth() + 10, seseLogo.getIconHeight() + 10);
    seseLogoPanel.setBackground(Color.white);
    seseLogoPanel.add(seseLogoLabel);
    c.add(seseLogoPanel);

    JPanel playerPanel = new JPanel(); // new panel for players
    playerPanel.setBounds(92, 200, 316, 27); // location
    playerPanel.setLayout(new GridLayout(1, 2)); // layout as grid
    playerPanel.setOpaque(false);
    c.add(playerPanel); // add to container

    combo.setBackground(Color.white);
    playerPanel.add(numOfP); // label to tell to select num of players
    playerPanel.add(combo); // drop down menu

    players.setEditable(false);
    players.setHorizontalAlignment(JLabel.CENTER);

    combo.addItemListener(
        new ItemListener() { // this is to set the number of players to be displayed
          public void itemStateChanged(ItemEvent ie) {

            if (ie.getStateChange() == ItemEvent.SELECTED) {
              String str =
                  (String)
                      combo
                          .getSelectedItem(); // if the number changes then change the number of
                                              // player message

              if (str == "2") {
                players.setText("2 players selected");
              }

              if (str == "3") {
                players.setText("3 players selected");
              }

              if (str == "4") {
                players.setText("4 players selected");
              }

              if (str == "5") {
                players.setText("5 players selected");
              }

              if (str == "6") {
                players.setText("6 players selected");
              }
            } // closes if statements
          } // closes method
        } // closes action listener
        ); // closes action listener

    JPanel startPanel = new JPanel(); // start panel for start button
    startPanel.setBounds(123, 239, 254, 70); // location
    startPanel.setLayout(new GridLayout(2, 1)); // using a grid layout
    startPanel.add(players); // text box says number of payers
    startPanel.setBackground(Color.white);

    startButton = new JButton();
    startButton.setText(
        "Start Game!"); // button has the label start												// actual start button
    startPanel.add(startButton); // button added
    startButton.addActionListener(startButtonActionListener); // added actionlistener
    c.add(startPanel); // added to container

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // close when closed
    setVisible(true); // takes off invisability cloak
  } // MyFrame constructor