Esempio n. 1
0
  /**
   * Sets the combo-boxes to a fixed size so they don't take up too much room that would be better
   * devoted to the test output box
   */
  protected void setComboSizes() {

    m_DatasetKeyBut.setPreferredSize(COMBO_SIZE);
    m_RunCombo.setPreferredSize(COMBO_SIZE);
    m_ResultKeyBut.setPreferredSize(COMBO_SIZE);
    m_CompareCombo.setPreferredSize(COMBO_SIZE);
    m_SigTex.setPreferredSize(COMBO_SIZE);

    m_DatasetKeyBut.setMaximumSize(COMBO_SIZE);
    m_RunCombo.setMaximumSize(COMBO_SIZE);
    m_ResultKeyBut.setMaximumSize(COMBO_SIZE);
    m_CompareCombo.setMaximumSize(COMBO_SIZE);
    m_SigTex.setMaximumSize(COMBO_SIZE);

    m_DatasetKeyBut.setMinimumSize(COMBO_SIZE);
    m_RunCombo.setMinimumSize(COMBO_SIZE);
    m_ResultKeyBut.setMinimumSize(COMBO_SIZE);
    m_CompareCombo.setMinimumSize(COMBO_SIZE);
    m_SigTex.setMinimumSize(COMBO_SIZE);

    // =============== BEGIN EDIT melville ===============
    m_PrecTex.setPreferredSize(COMBO_SIZE);
    m_PrecTex.setMaximumSize(COMBO_SIZE);
    m_PrecTex.setMinimumSize(COMBO_SIZE);
    // =============== END EDIT melville ===============
  }
Esempio n. 2
0
  public void buildPopulationBox() {
    rebuilding = true;
    populationBox.removeAll();
    peopleList = new ArrayList<Object>();
    famList = new ArrayList<Family>();
    peopleList.addAll(ctxt.individualCensus);
    String plur = (peopleList.size() == 1 ? "" : "s");
    populationBox.setLayout(new BoxLayout(populationBox, BoxLayout.PAGE_AXIS));
    populationBox.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.blue), "Current Population"));
    populationBox.setAlignmentX(0.5f);
    populationBox.add(Box.createRigidArea(new Dimension(8, 0)));
    indivLabel = new JLabel("Contains " + peopleList.size() + " Individual" + plur);
    indivLabel.setAlignmentX(0.5f);
    populationBox.add(indivLabel);
    if (peopleList.size() > 0) {
      JPanel indivBtnBox = new JPanel();
      indivBtnBox.setLayout(new BoxLayout(indivBtnBox, BoxLayout.LINE_AXIS));
      Dimension sizer2 = new Dimension(350, 50);
      String[] indMenu = genIndMenu(peopleList);
      indPick = new JComboBox(indMenu);
      indPick.addActionListener(listener);
      indPick.setActionCommand("view/edit person");
      indPick.setMinimumSize(sizer2);
      indPick.setMaximumSize(sizer2);
      indPick.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.blue), "View/Edit Person"));
      indivBtnBox.add(indPick);
      populationBox.add(indivBtnBox);
    } //  end of if-any-people-exist

    famList.addAll(ctxt.familyCensus); //  end of filtering deleted records
    plur = (famList.size() == 1 ? "y" : "ies");
    famLabel = new JLabel("Contains " + famList.size() + " Famil" + plur);
    famLabel.setAlignmentX(0.5f);
    populationBox.add(Box.createRigidArea(new Dimension(0, 4)));
    populationBox.add(famLabel);
    if (famList.size() > 0) {
      JPanel famBtnBox = new JPanel();
      famBtnBox.setLayout(new BoxLayout(famBtnBox, BoxLayout.LINE_AXIS));
      Dimension sizer2 = new Dimension(350, 50);
      String[] famMenu = genFamMenu(famList);
      famPick = new JComboBox(famMenu);
      famPick.addActionListener(listener);
      famPick.setActionCommand("view/edit family");
      famPick.setMinimumSize(sizer2);
      famPick.setMaximumSize(sizer2);
      famPick.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.blue), "View/Edit Family"));
      famBtnBox.add(famPick);
      populationBox.add(famBtnBox);
    } //  end of if-any-families-exist
    rebuilding = false;
  } //  end of method buildPopulationBox
  public FeaturePaletteScrollPane() {
    this.setBorder(BorderFactory.createTitledBorder("Feature Palette"));
    panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    setViewportView(panel);
    componentName = new JLabel("Component: ");
    componentName.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    componentName.setMinimumSize(new Dimension(200, 20));
    componentName.setMaximumSize(new Dimension(200, 20));
    cmbFeatures = new JComboBox();
    cmbFeatures.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    cmbFeatures.setMinimumSize(new Dimension(200, 20));
    cmbFeatures.setMaximumSize(new Dimension(200, 20));
    cmbValues = new JComboBox();
    cmbValues.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    cmbValues.setMinimumSize(new Dimension(200, 20));
    cmbValues.setMaximumSize(new Dimension(200, 20));
    resetButton = new JButton("Set ALL Features to Default");
    resetButton.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    resetButton.setMinimumSize(new Dimension(200, 20));
    resetButton.setMaximumSize(new Dimension(200, 20));
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    double width = screenSize.getWidth();
    double height = screenSize.getHeight();
    int palettewidth = (int) (width * 0.4);
    int paletteheight = (int) (height * 0.25);
    this.setPreferredSize(new Dimension(palettewidth, paletteheight));
    JLabel blankLabel = new JLabel("");
    blankLabel.setMinimumSize(new Dimension(200, 20));
    blankLabel.setMaximumSize(new Dimension(200, 20));
    blankLabel.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    JLabel blankLabel2 = new JLabel("");
    blankLabel2.setMinimumSize(new Dimension(200, 20));
    blankLabel2.setMaximumSize(new Dimension(200, 20));
    blankLabel2.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    JLabel blankLabel3 = new JLabel("");
    blankLabel3.setMinimumSize(new Dimension(200, 10));
    blankLabel3.setMaximumSize(new Dimension(200, 10));
    blankLabel3.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    panel.add(componentName);
    panel.add(blankLabel);
    panel.add(cmbFeatures);
    panel.add(blankLabel3);
    panel.add(cmbValues);
    panel.add(blankLabel2);
    panel.add(resetButton);

    initComponents();
  }
Esempio n. 4
0
 public HeaderPanel(String heading) {
   super();
   this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
   this.setBackground(background);
   JLabel panelLabel = new JLabel(" " + heading, SwingConstants.LEFT);
   Font labelFont = new Font("Dialog", Font.BOLD, 18);
   panelLabel.setFont(labelFont);
   this.add(panelLabel);
   this.add(Box.createHorizontalGlue());
   refresh = new JButton("Refresh");
   refresh.addActionListener(this);
   this.add(refresh);
   this.add(Box.createHorizontalStrut(5));
   root = new JComboBox();
   Dimension d = root.getPreferredSize();
   d.width = 90;
   root.setPreferredSize(d);
   root.setMaximumSize(d);
   File[] roots = directoryPane.getRoots();
   for (int i = 0; i < roots.length; i++) root.addItem(roots[i].getAbsolutePath());
   this.add(root);
   root.setSelectedIndex(directoryPane.getCurrentRootIndex());
   root.addActionListener(this);
   this.add(Box.createHorizontalStrut(17));
 }
Esempio n. 5
0
  /**
   * Constructs a special JComboBox with all cameras that have only 1 channel
   *
   * @param deviceName
   * @return
   */
  public JComboBox makeSingleCameraDeviceBox(Devices.Keys deviceName, int maximumWidth) {
    List<String> singleCameras = new ArrayList<String>();
    singleCameras.add(0, "");
    String originalCamera = core_.getCameraDevice();
    try {
      StrVector strvDevices = core_.getLoadedDevicesOfType(mmcorej.DeviceType.CameraDevice);
      for (int i = 0; i < strvDevices.size(); i++) {
        String test = strvDevices.get(i);
        core_.setCameraDevice(test);
        if (core_.getNumberOfCameraChannels() == 1) {
          singleCameras.add(test);
        }
      }
    } catch (Exception ex) {
      MyDialogUtils.showError("Error detecting single camera devices");
    } finally {
      try {
        core_.setCameraDevice(originalCamera);
      } catch (Exception e) {
        MyDialogUtils.showError(e);
      }
    }

    JComboBox deviceBox = new JComboBox(singleCameras.toArray());
    deviceBox.addActionListener(new DeviceBoxListener(deviceName, deviceBox));
    deviceBox.setSelectedItem(
        devices_.getMMDevice(deviceName)); // selects whatever device was read in by prefs
    deviceBox.setMaximumSize(new Dimension(maximumWidth, 30));
    return deviceBox;
  }
Esempio n. 6
0
  /**
   * Constructs a special JComboBox with all cameras that have more than 1 channel, which we expect
   * to just be a single Multicamera device
   *
   * @param deviceName
   * @return
   */
  public JComboBox makeMultiCameraDeviceBox(Devices.Keys deviceName, int maximumWidth) {
    List<String> multiCameras = new ArrayList<String>();
    multiCameras.add(0, "");
    try {
      StrVector strvDevices = core_.getLoadedDevicesOfType(mmcorej.DeviceType.CameraDevice);
      for (int i = 0; i < strvDevices.size(); i++) {
        // find all Multi-camera devices (usually just one)
        String test = strvDevices.get(i);
        if (core_.getDeviceLibrary(test).equals(Devices.Libraries.UTILITIES.toString())
            && core_
                .getDeviceDescription(test)
                .equals("Combine multiple physical cameras into a single logical camera")) {
          multiCameras.add(strvDevices.get(i));
        }
      }
    } catch (Exception ex) {
      MyDialogUtils.showError("Error detecting multi camera devices");
    }

    JComboBox deviceBox = new JComboBox(multiCameras.toArray());
    deviceBox.addActionListener(new DeviceBoxListener(deviceName, deviceBox));
    // if we have one and only one multi-camera then set box to it
    if (multiCameras.size() == 2) { // recall we added empty string as the first entry
      deviceBox.setSelectedIndex(1);
    } else {
      deviceBox.setSelectedItem(
          devices_.getMMDevice(deviceName)); // selects whatever device was read in by prefs
    }
    deviceBox.setMaximumSize(new Dimension(maximumWidth, 30));
    return deviceBox;
  }
Esempio n. 7
0
  /** Initialize the layout for the combo box. */
  private void init(Object[] items) {

    this.setTitle("Shell Command");
    this.setResizable(false);
    this.setMinimumSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT));
    this.setMaximumSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT));
    this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT));
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    JPanel mainWindow = new JPanel();
    mainWindow.setLayout(new BoxLayout(mainWindow, BoxLayout.Y_AXIS));
    mainWindow.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT));

    JLabel message = new JLabel("Please enter or select your shell command.");

    mainWindow.add(Box.createVerticalStrut(10));

    JPanel messagePanel = new JPanel();
    messagePanel.setLayout(new BoxLayout(messagePanel, BoxLayout.X_AXIS));
    messagePanel.add(message);
    mainWindow.add(messagePanel);

    mainWindow.add(Box.createVerticalStrut(5));

    comboBox = new JComboBox(items);
    comboBox.setEditable(true);
    comboBox.addActionListener(this);
    comboBox.setPreferredSize(new Dimension(COMBO_BOX_WIDTH, COMBO_BOX_HEIGHT));
    comboBox.setMinimumSize(new Dimension(COMBO_BOX_WIDTH, COMBO_BOX_HEIGHT));
    comboBox.setMaximumSize(new Dimension(COMBO_BOX_WIDTH, COMBO_BOX_HEIGHT));

    JPanel comboPane = new JPanel();
    comboPane.setLayout(new BoxLayout(comboPane, BoxLayout.X_AXIS));
    comboPane.add(comboBox);
    mainWindow.add(comboPane);

    mainWindow.add(Box.createVerticalStrut(5));

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));

    okButton = new JButton("OK");
    okButton.addActionListener(this);
    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);

    buttonPane.add(cancelButton);
    buttonPane.add(okButton);

    mainWindow.add(buttonPane);

    mainWindow.add(Box.createVerticalStrut(5));

    this.add(mainWindow);
    this.pack();
  }
Esempio n. 8
0
  private void populateGeneListComboBoxes() {
    geneClusterCB = new JComboBox();
    geneClusterCB.removeAllItems();
    for (int i = 0; i < framework.getClusterRepository(0).size(); i++) {
      if (framework.getClusterRepository(0).getCluster(i + 1) == null) break;
      Cluster cluster = framework.getClusterRepository(0).getCluster(i + 1);
      geneClusterCB.addItem(
          "Cluster #: " + cluster.getSerialNumber() + ", " + cluster.getClusterLabel());
    }
    geneClusterCB.setVisible(false);
    geneClusterCB.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {

            repaint();
          }
        });
    geneAnnotationCB = new JComboBox(framework.getData().getAllFilledAnnotationFields());
    geneAnnotationCB.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (chartTypeCB.getSelectedIndex() > 1) // this method only applies for single gene
            return;
            geneCB.removeAllItems();
            int selected = Math.max(geneAnnotationCB.getSelectedIndex(), 0);
            int numGenes =
                framework
                    .getData()
                    .getAnnotationList(framework.getData().getAllFilledAnnotationFields()[selected])
                    .length;
            StringExt[] stringext = new StringExt[numGenes];
            String[] geneNames =
                framework
                    .getData()
                    .getAnnotationList(
                        framework.getData().getAllFilledAnnotationFields()[selected]);
            for (int i = 0; i < numGenes; i++) stringext[i] = new StringExt(geneNames[i]);

            DefaultComboBoxModel cbm = new DefaultComboBoxModel(stringext);
            geneCB.setModel(cbm);
          }
        });
    geneCB =
        new JComboBox(
            framework
                .getData()
                .getAnnotationList(framework.getData().getAllFilledAnnotationFields()[0]));
    geneCB.setMaximumSize(new Dimension(150, geneCB.getHeight()));
    geneCB.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            repaint();
          }
        });
  }
Esempio n. 9
0
  protected void addCommonToolbarActions(final SwingEngine swingEngine, JToolBar tb) {
    // copy, paste and undo buttons
    tb.addSeparator();
    addToToolbar(actions.copyAction);
    addToToolbar(actions.pasteAction);
    tb.addSeparator();
    addToToolbar(actions.undoAction);
    tb.addSeparator();

    // zoom drop-down
    addToToolbar(new JLabel("Zoom:", JLabel.LEFT));
    zoomCombo = new JComboBox(actions.zoomActions);
    zoomCombo.setMaximumSize(zoomCombo.getPreferredSize());
    zoomCombo.setEditable(true);
    zoomCombo.setSelectedIndex(5); // 100%
    zoomCombo.addActionListener(new ZoomComboListener());
    addToToolbar(zoomCombo, TB_GROUP_SHOW_IF_VPATHWAY);
    tb.addSeparator();

    // define the drop-down menu for data nodes
    GraphicsChoiceButton datanodeButton = new GraphicsChoiceButton();
    datanodeButton.setToolTipText("Select a data node to draw");
    datanodeButton.addButtons("Data Nodes", actions.newDatanodeActions);
    //		datanodeButton.addButtons("Annotations", actions.newAnnotationActions);
    addToToolbar(datanodeButton, TB_GROUP_SHOW_IF_EDITMODE);
    tb.addSeparator(new Dimension(2, 0));

    // define the drop-down menu for shapes
    GraphicsChoiceButton shapeButton = new GraphicsChoiceButton();
    shapeButton.setToolTipText("Select a shape to draw");
    itemsDropDown = shapeButton;
    shapeButton.addButtons("Basic shapes", actions.newShapeActions);
    shapeButton.addButtons("Cellular components", actions.newCellularComponentActions);
    addToToolbar(shapeButton, TB_GROUP_SHOW_IF_EDITMODE);
    tb.addSeparator(new Dimension(2, 0));

    // define the drop-down menu for interactions
    GraphicsChoiceButton lineButton = new GraphicsChoiceButton();
    lineButton.setToolTipText("Select an interaction to draw");
    lineButton.addButtons("Basic interactions", actions.newInteractionActions);
    lineButton.addButtons("MIM interactions", actions.newMIMInteractionActions);
    addToToolbar(lineButton, TB_GROUP_SHOW_IF_EDITMODE);
    tb.addSeparator(new Dimension(2, 0));

    // define the drop-down menu for templates
    GraphicsChoiceButton templateButton = new GraphicsChoiceButton();
    templateButton.setToolTipText("Select a template to draw");
    templateButton.addButtons("Templates", actions.newTemplateActions);
    addToToolbar(templateButton, TB_GROUP_SHOW_IF_EDITMODE);
    tb.addSeparator();

    // layout actions
    addToToolbar(actions.layoutActions);
  }
Esempio n. 10
0
  /**
   * Sets the combo-boxes to a fixed size so they don't take up too much room that would be better
   * devoted to the test output box.
   */
  protected void setComboSizes() {

    m_TesterClasses.setPreferredSize(COMBO_SIZE);
    m_PanelDatasetResultKeys.setPreferredSize(COMBO_SIZE);
    m_CompareCombo.setPreferredSize(COMBO_SIZE);
    m_SigTex.setPreferredSize(COMBO_SIZE);
    m_SortCombo.setPreferredSize(COMBO_SIZE);

    m_TesterClasses.setMaximumSize(COMBO_SIZE);
    m_PanelDatasetResultKeys.setMaximumSize(COMBO_SIZE);
    m_CompareCombo.setMaximumSize(COMBO_SIZE);
    m_SigTex.setMaximumSize(COMBO_SIZE);
    m_SortCombo.setMaximumSize(COMBO_SIZE);

    m_TesterClasses.setMinimumSize(COMBO_SIZE);
    m_PanelDatasetResultKeys.setMinimumSize(COMBO_SIZE);
    m_CompareCombo.setMinimumSize(COMBO_SIZE);
    m_SigTex.setMinimumSize(COMBO_SIZE);
    m_SortCombo.setMinimumSize(COMBO_SIZE);
  }
Esempio n. 11
0
 public ReferencePropertyWidget(boolean containedByListReferenceGUI) {
   this.containedByListReferenceGUI = containedByListReferenceGUI;
   // get Options
   m_comboBox = new JComboBox();
   m_comboBox.setEditable(false);
   m_comboBox.setPreferredSize(new Dimension(300, 20));
   // m_comboBox.setMinimumSize(new Dimension(260, 20));
   m_comboBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 20));
   KeyStroke controlT = KeyStroke.getKeyStroke("control SPACE");
   getTextField().getInputMap().put(controlT, controlT);
   getTextField().getActionMap().put(controlT, new CodeCompleteAction());
   ToolTipManager.sharedInstance().registerComponent(m_comboBox);
 }
Esempio n. 12
0
  /**
   * adds comboBox to fxz composer toolbar
   *
   * @param toolbar Toolbar to add comboBox at
   * @param comboBox comboBox to add
   * @param index the position in the container's list at which to insert the component; <code>-1
   *     </code> means insert at the end component
   * @param isEditable is comboBox editable
   */
  public static void addCombo(JToolBar toolbar, JComboBox comboBox, int index, boolean isEditable) {
    GridBagConstraints constrains = new GridBagConstraints();
    constrains.anchor = GridBagConstraints.WEST;
    constrains.insets = new Insets(0, 3, 0, 2);

    // @inherited fix of issue #69642. Focus shouldn't stay in toolbar
    comboBox.setFocusable(false);

    Dimension size = comboBox.getPreferredSize();
    comboBox.setPreferredSize(size);
    comboBox.setSize(size);
    comboBox.setMinimumSize(size);
    comboBox.setMaximumSize(size);

    comboBox.setEditable(isEditable);

    toolbar.add(comboBox, constrains, index);
  }
Esempio n. 13
0
 /**
  * Constructs a JComboBox populated with devices of specified Micro-Manager type Attaches a
  * listener and sets selected item to what is specified in the Devices class.
  *
  * @param deviceType - Micro-Manager device type (mmcorej.DeviceType)
  * @param deviceKey - ASi diSPIM device key (see Devices class)
  * @param maximumWidth -
  * @return final JComboBox
  */
 public JComboBox makeDeviceSelectionBox(
     mmcorej.DeviceType deviceType, Devices.Keys deviceKey, int maximumWidth) {
   // when editing this method do the same to the one with array argument too
   JComboBox deviceBox = new JComboBox();
   ArrayList<String> devices = new ArrayList<String>();
   StrVector strvDevices = core_.getLoadedDevicesOfType(deviceType);
   devices.addAll(Arrays.asList(strvDevices.toArray()));
   devices.add(0, "");
   deviceBox.removeAllItems();
   for (String device : devices) {
     deviceBox.addItem(device);
   }
   deviceBox.addActionListener(new DeviceBoxListener(deviceKey, deviceBox));
   deviceBox.setSelectedItem(
       devices_.getMMDevice(deviceKey)); // selects whatever device was read in by prefs
   deviceBox.setMaximumSize(new Dimension(maximumWidth, 30));
   return deviceBox;
 }
  @Inject
  public ProblemSelectionPanel(qcevolutionbackend be) {
    this.setLayout(new BorderLayout());
    backend = be;
    Set<String> probs = backend.getProbmanager().getAvailableProblems();
    String[] options = new String[probs.size() + 1];
    options[0] = "Please Select Problem";
    int index = 1;
    Iterator<String> iter = probs.iterator();
    while (iter.hasNext()) {
      options[index++] = iter.next();
    }
    selection_model = new DefaultComboBoxModel(options);

    description = new JTextPane();
    description.setEditable(false);
    description_scroller = new JScrollPane(description);
    description_scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    description_scroller.setPreferredSize(new Dimension(250, 155));
    description_scroller.setMinimumSize(new Dimension(10, 10));

    if (backend.getCurrentse() != null) {
      String key = backend.getQproblem().getName();
      selection_model.setSelectedItem(key);
      description.setText(backend.getProbmanager().getSearchEngineDesc(key));
    }

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    selection = new JComboBox(selection_model);
    selection.addActionListener(this);
    selection.setPreferredSize(new Dimension((int) (screenSize.width * MainPanel.right_perc), 30));
    selection.setMaximumSize(new Dimension((int) (screenSize.width * MainPanel.right_perc), 30));

    be.addObserver(this);
    be.getProbmanager().addObserver(this);
    if (null != backend.getCurrentse()) {
      backend.getCurrentse().addObserver(this);
    }

    this.add(selection, BorderLayout.NORTH);
    this.add(description_scroller, BorderLayout.CENTER);
  }
  private JPanel createLeftPanel() {
    JPanel left = new JPanel();
    left.setLayout(new BoxLayout(left, BoxLayout.X_AXIS));

    imagesCombo = new JComboBox();
    imagesCombo.addItem("Thresholded");
    imagesCombo.addItem("Filtered");
    imagesCombo.addActionListener(this);
    imagesCombo.setSelectedIndex(1);
    imagesCombo.setMaximumSize(imagesCombo.getPreferredSize());

    selectThresh = new SelectHistogramThresholdPanel(20, true);
    selectThresh.setListener(this);

    left.add(imagesCombo);
    left.add(selectThresh);
    left.add(Box.createHorizontalGlue());

    return left;
  }
  private StaticPanel createStaticComboBoxPanel(
      PrimitiveForm primitiveForm, DOTProperty property, String labelText, Object[] items) {
    JLabel label = new JLabel(labelText);
    JComboBox comboBox = new JComboBox(items);
    comboBox.setMaximumSize(new Dimension(300, 25));
    comboBox.setEnabled(_dotDefinitionDialogFrame.isEditable());

    StaticPanel thePanel = new StaticPanel(primitiveForm, property);
    thePanel.setMaximumSize(new Dimension(300, 25));
    thePanel.setLayout(new SpringLayout());
    thePanel.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK));
    thePanel.add(label);
    thePanel.add(comboBox);
    SpringUtilities.makeCompactGrid(thePanel, 2, 5, 5);

    thePanel.setValue(comboBox);
    thePanel.addListener(comboBox);

    return thePanel;
  }
Esempio n. 17
0
  public void resetComboDimension(List<?> choices) {
    double w = 0;
    if (choices != null) {
      double longest = 0;
      for (int i = 0; i < choices.size(); i++) {
        try {
          w = getFontMetrics(getFont()).stringWidth(choices.get(i).toString());
          if (w > longest) longest = w;
        } catch (Exception ex) {
        }
      }

      w = longest + 25;
    }
    if (w < textDim.width) w = textDim.width;
    Dimension dim = new Dimension((int) w, textDim.height);
    jcb.setMinimumSize(dim);
    jcb.setMaximumSize(dim);
    jcb.setPreferredSize(dim);
  }
Esempio n. 18
0
  public static JComboBox addComboBox(
      Function method,
      int index,
      String[] arguments,
      String tooltip,
      boolean enabled,
      boolean visible,
      final IClientPluginAccess pluginAccess) {
    JComboBox box = new JComboBox(arguments);
    box.setPrototypeDisplayValue("XXXXXXXX"); // Set a desired width //$NON-NLS-1$
    box.setMaximumSize(box.getMinimumSize());
    box.setSelectedIndex(index);
    box.setEnabled(enabled);
    box.setVisible(visible);
    box.setToolTipText(tooltip);

    final FunctionDefinition functionDef = new FunctionDefinition(method);
    box.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JComboBox source = (JComboBox) e.getSource();

            Object args[] = new Object[4];

            args[0] = ((Toolbar) source.getParent()).getName();
            args[1] = ((Toolbar) source.getParent()).getDisplayName();
            args[2] = new Boolean(false);
            args[3] = source.getSelectedItem();

            try {
              functionDef.executeAsync(pluginAccess, args);
            } catch (Exception e1) {
              Debug.error(e1);
            }
          }
        });

    return box;
  }
Esempio n. 19
0
  /*
   * Create and set up a new CoreqPanel that is the correct size. Do not allow the user to modify any
   * of the characteristics of the panel; the panel will be the same for any course.
   */
  public CoreqPanel() {
    this.setMinimumSize(new Dimension(800, 25));
    this.setMaximumSize(new Dimension(2600, 26));
    this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    coreqField = new JTextField();
    coreqField.setMinimumSize(new Dimension(300, 20));
    coreqField.setMaximumSize(new Dimension(2000, 21));

    coreqType = new JComboBox();
    coreqType.addItem("Credits");
    coreqType.addItem("Course");
    coreqType.addItem("Requirement");

    coreqType.setMinimumSize(new Dimension(100, 20));
    coreqType.setMaximumSize(new Dimension(100, 21));
    JLabel coreqName = new JLabel("Name of Corequisite: ");

    this.add(coreqName);
    this.add(coreqField);
    this.add(Box.createRigidArea(new Dimension(10, 0)));
    this.add(coreqType);
    this.add(Box.createGlue());
  }
Esempio n. 20
0
 void jbInit() throws Exception {
   border1 = BorderFactory.createEmptyBorder(10, 10, 5, 5);
   panel1.setLayout(borderLayout1);
   jPanel1.setLayout(borderLayout2);
   jScrollPane1.getViewport().setBackground(Color.white);
   jPanel2.setLayout(gridBagLayout1);
   jLabel1.setText("Profile Name : ");
   nameTextField.setMinimumSize(new Dimension(4, 18));
   nameTextField.setPreferredSize(new Dimension(63, 18));
   jLabel2.setText("Profile Type : ");
   openButton.setMaximumSize(new Dimension(73, 24));
   openButton.setMinimumSize(new Dimension(73, 24));
   openButton.setPreferredSize(new Dimension(73, 24));
   openButton.setText("Open");
   openButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           openButton_actionPerformed(e);
         }
       });
   cancelButton.setMaximumSize(new Dimension(73, 24));
   cancelButton.setMinimumSize(new Dimension(73, 24));
   cancelButton.setPreferredSize(new Dimension(73, 24));
   cancelButton.setMargin(new Insets(0, 5, 0, 5));
   cancelButton.setText("Cancel");
   cancelButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           cancelButton_actionPerformed(e);
         }
       });
   profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   profileList.addMouseListener(
       new java.awt.event.MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           profileList_mouseClicked(e);
         }
       });
   jPanel2.setBorder(border1);
   typeComboBox.setMaximumSize(new Dimension(32767, 18));
   typeComboBox.setMinimumSize(new Dimension(122, 18));
   typeComboBox.setPreferredSize(new Dimension(176, 18));
   getContentPane().add(panel1);
   panel1.add(jPanel1, BorderLayout.CENTER);
   jPanel1.add(jScrollPane1, BorderLayout.CENTER);
   panel1.add(jPanel2, BorderLayout.SOUTH);
   jPanel2.add(
       jLabel1,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 7, 0),
           0,
           0));
   jPanel2.add(
       nameTextField,
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 11, 7, 0),
           0,
           0));
   jPanel2.add(
       jLabel2,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 17, 0),
           0,
           0));
   jScrollPane1.getViewport().add(profileList, null);
   jPanel2.add(
       openButton,
       new GridBagConstraints(
           3,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 11, 2, 10),
           0,
           0));
   jPanel2.add(
       cancelButton,
       new GridBagConstraints(
           3,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 11, 9, 10),
           0,
           0));
   jPanel2.add(
       typeComboBox,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 11, 17, 0),
           0,
           0));
 }
Esempio n. 21
0
  private void createGUI() {
    setTitle(textField ? app.getPlain("TextField") : app.getPlain("Button"));
    setResizable(false);

    // create caption panel
    JLabel captionLabel = new JLabel(app.getMenu("Button.Caption") + ":");
    String initString = button == null ? "" : button.getCaption();
    InputPanel ip = new InputPanel(initString, app, 1, 15, true);
    tfCaption = ip.getTextComponent();
    if (tfCaption instanceof AutoCompleteTextField) {
      AutoCompleteTextField atf = (AutoCompleteTextField) tfCaption;
      atf.setAutoComplete(false);
    }

    captionLabel.setLabelFor(tfCaption);
    JPanel captionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    captionPanel.add(captionLabel);
    captionPanel.add(ip);

    // combo box to link GeoElement to TextField
    comboModel = new DefaultComboBoxModel();
    TreeSet sortedSet = app.getKernel().getConstruction().getGeoSetNameDescriptionOrder();

    final JComboBox cbAdd = new JComboBox(comboModel);

    if (textField) {
      // lists for combo boxes to select input and output objects
      // fill combobox models
      Iterator it = sortedSet.iterator();
      comboModel.addElement(null);
      FontMetrics fm = getFontMetrics(getFont());
      int width = (int) cbAdd.getPreferredSize().getWidth();
      while (it.hasNext()) {
        GeoElement geo = (GeoElement) it.next();
        if (!geo.isGeoImage() && !(geo.isGeoButton()) && !(geo.isGeoBoolean())) {
          comboModel.addElement(geo);
          String str = geo.toString();
          if (width < fm.stringWidth(str)) width = fm.stringWidth(str);
        }
      }

      // make sure it's not too wide (eg long GeoList)
      Dimension size =
          new Dimension(
              Math.min(app.getScreenSize().width / 2, width), cbAdd.getPreferredSize().height);
      cbAdd.setMaximumSize(size);
      cbAdd.setPreferredSize(size);

      if (comboModel.getSize() > 1) {

        // listener for the combobox
        MyComboBoxListener ac =
            new MyComboBoxListener() {
              public void doActionPerformed(Object source) {
                GeoElement geo = (GeoElement) cbAdd.getSelectedItem();
                // if (geo == null)
                // {
                //
                //	return;
                // }

                linkedGeo = geo;
                // ((GeoTextField)button).setLinkedGeo(geo);

                cbAdd.removeActionListener(this);

                // cbAdd.setSelectedItem(null);
                cbAdd.addActionListener(this);
              }
            };
        cbAdd.addActionListener(ac);
        cbAdd.addMouseListener(ac);

        captionPanel.add(cbAdd);
      }
    }

    // create script panel
    JLabel scriptLabel = new JLabel(app.getPlain("Script") + ":");
    initString = (button == null) ? "" : button.getClickScript();
    InputPanel ip2 = new InputPanel(initString, app, 10, 40, false);
    tfScript = ip2.getTextComponent();
    if (tfScript instanceof AutoCompleteTextField) {
      AutoCompleteTextField atf = (AutoCompleteTextField) tfScript;
      atf.setAutoComplete(false);
    }

    scriptLabel.setLabelFor(tfScript);
    JPanel scriptPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    scriptPanel.add(scriptLabel);
    scriptPanel.add(ip2);

    JPanel linkedPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JLabel linkedLabel = new JLabel(app.getPlain("LinkedObject") + ":");
    linkedPanel.add(linkedLabel);
    linkedPanel.add(cbAdd);

    // buttons
    btApply = new JButton(app.getPlain("Apply"));
    btApply.setActionCommand("Apply");
    btApply.addActionListener(this);
    btCancel = new JButton(app.getPlain("Cancel"));
    btCancel.setActionCommand("Cancel");
    btCancel.addActionListener(this);
    btPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    btPanel.add(btApply);
    btPanel.add(btCancel);

    // Create the JOptionPane.
    optionPane = new JPanel(new BorderLayout(5, 5));

    // create object list
    optionPane.add(captionPanel, BorderLayout.NORTH);
    if (textField) optionPane.add(linkedPanel, BorderLayout.CENTER);
    else optionPane.add(scriptPanel, BorderLayout.CENTER);
    optionPane.add(btPanel, BorderLayout.SOUTH);
    optionPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    // Make this dialog display it.
    setContentPane(optionPane);

    /*

    inputPanel = new InputPanel("ggbApplet.evalCommand('A=(3,4)');", app, 10, 50, false, true, false );
    inputPanel2 = new InputPanel("function func() {\n}", app, 10, 50, false, true, false );

    JPanel centerPanel = new JPanel(new BorderLayout());

    centerPanel.add(inputPanel, BorderLayout.CENTER);
    centerPanel.add(inputPanel2, BorderLayout.SOUTH);
    getContentPane().add(centerPanel, BorderLayout.CENTER);
    //centerOnScreen();

    setContentPane(centerPanel);
    pack();
    setLocationRelativeTo(app.getFrame());	*/
  }
Esempio n. 22
0
  private void createStreamingButtons(JPanel panel) {
    JPanel subPanel = new JPanel();
    subPanel.setLayout(new BoxLayout(subPanel, BoxLayout.PAGE_AXIS));
    panel.add(subPanel);

    subPanel.add(new JLabel("Streaming:"));

    String streamingTypes[] = {
      DataTypes.title(DataTypes.DataType.THRESH),
      DataTypes.title(DataTypes.DataType.IMAGE),
      DataTypes.title(DataTypes.DataType.OBJECTS)
    };
    JComboBox streamComboBox = new JComboBox(streamingTypes);

    Dimension maxDim = new Dimension(200, 40);
    Dimension prefDim = new Dimension(200, 40);
    streamComboBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    streamComboBox.setMaximumSize(maxDim);
    streamComboBox.setPreferredSize(prefDim);

    streamComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JComboBox box = (JComboBox) e.getSource();
            if (box.getSelectedItem() == DataTypes.title(DataTypes.DataType.THRESH)) {
              streamType = DataTypes.DataType.THRESH;
            } else if (box.getSelectedItem() == DataTypes.title(DataTypes.DataType.IMAGE)) {
              streamType = DataTypes.DataType.IMAGE;
            } else if (box.getSelectedItem() == DataTypes.title(DataTypes.DataType.OBJECTS)) {
              streamType = DataTypes.DataType.OBJECTS;
            }
          }
        });

    subPanel.add(streamComboBox);

    startStopButton = new JButton("Start");
    startStopButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (selectedRobot == null) return;

            // Assuming we are using proper directory structure,
            // set the default save folder to
            // $ROBOCUP/man/frames/stream.

            if (saveFramePath == null) {
              if (tool.CONSOLE.pathExists("../man/frames/stream")) {
                saveFramePath = tool.CONSOLE.formatPath("../man/frames/stream");
              } else {
                saveFramePath = tool.CONSOLE.promptDirOpen("Save Destination", "../man/frames");
              }
            }

            if (saveFramePath == null) return;

            isStreaming = !isStreaming;

            if (isStreaming) {
              startStopButton.setText("Stop");
            } else {
              startStopButton.setText("Start");
            }
          }
        });
    subPanel.add(startStopButton);

    JButton frameDestButton = new JButton("Set destination");
    frameDestButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveFramePath = tool.CONSOLE.promptDirOpen("Save Destination", saveFramePath);
          }
        });
    subPanel.add(frameDestButton);

    saveStreamBox = new JCheckBox("Save stream");
    saveStreamBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
              isSavingStream = true;
            } else if (e.getStateChange() == ItemEvent.DESELECTED) {
              isSavingStream = false;
            }
          }
        });
    subPanel.add(saveStreamBox);
  }
  private JPanel createAttributePanel() {
    JPanel attributePanel = new JPanel();
    attributePanel.setLayout(new BoxLayout(attributePanel, BoxLayout.Y_AXIS));

    JLabel label = new JLabel("Attribute");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    attributePanel.add(label);

    attributeCombo = new JComboBox<String>();
    for (String attribute : getAttributes(true)) {
      attributeCombo.addItem(attribute);
    }
    attributeCombo.setAlignmentX(Component.LEFT_ALIGNMENT);
    attributeCombo.setPreferredSize(new Dimension(220, attributeCombo.getPreferredSize().height));
    attributeCombo.setMaximumSize(new Dimension(220, attributeCombo.getPreferredSize().height));
    attributePanel.add(attributeCombo);

    attributePanel.add(Box.createRigidArea(new Dimension(0, 10)));

    label = new JLabel("Edge Weight Attribute");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    attributePanel.add(label);

    weightCombo = new JComboBox<String>();
    weightCombo.addItem(NONE);
    for (String attribute : getAttributes(false)) {
      weightCombo.addItem(attribute);
    }
    weightCombo.setAlignmentX(Component.LEFT_ALIGNMENT);
    weightCombo.setPreferredSize(new Dimension(220, weightCombo.getPreferredSize().height));
    weightCombo.setMaximumSize(new Dimension(220, weightCombo.getPreferredSize().height));
    attributePanel.add(weightCombo);

    attributePanel.add(Box.createRigidArea(new Dimension(0, 10)));

    label = new JLabel("Edge Width");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    attributePanel.add(label);

    countRadio = new JRadioButton("Count");
    statisticsRadio = new JRadioButton("Statistics");
    groupButtons(countRadio, statisticsRadio);

    ActionListener radioListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateEnablement();
          }
        };

    countRadio.addActionListener(radioListener);
    statisticsRadio.addActionListener(radioListener);

    attributePanel.add(countRadio);
    attributePanel.add(statisticsRadio);

    attributePanel.add(Box.createRigidArea(new Dimension(0, 10)));

    label = new JLabel("Options");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    attributePanel.add(label);

    removeSelfEdges = new JCheckBox("Remove self edges");
    singleNodesCheck = new JCheckBox("Include single nodes");

    attributePanel.add(removeSelfEdges);
    attributePanel.add(singleNodesCheck);

    return attributePanel;
  }
Esempio n. 24
0
  private void build() {
    // ============= le panel du dialog
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // ================================
    catBox = new JComboBox(categories);
    catBox.setMinimumSize(new Dimension(150, 60));
    catBox.setMaximumSize(new Dimension(2000, 80));
    catBox.setBorder(BorderFactory.createTitledBorder("TYPE"));
    catBox.addFocusListener(this);
    panel.add(catBox);

    // ========= Le nom du nouveau media
    nameField.setMinimumSize(new Dimension(150, 60));
    nameField.setMaximumSize(new Dimension(2000, 80));
    nameField.setBorder(BorderFactory.createTitledBorder("NAME"));
    nameField.addFocusListener(this);
    nameField.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            nameField.selectAll();
          }

          public void focusLost(FocusEvent e) {}
        });
    panel.add(nameField);

    // ========== La release date par default
    dateChooser.setMinimumSize(new Dimension(150, 60));
    dateChooser.setMaximumSize(new Dimension(2000, 80));
    dateChooser.setFormats(UiConfig.getProperty(UiConfig.LONG_DATE_FORMAT));
    dateChooser.setDate(new Date());
    dateChooser.setBorder(BorderFactory.createTitledBorder("RELEASE DATE"));
    panel.add(dateChooser);

    // ============
    formatField.setMinimumSize(new Dimension(150, 60));
    formatField.setMaximumSize(new Dimension(2000, 80));
    formatField.setBorder(BorderFactory.createTitledBorder("FORMAT(experimental)"));
    formatField.addFocusListener(this);
    formatField.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            formatField.selectAll();
          }

          public void focusLost(FocusEvent e) {}
        });
    panel.add(formatField);

    // ============ Le bouton ok
    okButton.setActionCommand("CREATE");
    okButton.setToolTipText("Create " + catBox.getSelectedItem() + " " + nameField.getText());
    okButton.addActionListener(this);
    Icon icon1 = ThemeIcon.SAVE.d32x32();
    if (icon1 != null) {
      okButton.setText("");
      okButton.setIcon(icon1);
    }

    // =========== Le bouton cancel
    cancelButton.setActionCommand("CANCEL");
    cancelButton.addActionListener(this);
    cancelButton.setToolTipText("Cancel");
    Icon icon2 = ThemeIcon.CANCEL.d32x32();
    if (icon2 != null) {
      cancelButton.setText("");
      cancelButton.setIcon(icon2);
    }

    // =========== La toolBar
    toolBar.add(okButton);
    toolBar.add(cancelButton);
    panel.add(new JLabel());
    panel.add(toolBar);
    toolBar.setAlignmentX(CENTER_ALIGNMENT);
  }
Esempio n. 25
0
  private JComponent getButtonPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    choiceType = new JComboBox<PersonTypeItem>();
    choiceType.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceType.getPreferredSize().getHeight()));
    DefaultComboBoxModel<PersonTypeItem> personTypeModel = new DefaultComboBoxModel<>();
    personTypeModel.addElement(
        new PersonTypeItem(resourceMap.getString("primaryRole.choice.text"), null)); // $NON-NLS-1$
    for (int i = 1; i < Person.T_NUM; ++i) {
      personTypeModel.addElement(
          new PersonTypeItem(Person.getRoleDesc(i, campaign.getFaction().isClan()), i));
    }
    personTypeModel.addElement(
        new PersonTypeItem(Person.getRoleDesc(0, campaign.getFaction().isClan()), 0));
    // Add "none" for generic AsTechs
    choiceType.setModel(personTypeModel);
    choiceType.setSelectedIndex(0);
    choiceType.addActionListener(
        e -> {
          personnelFilter.setPrimaryRole(((PersonTypeItem) choiceType.getSelectedItem()).id);
          updatePersonnelTable();
        });
    panel.add(choiceType);

    choiceExp = new JComboBox<PersonTypeItem>();
    choiceExp.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceType.getPreferredSize().getHeight()));
    DefaultComboBoxModel<PersonTypeItem> personExpModel = new DefaultComboBoxModel<>();
    personExpModel.addElement(
        new PersonTypeItem(resourceMap.getString("experience.choice.text"), null)); // $NON-NLS-1$
    for (int i = 0; i < 5; ++i) {
      personExpModel.addElement(new PersonTypeItem(SkillType.getExperienceLevelName(i), i));
    }
    choiceExp.setModel(personExpModel);
    choiceExp.setSelectedIndex(0);
    choiceExp.addActionListener(
        e -> {
          personnelFilter.setExpLevel(((PersonTypeItem) choiceExp.getSelectedItem()).id);
          updatePersonnelTable();
        });
    panel.add(choiceExp);

    choiceSkill = new JComboBox<String>();
    choiceSkill.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceSkill.getPreferredSize().getHeight()));
    DefaultComboBoxModel<String> personSkillModel = new DefaultComboBoxModel<>();
    personSkillModel.addElement(choiceNoSkill);
    for (String skill : SkillType.getSkillList()) {
      personSkillModel.addElement(skill);
    }
    choiceSkill.setModel(personSkillModel);
    choiceSkill.setSelectedIndex(0);
    choiceSkill.addActionListener(
        e -> {
          if (choiceNoSkill.equals(choiceSkill.getSelectedItem())) {
            personnelFilter.setSkill(null);
            ((SpinnerNumberModel) skillLevel.getModel()).setMaximum(10);
            buttonSpendXP.setEnabled(false);
          } else {
            String skillName = (String) choiceSkill.getSelectedItem();
            personnelFilter.setSkill(skillName);
            int maxSkillLevel = SkillType.getType(skillName).getMaxLevel();
            int currentLevel = (Integer) skillLevel.getModel().getValue();
            ((SpinnerNumberModel) skillLevel.getModel()).setMaximum(maxSkillLevel);
            if (currentLevel > maxSkillLevel) {
              skillLevel.getModel().setValue(Integer.valueOf(maxSkillLevel));
            }
            buttonSpendXP.setEnabled(true);
          }
          updatePersonnelTable();
        });
    panel.add(choiceSkill);

    panel.add(Box.createRigidArea(new Dimension(10, 10)));
    panel.add(new JLabel(resourceMap.getString("targetSkillLevel.text"))); // $NON-NLS-1$

    skillLevel = new JSpinner(new SpinnerNumberModel(10, 0, 10, 1));
    skillLevel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) skillLevel.getPreferredSize().getHeight()));
    skillLevel.addChangeListener(
        e -> {
          personnelFilter.setMaxSkillLevel((Integer) skillLevel.getModel().getValue());
          updatePersonnelTable();
        });
    panel.add(skillLevel);

    allowPrisoners = new JCheckBox(resourceMap.getString("allowPrisoners.text")); // $NON-NLS-1$
    allowPrisoners.setHorizontalAlignment(SwingConstants.LEFT);
    allowPrisoners.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) allowPrisoners.getPreferredSize().getHeight()));
    allowPrisoners.addChangeListener(
        e -> {
          personnelFilter.setAllowPrisoners(allowPrisoners.isSelected());
          updatePersonnelTable();
        });
    JPanel allowPrisonersPanel = new JPanel(new GridLayout(1, 1));
    allowPrisonersPanel.setAlignmentY(JComponent.LEFT_ALIGNMENT);
    allowPrisonersPanel.add(allowPrisoners);
    allowPrisonersPanel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) allowPrisonersPanel.getPreferredSize().getHeight()));
    panel.add(allowPrisonersPanel);

    panel.add(Box.createVerticalGlue());

    matchedPersonnelLabel = new JLabel(""); // $NON-NLS-1$
    matchedPersonnelLabel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) matchedPersonnelLabel.getPreferredSize().getHeight()));
    panel.add(matchedPersonnelLabel);

    JPanel buttons = new JPanel(new FlowLayout());
    buttons.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) buttons.getPreferredSize().getHeight()));

    buttonSpendXP = new JButton(resourceMap.getString("spendXP.text")); // $NON-NLS-1$
    buttonSpendXP.setEnabled(false);
    buttonSpendXP.addActionListener(e -> spendXP());
    buttons.add(buttonSpendXP);

    JButton button = new JButton(resourceMap.getString("close.text")); // $NON-NLS-1$
    button.addActionListener(e -> setVisible(false));
    buttons.add(button);

    panel.add(buttons);

    panel.setMaximumSize(new Dimension((int) panel.getPreferredSize().getWidth(), Short.MAX_VALUE));
    panel.setMinimumSize(new Dimension((int) panel.getPreferredSize().getWidth(), 300));

    return panel;
  }
Esempio n. 26
0
  public LingDisplay(final Ling.StoredGraphs storedGraphs) {
    this.storedGraphs = storedGraphs;

    if (storedGraphs.getNumGraphs() == 0) {
      workbench = new GraphWorkbench();
    } else {
      workbench = new GraphWorkbench(storedGraphs.getGraph(0));
    }

    subsetIndices = getStableIndices(storedGraphs);

    final SpinnerNumberModel model =
        new SpinnerNumberModel(subsetIndices.size() == 0 ? 0 : 1, 0, subsetIndices.size(), 1);
    model.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            int index = model.getNumber().intValue();
            workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1)));
          }
        });

    spinner = new JSpinner();
    subsetCombo = new JComboBox(new String[] {"Show Stable", "Show Unstable", "Show All"});
    subsetCombo.setSelectedItem("Show Stable");
    spinner.setModel(model);
    totalLabel = new JLabel(" of " + subsetIndices.size());

    subsetCombo.setMaximumSize(subsetCombo.getPreferredSize());
    subsetCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            resetDisplay();
          }
        });

    spinner.setPreferredSize(new Dimension(50, 20));
    spinner.setMaximumSize(spinner.getPreferredSize());
    Box b = Box.createVerticalBox();
    Box b1 = Box.createHorizontalBox();
    //        b1.add(Box.createHorizontalGlue());
    //        b1.add(Box.createHorizontalStrut(10));
    b1.add(subsetCombo);
    b1.add(Box.createHorizontalGlue());
    b1.add(new JLabel("DAG "));
    b1.add(spinner);
    b1.add(totalLabel);

    b.add(b1);

    Box b2 = Box.createHorizontalBox();
    JPanel graphPanel = new JPanel();
    graphPanel.setLayout(new BorderLayout());
    JScrollPane jScrollPane = new JScrollPane(workbench);
    //        jScrollPane.setPreferredSize(new Dimension(400, 400));
    graphPanel.add(jScrollPane);
    //        graphPanel.setBorder(new TitledBorder("DAG"));
    b2.add(graphPanel);
    b.add(b2);

    setLayout(new BorderLayout());
    //        add(menuBar(), BorderLayout.NORTH);
    add(b, BorderLayout.CENTER);
  }
  private void initGui(AnnotatedFeatureI annot) {
    translationViewer = new TranslationViewer(editorPanel);
    translationViewer.setBackground(Color.black);
    transcriptComboBox = new JComboBox();
    lengthLabel = new JLabel("Translation length: <no feature selected>");
    lengthLabel.setForeground(Color.black);
    findButton = new JButton("Find sequence...");
    clearFindsButton = new JButton("Clear search hits");
    // Disable until we actually get search results
    clearFindsButton.setEnabled(false);

    goToButton = new JButton("GoTo...");
    showIntronBox = new JCheckBox("Show introns in translation viewer", true);
    showIntronBox.setBackground(Color.white);
    followSelectionCheckBox = new JCheckBox("Follow external selection", false);
    followSelectionCheckBox.setBackground(Color.white);
    upstream_button = new JButton();
    downstream_button = new JButton();

    colorSwatch = new JPanel();

    setSize(824, 500);
    JScrollPane pane = new JScrollPane(editorPanel);
    pane.setHorizontalScrollBarPolicy(
        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); // RAY: SET SCROLL POLICY HERE! WAS
    // HORIZONTAL_SCROLLBAR_NEVER

    // pane.setColumnHeaderView(new BaseFineEditorRowHeader(editorPanel)); // RAY: setRowHeader need
    // to create column header
    pane.setColumnHeaderView(new BaseFineEditorHorizontalColHeader(editorPanel));
    viewport = pane.getViewport();
    colorSwatch.setPreferredSize(new Dimension(10, 10));

    getContentPane().setBackground(Color.white);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(colorSwatch, "North");
    getContentPane().add(pane, "Center");

    Box transcriptListBox = new Box(BoxLayout.X_AXIS);
    JLabel tranLabel;
    // 1 LEVEL ANNOT
    if (annot.isAnnotTop()) tranLabel = new JLabel("Annotation: ");
    else // 3-level
    tranLabel = new JLabel("Transcript: ");
    tranLabel.setForeground(Color.black);
    transcriptListBox.add(Box.createHorizontalStrut(5));
    transcriptListBox.add(tranLabel);
    transcriptListBox.setBackground(Color.white);
    transcriptComboBox.setMaximumSize(new Dimension(300, 30));
    transcriptListBox.add(transcriptComboBox);
    transcriptListBox.add(Box.createHorizontalGlue());
    transcriptListBox.add(Box.createHorizontalStrut(5));
    transcriptListBox.add(lengthLabel);
    transcriptListBox.add(Box.createHorizontalGlue());

    Box checkboxesTop = new Box(BoxLayout.X_AXIS);
    checkboxesTop.setBackground(Color.white);
    checkboxesTop.add(Box.createHorizontalStrut(5));
    checkboxesTop.add(findButton);
    checkboxesTop.add(Box.createHorizontalStrut(10));
    checkboxesTop.add(clearFindsButton);
    checkboxesTop.add(Box.createHorizontalStrut(15));
    checkboxesTop.add(goToButton);
    checkboxesTop.add(Box.createHorizontalGlue());
    Box checkboxesBottom = new Box(BoxLayout.X_AXIS);
    checkboxesBottom.add(showIntronBox);
    checkboxesBottom.add(Box.createHorizontalGlue());
    checkboxesBottom.add(Box.createHorizontalStrut(10));
    checkboxesBottom.add(followSelectionCheckBox);
    Box checkboxes = new Box(BoxLayout.Y_AXIS);
    checkboxes.add(checkboxesTop);
    checkboxes.add(checkboxesBottom);

    Box labelPanel = new Box(BoxLayout.Y_AXIS);
    labelPanel.setBackground(Color.white);
    labelPanel.add(transcriptListBox);
    labelPanel.add(Box.createVerticalStrut(5));
    labelPanel.add(checkboxes);

    Box navPanel = new Box(BoxLayout.Y_AXIS);
    navPanel.setBackground(Color.white);
    navPanel.add(upstream_button);
    navPanel.add(Box.createVerticalStrut(10));
    navPanel.add(downstream_button);
    navPanel.add(Box.createVerticalGlue());

    Box textBoxes = new Box(BoxLayout.X_AXIS);
    textBoxes.setBackground(Color.white);
    textBoxes.add(labelPanel);
    textBoxes.add(navPanel);

    Box detailPanel = new Box(BoxLayout.Y_AXIS);
    detailPanel.setBackground(Color.white);
    detailPanel.add(translationViewer);
    detailPanel.add(textBoxes);
    getContentPane().add(detailPanel, "South");

    validateTree();
    scrollListener = new FineEditorScrollListener();
    viewport.addChangeListener(scrollListener);

    transcriptComboBox.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_U && (e.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
              CurationManager.getActiveCurationState().getTransactionManager().undo(this);
            }
          }
        });
  }
Esempio n. 28
0
  private JPanel buildMainContentPane() {
    JPanel backPanel = new JPanel();
    backPanel.setSize(600, 400);
    backPanel.setLayout(new BoxLayout(backPanel, BoxLayout.Y_AXIS));
    backPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.LINE_AXIS));
    // mainPanel.setBorder(BorderFactory.createEmptyBorder(0,0,20,0));
    final JTextArea textArea = new JTextArea("Type your troll text here");
    textArea.addKeyListener(
        new KeyListener() {

          @Override
          public void keyTyped(KeyEvent arg0) {}

          @Override
          public void keyReleased(KeyEvent arg0) {
            if (autoupdate) destinationGUI.setTextCenter(textArea.getText());
          }

          @Override
          public void keyPressed(KeyEvent arg0) {}
        });
    textArea.setPreferredSize(new Dimension(260, 200));
    textArea.setMaximumSize(new Dimension(260, 200));
    textArea.setMinimumSize(new Dimension(260, 200));
    mainPanel.add(textArea);

    JPanel settingsPanel = new JPanel();
    settingsPanel.setSize(150, 220);
    settingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
    settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS));

    // CheckBox - Mise à jour auto du texte
    JCheckBox autoUpdateCB = new JCheckBox("Mise à jour auto du texte");
    autoUpdateCB.setSelected(autoupdate);
    autoUpdateCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            autoupdate = !autoupdate;
          }
        });
    autoUpdateCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(autoUpdateCB);

    // CheckBox - Mise à jour auto de la couleur du texte
    JCheckBox autoUpdateTextColorCB = new JCheckBox("Mise à jour auto de la couleur du texte");
    autoUpdateTextColorCB.setSelected(autoupdateTextColor);
    autoUpdateTextColorCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            autoupdateTextColor = !autoupdateTextColor;
          }
        });
    autoUpdateTextColorCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(autoUpdateTextColorCB);

    // CheckBox - Mise à jour auto de la couleur d'arri�re plan
    JCheckBox autoUpdateBackgroundColorCB =
        new JCheckBox("Mise à jour auto de la couleur d'arrière-plan");
    autoUpdateBackgroundColorCB.setSelected(autoupdateBackgroundColor);
    autoUpdateBackgroundColorCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            autoupdateBackgroundColor = !autoupdateBackgroundColor;
          }
        });
    autoUpdateBackgroundColorCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(autoUpdateBackgroundColorCB);

    // Checkbox - MAJ auto de la taille du texte
    JCheckBox autoUpdateTextSizeCB = new JCheckBox("Mise à jour auto de la taille du texte");
    autoUpdateTextSizeCB.setSelected(autoupdateTextSize);
    autoUpdateTextSizeCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            autoupdateTextSize = !autoupdateTextSize;
          }
        });
    autoUpdateTextSizeCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(autoUpdateTextSizeCB);

    // Chekbox - fullscreen on second Screen
    JCheckBox fullscreenCB = new JCheckBox("Activer le plein écran sur le deuxième écran");
    fullscreenCB.setSelected(fullscreen);
    fullscreenCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            fullscreen = !fullscreen;
          }
        });
    fullscreenCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(fullscreenCB);

    JPanel backgroundColorPanel = new JPanel();
    backgroundColorPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    final JPanel backgroundColorPreviewPanel = new JPanel();
    backgroundColorPreviewPanel.setMaximumSize(new Dimension(50, 25));
    backgroundColorPreviewPanel.setPreferredSize(new Dimension(50, 25));
    backgroundColorPreviewPanel.setBackground(backgroundColor);

    JButton backgroundColorButton = new JButton("Choisir la couleur d'arrière-plan");
    backgroundColorButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            Color newColor =
                JColorChooser.showDialog(colorChooser, "Couleur d'arrière-plan", backgroundColor);
            if (newColor != null) {
              backgroundColor = newColor;
              backgroundColorPreviewPanel.setBackground(backgroundColor);
              if (autoupdateBackgroundColor) destinationGUI.setBackgroundColor(backgroundColor);
            }
          }
        });
    backgroundColorPanel.add(backgroundColorPreviewPanel);
    backgroundColorPanel.add(backgroundColorButton);
    backgroundColorPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(backgroundColorPanel);

    JPanel textColorPanel = new JPanel();
    textColorPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    final JPanel textColorPreviewPanel = new JPanel();
    textColorPreviewPanel.setMaximumSize(new Dimension(50, 25));
    textColorPreviewPanel.setPreferredSize(new Dimension(50, 25));
    textColorPreviewPanel.setBackground(textColor);

    JButton textColorButton = new JButton("Choisir la couleur du texte");
    textColorButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            Color newColor = JColorChooser.showDialog(colorChooser, "Couleur du texte", textColor);
            if (newColor != null) {
              textColor = newColor;
              textColorPreviewPanel.setBackground(textColor);
              if (autoupdateTextColor) destinationGUI.setTextColor(textColor);
            }
          }
        });

    textColorPanel.add(textColorPreviewPanel);
    textColorPanel.add(textColorButton);
    textColorPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(textColorPanel);

    colorChooser = new JColorChooser();

    SpinnerModel textSizeSpinnerModel = new SpinnerNumberModel(textSize, 1, 300, 1);
    final JSpinner textSizeSpinner = new JSpinner(textSizeSpinnerModel);
    textSizeSpinner.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent arg0) {
            if ((int) textSizeSpinner.getValue() != textSize) {
              textSize = (int) textSizeSpinner.getValue();
              if (autoupdateTextSize) destinationGUI.setTextSize(textSize);
            }
          }
        });
    JPanel textSizePanel = new JPanel();
    textSizePanel.setMaximumSize(new Dimension(300, 60));
    textSizePanel.setPreferredSize(new Dimension(300, 30));
    textSizePanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    textSizePanel.setAlignmentX(LEFT_ALIGNMENT);
    JLabel textSizeLabel = new JLabel("Taille du texte");
    textSizeSpinner.setMaximumSize(new Dimension(45, 20));
    textSizePanel.add(textSizeLabel);
    textSizePanel.add(textSizeSpinner);
    JLabel screenLabel = new JLabel("Second écran");
    Integer[] screens = {0, 1};
    JComboBox<Integer> screenComboBox = new JComboBox<Integer>(screens);
    screenComboBox.setSelectedIndex(Main.secondScreen);
    screenComboBox.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            JComboBox<Integer> cb = (JComboBox<Integer>) e.getSource();
            if (cb.getSelectedItem().equals(0)) {
              Main.mainScreen = 1;
              Main.secondScreen = 0;
            } else {
              Main.mainScreen = 0;
              Main.secondScreen = 1;
            }
          }
        });
    screenComboBox.setMaximumSize(new Dimension(45, 20));
    textSizePanel.add(screenLabel);
    textSizePanel.add(screenComboBox);

    settingsPanel.add(textSizePanel);
    mainPanel.add(settingsPanel);
    backPanel.add(mainPanel);

    // RAINBOW PANEL
    JPanel rainbowPanel = new JPanel();
    rainbowPanel.setMinimumSize(new Dimension(50, 40));
    rainbowPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 10));
    final JButton rainbowButton = new JButton("Activer le Rainbow Mode");
    rainbowButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // rainbow mode is already activated :
            // stopping it...
            if (destinationGUI.isRainbowEnabled()) {
              destinationGUI.stopTimer();
              destinationGUI.setTextColor(textColor);
              destinationGUI.setBackgroundColor(backgroundColor);
              rainbowButton.setText("Activer le Rainbow Mode");
            }
            // Rainbow Mode is stopped :
            // starting it...
            else {
              destinationGUI.startTimer();
              rainbowButton.setText("Désactiver le Rainbow Mode");
            }
          }
        });

    JLabel epilepticLabel = new JLabel("Mode épileptique");
    final JCheckBox epilepticCheckBox = new JCheckBox();
    epilepticCheckBox.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            destinationGUI.setEpileptic(epilepticCheckBox.isSelected());
          }
        });
    JLabel speedLabel = new JLabel("Vitesse");
    final JSlider speedSlider =
        new JSlider(SwingConstants.HORIZONTAL, SPEED_MIN, SPEED_MAX, SPEED_INIT);
    speedSlider.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            if (!speedSlider.getValueIsAdjusting()) {
              destinationGUI.setSpeed(speedSlider.getValue());
            }
          }
        });
    destinationGUI.setSpeed(SPEED_INIT);
    speedSlider.setPreferredSize(new Dimension(100, 30));

    rainbowPanel.add(rainbowButton);
    rainbowPanel.add(speedLabel);
    rainbowPanel.add(speedSlider);
    rainbowPanel.add(epilepticLabel);
    rainbowPanel.add(epilepticCheckBox);
    backPanel.add(rainbowPanel);

    // BOTTOM PANEL
    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 30, 10));
    bottomPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0));
    JButton updateButton = new JButton("Mettre à jour les modifications");
    updateButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {

            destinationGUI.setTextCenter(textArea.getText().replaceAll("\n", "<br>"));
            destinationGUI.setTextColor(textColor);
            destinationGUI.setBackgroundColor(backgroundColor);
            destinationGUI.setTextSize(textSize);
          }
        });
    bottomPanel.add(updateButton);

    final JButton secondScreen = new JButton("Envoyer sur le second écran");
    secondScreen.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {

            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice[] gd = ge.getScreenDevices();
            // Ramener sur le premier ecran
            if (isOnSecondScreen) {
              secondScreen.setText("Envoyer sur le second écran");
              showDestGUIOnScreen(Main.mainScreen);
              isOnSecondScreen = false;
              if (wasFullscreen) {
                quitFullscreen();
                destinationGUI = new GUI();
                destinationGUI.setTextCenter(textArea.getText());
                destinationGUI.setTextColor(textColor);
                destinationGUI.setBackgroundColor(backgroundColor);
                destinationGUI.setTextSize(textSize);
              }
            }
            // Envoyer sur le deuxieme ecran
            else {
              if (Main.protection && gd.length <= 1) {
                System.out.println("Erreur : Pas de second écran trouve");
                return;
              }
              showDestGUIOnScreen(Main.secondScreen);
              secondScreen.setText("Ramener sur le premier écran");
              isOnSecondScreen = true;
              wasFullscreen = fullscreen;
            }
          }
        });

    bottomPanel.add(secondScreen);
    bottomPanel.setAlignmentX(CENTER_ALIGNMENT);

    destinationGUI.setTextSize(textSize);
    destinationGUI.setTextColor(textColor);
    destinationGUI.setBackgroundColor(backgroundColor);
    destinationGUI.setTextCenter(textArea.getText());

    backPanel.add(bottomPanel);
    return backPanel;
  }
Esempio n. 29
0
  public SchemaEditorToolBar(final BasicGraphEditor editor, int orientation) {
    super(orientation);
    setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createEmptyBorder(3, 3, 3, 3), getBorder()));
    setFloatable(false);

    add(
        editor.bind(
            "New", new EditorActions.NewAction(), "/com/gkd/jgraphx_example/images/new.gif"));
    add(
        editor.bind(
            "Open", new EditorActions.OpenAction(), "/com/gkd/jgraphx_example/images/open.gif"));
    add(
        editor.bind(
            "Save",
            new EditorActions.SaveAction(false),
            "/com/gkd/jgraphx_example/images/save.gif"));

    addSeparator();

    add(
        editor.bind(
            "Print", new EditorActions.PrintAction(), "/com/gkd/jgraphx_example/images/print.gif"));

    addSeparator();

    add(
        editor.bind(
            "Cut", TransferHandler.getCutAction(), "/com/gkd/jgraphx_example/images/cut.gif"));
    add(
        editor.bind(
            "Copy", TransferHandler.getCopyAction(), "/com/gkd/jgraphx_example/images/copy.gif"));
    add(
        editor.bind(
            "Paste",
            TransferHandler.getPasteAction(),
            "/com/gkd/jgraphx_example/images/paste.gif"));

    addSeparator();

    add(
        editor.bind(
            "Delete",
            mxGraphActions.getDeleteAction(),
            "/com/gkd/jgraphx_example/images/delete.gif"));

    addSeparator();

    add(
        editor.bind(
            "Undo",
            new EditorActions.HistoryAction(true),
            "/com/gkd/jgraphx_example/images/undo.gif"));
    add(
        editor.bind(
            "Redo",
            new EditorActions.HistoryAction(false),
            "/com/gkd/jgraphx_example/images/redo.gif"));

    addSeparator();

    final mxGraphView view = editor.getGraphComponent().getGraph().getView();
    final JComboBox zoomCombo =
        new JComboBox(
            new Object[] {
              "400%",
              "200%",
              "150%",
              "100%",
              "75%",
              "50%",
              mxResources.get("page"),
              mxResources.get("width"),
              mxResources.get("actualSize")
            });
    zoomCombo.setEditable(true);
    zoomCombo.setMinimumSize(new Dimension(75, 0));
    zoomCombo.setPreferredSize(new Dimension(75, 0));
    zoomCombo.setMaximumSize(new Dimension(75, 100));
    zoomCombo.setMaximumRowCount(9);
    add(zoomCombo);

    // Sets the zoom in the zoom combo the current value
    mxIEventListener scaleTracker =
        new mxIEventListener() {
          /** */
          public void invoke(Object sender, mxEventObject evt) {
            ignoreZoomChange = true;

            try {
              zoomCombo.setSelectedItem((int) Math.round(100 * view.getScale()) + "%");
            } finally {
              ignoreZoomChange = false;
            }
          }
        };

    // Installs the scale tracker to update the value in the combo box
    // if the zoom is changed from outside the combo box
    view.getGraph().getView().addListener(mxEvent.SCALE, scaleTracker);
    view.getGraph().getView().addListener(mxEvent.SCALE_AND_TRANSLATE, scaleTracker);

    // Invokes once to sync with the actual zoom value
    scaleTracker.invoke(null, null);

    zoomCombo.addActionListener(
        new ActionListener() {
          /** */
          public void actionPerformed(ActionEvent e) {
            mxGraphComponent graphComponent = editor.getGraphComponent();

            // Zoomcombo is changed when the scale is changed in the diagram
            // but the change is ignored here
            if (!ignoreZoomChange) {
              String zoom = zoomCombo.getSelectedItem().toString();

              if (zoom.equals(mxResources.get("page"))) {
                graphComponent.setPageVisible(true);
                graphComponent.setZoomPolicy(mxGraphComponent.ZOOM_POLICY_PAGE);
              } else if (zoom.equals(mxResources.get("width"))) {
                graphComponent.setPageVisible(true);
                graphComponent.setZoomPolicy(mxGraphComponent.ZOOM_POLICY_WIDTH);
              } else if (zoom.equals(mxResources.get("actualSize"))) {
                graphComponent.zoomActual();
              } else {
                try {
                  zoom = zoom.replace("%", "");
                  double scale = Math.min(16, Math.max(0.01, Double.parseDouble(zoom) / 100));
                  graphComponent.zoomTo(scale, graphComponent.isCenterZoom());
                } catch (Exception ex) {
                  JOptionPane.showMessageDialog(editor, ex.getMessage());
                }
              }
            }
          }
        });
  }
Esempio n. 30
0
  public GUI() {

    // Frame
    frame = new JFrame("HardwareSwap Notifier");

    // Panels
    panel = new JPanel();
    group1 = new JPanel();
    group2 = new JPanel();
    group3 = new JPanel();
    group4 = new JPanel();
    group5 = new JPanel();
    group6 = new JPanel();
    group7 = new JPanel();
    group8 = new JPanel();

    // Menu Bar
    menus = new JMenuBar();
    fileMenu = new JMenu("File");
    clearCurrent = new JMenuItem("Clear");
    quitItem = new JMenuItem("Quit");
    load = new JMenuItem("Load");
    saveCurrent = new JMenuItem("Save All");
    clearSaved = new JMenuItem("Clear Saved");
    removeItem = new JMenuItem("Remove Item");
    removePhone = new JMenuItem("Remove Phone");
    saveCurrent = new JMenuItem("Save Current");
    helpMenu = new JMenu("Help");
    help = new JMenuItem("How To Use");
    about = new JMenuItem("About");

    // Buttons
    add1 = new JButton("Add");
    add2 = new JButton("Add");
    start = new JButton("Start");
    stop = new JButton("Stop");
    save1 = new JButton("Add/Save");
    save2 = new JButton("Add/Save");
    show = new JButton("Display Data");

    add1.setFocusPainted(false);
    add2.setFocusPainted(false);
    start.setFocusPainted(false);
    stop.setFocusPainted(false);
    save1.setFocusPainted(false);
    save2.setFocusPainted(false);
    show.setFocusPainted(false);

    stop.setEnabled(false);

    // CheckBox
    remove = new JCheckBox("Remove items when found");
    remove.setFocusable(false);

    // Listener
    ButtonListener listener = new ButtonListener();

    add1.addActionListener(listener);
    add2.addActionListener(listener);
    start.addActionListener(listener);
    stop.addActionListener(listener);
    load.addActionListener(listener);
    save1.addActionListener(listener);
    save2.addActionListener(listener);
    saveCurrent.addActionListener(listener);
    show.addActionListener(listener);
    quitItem.addActionListener(listener);
    clearCurrent.addActionListener(listener);
    clearSaved.addActionListener(listener);
    saveCurrent.addActionListener(listener);
    help.addActionListener(listener);
    about.addActionListener(listener);
    removePhone.addActionListener(listener);
    removeItem.addActionListener(listener);
    remove.addActionListener(listener);

    // Carrier Selection
    options = new String[10];
    options[0] = "AT&T";
    options[1] = "Boost Mobile";
    options[2] = "Cellular One";
    options[3] = "Nextel";
    options[4] = "T-Mobile";
    options[5] = "Tracfone";
    options[6] = "US Cellular";
    options[7] = "Sprint";
    options[8] = "Verizon";
    options[9] = "Virgin Mobile";

    carriers = new JComboBox<String>(options);

    // Text Fields
    searchName = new JTextField(15);
    item = new JTextField(15);
    phone = new JTextField(15);
    interval2 = new JTextField(15);
    results = new JTextArea(10, 20);

    JScrollPane scrollPane = new JScrollPane(results);

    results.setEditable(false);

    // Interval
    intOptions = new SpinnerNumberModel(5, 1, 60, 1);
    interval = new JSpinner(intOptions);
    JFormattedTextField tf = ((JSpinner.DefaultEditor) interval.getEditor()).getTextField();
    tf.setHorizontalAlignment(JFormattedTextField.LEFT);

    // Background
    panelBackground = new Color(237, 237, 237);

    panel.setBackground(panelBackground);
    searchName.setBackground(panelBackground);
    item.setBackground(panelBackground);
    phone.setBackground(panelBackground);
    interval.setBackground(panelBackground);

    // Panel Layouts
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    group1.setLayout(new BoxLayout(group1, BoxLayout.PAGE_AXIS));
    group2.setLayout(new BoxLayout(group2, BoxLayout.X_AXIS));
    group3.setLayout(new BoxLayout(group3, BoxLayout.PAGE_AXIS));
    group4.setLayout(new BoxLayout(group4, BoxLayout.X_AXIS));
    group5.setLayout(new BoxLayout(group5, BoxLayout.X_AXIS));
    group6.setLayout(new BoxLayout(group6, BoxLayout.X_AXIS));
    group7.setLayout(new BoxLayout(group7, BoxLayout.X_AXIS));
    group8.setLayout(new BoxLayout(group8, BoxLayout.X_AXIS));

    // Borders
    searchName.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Search Name",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    item.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Item",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    phone.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Cell Phone",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    group5.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Check Interval (mins)",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));

    // Sizes
    panel.setPreferredSize(new Dimension(200, 0));
    searchName.setMaximumSize(new Dimension(190, 50));
    item.setMaximumSize(new Dimension(190, 50));
    phone.setMaximumSize(new Dimension(185, 50));
    carriers.setMaximumSize(new Dimension(175, 20));
    group5.setPreferredSize(new Dimension(190, 47));
    group5.setMaximumSize(new Dimension(190, 47));

    add1.setMaximumSize(new Dimension(90, 20));
    save1.setMaximumSize(new Dimension(90, 20));
    add2.setMaximumSize(new Dimension(90, 20));
    save2.setMaximumSize(new Dimension(90, 20));
    start.setMaximumSize(new Dimension(90, 20));
    stop.setMaximumSize(new Dimension(90, 20));
    show.setMaximumSize(new Dimension(120, 20));

    // Add file menu items
    fileMenu.add(clearCurrent);
    fileMenu.add(clearSaved);
    fileMenu.add(load);
    fileMenu.add(removeItem);
    fileMenu.add(removePhone);
    fileMenu.add(saveCurrent);
    fileMenu.add(quitItem);

    // Add help menu items
    helpMenu.add(help);
    helpMenu.add(about);

    // Add to menu bar
    menus.add(fileMenu);
    menus.add(helpMenu);

    // Add items to panel
    group1.add(searchName);
    group1.add(item);

    group2.add(add1);
    group2.add(Box.createHorizontalStrut(10));
    group2.add(save1);

    group6.add(remove);

    group3.add(phone);
    group3.add(Box.createVerticalStrut(10));
    group3.add(carriers);

    group4.add(add2);
    group4.add(Box.createHorizontalStrut(10));
    group4.add(save2);

    group5.add(interval);

    group7.add(show);

    group8.add(start);
    group8.add(Box.createHorizontalStrut(10));
    group8.add(stop);

    panel.add(Box.createVerticalStrut(10));
    panel.add(group1);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group2);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group3);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group4);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group5);
    panel.add(Box.createVerticalStrut(30));
    panel.add(group6);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group7);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group8);
    panel.add(Box.createVerticalStrut(10));

    // Setup frame
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menus);
    frame.add(scrollPane);
    frame.add(BorderLayout.EAST, panel);
    frame.pack();
    frame.setSize(new Dimension(670, 620));
    frame.setVisible(true);
  }