/** Create menus to selct cross-section and spine */
  private void initMenus() {
    JMenuBar menuBar = new JMenuBar();

    JMenu crosssectionMenu = new JMenu("Cross-section");
    menuBar.add(crosssectionMenu);

    myCrossSectionSelection = new ButtonGroup();
    for (String s : myCrossSections.keySet()) {
      JMenuItem item = new JRadioButtonMenuItem(s);
      crosssectionMenu.add(item);
      myCrossSectionSelection.add(item);
      item.addItemListener(this);
    }
    myCrossSectionSelection.setSelected(
        myCrossSectionSelection.getElements().nextElement().getModel(), true);

    JMenu spineMenu = new JMenu("Spine");
    menuBar.add(spineMenu);

    mySpineSelection = new ButtonGroup();
    for (String s : mySpines.keySet()) {
      JMenuItem item = new JRadioButtonMenuItem(s);
      spineMenu.add(item);
      mySpineSelection.add(item);
      item.addItemListener(this);
    }
    mySpineSelection.setSelected(mySpineSelection.getElements().nextElement().getModel(), true);

    setJMenuBar(menuBar);
  }
Example #2
0
 public void setPurpose(LensPurposeType purpose) {
   switch (purpose) {
     case DEFAULT:
       buttonGroup.setSelected(defaultButton.getModel(), true);
       break;
     case LABEL:
       buttonGroup.setSelected(labelbutton.getModel(), true);
       break;
     case NOT_SPECIFIED:
     default:
       buttonGroup.setSelected(undefinedButton.getModel(), true);
   }
 }
Example #3
0
  /** kreiert das Menü oben */
  private JToolBar createMenu() {
    JToolBar toolbar = new JToolBar();
    toolbar.setOrientation(SwingConstants.HORIZONTAL);
    toolbar.setFloatable(false);
    toolbar.setMargin(new Insets(2, 35, 2, 0));
    toolbar.setBackground(new Color(219, 255, 179));

    zoomIn = FsmUtils.createButton(zoomInImg);
    zoomIn.setToolTipText("Vergr��ern");
    zoomIn.addMouseListener(new ZoomInHandler(this));

    zoomOut = FsmUtils.createButton(zoomOutImg);
    zoomOut.setToolTipText("Verkleinern");
    zoomOut.addMouseListener(new ZoomOutHandler(this));

    layout = FsmUtils.createButton(layoutImg);
    layout.setToolTipText("Automatisch layouten");
    layout.addMouseListener(new LayoutHandler(this));

    deterministic = new JRadioButton("deterministisch");
    deterministic.setToolTipText("Der endliche Automat wird deterministisch");
    deterministic.setBackground(new Color(219, 255, 179));
    deterministic.addMouseListener(new TypeOfFsmHandler(this, false));

    nondeterministic = new JRadioButton("nichtdeterministisch");
    nondeterministic.setToolTipText("Der endliche Automat wird nichtdeterministisch");
    nondeterministic.setBackground(new Color(219, 255, 179));
    nondeterministic.addMouseListener(new TypeOfFsmHandler(this, true));

    ButtonGroup group = new ButtonGroup();
    group.add(deterministic);
    group.add(nondeterministic);
    if (this.getFsmProgram().isNondeterministic()) {
      group.setSelected(nondeterministic.getModel(), true);
    } else {
      group.setSelected(deterministic.getModel(), true);
    }

    toolbar.add(zoomIn);
    toolbar.add(Box.createHorizontalStrut(2));
    toolbar.add(zoomOut);
    toolbar.add(Box.createHorizontalStrut(2));
    toolbar.add(Box.createHorizontalStrut(2));
    toolbar.add(layout);
    toolbar.addSeparator();
    toolbar.add(deterministic);
    toolbar.add(nondeterministic);

    return toolbar;
  }
Example #4
0
  private JPanel createFoodTypeButtons(String[] array) {

    JPanel radioPanel = new JPanel();
    typeOfFood = new ArrayList<JRadioButton>();
    JRadioButton type0Radio = new JRadioButton(this.e.nonPerishableFood);
    JRadioButton type1Radio = new JRadioButton(this.e.perishableFood);

    typeOfFood.add(type0Radio);
    typeOfFood.add(type1Radio);

    type0Radio.setActionCommand(this.e.nonPerishableFood);
    type1Radio.setActionCommand(this.e.perishableFood);

    // Register a listener for the radio buttons.
    RadioListener myListener =
        new RadioListener(type0Radio, type1Radio, newCreatureButton, newJewelButton);
    type0Radio.addActionListener(myListener);
    type1Radio.addActionListener(myListener);

    // Group the radio buttons.
    group = new ButtonGroup();
    group.add(type0Radio);
    group.add(type1Radio);

    model = new DefaultButtonModel();
    group.setSelected(model, false);

    radioPanel.setLayout(new GridLayout(0, 1));
    radioPanel.add(type0Radio);
    radioPanel.add(type1Radio);

    return radioPanel;
  }
Example #5
0
    protected void refreshTransformers() {
      if (model != null) {
        // Select the right transformer
        int index = 0;
        for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) {
          for (TransformerCategory c : controller.getCategories(elmtType)) {
            ButtonGroup g = buttonGroups.get(index);

            boolean active =
                model.getSelectedElementClass().equals(elmtType)
                    && model.getSelectedCategory().equals(c);
            g.clearSelection();
            TransformerUI t = model.getSelectedTransformerUI();

            for (Enumeration<AbstractButton> btns = g.getElements(); btns.hasMoreElements(); ) {
              AbstractButton btn = btns.nextElement();
              btn.setVisible(active);
              if (t != null && btn.getName().equals(t.getDisplayName())) {
                g.setSelected(btn.getModel(), true);
              }
            }
            index++;
          }
        }
      }
    }
Example #6
0
  /**
   * Set the console wrapping style to one of the following:
   *
   * @param style one of the defined style attributes - one of
   *     <ul>
   *       <li>{@link #WRAP_STYLE_NONE} No wrapping
   *       <li>{@link #WRAP_STYLE_LINE} Wrap at end of line
   *       <li>{@link #WRAP_STYLE_WORD} Wrap by word boundaries
   *     </ul>
   */
  public void setWrapStyle(int style) {
    wrapStyle = style;
    console.setLineWrap(style != WRAP_STYLE_NONE);
    console.setWrapStyleWord(style == WRAP_STYLE_WORD);

    if (wrapGroup != null) {
      wrapGroup.setSelected(wrapMenu.getItem(style).getModel(), true);
    }
  }
Example #7
0
  public void showForCreation() {

    hiddenObstacle.setSelected(false);
    hiddenObstacle.setEnabled(false);
    for (JRadioButton tof : typeOfFood) {
      tof.setEnabled(true);
    }
    newCreatureButton.setEnabled(true);
    newJewelButton.setEnabled(true);
    group.setSelected(model, true);
  }
Example #8
0
  public void update() {

    newCreatureButton.setEnabled(false);
    newJewelButton.setEnabled(false);

    if (food != null) {

      for (JRadioButton tof : typeOfFood) {
        tof.setEnabled(false);
      }
      group.setSelected(model, false);

      hiddenObstacle.setEnabled(true);
      if (food.returnIfWasHidden()) {
        hiddenObstacle.setSelected(true);

      } else {
        hiddenObstacle.setSelected(false);
      }
    }
  }
Example #9
0
  /**
   * Set the console colour scheme
   *
   * @param which the scheme to use
   */
  public void setScheme(int which) {
    scheme = which;

    if (schemes == null) {
      defineSchemes();
    }

    Scheme s;

    try {
      s = schemes.get(which);
    } catch (IndexOutOfBoundsException ex) {
      s = schemes.get(0);
      scheme = 0;
    }

    console.setForeground(s.foreground);
    console.setBackground(s.background);

    if (schemeGroup != null) {
      schemeGroup.setSelected(schemeMenu.getItem(scheme).getModel(), true);
    }
  }
  /**
   * This executes one of the actions, based on the stored ArgoUML configuration. This function is
   * intended for the initial setting of the snap when ArgoUML is started.
   */
  static void init() {
    String id = Configuration.getString(Argo.KEY_SNAP, DEFAULT_ID);
    List<Action> actions = createAdjustSnapActions();
    for (Action a : actions) {
      if (a.getValue("ID").equals(id)) {
        a.actionPerformed(null);

        if (myGroup != null) {
          for (Enumeration e = myGroup.getElements(); e.hasMoreElements(); ) {
            AbstractButton ab = (AbstractButton) e.nextElement();
            Action action = ab.getAction();
            if (action instanceof ActionAdjustSnap) {
              String currentID = (String) action.getValue("ID");
              if (id.equals(currentID)) {
                myGroup.setSelected(ab.getModel(), true);
                return;
              }
            }
          }
        }
        return;
      }
    }
  }
Example #11
0
  /**
   * Constructs a new {@code MapFrame}.
   *
   * @param contentPane The content pane used to register shortcuts in its {@link
   *     javax.swing.InputMap} and {@link javax.swing.ActionMap}
   * @param viewportData the initial viewport of the map. Can be null, then the viewport is derived
   *     from the layer data.
   */
  public MapFrame(JPanel contentPane, ViewportData viewportData) {
    setSize(400, 400);
    setLayout(new BorderLayout());

    mapView = new MapView(contentPane, viewportData);
    new FileDrop(mapView);

    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);

    leftPanel = new JPanel();
    leftPanel.setLayout(new GridBagLayout());
    leftPanel.add(mapView, GBC.std().fill());
    splitPane.setLeftComponent(leftPanel);

    dialogsPanel = new DialogsPanel(splitPane);
    splitPane.setRightComponent(dialogsPanel);

    /** All additional space goes to the mapView */
    splitPane.setResizeWeight(1.0);

    /** Some beautifications. */
    splitPane.setDividerSize(5);
    splitPane.setBorder(null);
    splitPane.setUI(
        new BasicSplitPaneUI() {
          @Override
          public BasicSplitPaneDivider createDefaultDivider() {
            return new BasicSplitPaneDivider(this) {
              @Override
              public void setBorder(Border b) {}
            };
          }
        });

    // JSplitPane supports F6 and F8 shortcuts by default, but we need them for Audio actions
    splitPane
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), new Object());
    splitPane
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0), new Object());

    add(splitPane, BorderLayout.CENTER);

    dialogsPanel.setLayout(new BoxLayout(dialogsPanel, BoxLayout.Y_AXIS));
    dialogsPanel.setPreferredSize(
        new Dimension(Main.pref.getInteger("toggleDialogs.width", DEF_TOGGLE_DLG_WIDTH), 0));
    dialogsPanel.setMinimumSize(new Dimension(24, 0));
    mapView.setMinimumSize(new Dimension(10, 0));

    // toolBarActions, map mode buttons
    addMapMode(new IconToggleButton(mapModeSelect = new SelectAction(this)));
    addMapMode(new IconToggleButton(new LassoModeAction(), true));
    addMapMode(new IconToggleButton(mapModeDraw = new DrawAction(this)));
    addMapMode(new IconToggleButton(mapModeZoom = new ZoomAction(this)));
    addMapMode(new IconToggleButton(new DeleteAction(this), true));
    addMapMode(new IconToggleButton(new ParallelWayAction(this), true));
    addMapMode(new IconToggleButton(new ExtrudeAction(this), true));
    addMapMode(new IconToggleButton(new ImproveWayAccuracyAction(Main.map), false));
    toolBarActionsGroup.setSelected(allMapModeButtons.get(0).getModel(), true);
    toolBarActions.setFloatable(false);

    // toolBarToggles, toggle dialog buttons
    LayerListDialog.createInstance(this);
    addToggleDialog(LayerListDialog.getInstance());
    addToggleDialog(propertiesDialog = new PropertiesDialog());
    addToggleDialog(selectionListDialog = new SelectionListDialog());
    addToggleDialog(relationListDialog = new RelationListDialog());
    addToggleDialog(new CommandStackDialog());
    addToggleDialog(new UserListDialog());
    addToggleDialog(new HistoryDialog(), true);
    addToggleDialog(conflictDialog = new ConflictDialog());
    addToggleDialog(validatorDialog = new ValidatorDialog());
    addToggleDialog(filterDialog = new FilterDialog());
    addToggleDialog(new ChangesetDialog(), true);
    addToggleDialog(new MapPaintDialog());
    toolBarToggle.setFloatable(false);

    // status line below the map
    statusLine = new MapStatus(this);
    MapView.addLayerChangeListener(this);

    boolean unregisterTab = Shortcut.findShortcut(KeyEvent.VK_TAB, 0) != null;
    if (unregisterTab) {
      for (JComponent c : allDialogButtons) c.setFocusTraversalKeysEnabled(false);
      for (JComponent c : allMapModeButtons) c.setFocusTraversalKeysEnabled(false);
    }
  }
 public void setSelected(ButtonModel model, boolean selected) {
   bg.setSelected(model, selected);
 }
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  private void initComponents() {

    jPanel1 = new JPanel();
    jPanel3 = new JPanel();
    jLabelForBrowseOPCItem = new JLabel();
    jLabelForFilterCondition = new JLabel();
    jTextFieldForFilterCondition = new JTextField();
    jScrollPaneForBrowseOPCItem = new JScrollPane();
    jTree1 = new JTree();
    jScrollPaneForOPCItems = new JScrollPane();
    opcItemsPanel = new JPanel();
    jPanel2 = new JPanel();
    jLabelForAccessPath = new JLabel();
    jTextFieldForAccessPath = new JTextField();
    jLabelForOPCItemName = new JLabel();
    jTextFieldForOPCItemName = new JTextField();
    confirmButton = new JButton();
    cancelButton = new JButton();
    jPanel4 = new JPanel();
    jRadioButtonForNativeType = new JRadioButton();
    jRadioButtonForBool = new JRadioButton();
    jRadioButtonForString = new JRadioButton();
    jRadioButtonForShort = new JRadioButton();
    jRadioButtonForLong = new JRadioButton();
    jRadioButtonForDouble = new JRadioButton();

    varStyleButtonGroup = new ButtonGroup();
    varStyleButtonGroup.add(jRadioButtonForNativeType);
    varStyleButtonGroup.add(jRadioButtonForBool);
    varStyleButtonGroup.add(jRadioButtonForString);
    varStyleButtonGroup.add(jRadioButtonForShort);
    varStyleButtonGroup.add(jRadioButtonForLong);
    varStyleButtonGroup.add(jRadioButtonForDouble);
    varStyleButtonGroup.setSelected(jRadioButtonForNativeType.getModel(), true);
    selectItemButtonGroup = new ButtonGroup();

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    jLabelForBrowseOPCItem.setText(resourceMap.getString("jLabelForBrowseOPCItem.text"));

    jLabelForFilterCondition.setText(resourceMap.getString("jLabelForFilterCondition.text"));

    jTextFieldForFilterCondition.setColumns(12);
    jTextFieldForFilterCondition.setText(
        resourceMap.getString("jTextFieldForFilterCondition.text"));

    GroupLayout jPanel3Layout = new GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout.setHorizontalGroup(
        jPanel3Layout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                jPanel3Layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabelForBrowseOPCItem)
                    .addGap(106, 106, 106)
                    .addComponent(jLabelForFilterCondition)
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addComponent(
                        jTextFieldForFilterCondition,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(41, Short.MAX_VALUE)));
    jPanel3Layout.setVerticalGroup(
        jPanel3Layout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                jPanel3Layout
                    .createSequentialGroup()
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(
                        jPanel3Layout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(jLabelForBrowseOPCItem)
                            .addComponent(jLabelForFilterCondition)
                            .addComponent(
                                jTextFieldForFilterCondition,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .addContainerGap()));

    jScrollPaneForBrowseOPCItem.setName("jScrollPaneForBrowseOPCItem");
    jScrollPaneForBrowseOPCItem.setViewportView(jTree1);

    opcItemsPanel.setBackground(resourceMap.getColor("opcItemsPanel.background"));
    jScrollPaneForOPCItems.setViewportView(opcItemsPanel);

    GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                jPanel1Layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(Alignment.LEADING)
                            .addGroup(
                                jPanel1Layout
                                    .createSequentialGroup()
                                    .addComponent(
                                        jScrollPaneForBrowseOPCItem,
                                        GroupLayout.PREFERRED_SIZE,
                                        170,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(
                                        jScrollPaneForOPCItems,
                                        GroupLayout.PREFERRED_SIZE,
                                        150,
                                        GroupLayout.PREFERRED_SIZE))
                            .addComponent(
                                jPanel3,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE))
                    .addContainerGap()));
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                jPanel1Layout
                    .createSequentialGroup()
                    .addComponent(
                        jPanel3, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(
                                jScrollPaneForOPCItems,
                                GroupLayout.DEFAULT_SIZE,
                                168,
                                Short.MAX_VALUE)
                            .addComponent(
                                jScrollPaneForBrowseOPCItem,
                                GroupLayout.PREFERRED_SIZE,
                                168,
                                GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    jLabelForAccessPath.setText(resourceMap.getString("jLabelForAccessPath.text"));

    jTextFieldForAccessPath.setColumns(25);
    jTextFieldForAccessPath.setText(resourceMap.getString("jTextFieldForAccessPath.text"));

    jLabelForOPCItemName.setText(resourceMap.getString("jLabelForOPCItemName.text"));

    jTextFieldForOPCItemName.setColumns(25);
    jTextFieldForOPCItemName.setText(resourceMap.getString("jTextFieldForOPCItemName.text"));

    confirmButton.setAction(actionMap.get("confirm"));
    cancelButton.setAction(actionMap.get("cancel"));

    GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
        jPanel2Layout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                jPanel2Layout
                    .createSequentialGroup()
                    .addGap(18, 18, 18)
                    .addGroup(
                        jPanel2Layout
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(jLabelForOPCItemName)
                            .addComponent(jLabelForAccessPath))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(
                        jPanel2Layout
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(
                                jTextFieldForAccessPath,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                jTextFieldForOPCItemName,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
                    .addGroup(
                        jPanel2Layout
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(cancelButton)
                            .addComponent(confirmButton))
                    .addContainerGap()));
    jPanel2Layout.setVerticalGroup(
        jPanel2Layout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                jPanel2Layout
                    .createSequentialGroup()
                    .addGap(22, 22, 22)
                    .addGroup(
                        jPanel2Layout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(jLabelForAccessPath)
                            .addComponent(
                                jTextFieldForAccessPath,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(confirmButton))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(
                        jPanel2Layout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(jLabelForOPCItemName)
                            .addComponent(
                                jTextFieldForOPCItemName,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(cancelButton))
                    .addContainerGap(14, Short.MAX_VALUE)));

    jPanel4.setBorder(
        BorderFactory.createTitledBorder(resourceMap.getString("jPanel4.border.title")));

    jRadioButtonForNativeType.setText(resourceMap.getString("jRadioButtonForNativeType.text"));
    jRadioButtonForNativeType.setName(TempOpcItemVariantType.VT_NATIVE);

    jRadioButtonForBool.setText(resourceMap.getString("jRadioButtonForBool.text"));
    jRadioButtonForBool.setName(TempOpcItemVariantType.VT_BOOL);

    jRadioButtonForString.setText(resourceMap.getString("jRadioButtonForString.text"));
    jRadioButtonForString.setName(TempOpcItemVariantType.VT_BSTR);

    jRadioButtonForShort.setText(resourceMap.getString("jRadioButtonForShort.text"));
    jRadioButtonForShort.setName(TempOpcItemVariantType.VT_I2);

    jRadioButtonForLong.setText(resourceMap.getString("jRadioButtonForLong.text"));
    jRadioButtonForLong.setName(TempOpcItemVariantType.VT_I4);

    jRadioButtonForDouble.setText(resourceMap.getString("jRadioButtonForDouble.text"));
    jRadioButtonForDouble.setName(TempOpcItemVariantType.VT_R8);

    GroupLayout jPanel4Layout = new GroupLayout(jPanel4);
    jPanel4.setLayout(jPanel4Layout);
    jPanel4Layout.setHorizontalGroup(
        jPanel4Layout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                jPanel4Layout
                    .createSequentialGroup()
                    .addGap(22, 22, 22)
                    .addGroup(
                        jPanel4Layout
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(jRadioButtonForNativeType)
                            .addComponent(jRadioButtonForBool)
                            .addComponent(jRadioButtonForString))
                    .addGap(53, 53, 53)
                    .addGroup(
                        jPanel4Layout
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(jRadioButtonForLong)
                            .addComponent(jRadioButtonForShort)
                            .addComponent(jRadioButtonForDouble))
                    .addContainerGap(74, Short.MAX_VALUE)));
    jPanel4Layout.setVerticalGroup(
        jPanel4Layout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                jPanel4Layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        jPanel4Layout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(jRadioButtonForNativeType)
                            .addComponent(jRadioButtonForShort))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(
                        jPanel4Layout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(jRadioButtonForBool)
                            .addComponent(jRadioButtonForLong))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(
                        jPanel4Layout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(jRadioButtonForString)
                            .addComponent(jRadioButtonForDouble))
                    .addContainerGap(19, Short.MAX_VALUE)));

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGroup(
                        layout
                            .createParallelGroup(Alignment.LEADING)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGap(20, 20, 20)
                                    .addComponent(
                                        jPanel4,
                                        GroupLayout.PREFERRED_SIZE,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.PREFERRED_SIZE))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addContainerGap()
                                    .addGroup(
                                        layout
                                            .createParallelGroup(Alignment.LEADING)
                                            .addComponent(
                                                jPanel1,
                                                GroupLayout.PREFERRED_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.PREFERRED_SIZE)
                                            .addComponent(
                                                jPanel2,
                                                GroupLayout.PREFERRED_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.PREFERRED_SIZE))))
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(
                        jPanel2,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(
                        jPanel1,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(
                        jPanel4,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)
                    .addContainerGap()));

    setTitle(resourceMap.getString("view.title"));
    setResizable(false);
    pack();
  }
Example #14
0
  CatenaSetting() {
    super(PeaFactory.getFrame());
    setting = this;
    // setting.setUndecorated(true);
    setting.setAlwaysOnTop(true);

    this.setIconImage(MainView.getImage());

    JPanel scryptPane = (JPanel) setting.getContentPane(); // new JPanel();
    scryptPane.setBorder(new LineBorder(Color.GRAY, 2));
    scryptPane.setLayout(new BoxLayout(scryptPane, BoxLayout.Y_AXIS));

    JLabel scryptLabel = new JLabel("Settings for CATENA:");
    scryptLabel.setPreferredSize(new Dimension(250, 30));

    JLabel tipLabel1 = new JLabel("Settings for this session only");
    tipLabel1.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    tipLabel1.setPreferredSize(new Dimension(250, 20));
    scryptPane.add(scryptLabel);
    scryptPane.add(tipLabel1);

    JLabel instanceLabel = new JLabel("Select an instance of Catena:");
    instanceLabel.setPreferredSize(new Dimension(250, 40));
    scryptPane.add(instanceLabel);

    JLabel instanceRecommendedLabel = new JLabel("recommended: Dragonfly-Full");
    instanceRecommendedLabel.setPreferredSize(new Dimension(250, 20));
    instanceRecommendedLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    scryptPane.add(instanceRecommendedLabel);

    JRadioButton dragonflyFullButton = new JRadioButton("Dragonfly-Full");
    dragonflyFullButton.setMnemonic(KeyEvent.VK_U);
    dragonflyFullButton.addActionListener(this);
    dragonflyFullButton.setActionCommand("Dragonfly-Full");
    scryptPane.add(dragonflyFullButton);

    JRadioButton butterflyFullButton = new JRadioButton("Butterfly-Full");
    butterflyFullButton.setMnemonic(KeyEvent.VK_U);
    butterflyFullButton.addActionListener(this);
    butterflyFullButton.setActionCommand("Butterfly-Full");
    scryptPane.add(butterflyFullButton);

    JRadioButton dragonflyButton = new JRadioButton("Dragonfly");
    dragonflyButton.setMnemonic(KeyEvent.VK_B);
    dragonflyButton.addActionListener(this);
    dragonflyButton.setActionCommand("Dragonfly");
    scryptPane.add(dragonflyButton);

    JRadioButton butterflyButton = new JRadioButton("Butterfly");
    butterflyButton.setMnemonic(KeyEvent.VK_B);
    butterflyButton.addActionListener(this);
    butterflyButton.setActionCommand("Butterfly");
    scryptPane.add(butterflyButton);

    // Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(dragonflyButton);
    group.add(dragonflyFullButton);
    group.add(butterflyButton);
    group.add(butterflyFullButton);

    group.setSelected(dragonflyFullButton.getModel(), true);

    scryptPane.add(Box.createVerticalStrut(20));

    JLabel memoryLabel = new JLabel("Memory cost parameter GARLIC: ");
    memoryLabel.setPreferredSize(new Dimension(220, 40));
    scryptPane.add(memoryLabel);
    memoryField =
        new JTextField() {
          private static final long serialVersionUID = 1L;

          public void processKeyEvent(KeyEvent ev) {
            char c = ev.getKeyChar();
            try {
              // printable characters
              if (c > 31 && c < 65535 && c != 127) {
                Integer.parseInt(c + ""); // parse
              }
              super.processKeyEvent(ev);
            } catch (NumberFormatException nfe) {
              // if not a number: ignore
            }
          }
        };
    memoryField.setText("18");
    memoryField.setColumns(2);
    memoryField.setDragEnabled(true);

    memoryField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent e) {
                warn();
              }

              public void removeUpdate(DocumentEvent e) {
                warn();
              }

              public void insertUpdate(DocumentEvent e) {
                warn();
              }

              public void warn() {
                int garlic = 0;
                try {
                  garlic = Integer.parseInt(memoryField.getText());
                } catch (Exception nfe) {
                  errorLabel.setText("Invalid input");
                  return;
                }
                if (garlic == 0) {
                  errorLabel.setText("Invalid value");
                } else if (garlic < 14) {
                  errorLabel.setText("Warning: Weak parameter");
                } else if (garlic > 22 && garlic < 64) {
                  errorLabel.setText("Warning: Long execution time");
                } else if (garlic > 63) {
                  errorLabel.setText("Invalid value: must be < 64");
                } else {
                  errorLabel.setText("");
                }
              }
            });

    memoryRecommendedLabel = new JLabel("recommended >= 18");
    memoryRecommendedLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    JPanel memoryPanel = new JPanel();
    memoryPanel.add(memoryField);
    memoryPanel.add(memoryRecommendedLabel);
    scryptPane.add(memoryPanel);

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

    JLabel timeLabel = new JLabel("Time cost parameter LAMBDA: ");
    timeLabel.setPreferredSize(new Dimension(220, 40));
    scryptPane.add(timeLabel);
    timeField =
        new JTextField() {
          private static final long serialVersionUID = 1L;

          public void processKeyEvent(KeyEvent ev) {
            char c = ev.getKeyChar();
            try {
              // printable characters
              if (c > 31 && c < 65535 && c != 127) {
                Integer.parseInt(c + ""); // parse
              }
              super.processKeyEvent(ev);
            } catch (NumberFormatException nfe) {
              // if not a number: ignore
            }
          }
        };
    timeField.setText("2");
    timeField.setColumns(3);
    timeField.setDragEnabled(true);

    timeField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent e) {
                warn();
              }

              public void removeUpdate(DocumentEvent e) {
                warn();
              }

              public void insertUpdate(DocumentEvent e) {
                warn();
              }

              public void warn() {
                int lambda = 0;
                try {
                  lambda = Integer.parseInt(timeField.getText());
                } catch (Exception nfe) {
                  errorLabel.setText("Invalid input");
                  return;
                }
                if (lambda == 0) {
                  errorLabel.setText("Invalid value");
                } else if (lambda == 1) {
                  errorLabel.setText("Warning: Weak parameter");
                } else if (lambda > 4) {
                  errorLabel.setText("Warning: Long execution time");
                } else {
                  errorLabel.setText("");
                }
              }
            });

    timeRecommendedLabel = new JLabel("recommended 2");
    timeRecommendedLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    JPanel timePanel = new JPanel();
    timePanel.add(timeField);
    timePanel.add(timeRecommendedLabel);
    scryptPane.add(timePanel);

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

    errorLabel = new JLabel("");
    errorLabel.setForeground(Color.RED);
    scryptPane.add(errorLabel);

    JButton scryptOkButton = new JButton("ok");
    scryptOkButton.setActionCommand("newSetting");
    scryptOkButton.addActionListener(this);
    scryptPane.add(scryptOkButton);
    setting.pack();
    setting.setLocation(100, 100);
    setting.setVisible(true);
  }
Example #15
0
  /** Erstellt das Menü auf der linken Seite */
  private JToolBar createFSMMenu() {
    JToolBar toolbar = new JToolBar();
    toolbar.setOrientation(SwingConstants.VERTICAL);
    toolbar.setFloatable(false);
    toolbar.setMargin(new Insets(5, -3, 0, 2));
    toolbar.setBackground(new Color(219, 255, 179));

    editMode = FsmUtils.createToggleButton(editImg);
    editMode.setToolTipText("Editieren");
    editMode.addMouseListener(new EditModeHandler(this.automataPanel));

    deleteMode = FsmUtils.createToggleButton(deleteImg);
    deleteMode.setToolTipText("L�schen");
    deleteMode.addMouseListener(new DeleteModeHandler(this.automataPanel));

    createState = FsmUtils.createToggleButton(createStateImg);
    createState.setToolTipText("Zustand erzeugen");
    createState.addMouseListener(new CreateStateHandler(this.automataPanel));

    markStartState = FsmUtils.createToggleButton(markStartStateImg);
    markStartState.setToolTipText("Startzustand markieren");
    markStartState.addMouseListener(new MarkStartStateHandler(this.automataPanel));

    markFinalState = FsmUtils.createToggleButton(markFinalStateImg);
    markFinalState.setToolTipText("Endzustand markieren");
    markFinalState.addMouseListener(new MarkFinalStateHandler(this.automataPanel));

    createTransistion = FsmUtils.createToggleButton(createTransistionImg);
    createTransistion.setToolTipText("Transition erzeugen");
    createTransistion.addMouseListener(new CreateTransistionHandler(this.automataPanel));

    createComment = FsmUtils.createToggleButton(createCommentImg);
    createComment.setToolTipText("Kommentar erzeugen");
    createComment.addMouseListener(new CreateCommentHandler(this.automataPanel));

    // Nur ein Button darf aktiv sein
    ButtonGroup group = new ButtonGroup();
    group.add(editMode);
    group.add(deleteMode);
    group.add(createState);
    group.add(markStartState);
    group.add(markFinalState);
    group.add(createTransistion);
    group.add(createComment);
    group.setSelected(editMode.getModel(), true);

    toolbar.add(editMode);
    toolbar.add(Box.createVerticalStrut(2));
    toolbar.add(deleteMode);

    toolbar.addSeparator();
    toolbar.add(createState);
    toolbar.add(Box.createVerticalStrut(2));
    toolbar.add(markStartState);
    toolbar.add(Box.createVerticalStrut(2));
    toolbar.add(markFinalState);
    toolbar.add(Box.createVerticalStrut(2));
    toolbar.add(createTransistion);
    toolbar.add(Box.createVerticalStrut(2));
    toolbar.add(createComment);

    return toolbar;
  }
Example #16
0
 public void setTwoGame(boolean twoGame) {
   m_twoGame = twoGame;
   m_winGroup.setSelected(twoGame ? m_twoGameModel : m_threeGameModel, true);
 }
Example #17
0
 public void setRedWin(boolean redWin) {
   m_redWin = redWin;
   m_winGroup.setSelected(redWin ? m_redWinModel : m_blueWinModel, true);
 }