private void createComponents(JPanel p) {
    String tt = "Any of these:  45.5 -120.2   or   45 30 0 n 120 12 0 w   or   Seattle";

    JComboBox field = new JComboBox();
    field.setOpaque(false);
    field.setEditable(true);
    field.setLightWeightPopupEnabled(false);
    field.setPreferredSize(new Dimension(200, field.getPreferredSize().height));
    field.setToolTipText(tt);

    JLabel label = new JLabel(ImageLibrary.getIcon("gov/nasa/worldwindow/images/safari-24x24.png"));
    //            new
    // ImageIcon(getClass().getResource("gov/nasa/worldwindow/images/safari-24x24.png")));
    label.setOpaque(false);
    label.setToolTipText(tt);

    p.add(label, BorderLayout.WEST);
    p.add(field, BorderLayout.CENTER);

    field.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            performGazeteerAction(actionEvent);
          }
        });
  }
 @NotNull
 JComponent createComponent() {
   myRemoteCombobox = new JComboBox();
   myRemoteCombobox.setRenderer(new RemoteCellRenderer(myRemoteCombobox.getRenderer()));
   for (GitRemote remote : myRemotes) {
     myRemoteCombobox.addItem(remote);
   }
   myRemoteCombobox.setToolTipText("Select remote");
   if (myRemotes.size() == 1) {
     myRemoteCombobox.setEnabled(false);
   }
   return myRemoteCombobox;
 }
 private void initCompilerTypeCmb() {
   myIncrementalTypeCmb.setModel(new ListComboBoxModel<String>(mySettings.INCREMENTAL_TYPES));
   myIncrementalTypeCmb.setSelectedItem(mySettings.INCREMENTAL_TYPE);
   myIncrementalTypeCmb.setRenderer(
       new ListCellRendererWrapper<String>() {
         @Override
         public void customize(
             JList list, String value, int index, boolean selected, boolean hasFocus) {
           if (value.equals("SBT")) setText("SBT incremental compiler");
           if (value.equals("IDEA")) setText("IntelliJ IDEA");
         }
       });
   myIncrementalTypeCmb.setToolTipText("Rebuild is required after change");
 }
Esempio n. 4
0
  /**
   * Contruct a new AnimationWidget.
   *
   * @param parentf the parent JFrame
   * @param anim a ucar.visad.display.Animation object to manage
   * @param info Default values for the AnimationInfo
   */
  public AnimationWidget(JFrame parentf, Animation anim, AnimationInfo info) {

    // Initialize sharing to true
    super("AnimationWidget", true);
    timesCbx =
        new JComboBox() {
          public String getToolTipText(MouseEvent event) {
            if (boxPanel != null) {
              return boxPanel.getToolTipText();
            }
            return " ";
          }
        };
    timesCbx.setToolTipText("");
    timesCbxMutex = timesCbx.getTreeLock();
    timesCbx.setFont(new Font("Dialog", Font.PLAIN, 9));
    timesCbx.setLightWeightPopupEnabled(false);
    // set to non-visible until items are added
    timesCbx.setVisible(false);
    timesCbx.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!ignoreTimesCbxEvents && (anime != null)) {
              debug("got timesCbx event");
              setTimeFromUser((Real) timesCbx.getSelectedItem());
              if (boxPanel != null) {
                boxPanel.setOnIndex(timesCbx.getSelectedIndex());
              }
            }
          }
        });

    animationInfo = new AnimationInfo();
    if (anim != null) {
      setAnimation(anim);
    }
    if (anime != null) {
      animationInfo.set(anime.getAnimationInfo());
    }
    if (info != null) {
      setProperties(info);
      animationInfo.setRunning(info.getRunning());
    }

    boxPanel = new AnimationBoxPanel(this);
    if (timesArray != null) {
      updateBoxPanel(timesArray);
    }
  }
Esempio n. 5
0
  private void updateParams(EDPCellData data) {
    paramComboBox.removeAllItems();
    paramKeys = data.getPlugin().getPrintfDescrs(!m_isCrawlRuleEditor);
    if (!m_isCrawlRuleEditor) {
      paramComboBox.addItem(STRING_LITERAL);
    }

    for (Iterator it = paramKeys.values().iterator(); it.hasNext(); ) {
      ConfigParamDescr descr = (ConfigParamDescr) it.next();
      int type = descr.getType();
      if (!m_isCrawlRuleEditor
          && (type == ConfigParamDescr.TYPE_SET || type == ConfigParamDescr.TYPE_RANGE)) continue;
      paramComboBox.addItem(descr);
    }
    paramComboBox.setEnabled(true);
    paramComboBox.setSelectedIndex(0);
    paramComboBox.setToolTipText("Select a parameter to insert into the format string");
    insertButton.setEnabled(true);
  }
Esempio n. 6
0
  public Animation() {
    String[] keys = {"no Animator found"};
    if (tryDir(".")) // || tryDir("BLM305") || tryDir("CSE470"))
    keys = map.keySet().toArray(keys);
    System.out.println(map.size() + " classes loaded");
    menu = new JComboBox(keys);

    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COLOR);

    last = new JPanel();
    last.setPreferredSize(DIM);
    pan.add(last, "Center");

    ref.setFont(NORM);
    ref.setEditable(false);
    ref.setColumns(35);
    ref.setDragEnabled(true);
    pan.add(ref, "North");

    pan.add(bottomPanel(), "South");

    pan.setToolTipText("A collective project for BLM320");
    menu.setToolTipText("Animator classes");
    who.setToolTipText("author()");
    ref.setToolTipText("description()");

    Closer ear = new Closer();
    menu.addActionListener(ear);
    stop.addActionListener(ear);
    frm.addWindowListener(ear);

    if (map.size() > 0) setItem(0);
    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frm.setLocation(scaled(120), scaled(90));
    frm.pack(); // setSize() is called here
    frm.setVisible(true);
    start();
  }
Esempio n. 7
0
  public GUI() {
    String[] keys = {"no Quotation found"};
    if (tryDir(".") || tryDir("BLM305") || tryDir("CSE470")) keys = Q.keySet().toArray(keys);
    menu = new JComboBox<String>(keys);
    if (Q.size() > 0) setMessage(0);

    JPanel pan = new JPanel();
    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COLOR);

    pan.add(topPanel(), "North");

    txt.setFont(LARGE);
    txt.setEditable(false);
    txt.setRows(5);
    txt.setColumns(30);
    txt.setWrapStyleWord(true);
    txt.setLineWrap(true);
    txt.setDragEnabled(true);
    pan.add(new JScrollPane(txt), "Center");

    ref.setFont(SMALL);
    ref.setEditable(false);
    ref.setColumns(35);
    ref.setDragEnabled(true);
    pan.add(ref, "South");

    pan.setToolTipText("A project realized collectively by the class");
    menu.setToolTipText("Quotation classes");
    who.setToolTipText("author()+year()");
    txt.setToolTipText("text()");
    ref.setToolTipText("reference()");

    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frm.setLocation(scaled(120), scaled(90));
    frm.pack();
    frm.setVisible(true);
  }
  /**
   * Create a choicebox for link line style options and return the panel it is in.
   *
   * @return JPanel the panel holding the new choicebox for the link style options.
   */
  private JPanel createLinkDashedChoiceBox() {

    JPanel drawPanel = new JPanel(new BorderLayout());
    CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$

    cbLinkDashed = new JComboBox();
    cbLinkDashed.setToolTipText(
        LanguageProperties.getString(
            LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectDashed")); // $NON-NLS-1$
    cbLinkDashed.setOpaque(true);
    cbLinkDashed.setEditable(false);
    cbLinkDashed.setEnabled(false);
    cbLinkDashed.setMaximumRowCount(10);
    cbLinkDashed.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$

    cbLinkDashed.addItem(
        new String(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE,
                "UIToolBarFormatLink.plainLine"))); //$NON-NLS-1$
    cbLinkDashed.addItem(
        new String(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE,
                "UIToolBarFormatLink.largeDashes"))); //$NON-NLS-1$
    cbLinkDashed.addItem(
        new String(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE,
                "UIToolBarFormatLink.smallDashes"))); //$NON-NLS-1$

    cbLinkDashed.validate();

    cbLinkDashed.setSelectedIndex(0);

    DefaultListCellRenderer drawRenderer =
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) {
            if (list != null) {
              if (isSelected) {
                setBackground(list.getSelectionBackground());
                setForeground(list.getSelectionForeground());
              } else {
                setBackground(list.getBackground());
                setForeground(list.getForeground());
              }
            }

            setText((String) value);
            return this;
          }
        };

    cbLinkDashed.setRenderer(drawRenderer);

    ActionListener drawActionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onUpdateLinkDashed(cbLinkDashed.getSelectedIndex());
          }
        };
    cbLinkDashed.addActionListener(drawActionListener);

    drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$
    drawPanel.add(cbLinkDashed, BorderLayout.CENTER);
    return drawPanel;
  }
  /**
   * Create a choicbox for link line thickness options and return the panel it is in.
   *
   * @return JPanel the panel holding the new choicebox for the line thickness options.
   */
  private JPanel createWeightChoiceBox() {

    JPanel drawPanel = new JPanel(new BorderLayout());
    CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$

    cbLineWeight = new JComboBox();
    cbLineWeight.setToolTipText(
        LanguageProperties.getString(
            LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectWeight")); // $NON-NLS-1$
    cbLineWeight.setOpaque(true);
    cbLineWeight.setEditable(false);
    cbLineWeight.setEnabled(false);
    cbLineWeight.setMaximumRowCount(10);
    cbLineWeight.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$

    cbLineWeight.addItem(new String("1 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("2 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("3 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("4 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("5 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("6 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("7 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("8 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("9 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("10 px")); // $NON-NLS-1$

    cbLineWeight.validate();

    cbLineWeight.setSelectedIndex(0);

    DefaultListCellRenderer drawRenderer =
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) {
            if (list != null) {
              if (isSelected) {
                setBackground(list.getSelectionBackground());
                setForeground(list.getSelectionForeground());
              } else {
                setBackground(list.getBackground());
                setForeground(list.getForeground());
              }
            }

            setText((String) value);
            return this;
          }
        };

    cbLineWeight.setRenderer(drawRenderer);

    ActionListener drawActionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int ind = cbLineWeight.getSelectedIndex();

            if (ind == 0) onUpdateLinkWeight(1);
            else if (ind == 1) onUpdateLinkWeight(2);
            else if (ind == 2) onUpdateLinkWeight(3);
            else if (ind == 3) onUpdateLinkWeight(4);
            else if (ind == 4) onUpdateLinkWeight(5);
            else if (ind == 5) onUpdateLinkWeight(6);
            else if (ind == 6) onUpdateLinkWeight(7);
            else if (ind == 7) onUpdateLinkWeight(8);
            else if (ind == 8) onUpdateLinkWeight(9);
            else if (ind == 9) onUpdateLinkWeight(10);
          }
        };
    cbLineWeight.addActionListener(drawActionListener);

    drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$
    drawPanel.add(cbLineWeight, BorderLayout.CENTER);
    return drawPanel;
  }
Esempio n. 10
0
  /** Create the arrow head choicebox. */
  private JPanel createArrowChoiceBox() {

    JPanel drawPanel = new JPanel(new BorderLayout());
    CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$

    cbArrows = new JComboBox();
    cbArrows.setToolTipText(
        LanguageProperties.getString(
            LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectArrow")); // $NON-NLS-1$
    cbArrows.setOpaque(true);
    cbArrows.setEditable(false);
    cbArrows.setEnabled(false);
    cbArrows.setMaximumRowCount(4);
    cbArrows.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$

    Vector arrows = new Vector(5);
    arrows.insertElementAt(
        LanguageProperties.getString(
            LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.noArrows"),
        0); //$NON-NLS-1$
    arrows.insertElementAt(
        LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.fromTo"),
        1); //$NON-NLS-1$
    arrows.insertElementAt(
        LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.toFfrom"),
        2); //$NON-NLS-1$
    arrows.insertElementAt(
        LanguageProperties.getString(
            LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.bothWays"),
        3); //$NON-NLS-1$
    DefaultComboBoxModel comboModel = new DefaultComboBoxModel(arrows);
    cbArrows.setModel(comboModel);
    cbArrows.setSelectedIndex(0);

    DefaultListCellRenderer comboRenderer =
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) {
            if (isSelected) {
              setBackground(list.getSelectionBackground());
              setForeground(list.getSelectionForeground());
            } else {
              setBackground(list.getBackground());
              setForeground(list.getForeground());
            }

            setText((String) value);

            return this;
          }
        };
    cbArrows.setRenderer(comboRenderer);

    cbArrows.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onUpdateArrowType(cbArrows.getSelectedIndex());
          }
        });

    drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$
    drawPanel.add(cbArrows, BorderLayout.CENTER);
    return drawPanel;
  }
  private JPanel createPanel1() {
    JPanel panel = new JPanel();
    panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS));
    panel.setBorder(
        BorderFactory.createCompoundBorder(
            new JideTitledBorder(
                new PartialEtchedBorder(PartialEtchedBorder.LOWERED, PartialSide.NORTH),
                "AutoCompletion combo box and text field",
                JideTitledBorder.LEADING,
                JideTitledBorder.ABOVE_TOP),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));

    JComboBox autoCompletionComboBox = new AutoCompletionComboBox(_fontNames);
    autoCompletionComboBox.setName("AutoCompletion JComboBox (Strict)");
    autoCompletionComboBox.setToolTipText("AutoCompletion JComboBox (Strict)");
    panel.add(new JLabel("AutoCompletion JComboBox (Strict)"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(autoCompletionComboBox);
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    AutoCompletionComboBox autoCompletionComboBoxNotStrict = new AutoCompletionComboBox(_fontNames);
    autoCompletionComboBoxNotStrict.setStrict(false);
    autoCompletionComboBoxNotStrict.setName("AutoCompletion JComboBox (Not strict)");
    autoCompletionComboBoxNotStrict.setToolTipText("AutoCompletion JComboBox (Not strict)");
    panel.add(new JLabel("AutoCompletion JComboBox (Not strict)"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(autoCompletionComboBoxNotStrict);
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    // create tree combobox
    final JTextField textField = new JTextField();
    textField.setName("AutoCompletion JTextField with a hidden data");
    SelectAllUtils.install(textField);
    new AutoCompletion(textField, _fontList);
    panel.add(new JLabel("AutoCompletion JTextField with a hidden data"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(textField);
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    //        panel.add(Box.createVerticalStrut(24), JideBoxLayout.FIX);
    //        panel.add(new JLabel("As comparisons:"));
    //        panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);
    //
    //        JComboBox searchableComboBox = new JComboBox(_fontNames);
    //        searchableComboBox.setEditable(false);
    //        SearchableUtils.installSearchable(searchableComboBox);
    //        searchableComboBox.setToolTipText("Searchable JComboBox");
    //        panel.add(new JLabel("Searchable JComboBox"));
    //        panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    //        panel.add(searchableComboBox);
    //        panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);
    //
    //        JTextField completionTextField = new JTextField();
    //        new ListCompletion(completionTextField, _fontNames);
    //        completionTextField.setToolTipText("Completion JTextField (not auto-complete)");
    //        panel.add(new JLabel("Completion JTextField (not auto-complete)"));
    //        panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    //        panel.add(completionTextField);
    //        panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    return panel;
  }
Esempio n. 12
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 );
  }
Esempio n. 13
0
  private void makeUI(int defaultHeight) {

    datasetNameLabel = new JLabel();
    /* gridPP = new PrefPanel("GridView", (PreferencesExt) store.node("GridViewPrefs"));
    gridUrlIF = gridPP.addTextComboField("url", "Gridded Data URL", null, 10, false);
    gridPP.addButton( BAMutil.makeButtconFromAction( chooseLocalDatasetAction ));
    gridPP.finish(true, BorderLayout.EAST);
    gridPP.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        InvDatasetImpl ds = new InvDatasetImpl( gridUrlIF.getText(), thredds.catalog.DataType.GRID, ServiceType.NETCDF);
        setDataset( ds);
      }
    }); */

    // top tool panel
    toolPanel = new JPanel();
    toolPanel.setBorder(new EtchedBorder());
    toolPanel.setLayout(new MFlowLayout(FlowLayout.LEFT, 0, 0));

    // menus
    JMenu dataMenu = new JMenu("Dataset");
    dataMenu.setMnemonic('D');
    configMenu = new JMenu("Configure");
    configMenu.setMnemonic('C');
    JMenu toolMenu = new JMenu("Controls");
    toolMenu.setMnemonic('T');
    addActionsToMenus(dataMenu, configMenu, toolMenu);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(dataMenu);
    menuBar.add(configMenu);
    menuBar.add(toolMenu);
    toolPanel.add(menuBar);

    // field choosers
    fieldPanel = new JPanel();
    fieldPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    toolPanel.add(fieldPanel);

    // stride
    toolPanel.add(controller.strideSpinner);

    // buttcons
    BAMutil.addActionToContainer(toolPanel, controller.drawHorizAction);
    BAMutil.addActionToContainer(toolPanel, controller.drawVertAction);
    mapBeanMenu = MapBean.makeMapSelectButton();
    toolPanel.add(mapBeanMenu.getParentComponent());

    // the Navigated panel and its toolbars
    panz.setLayout(new FlowLayout());
    navToolbar = panz.getNavToolBar();
    moveToolbar = panz.getMoveToolBar();
    if (((Boolean) navToolbarAction.getValue(BAMutil.STATE)).booleanValue())
      toolPanel.add(navToolbar);
    if (((Boolean) moveToolbarAction.getValue(BAMutil.STATE)).booleanValue())
      toolPanel.add(moveToolbar);

    BAMutil.addActionToContainer(toolPanel, panz.setReferenceAction);
    BAMutil.addActionToContainer(toolPanel, controller.dataProjectionAction);
    BAMutil.addActionToContainer(toolPanel, controller.showGridAction);
    BAMutil.addActionToContainer(toolPanel, controller.showContoursAction);
    BAMutil.addActionToContainer(toolPanel, controller.showContourLabelsAction);

    BAMutil.addActionToContainer(toolPanel, redrawAction);

    //  vertical split
    vertPanel = new VertPanel();
    splitDraw = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panz, vertPanel);
    int divLoc = store.getInt("vertSplit", 2 * defaultHeight / 3);
    splitDraw.setDividerLocation(divLoc);
    drawingPanel = new JPanel(new BorderLayout()); // filled later

    // status panel
    JPanel statusPanel = new JPanel(new BorderLayout());
    statusPanel.setBorder(new EtchedBorder());
    positionLabel = new JLabel("position");
    positionLabel.setToolTipText("position at cursor");
    dataValueLabel = new JLabel("data value", SwingConstants.CENTER);
    dataValueLabel.setToolTipText("data value (double click on grid)");
    statusPanel.add(positionLabel, BorderLayout.WEST);
    statusPanel.add(dataValueLabel, BorderLayout.CENTER);
    panz.setPositionLabel(positionLabel);

    // colorscale panel
    colorScalePanel = new ColorScale.Panel(this, controller.getColorScale());
    csDataMinMax = new JComboBox(GridRenderer.MinMaxType.values());
    csDataMinMax.setToolTipText("ColorScale Min/Max setting");
    csDataMinMax.addActionListener(
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            controller.setDataMinMaxType((GridRenderer.MinMaxType) csDataMinMax.getSelectedItem());
          }
        });
    JPanel westPanel = new JPanel(new BorderLayout());
    westPanel.add(colorScalePanel, BorderLayout.CENTER);
    westPanel.add(csDataMinMax, BorderLayout.NORTH);

    // lay it out
    JPanel northPanel = new JPanel();
    // northPanel.setLayout( new BoxLayout(northPanel, BoxLayout.Y_AXIS));
    northPanel.setLayout(new BorderLayout());
    northPanel.add(datasetNameLabel, BorderLayout.NORTH);
    northPanel.add(toolPanel, BorderLayout.SOUTH);

    setLayout(new BorderLayout());
    add(northPanel, BorderLayout.NORTH);
    add(statusPanel, BorderLayout.SOUTH);
    add(westPanel, BorderLayout.WEST);
    add(drawingPanel, BorderLayout.CENTER);

    setDrawHorizAndVert(controller.drawHorizOn, controller.drawVertOn);
  }
Esempio n. 14
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();
  }
Esempio n. 15
0
  public ThumbMaker() {
    super("ThumbMaker");

    // grab the preferences so that they can be used to fill out the layout
    ThumbMakerPreferences myPrefs = ThumbMakerPreferences.getInstance();

    // content pane
    JPanel pane = new JPanel();
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    setContentPane(pane);

    // top panel
    JPanel top = new JPanel();
    top.setLayout(new BoxLayout(top, BoxLayout.X_AXIS));
    pane.add(top);

    // left-hand panel
    JPanel left = new JPanel();
    left.setLayout(new BoxLayout(left, BoxLayout.Y_AXIS));
    top.add(left);

    // horizontal padding
    top.add(Box.createHorizontalStrut(5));

    // label for file list
    JLabel listLabel = GUIUtil.makeLabel("Files to process:");
    listLabel.setDisplayedMnemonic('f');
    String listTip = "List of files from which to create thumbnails";
    listLabel.setToolTipText(listTip);
    left.add(GUIUtil.pad(listLabel));

    // list of files to convert
    list = new JList();
    listLabel.setLabelFor(list);
    list.setToolTipText(listTip);
    list.setModel(new DefaultListModel());
    list.setDragEnabled(true);
    changeFilesInList = new ThumbTransferHandler();
    list.setTransferHandler(changeFilesInList);
    left.add(new JScrollPane(list));

    // progress bar
    progress = new JProgressBar(0, 1);
    progress.setString("[Drag and drop files onto list to begin]");
    progress.setStringPainted(true);
    progress.setToolTipText("Status of thumbnail processing operation");
    left.add(progress);

    // panel for process and remove buttons
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    // add files button
    addFiles = new JButton("Add Files");
    addFiles.setMnemonic('d');
    addFiles.setToolTipText("Add files to be processed.");
    addFiles.addActionListener(this);
    p.add(addFiles);

    p.add(Box.createHorizontalStrut(5));

    // process button
    process = new JButton("Process");
    process.setMnemonic('p');
    process.setToolTipText("Begin creating thumbnails");
    process.addActionListener(this);
    p.add(process);

    p.add(Box.createHorizontalStrut(5));

    // remove button
    remove = new JButton("Remove");
    remove.setMnemonic('v');
    remove.setToolTipText("Remove selected files from the list");
    remove.addActionListener(this);
    p.add(remove);

    left.add(GUIUtil.pad(p));

    // right-hand panel
    JPanel right = new JPanel();
    right.setLayout(new BoxLayout(right, BoxLayout.Y_AXIS));
    top.add(right);

    // panel for resolution settings
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    // resolution label
    JLabel resLabel = GUIUtil.makeLabel("Resolution: ");
    resLabel.setDisplayedMnemonic('s');
    resLabel.setToolTipText("Resolution of the thumbnails");
    p.add(resLabel);

    // x resolution text box
    xres =
        GUIUtil.makeTextField(myPrefs.getStringPref(ThumbMakerPreferences.RES_WIDTH_PREF_NAME), 2);
    resLabel.setLabelFor(xres);
    xres.setToolTipText("Thumbnail width");
    p.add(xres);

    // "by" label
    JLabel byLabel = GUIUtil.makeLabel(" by ");
    byLabel.setDisplayedMnemonic('y');
    p.add(byLabel);

    // y resolution text box
    yres =
        GUIUtil.makeTextField(myPrefs.getStringPref(ThumbMakerPreferences.RES_HEIGHT_PREF_NAME), 2);
    byLabel.setLabelFor(yres);
    yres.setToolTipText("Thumbnail height");
    p.add(yres);

    right.add(GUIUtil.pad(p));
    right.add(Box.createVerticalStrut(8));

    // aspect ratio checkbox
    aspect = new JCheckBox("Maintain aspect ratio", true);
    aspect.setMnemonic('m');
    aspect.setToolTipText(
        "When checked, thumbnails are not stretched, "
            + "but rather padded with the background color.");
    aspect.addActionListener(this);
    right.add(GUIUtil.pad(aspect));
    // make sure that the check box is initialized correctly
    aspect.setSelected(
        myPrefs
            .getStringPref(ThumbMakerPreferences.DO_MAINTAIN_ASPECT_PREF_NAME)
            .equalsIgnoreCase(ThumbMakerPreferences.BOOLEAN_TRUE_STRING));

    // panel for background color
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    // load the color values from the preferences
    int redValueNumber = myPrefs.getIntegerPref(ThumbMakerPreferences.RED_VALUE_PREF_NAME);
    int greenValueNumber = myPrefs.getIntegerPref(ThumbMakerPreferences.GREEN_VALUE_PREF_NAME);
    int blueValueNumber = myPrefs.getIntegerPref(ThumbMakerPreferences.BLUE_VALUE_PREF_NAME);

    // background color label
    colorLabel = GUIUtil.makeLabel("Background color: ");
    String colorTip = "Thumbnail background color";
    colorLabel.setToolTipText(colorTip);
    p.add(colorLabel);

    // background color
    colorBox = new JPanel();
    colorBox.setToolTipText(colorTip);
    colorBox.setBorder(new LineBorder(Color.black, 1));
    Dimension colorBoxSize = new Dimension(45, 15);
    colorBox.setMaximumSize(colorBoxSize);
    colorBox.setMinimumSize(colorBoxSize);
    colorBox.setPreferredSize(colorBoxSize);
    colorBox.setBackground(new Color(redValueNumber, greenValueNumber, blueValueNumber));
    p.add(colorBox);

    right.add(GUIUtil.pad(p));
    right.add(Box.createVerticalStrut(2));

    // red slider
    redLabel = GUIUtil.makeLabel("R");
    red = new JSlider(0, 255, redValueNumber);
    redValue = GUIUtil.makeLabel("" + redValueNumber);
    redValue.setToolTipText("Red color component slider");
    right.add(makeSlider(redLabel, red, redValue, "Red"));

    // green slider
    greenLabel = GUIUtil.makeLabel("G");
    green = new JSlider(0, 255, greenValueNumber);
    greenValue = GUIUtil.makeLabel("" + greenValueNumber);
    greenValue.setToolTipText("Green color component slider");
    right.add(makeSlider(greenLabel, green, greenValue, "Green"));

    // blue slider
    blueLabel = GUIUtil.makeLabel("B");
    blue = new JSlider(0, 255, blueValueNumber);
    blueValue = GUIUtil.makeLabel("" + blueValueNumber);
    right.add(makeSlider(blueLabel, blue, blueValue, "Blue"));

    right.add(Box.createVerticalStrut(8));

    // panel for algorithm
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    // algorithm label
    JLabel algorithmLabel = GUIUtil.makeLabel("Algorithm: ");
    algorithmLabel.setDisplayedMnemonic('l');
    String algorithmTip = "Resizing algorithm to use";
    algorithmLabel.setToolTipText(algorithmTip);
    p.add(algorithmLabel);

    // algorithm combo box
    algorithm =
        GUIUtil.makeComboBox(
            new String[] {"Smooth", "Standard", "Fast", "Replicate", "Area averaging"});
    algorithmLabel.setLabelFor(algorithm);
    algorithm.setToolTipText(algorithmTip);
    p.add(algorithm);
    // set the algorithm value from the preferences
    algorithm.setSelectedIndex(myPrefs.getIntegerPref(ThumbMakerPreferences.RESIZE_ALG_PREF_NAME));

    right.add(GUIUtil.pad(p));

    // panel for output format
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    // format label
    JLabel formatLabel = GUIUtil.makeLabel("Format: ");
    formatLabel.setDisplayedMnemonic('f');
    String formatTip = "Thumbnail output format";
    formatLabel.setToolTipText(formatTip);
    p.add(formatLabel);

    // format combo box
    format = GUIUtil.makeComboBox(new String[] {"PNG", "JPG"});
    formatLabel.setLabelFor(format);
    format.setToolTipText(formatTip);
    p.add(format);
    // set the format value from the preferences
    format.setSelectedIndex(myPrefs.getIntegerPref(ThumbMakerPreferences.THUMB_FORMAT_PREF_NAME));

    right.add(GUIUtil.pad(p));
    right.add(Box.createVerticalStrut(5));

    // panel for prepend string
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    // prepend label
    JLabel prependLabel = GUIUtil.makeLabel("Prepend: ");
    prependLabel.setDisplayedMnemonic('e');
    String prependTip = "Starting string for each thumbnail filename";
    prependLabel.setToolTipText(prependTip);
    p.add(prependLabel);

    // prepend field
    prepend =
        GUIUtil.makeTextField(
            myPrefs.getStringPref(ThumbMakerPreferences.STRING_TO_PREPEND_PREF_NAME), 4);
    prependLabel.setLabelFor(prepend);
    prepend.setToolTipText(prependTip);
    p.add(prepend);

    p.add(Box.createHorizontalStrut(5));

    // append label
    JLabel appendLabel = GUIUtil.makeLabel("Append: ");
    appendLabel.setDisplayedMnemonic('a');
    String appendTip = "Ending string for each thumbnail filename";
    appendLabel.setToolTipText(appendTip);
    p.add(appendLabel);

    // append field
    append =
        GUIUtil.makeTextField(
            myPrefs.getStringPref(ThumbMakerPreferences.STRING_TO_APPEND_PREF_NAME), 4);
    appendLabel.setLabelFor(append);
    append.setToolTipText(appendTip);
    p.add(append);

    right.add(GUIUtil.pad(p));

    // vertical padding
    right.add(Box.createVerticalGlue());

    // bottom panel
    JPanel bottom = new JPanel();
    bottom.setLayout(new BoxLayout(bottom, BoxLayout.X_AXIS));
    pane.add(bottom);

    // output folder label
    JLabel outputLabel = GUIUtil.makeLabel("Output folder: ");
    outputLabel.setDisplayedMnemonic('o');
    String outputTip = "Thumbnail output folder";
    outputLabel.setToolTipText(outputTip);
    bottom.add(outputLabel);

    // output folder field
    String filePath =
        new File(myPrefs.getStringPref(ThumbMakerPreferences.FILE_PATH_STRING_PREF_NAME))
            .getAbsolutePath();
    output = GUIUtil.makeTextField(filePath, 8);
    outputLabel.setLabelFor(output);
    output.setToolTipText(outputTip);
    // start this in default and then lock down so "..." is used
    output.setEditable(false);
    output.setBackground(Color.LIGHT_GRAY);
    bottom.add(output);

    // add a file chooser button "..."
    dotDotDot = new JButton("...");
    dotDotDot.setMnemonic('.');
    dotDotDot.setToolTipText("Select destination directory.");
    dotDotDot.addActionListener(this);
    bottom.add(dotDotDot);

    right.add(GUIUtil.pad(p));

    setFromPreferences();
    addWindowListener(this);
  }
Esempio n. 16
0
  public BeastDialog(final JFrame frame, final String titleString, final Icon icon) {
    this.frame = frame;

    optionPanel = new OptionsPanel(12, 12);

    // this.frame = frame;

    JPanel panel = new JPanel(new BorderLayout());
    panel.setOpaque(false);

    final OptionsPanel optionPanel3 = new OptionsPanel(0, 3);

    final JLabel titleIcon = new JLabel();
    titleIcon.setIcon(icon);

    final JLabel titleText = new JLabel(titleString);
    optionPanel3.addComponent(titleText);

    //        final JButton aboutButton = new JButton("About BEAST...");
    //        //aboutButton.setAction();
    //        optionPanel3.addComponent(aboutButton);

    optionPanel.addComponents(titleIcon, optionPanel3);

    final JButton inputFileButton = new JButton("Choose File...");
    final JTextField inputFileNameText = new JTextField("not selected", 16);

    inputFileButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            FileDialog dialog = new FileDialog(frame, "Select target file...", FileDialog.LOAD);

            dialog.setVisible(true);
            if (dialog.getFile() == null) {
              // the dialog was cancelled...
              return;
            }

            inputFile = new File(dialog.getDirectory(), dialog.getFile());
            inputFileNameText.setText(inputFile.getName());
          }
        });
    inputFileNameText.setEditable(false);

    JPanel panel1 = new JPanel(new BorderLayout(0, 0));
    panel1.add(inputFileNameText, BorderLayout.CENTER);
    panel1.add(inputFileButton, BorderLayout.EAST);
    inputFileNameText.setToolTipText(
        "<html>Drag a BEAST XML file here or use the button to<br>"
            + "select one from a file dialog box.</html>");
    inputFileButton.setToolTipText(
        "<html>Drag a BEAST XML file here or use the button to<br>"
            + "select one from a file dialog box.</html>");
    optionPanel.addComponentWithLabel("BEAST XML File: ", panel1);

    Color focusColor = UIManager.getColor("Focus.color");
    Border focusBorder = BorderFactory.createMatteBorder(2, 2, 2, 2, focusColor);
    new FileDrop(
        null,
        inputFileNameText,
        focusBorder,
        new FileDrop.Listener() {
          public void filesDropped(java.io.File[] files) {
            inputFile = files[0];
            inputFileNameText.setText(inputFile.getName());
          } // end filesDropped
        }); // end FileDrop.Listener

    overwriteCheckBox.setToolTipText(
        "<html>Specify whether BEAST will overwrite existing log files<br>"
            + "with the same name.</html>");
    optionPanel.addComponent(overwriteCheckBox);

    optionPanel.addSeparator();

    seedText.setColumns(12);
    seedText.setToolTipText(
        "<html>Specify a particular random number seed to replicate<br>"
            + "precisely the sequence of steps in the MCMC chain. By<br>"
            + "default this uses system information to provide a new<br>"
            + "seed each run.</html>");

    optionPanel.addComponentWithLabel("Random number seed: ", seedText);

    threadsCombo.setToolTipText(
        "<html>Specify how large a thread pool to use.<br>"
            + "In most circumstances this should be set to 'automatic'<br>"
            + "but in some circumstances it may be desirable to restict<br>"
            + "the number of cores being used. 0 will turn off threading</html>");

    optionPanel.addComponentWithLabel("Thread pool size: ", threadsCombo);

    optionPanel.addSeparator();

    optionPanel.addSpanningComponent(beagleCheckBox);
    beagleCheckBox.setSelected(true);

    final OptionsPanel optionPanel1 = new OptionsPanel(0, 6);
    //        optionPanel1.setBorder(BorderFactory.createEmptyBorder());
    optionPanel1.setBorder(new TitledBorder(""));

    OptionsPanel optionPanel2 = new OptionsPanel(0, 3);
    optionPanel2.setBorder(BorderFactory.createEmptyBorder());
    final JLabel label1 =
        optionPanel2.addComponentWithLabel("Prefer use of: ", beagleResourceCombo);
    optionPanel2.addComponent(beagleSSECheckBox);
    beagleSSECheckBox.setSelected(true);
    final JLabel label2 =
        optionPanel2.addComponentWithLabel("Prefer precision: ", beaglePrecisionCombo);
    final JLabel label3 =
        optionPanel2.addComponentWithLabel("Rescaling scheme: ", beagleScalingCombo);
    optionPanel2.addComponent(beagleInfoCheckBox);
    optionPanel2.setBorder(BorderFactory.createEmptyBorder());

    optionPanel1.addComponent(optionPanel2);

    final JEditorPane beagleInfo =
        new JEditorPane(
            "text/html",
            "<html><div style=\"font-family:'helvetica neue light',helvetica,sans-serif;font-size:12;\"><p>BEAGLE is a high-performance phylogenetic library that can make use of<br>"
                + "additional computational resources such as graphics boards. It must be<br>"
                + "downloaded and installed independently of BEAST:</p>"
                + "<pre><a href=\"http://beagle-lib.googlecode.com/\">http://beagle-lib.googlecode.com/</a></pre></div>");
    beagleInfo.setOpaque(false);
    beagleInfo.setEditable(false);
    beagleInfo.addHyperlinkListener(new SimpleLinkListener());
    optionPanel1.addComponent(beagleInfo);
    optionPanel1.setBorder(BorderFactory.createEmptyBorder());
    optionPanel.addSpanningComponent(optionPanel1);

    beagleInfoCheckBox.setEnabled(false);
    beagleCheckBox.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            beagleInfo.setEnabled(beagleCheckBox.isSelected());
            beagleInfoCheckBox.setEnabled(beagleCheckBox.isSelected());
            label1.setEnabled(beagleCheckBox.isSelected());
            beagleResourceCombo.setEnabled(beagleCheckBox.isSelected());
            beagleSSECheckBox.setEnabled(beagleCheckBox.isSelected());
            label2.setEnabled(beagleCheckBox.isSelected());
            beaglePrecisionCombo.setEnabled(beagleCheckBox.isSelected());
            label3.setEnabled(beagleCheckBox.isSelected());
            beagleScalingCombo.setEnabled(beagleCheckBox.isSelected());
          }
        });

    beagleCheckBox.setSelected(false);
    beagleResourceCombo.setSelectedItem("CPU");
  }