Esempio n. 1
0
  public JPanel getResetPanel() {
    final JPanel panel_2 = new JPanel();
    panel_2.setAlignmentY(Component.TOP_ALIGNMENT);
    panel_2.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel_2.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 3));
    panel_2.setBorder(
        BorderFactory.createCompoundBorder(
            spaceY,
            new TitledBorder(
                null,
                Messages.getString("ImageTool.reset"), // $NON-NLS-1$
                TitledBorder.DEFAULT_JUSTIFICATION,
                TitledBorder.DEFAULT_POSITION,
                TITLE_FONT,
                TITLE_COLOR)));
    final JComboBox resetComboBox = new JComboBox(ResetTools.values());
    panel_2.add(resetComboBox);

    final JButton resetButton = new JButton();
    resetButton.setText(Messages.getString("ImageTool.reset")); // $NON-NLS-1$
    resetButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            EventManager.getInstance().reset((ResetTools) resetComboBox.getSelectedItem());
          }
        });
    panel_2.add(resetButton);
    ActionState resetAction = EventManager.getInstance().getAction(ActionW.RESET);
    if (resetAction != null) {
      resetAction.registerActionState(resetButton);
    }
    return panel_2;
  }
 @Nullable
 @Override
 public JComponent createComponent() {
   myEnabled = new JBCheckBox("Enable EditorConfig support");
   final JPanel result = new JPanel();
   result.setLayout(new BoxLayout(result, BoxLayout.LINE_AXIS));
   final JPanel panel = new JPanel(new VerticalFlowLayout());
   result.setBorder(IdeBorderFactory.createTitledBorder("EditorConfig", false));
   panel.add(myEnabled);
   final JLabel warning = new JLabel("EditorConfig may override the IDE code style settings");
   warning.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
   warning.setBorder(IdeBorderFactory.createEmptyBorder(0, 20, 0, 0));
   panel.add(warning);
   panel.setAlignmentY(Component.TOP_ALIGNMENT);
   result.add(panel);
   final JButton export = new JButton("Export");
   export.addActionListener(
       (event) -> {
         final Component parent = UIUtil.findUltimateParent(result);
         if (parent instanceof IdeFrame) {
           Utils.export(((IdeFrame) parent).getProject());
         }
       });
   export.setAlignmentY(Component.TOP_ALIGNMENT);
   result.add(export);
   return result;
 }
Esempio n. 3
0
  public JPanel getSlicePanel() {

    final JPanel framePanel = new JPanel();
    framePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    framePanel.setAlignmentY(Component.TOP_ALIGNMENT);
    framePanel.setLayout(new BoxLayout(framePanel, BoxLayout.Y_AXIS));
    framePanel.setBorder(
        BorderFactory.createCompoundBorder(
            spaceY,
            new TitledBorder(
                null,
                Messages.getString("ImageTool.frame"), // $NON-NLS-1$
                TitledBorder.DEFAULT_JUSTIFICATION,
                TitledBorder.DEFAULT_POSITION,
                TITLE_FONT,
                TITLE_COLOR)));

    ActionState sequence = EventManager.getInstance().getAction(ActionW.SCROLL_SERIES);
    if (sequence instanceof SliderCineListener) {
      SliderCineListener cineAction = (SliderCineListener) sequence;
      final JSliderW frameSlider = cineAction.createSlider(4, true);
      framePanel.add(frameSlider.getParent());

      final JPanel panel_3 = new JPanel();
      panel_3.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 3));
      final JLabel speedLabel = new JLabel();
      speedLabel.setText(
          Messages.getString("ImageTool.cine_speed") + StringUtil.COLON); // $NON-NLS-1$
      panel_3.add(speedLabel);

      final JSpinner speedSpinner = new JSpinner(cineAction.getSpeedModel());
      JMVUtils.formatCheckAction(speedSpinner);
      panel_3.add(speedSpinner);
      final JButton startButton = new JButton();
      startButton.setActionCommand(ActionW.CINESTART.cmd());
      startButton.setPreferredSize(JMVUtils.getBigIconButtonSize());
      startButton.setToolTipText(Messages.getString("ImageTool.cine_start")); // $NON-NLS-1$
      startButton.setIcon(
          new ImageIcon(
              MouseActions.class.getResource(
                  "/icon/22x22/media-playback-start.png"))); //$NON-NLS-1$
      startButton.addActionListener(EventManager.getInstance());
      panel_3.add(startButton);
      cineAction.registerActionState(startButton);

      final JButton stopButton = new JButton();
      stopButton.setActionCommand(ActionW.CINESTOP.cmd());
      stopButton.setPreferredSize(JMVUtils.getBigIconButtonSize());
      stopButton.setToolTipText(Messages.getString("ImageTool.cine_stop")); // $NON-NLS-1$
      stopButton.setIcon(
          new ImageIcon(
              MouseActions.class.getResource(
                  "/icon/22x22/media-playback-stop.png"))); //$NON-NLS-1$
      stopButton.addActionListener(EventManager.getInstance());
      panel_3.add(stopButton);
      cineAction.registerActionState(stopButton);
      framePanel.add(panel_3);
    }
    return framePanel;
  }
Esempio n. 4
0
 public static JPanel createHorizontalMarginPanel(
     JComponent content, int leftMargin, int rightMargin) {
   JPanel panel = new JPanel();
   panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
   panel.setAlignmentY(JPanel.TOP_ALIGNMENT);
   panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
   panel.add(Box.createHorizontalStrut(leftMargin));
   panel.add(content);
   panel.add(Box.createHorizontalStrut(rightMargin));
   return panel;
 }
Esempio n. 5
0
  private void jbInit() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(getWindowLevelPanel());
    add(getTransformPanel());
    add(getSlicePanel());
    add(getResetPanel());

    final JPanel panel_1 = new JPanel();
    panel_1.setAlignmentY(Component.TOP_ALIGNMENT);
    panel_1.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel_1.setLayout(new GridBagLayout());
    add(panel_1);
  }
Esempio n. 6
0
  // type 'java Parallel' to run this application
  public static void main(String args[]) throws VisADException, RemoteException, IOException {

    RealType index = RealType.getRealType("index");
    RealType[] coords = new RealType[NCOORDS];
    for (int i = 0; i < NCOORDS; i++) {
      coords[i] = RealType.getRealType("coord" + i);
    }
    RealTupleType range = new RealTupleType(coords);
    FunctionType ftype = new FunctionType(index, range);
    Integer1DSet index_set = new Integer1DSet(NROWS);

    float[][] samples = new float[NCOORDS][NROWS];
    for (int i = 0; i < NCOORDS; i++) {
      for (int j = 0; j < NROWS; j++) {
        samples[i][j] = (float) Math.random();
      }
    }

    FlatField data = new FlatField(ftype, index_set);
    data.setSamples(samples, false);

    // create a 2-D Display using Java3D
    DisplayImpl display = new DisplayImplJ3D("display", new TwoDDisplayRendererJ3D());

    parallel(display, data);

    // create JFrame (i.e., a window) for display and slider
    JFrame frame = new JFrame("Parallel Coordinates VisAD Application");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    // create JPanel in JFrame
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setAlignmentY(JPanel.TOP_ALIGNMENT);
    panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
    frame.getContentPane().add(panel);

    // add display to JPanel
    panel.add(display.getComponent());

    // set size of JFrame and make it visible
    frame.setSize(500, 500);
    frame.setVisible(true);
  }
  /** It has all the components of the inspector panel. */
  private void guiComponents() {
    desktop = new JScrollPane();
    pReceive = new JPanel();

    desktop.setBorder(null);
    desktop.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    desktop.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    desktop.setAlignmentX(0.0F);
    desktop.setAlignmentY(0.0F);

    pReceive.setAlignmentX(0.0F);
    pReceive.setAlignmentY(0.0F);
    pReceive.setLayout(new CardLayout());

    desktop.setViewportView(pReceive);
  }
  /** Opens a new window with a drawing view. */
  protected void open(DrawingView newDrawingView) {
    getVersionControlStrategy().assertCompatibleVersion();
    setUndoManager(new UndoManager());
    fIconkit = new Iconkit(this);
    getContentPane().setLayout(new BorderLayout());

    // status line must be created before a tool is set
    fStatusLine = createStatusLine();
    getContentPane().add(fStatusLine, BorderLayout.SOUTH);

    // create dummy tool until the default tool is activated during toolDone()
    setTool(new NullTool(this), "");
    setView(newDrawingView);
    JComponent contents = createContents(view());
    contents.setAlignmentX(LEFT_ALIGNMENT);

    JToolBar tools = createToolPalette();
    createTools(tools);

    JPanel activePanel = new JPanel();
    activePanel.setAlignmentX(LEFT_ALIGNMENT);
    activePanel.setAlignmentY(TOP_ALIGNMENT);
    activePanel.setLayout(new BorderLayout());
    activePanel.add(tools, BorderLayout.NORTH);
    activePanel.add(contents, BorderLayout.CENTER);

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

    JMenuBar mb = new JMenuBar();
    createMenus(mb);
    setJMenuBar(mb);

    Dimension d = defaultSize();
    if (d.width > mb.getPreferredSize().width) {
      setSize(d.width, d.height);
    } else {
      setSize(mb.getPreferredSize().width, d.height);
    }
    addListeners();
    setVisible(true);
    fStorageFormatManager = createStorageFormatManager();

    toolDone();
  }
  /**
   * Constructor del panel.
   *
   * @param nPrincipal Interfaz principal de la aplicación.
   */
  public PanelLibros(InterfazBiblioteca nPrincipal) {
    principal = nPrincipal;

    setLayout(new BorderLayout());
    panelCentral = new JPanel();
    panelCentral.setAlignmentX(0.0F);
    panelCentral.setBackground(Color.white);
    panelCentral.setAlignmentY(0.0F);
    layout = new GridLayout();
    panelCentral.setLayout(layout);

    // Inicialización del scroll pane.
    scroll = new JScrollPane();
    scroll.setSize(530, 572);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scroll.setPreferredSize(new Dimension(530, 572));
    scroll.setViewportView(panelCentral);
    add(scroll, BorderLayout.CENTER);
  }
  /**
   * The constructor.
   *
   * @param parent The parent window.
   * @param idata The installation data.
   */
  public SudoPanel(InstallerFrame parent, InstallData idata) {
    super(parent, idata);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.info")*/ "For installing administrator privileges are necessary",
            JLabel.TRAILING));

    add(Box.createRigidArea(new Dimension(0, 5)));

    add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.tip")*/ "Please note that passwords are case-sensitive",
            parent.icons.getImageIcon("tip"),
            JLabel.TRAILING));

    add(Box.createRigidArea(new Dimension(0, 5)));

    JPanel spacePanel = new JPanel();
    spacePanel.setAlignmentX(LEFT_ALIGNMENT);
    spacePanel.setAlignmentY(CENTER_ALIGNMENT);
    spacePanel.setBorder(BorderFactory.createEmptyBorder(80, 30, 0, 50));
    spacePanel.setLayout(new BorderLayout(5, 5));
    spacePanel.add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.specifyAdminPassword")*/ "Please specify your password:"),
        BorderLayout.NORTH);
    passwordField = new JPasswordField();
    passwordField.addActionListener(this);
    JPanel space2Panel = new JPanel();
    space2Panel.setLayout(new BorderLayout());
    space2Panel.add(passwordField, BorderLayout.NORTH);
    space2Panel.add(Box.createRigidArea(new Dimension(0, 5)), BorderLayout.CENTER);
    spacePanel.add(space2Panel, BorderLayout.CENTER);
    add(spacePanel);
  }
Esempio n. 11
0
 public JPanel getTransformPanel() {
   final JPanel transform = new JPanel();
   transform.setAlignmentY(Component.TOP_ALIGNMENT);
   transform.setAlignmentX(Component.LEFT_ALIGNMENT);
   transform.setLayout(new BoxLayout(transform, BoxLayout.Y_AXIS));
   transform.setBorder(
       BorderFactory.createCompoundBorder(
           spaceY,
           new TitledBorder(
               null,
               Messages.getString("ImageTool.transform"), // $NON-NLS-1$
               TitledBorder.DEFAULT_JUSTIFICATION,
               TitledBorder.DEFAULT_POSITION,
               TITLE_FONT,
               TITLE_COLOR)));
   ActionState zoomAction = EventManager.getInstance().getAction(ActionW.ZOOM);
   if (zoomAction instanceof SliderChangeListener) {
     final JSliderW zoomSlider = ((SliderChangeListener) zoomAction).createSlider(0, true);
     JMVUtils.setPreferredWidth(zoomSlider, 100);
     transform.add(zoomSlider.getParent());
   }
   ActionState rotateAction = EventManager.getInstance().getAction(ActionW.ROTATION);
   if (rotateAction instanceof SliderChangeListener) {
     final JSliderW rotationSlider = ((SliderChangeListener) rotateAction).createSlider(4, true);
     JMVUtils.setPreferredWidth(rotationSlider, 100);
     transform.add(rotationSlider.getParent());
   }
   ActionState flipAction = EventManager.getInstance().getAction(ActionW.FLIP);
   if (flipAction instanceof ToggleButtonListener) {
     JPanel pane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 3));
     pane.add(
         ((ToggleButtonListener) flipAction)
             .createCheckBox(Messages.getString("ImageTool.flip"))); // $NON-NLS-1$
     transform.add(pane);
   }
   return transform;
 }
Esempio n. 12
0
  /** Create the dialog. */
  public MainApplicationWindow() {
    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent arg0) {
            try {
              bgd.close();
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        });

    final JDialog d = new JDialog();
    JPanel p1 = new JPanel(new GridBagLayout());
    p1.add(new JLabel("Prosim cakajte, pripravujem data..."), new GridBagConstraints());
    d.getContentPane().add(p1);
    d.setSize(300, 100);
    d.setLocationRelativeTo(this);
    d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    waitDialog = d;

    setTitle("Wiki kategorie");
    setBounds(100, 100, 614, 455);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));
    {
      JPanel panel = new JPanel();
      contentPanel.add(panel, BorderLayout.NORTH);
      GridBagLayout gbl_panel = new GridBagLayout();
      gbl_panel.columnWidths = new int[] {588, 0};
      gbl_panel.rowHeights = new int[] {23, 0};
      gbl_panel.columnWeights = new double[] {1.0, Double.MIN_VALUE};
      gbl_panel.rowWeights = new double[] {0.0, Double.MIN_VALUE};
      panel.setLayout(gbl_panel);
      {
        JButton btnNewButton_1 = new JButton("Vycistit textove pole");
        btnNewButton_1.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent arg0) {
                clearTextArea();
              }
            });
        GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
        gbc_btnNewButton_1.anchor = GridBagConstraints.NORTHEAST;
        gbc_btnNewButton_1.gridx = 0;
        gbc_btnNewButton_1.gridy = 0;
        panel.add(btnNewButton_1, gbc_btnNewButton_1);
      }
    }
    {
      JTextArea mainTextArea = new JTextArea();
      mainTextArea.setEditable(false);
      mainTextArea.setBackground(Color.LIGHT_GRAY);
      myTextArea = mainTextArea;
    }
    {
      JScrollPane scrollPane = new JScrollPane(myTextArea);
      contentPanel.add(scrollPane, BorderLayout.CENTER);
    }

    {
      JPanel panel = new JPanel();
      getContentPane().add(panel, BorderLayout.SOUTH);
      panel.setLayout(new BorderLayout(0, 0));
      {
        JLabel lblNewLabel =
            new JLabel(
                "Prehladaj na zaklade nazvu clanku alebo kategorie (pouzi cele slovo, nie iba cast)");
        panel.add(lblNewLabel, BorderLayout.NORTH);
      }
      {
        JPanel textPanel = new JPanel();
        panel.add(textPanel);
        textPanel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
        textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS));
        {
          textField = new JTextField();
          textPanel.add(textField);
          textField.setColumns(10);
        }
        {
          JButton enterButton = new JButton("Clanok alebo kategoria");
          enterButton.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                  if (!textField.getText().isEmpty()) {
                    RefreshArtOrCateg(textField.getText());
                  }
                }
              });
          textPanel.add(enterButton);
          enterButton.setAlignmentX(Component.CENTER_ALIGNMENT);
        }
      }
      {
        JPanel buttonPane = new JPanel();
        panel.add(buttonPane, BorderLayout.SOUTH);
        {
          JButton exitlButton = new JButton("Koniec");
          exitlButton.addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent arg0) {
                  Exit();
                }
              });
          {
            JButton btnNewButton = new JButton("Zobraz");
            btnNewButton.addActionListener(
                new ActionListener() {
                  public void actionPerformed(ActionEvent arg0) {
                    Refresh(myComboBox.getSelectedIndex());
                  }
                });
            buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
            {
              JLabel lblNewLabel_1 = new JLabel("Preddefinovane statistiky: ");
              buttonPane.add(lblNewLabel_1);
            }
            {
              JComboBox comboBox = new JComboBox();
              comboBox.setModel(
                  new DefaultComboBoxModel(
                      new String[] {
                        "Porovnanie kategorii z XML a SQL",
                        "Priemerny pocet kategorii",
                        "Kategorie s max a min poctom pouziti (podla XML)",
                        "Kategorie s max a min poctom pouziti (podla SQL)"
                      }));
              myComboBox = comboBox;
              buttonPane.add(comboBox);
            }
            buttonPane.add(btnNewButton);
          }
          buttonPane.add(exitlButton);
        }
      }
    }
  }
Esempio n. 13
0
  /** Returns input pane where user can configure a drbd resource. */
  @Override
  protected JComponent getInputPane() {
    final DrbdResourceInfo dri = getDrbdVolumeInfo().getDrbdResourceInfo();
    final DrbdInfo drbdInfo = dri.getDrbdInfo();
    dri.getInfoPanel();
    dri.waitForInfoPanel();
    Tools.waitForSwing();
    final JPanel inputPane = new JPanel();
    inputPane.setLayout(new BoxLayout(inputPane, BoxLayout.X_AXIS));

    final JPanel optionsPanel = new JPanel();
    optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS));
    optionsPanel.setAlignmentY(Component.TOP_ALIGNMENT);
    /* common options */
    final Map<String, String> commonPreferredValue = new HashMap<String, String>();
    commonPreferredValue.put(PROTOCOL, "C");
    commonPreferredValue.put(DEGR_WFC_TIMEOUT_PARAM, "0");
    commonPreferredValue.put(CRAM_HMAC_ALG, "sha1");
    commonPreferredValue.put(SHARED_SECRET, getRandomSecret());
    commonPreferredValue.put(ON_IO_ERROR, "detach");
    if (drbdInfo.getDrbdResources().size() <= 1) {
      for (final String commonP : COMMON_PARAMS) {
        /* for the first resource set common options. */
        final String commonValue = drbdInfo.getResource().getValue(commonP);
        if (commonPreferredValue.containsKey(commonP)) {
          final String defaultValue = drbdInfo.getParamDefault(commonP);
          if ((defaultValue == null && "".equals(commonValue))
              || (defaultValue != null && defaultValue.equals(commonValue))) {
            drbdInfo.getWidget(commonP, null).setValue(commonPreferredValue.get(commonP));
            dri.getResource().setValue(commonP, commonPreferredValue.get(commonP));
          } else {
            dri.getResource().setValue(commonP, commonValue);
          }
        }
      }
    } else {
      /* resource options, if not defined in common section. */
      for (final String commonP : COMMON_PARAMS) {
        final String commonValue = drbdInfo.getResource().getValue(commonP);
        if ("".equals(commonValue) && commonPreferredValue.containsKey(commonP)) {
          dri.getResource().setValue(commonP, commonPreferredValue.get(commonP));
        }
      }
    }

    /* address combo boxes */
    dri.addHostAddresses(
        optionsPanel,
        ClusterBrowser.SERVICE_LABEL_WIDTH,
        ClusterBrowser.SERVICE_FIELD_WIDTH,
        true,
        buttonClass(nextButton()));
    dri.addWizardParams(
        optionsPanel,
        PARAMS,
        buttonClass(nextButton()),
        Tools.getDefaultSize("Dialog.DrbdConfig.Resource.LabelWidth"),
        Tools.getDefaultSize("Dialog.DrbdConfig.Resource.FieldWidth"),
        null);

    inputPane.add(optionsPanel);
    final JScrollPane sp = new JScrollPane(inputPane);
    sp.setMaximumSize(new Dimension(Short.MAX_VALUE, 200));
    sp.setPreferredSize(new Dimension(Short.MAX_VALUE, 200));
    return sp;
  }
  /**
   * Creates a new instance of CategoryPropertyRenderer
   *
   * @param property an instance of XmlCategory
   * @param ignoreCategory true if it must only render the sub items of the given category
   */
  public CategoryPropertyRenderer(XmlCategory category, boolean ignoreCategory) {
    super(new GridBagLayout());

    this.category = category;

    this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    this.setAlignmentX(0.0f);
    this.setAlignmentY(0.0f);

    int y = 1;
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.anchor = gbc.LINE_START;

    if (!ignoreCategory) {
      gbc.gridx = 1;
      gbc.gridy = y;
      gbc.gridheight = 1;
      gbc.gridwidth = 1;
      gbc.anchor = gbc.WEST;
      //            gbc.anchor = gbc.FIRST_LINE_START;
      //            gbc.weightx = 1;
      //            gbc.weighty = 0;
      gbc.insets = new Insets(0, 0, 3, 0);

      JLabel title =
          new JLabel(
              "<html><u><font color=\"#FF0000\">" + category.getLabel() + "</font></u></html>");

      if (DEBUG) {
        title.setBackground(Color.PINK);
        title.setOpaque(true);
      }

      title.setHorizontalTextPosition(SwingConstants.RIGHT);
      title.setAlignmentX(0.0f);

      if (category.getIcon() != null) {
        if (category.getIcon().trim().length() > 0) {
          try {
            title.setIcon(ResourceLoader.getInstance().getIconNamed(category.getIcon()));
          } catch (ResourceException e) {
            e.printStackTrace();
          }
        }
      }

      this.add(title, gbc);

      y += 2;
    }

    int separatorStart = y;

    /* add elements recursively */
    if (this.category != null) {
      if (this.category.getItems() != null) {
        Iterator<XmlPropertyContainer> it = this.category.getItems().iterator();

        while (it.hasNext()) {
          Object current = it.next();

          boolean added = false;

          if (current instanceof XmlProperty) {
            XmlProperty property = (XmlProperty) current;

            PropertyEditor editor = EditorPropertiesComponentFactory.editProperty(property);

            if (editor != null) {
              /* create property label */
              JLabel label = EditorPropertiesComponentFactory.createLabel(property);
              editor.setLabel(label);

              JComponent[] components = new JComponent[2];
              components[0] = label;
              components[1] = editor.getComponent();

              for (int i = 0; i < components.length; i++) {
                JComponent component = components[i];
                if (component != null) {
                  if (!added) added = true;

                  gbc = new GridBagConstraints();

                  gbc.gridx = i + 1;
                  gbc.gridy = y;
                  gbc.gridheight = 1;
                  gbc.gridwidth = 1;
                  //                                    gbc.weightx = 1;
                  //                                    gbc.weighty = 0;
                  gbc.anchor = gbc.FIRST_LINE_START;

                  gbc.anchor = gbc.WEST;

                  gbc.insets = new Insets(0, LEFT_BORDER, 0, 0);
                  component.setAlignmentX(0.0f);
                  component.setAlignmentY(0.0f);
                  this.add(component, gbc);
                }
              }
            }
          } else if (current instanceof XmlCategory) {
            gbc = new GridBagConstraints();

            gbc.gridx = 1;
            gbc.gridy = y;
            gbc.gridheight = 1;
            gbc.gridwidth = 10;
            gbc.insets = new Insets(0, LEFT_BORDER, 0, 0);
            gbc.anchor = gbc.WEST;
            //                        gbc.weightx = 1;
            //                        gbc.weighty = 0;
            added = true;
            JPanel panel = EditorPropertiesComponentFactory.renderCategory((XmlCategory) current);
            //                        JPanel panel =
            // EditorPropertiesComponentFactory.renderCategoryItems( (XmlCategory)current );

            panel.setAlignmentX(0.0f);
            panel.setAlignmentY(0.0f);

            if (DEBUG) {
              panel.setBackground(Color.GREEN);

              System.out.println("sub category : " + ((XmlCategory) current).getLabel());

              System.out.println("ajout avec contrainte : ");
              System.out.println("\tgridx : " + gbc.gridx);
              System.out.println("\tgridy : " + gbc.gridy);
              System.out.println("\tanchor : " + gbc.anchor);
              System.out.println("\tfill : " + gbc.fill);
              System.out.println("\tgridheight : " + gbc.gridheight);
              System.out.println("\tgridwidth : " + gbc.gridwidth);
              System.out.println("\tinsets : " + gbc.insets);
              System.out.println("\tipadx : " + gbc.ipadx);
              System.out.println("\tipady : " + gbc.ipady);
              System.out.println("\tweightx : " + gbc.weightx);
              System.out.println("\tweighty : " + gbc.weighty);

              System.out.println("panel properties : ");
              System.out.println("\tpanel align x : " + panel.getAlignmentX());
              System.out.println("\tpanel align y : " + panel.getAlignmentY());
              System.out.println("\tborder : " + panel.getBorder());
              System.out.println("\tinsets : " + panel.getInsets());
            }

            this.add(panel, gbc);
          }

          if (added) {
            y += 2;
            gbc = new GridBagConstraints();
            gbc.gridy = y;
            this.add(new JToolBar.Separator(new Dimension(2, 2)), gbc);

            y += 1;

            if (current instanceof XmlCategory) {
              gbc = new GridBagConstraints();
              gbc.gridy = y;
              this.add(new JToolBar.Separator(new Dimension(2, 2)), gbc);

              y += 1;
            }
          }
        }

        /* add a JSeparator to group elements of this category */
        //                gbc.gridx      = 1;
        //                gbc.gridy      = separatorStart;
        //                gbc.gridwidth  = 1;
        //                gbc.gridheight = y - separatorStart;
        //                gbc.insets     = new Insets(0, 0, 0, 0);
        //
        //                System.out.println("height : " + (y - separatorStart));
        //                this.add(new JSeparator(SwingConstants.VERTICAL), gbc);
      }
    }

    /** add a virtual label with weight at 1 to disable space distribution to previous items */
    gbc = new GridBagConstraints();

    gbc.gridx = 999;
    gbc.gridy = 999;
    gbc.weightx = 1.0f;
    gbc.weighty = 1.0f;
    this.add(new JLabel(""), gbc);
  }
Esempio n. 15
0
    @Override
    public Void doInBackground() throws Exception {
      StringBuilder message = new StringBuilder();
      try {
        getManager().deleteBean(t, "CanDelete"); // IN18N
      } catch (PropertyVetoException e) {
        if (e.getPropertyChangeEvent().getPropertyName().equals("DoNotDelete")) { // IN18N
          log.warn(e.getMessage());
          message.append(
              Bundle.getMessage(
                  "VetoDeleteBean",
                  t.getBeanType(),
                  t.getFullyFormattedDisplayName(),
                  e.getMessage()));
          JOptionPane.showMessageDialog(
              null,
              message.toString(),
              Bundle.getMessage("WarningTitle"),
              JOptionPane.ERROR_MESSAGE);
          return null;
        }
        message.append(e.getMessage());
      }
      int count = t.getNumPropertyChangeListeners();
      if (log.isDebugEnabled()) {
        log.debug("Delete with " + count);
      }
      if (getDisplayDeleteMsg() == 0x02 && message.toString().equals("")) {
        doDelete(t);
      } else {
        final JDialog dialog = new JDialog();
        dialog.setTitle(Bundle.getMessage("WarningTitle"));
        dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        JPanel container = new JPanel();
        container.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
        if (count > 0) { // warn of listeners attached before delete

          JLabel question =
              new JLabel(Bundle.getMessage("DeletePrompt", t.getFullyFormattedDisplayName()));
          question.setAlignmentX(Component.CENTER_ALIGNMENT);
          container.add(question);

          ArrayList<String> listenerRefs = t.getListenerRefs();
          if (listenerRefs.size() > 0) {
            ArrayList<String> listeners = new ArrayList<>();
            for (int i = 0; i < listenerRefs.size(); i++) {
              if (!listeners.contains(listenerRefs.get(i))) {
                listeners.add(listenerRefs.get(i));
              }
            }

            message.append("<br>");
            message.append(Bundle.getMessage("ReminderInUse", count));
            message.append("<ul>");
            for (int i = 0; i < listeners.size(); i++) {
              message.append("<li>");
              message.append(listeners.get(i));
              message.append("</li>");
            }
            message.append("</ul>");

            JEditorPane pane = new JEditorPane();
            pane.setContentType("text/html");
            pane.setText("<html>" + message.toString() + "</html>");
            pane.setEditable(false);
            JScrollPane jScrollPane = new JScrollPane(pane);
            container.add(jScrollPane);
          }
        } else {
          String msg =
              MessageFormat.format(
                  Bundle.getMessage("DeletePrompt"), new Object[] {t.getSystemName()});
          JLabel question = new JLabel(msg);
          question.setAlignmentX(Component.CENTER_ALIGNMENT);
          container.add(question);
        }

        final JCheckBox remember = new JCheckBox(Bundle.getMessage("MessageRememberSetting"));
        remember.setFont(remember.getFont().deriveFont(10f));
        remember.setAlignmentX(Component.CENTER_ALIGNMENT);

        JButton yesButton = new JButton(Bundle.getMessage("ButtonYes"));
        JButton noButton = new JButton(Bundle.getMessage("ButtonNo"));
        JPanel button = new JPanel();
        button.setAlignmentX(Component.CENTER_ALIGNMENT);
        button.add(yesButton);
        button.add(noButton);
        container.add(button);

        noButton.addActionListener(
            (ActionEvent e) -> {
              // there is no point in remembering this the user will never be
              // able to delete a bean!
              dialog.dispose();
            });

        yesButton.addActionListener(
            (ActionEvent e) -> {
              if (remember.isSelected()) {
                setDisplayDeleteMsg(0x02);
              }
              doDelete(t);
              dialog.dispose();
            });
        container.add(remember);
        container.setAlignmentX(Component.CENTER_ALIGNMENT);
        container.setAlignmentY(Component.CENTER_ALIGNMENT);
        dialog.getContentPane().add(container);
        dialog.pack();
        dialog.setLocation(
            (Toolkit.getDefaultToolkit().getScreenSize().width) / 2 - dialog.getWidth() / 2,
            (Toolkit.getDefaultToolkit().getScreenSize().height) / 2 - dialog.getHeight() / 2);
        dialog.setModal(true);
        dialog.setVisible(true);
      }
      return null;
    }
  // Constructor for the dialogue box
  public Route_addroute_dialogue(String[] Airports) {

    String[] Carriers = {"Delta", "United"};

    // Initialize all input boxes and drop-down menus
    JTextField Routenumtxt = new JTextField("0");
    JTextField Pricetxt = new JTextField("0.00");

    JComboBox Carrierchoice = new JComboBox(Carriers);
    JComboBox DepAPchoice = new JComboBox(Airports);
    JComboBox ArrAPchoice = new JComboBox(Airports);

    TimeSelectBoxPanel Deptimechoice = new TimeSelectBoxPanel();
    TimeSelectBoxPanel Arrtimechoice = new TimeSelectBoxPanel();

    // Combine choice fields with their appropriate labels in panels
    Routenumpanel.add(Routenumlabel);
    Routenumpanel.add(Routenumtxt);
    Routenumpanel.setLayout(new BoxLayout(Routenumpanel, BoxLayout.Y_AXIS));
    Routenumpanel.setAlignmentY(CENTER_ALIGNMENT);

    Carrierpanel.add(Carrierlabel);
    Carrierpanel.add(Carrierchoice);
    Carrierpanel.setLayout(new BoxLayout(Carrierpanel, BoxLayout.Y_AXIS));
    Carrierpanel.setAlignmentY(LEFT_ALIGNMENT);

    DepAPpanel.add(DepAPlabel);
    DepAPpanel.add(DepAPchoice);
    DepAPpanel.setLayout(new BoxLayout(DepAPpanel, BoxLayout.Y_AXIS));
    DepAPpanel.setAlignmentY(CENTER_ALIGNMENT);

    Deptimepanel.add(Deptimelabel);
    Deptimepanel.add(Deptimechoice);
    Deptimepanel.setLayout(new BoxLayout(Deptimepanel, BoxLayout.Y_AXIS));
    Deptimepanel.setAlignmentY(CENTER_ALIGNMENT);

    ArrAPpanel.add(ArrAPlabel);
    ArrAPpanel.add(ArrAPchoice);
    ArrAPpanel.setLayout(new BoxLayout(ArrAPpanel, BoxLayout.Y_AXIS));
    ArrAPpanel.setAlignmentY(CENTER_ALIGNMENT);

    Arrtimepanel.add(Arrtimelabel);
    Arrtimepanel.add(Arrtimechoice);
    Arrtimepanel.setLayout(new BoxLayout(Arrtimepanel, BoxLayout.Y_AXIS));
    Arrtimepanel.setAlignmentY(CENTER_ALIGNMENT);

    Pricepanel.add(Pricelabel);
    Pricepanel.add(Pricetxt);
    Pricepanel.setLayout(new BoxLayout(Pricepanel, BoxLayout.Y_AXIS));
    Pricepanel.setAlignmentY(CENTER_ALIGNMENT);

    // Add all choice panels to the overall choice panel
    Choicepanel.setLayout(new FlowLayout());
    Choicepanel.add(Routenumpanel);
    Choicepanel.add(Carrierpanel);
    Choicepanel.add(DepAPpanel);
    Choicepanel.add(Deptimepanel);
    Choicepanel.add(ArrAPpanel);
    Choicepanel.add(Arrtimepanel);
    Choicepanel.add(Pricepanel);

    // Add the buttons to the overall button panel
    Buttonpanel.setLayout(new FlowLayout());
    Buttonpanel.add(Cancelbutton);
    Buttonpanel.add(Addroutebutton);

    // Add the choice panel and button to the dialogue box
    setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
    add(Choicepanel);
    add(Buttonpanel);
  }
  /** return the index toolbar for the left subwindow */
  @Override
  protected JScrollPane getToolbar() {

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

    panel.setBackground(Color.YELLOW);
    panel.setAlignmentY(0);

    // Button slideshow
    JButton buttonDiashow = new JButton("?Diashow?");
    //   panelErsteZeile.setBackground(color);
    panel.add(buttonDiashow);
    ActionListener alDiashow =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            List<PM_Picture> pictures = indexController.getPictureListDisplayed();
            if (!pictures.isEmpty()) {
              PM_Picture picSelected = indexController.getFirstPictureSelected();
              if (picSelected == null) {
                picSelected = pictures.get(0);
              }
              windowMain.doDiaShow(picSelected, pictures, DIASHOW_NORMAL);
            }
          }
        };
    buttonDiashow.addActionListener(alDiashow);

    // Clear Button
    JButton clearButton = PM_Utils.getJButon(ICON_DELETE);
    panel.add(clearButton);
    ActionListener alClearButton =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            windowBase.removeAllPictures();
          }
        };
    clearButton.addActionListener(alClearButton);

    // Button "reread"
    JButton buttonReRead = PM_Utils.getJButon(ICON_REREAD);
    panel.add(buttonReRead);
    ActionListener alReRead =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            index.controller.rereadAllThumbs();
          }
        };
    buttonReRead.addActionListener(alReRead);

    // Button to right >
    rButton = PM_Utils.getJButon(ICON_1_RIGHT);
    panel.add(rButton);
    ActionListener alR =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            PM_WindowBase window = windowMain.getWindowRightSelected();
            window.getAllThumbs(index);
          }
        };
    rButton.addActionListener(alR);

    // Button append to right >>
    rrButton = PM_Utils.getJButon(ICON_2_RIGHT); // new JButton(">")
    panel.add(rrButton);
    ActionListener alRR =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            PM_WindowBase window = windowMain.getWindowRightSelected();
            window.appendAllThumbs(index);
          }
        };
    rrButton.addActionListener(alRR);

    // make scroll pane
    JScrollPane sc = new JScrollPane(panel);
    sc.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    return sc;
  }
Esempio n. 18
0
  ConversionPanel(
      Converter myController, String myTitle, Unit[] myUnits, ConverterRangeModel myModel) {
    if (MULTICOLORED) {
      setOpaque(true);
      setBackground(new Color(0, 255, 255));
    }
    setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(myTitle),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Save arguments in instance variables.
    controller = myController;
    units = myUnits;
    title = myTitle;
    sliderModel = myModel;

    // Create the text field format, and then the text field.
    numberFormat = NumberFormat.getNumberInstance();
    numberFormat.setMaximumFractionDigits(2);
    NumberFormatter formatter = new NumberFormatter(numberFormat);
    formatter.setAllowsInvalid(false);
    formatter.setCommitsOnValidEdit(true); // seems to be a no-op --
    // aha -- it changes the value property but doesn't cause the result to
    // be parsed (that happens on focus loss/return, I think).
    //
    textField = new JFormattedTextField(formatter);
    textField.setColumns(10);
    textField.setValue(new Double(sliderModel.getDoubleValue()));
    textField.addPropertyChangeListener(this);

    // Add the combo box.
    unitChooser = new JComboBox();
    for (int i = 0; i < units.length; i++) { // Populate it.
      unitChooser.addItem(units[i].description);
    }
    unitChooser.setSelectedIndex(0);
    sliderModel.setMultiplier(units[0].multiplier);
    unitChooser.addActionListener(this);

    // Add the slider.
    slider = new JSlider(sliderModel);
    sliderModel.addChangeListener(this);

    // Make the text field/slider group a fixed size
    // to make stacked ConversionPanels nicely aligned.
    JPanel unitGroup =
        new JPanel() {
          public Dimension getMinimumSize() {
            return getPreferredSize();
          }

          public Dimension getPreferredSize() {
            return new Dimension(150, super.getPreferredSize().height);
          }

          public Dimension getMaximumSize() {
            return getPreferredSize();
          }
        };
    unitGroup.setLayout(new BoxLayout(unitGroup, BoxLayout.PAGE_AXIS));
    if (MULTICOLORED) {
      unitGroup.setOpaque(true);
      unitGroup.setBackground(new Color(0, 0, 255));
    }
    unitGroup.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    unitGroup.add(textField);
    unitGroup.add(slider);

    // Create a subpanel so the combo box isn't too tall
    // and is sufficiently wide.
    JPanel chooserPanel = new JPanel();
    chooserPanel.setLayout(new BoxLayout(chooserPanel, BoxLayout.PAGE_AXIS));
    if (MULTICOLORED) {
      chooserPanel.setOpaque(true);
      chooserPanel.setBackground(new Color(255, 0, 255));
    }
    chooserPanel.add(unitChooser);
    chooserPanel.add(Box.createHorizontalStrut(100));

    // Put everything together.
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    add(unitGroup);
    add(chooserPanel);
    unitGroup.setAlignmentY(TOP_ALIGNMENT);
    chooserPanel.setAlignmentY(TOP_ALIGNMENT);
  }
Esempio n. 19
0
  /**
   * run 'java visad.bom.ImageRendererJ3D len step' to test animation behavior of ImageRendererJ3D
   * renders a loop of len at step ms per frame then updates loop by deleting first time and adding
   * a new last time
   */
  public static void main(String args[]) throws VisADException, RemoteException, IOException {

    int step = 1000;
    int len = 3;
    if (args.length > 0) {
      try {
        len = Integer.parseInt(args[0]);
      } catch (NumberFormatException e) {
        len = 3;
      }
    }
    if (len < 1) len = 1;
    if (args.length > 1) {
      try {
        step = Integer.parseInt(args[1]);
      } catch (NumberFormatException e) {
        step = 1000;
      }
    }
    if (step < 1) step = 1;

    // create a netCDF reader
    Plain plain = new Plain();

    // open a netCDF file containing an image sequence and adapt
    // it to a Field Data object
    Field raw_image_sequence = null;
    try {
      // raw_image_sequence = (Field) plain.open("images256x256.nc");
      raw_image_sequence = (Field) plain.open("images.nc");
    } catch (IOException exc) {
      String s =
          "To run this example, the images.nc file must be "
              + "present in\nthe current directory."
              + "You can obtain this file from:\n"
              + "  ftp://www.ssec.wisc.edu/pub/visad-2.0/images.nc.Z";
      System.out.println(s);
      System.exit(0);
    }

    // just take first half of raw_image_sequence
    FunctionType image_sequence_type = (FunctionType) raw_image_sequence.getType();
    Set raw_set = raw_image_sequence.getDomainSet();
    float[][] raw_times = raw_set.getSamples();
    int raw_len = raw_times[0].length;
    if (raw_len != 4) {
      throw new VisADException("wrong number of images in sequence");
    }
    float raw_span = (4.0f / 3.0f) * (raw_times[0][3] - raw_times[0][0]);

    double[][] times = new double[1][len];
    for (int i = 0; i < len; i++) {
      times[0][i] = raw_times[0][i % raw_len] + raw_span * (i / raw_len);
    }
    Gridded1DDoubleSet set = new Gridded1DDoubleSet(raw_set.getType(), times, len);
    Field image_sequence = new FieldImpl(image_sequence_type, set);
    for (int i = 0; i < len; i++) {
      image_sequence.setSample(i, raw_image_sequence.getSample(i % raw_len));
    }

    // create a DataReference for image sequence
    final DataReference image_ref = new DataReferenceImpl("image");
    image_ref.setData(image_sequence);

    // create a Display using Java3D
    DisplayImpl display = new DisplayImplJ3D("image display");

    // extract the type of image and use
    // it to determine how images are displayed
    FunctionType image_type = (FunctionType) image_sequence_type.getRange();
    RealTupleType domain_type = image_type.getDomain();
    // map image coordinates to display coordinates
    display.addMap(new ScalarMap((RealType) domain_type.getComponent(0), Display.XAxis));
    display.addMap(new ScalarMap((RealType) domain_type.getComponent(1), Display.YAxis));
    // map image brightness values to RGB (default is grey scale)
    display.addMap(new ScalarMap((RealType) image_type.getRange(), Display.RGB));
    RealType hour_type = (RealType) image_sequence_type.getDomain().getComponent(0);
    ScalarMap animation_map = new ScalarMap(hour_type, Display.Animation);
    display.addMap(animation_map);
    AnimationControl animation_control = (AnimationControl) animation_map.getControl();
    animation_control.setStep(step);
    animation_control.setOn(true);

    /*
        // link the Display to image_ref
        ImageRendererJ3D renderer = new ImageRendererJ3D();
        display.addReferences(renderer, image_ref);
        // display.addReference(image_ref);
    */

    // create JFrame (i.e., a window) for display and slider
    JFrame frame = new JFrame("ImageRendererJ3D test");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    // create JPanel in JFrame
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setAlignmentY(JPanel.TOP_ALIGNMENT);
    panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
    frame.getContentPane().add(panel);

    // add display to JPanel
    panel.add(display.getComponent());

    // set size of JFrame and make it visible
    frame.setSize(500, 500);
    frame.setVisible(true);

    System.out.println("first animation sequence");
    // link the Display to image_ref
    ImageRendererJ3D renderer = new ImageRendererJ3D();
    display.addReferences(renderer, image_ref);
    // display.addReference(image_ref);

    // wait 4 * len seconds
    new Delay(len * 4000);

    // substitute a new image sequence for the old one
    for (int i = 0; i < len; i++) {
      times[0][i] = raw_times[0][(i + 1) % raw_len] + raw_span * ((i + 1) / raw_len);
    }
    set = new Gridded1DDoubleSet(raw_set.getType(), times, len);
    FieldImpl new_image_sequence = new FieldImpl(image_sequence_type, set);
    for (int i = 0; i < len; i++) {
      new_image_sequence.setSample(i, raw_image_sequence.getSample((i + 1) % raw_len));
    }

    System.out.println("second animation sequence");

    // tell renderer to resue frames in its scene graph
    renderer.setReUseFrames(true);
    image_ref.setData(new_image_sequence);
  }
Esempio n. 20
0
  public AlbumScreen(
      LoginScreen login, AlbumsScreen albumsScreen, IUserController currentUser, AlbumModel album) {
    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            logout();
          }
        });

    // Error image that will be displayed if a photo has an invalid path
    try {
      errorImage = ImageIO.read(new File("data//error.png"));
    } catch (IOException e) {

    }

    this.currentUser = currentUser;
    this.album = album;
    this.albumsScreen = albumsScreen;
    this.login = login;

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setBounds(100, 100, 800, 600);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    GridBagLayout gbl_contentPane = new GridBagLayout();
    gbl_contentPane.columnWidths = new int[] {0, 0, 0, 0, 0, 0};
    gbl_contentPane.rowHeights = new int[] {0, 0, 0, 0};
    gbl_contentPane.columnWeights = new double[] {0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    gbl_contentPane.rowWeights = new double[] {0.0, 1.0, 0.0, Double.MIN_VALUE};
    contentPane.setLayout(gbl_contentPane);

    JLabel lblAlbumName = new JLabel("Album name");
    lblAlbumName.setText("Album name: " + album.getAlbumName());
    setTitle("Album " + album.getAlbumName());
    GridBagConstraints gbc_lblAlbumName = new GridBagConstraints();
    gbc_lblAlbumName.anchor = GridBagConstraints.WEST;
    gbc_lblAlbumName.gridwidth = 2;
    gbc_lblAlbumName.insets = new Insets(0, 0, 5, 5);
    gbc_lblAlbumName.gridx = 0;
    gbc_lblAlbumName.gridy = 0;
    contentPane.add(lblAlbumName, gbc_lblAlbumName);

    JButton btnNewButton_1 = new JButton("Slideshow");
    btnNewButton_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            showSlideshow();
          }
        });
    GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
    gbc_btnNewButton_1.insets = new Insets(0, 0, 5, 0);
    gbc_btnNewButton_1.gridx = 4;
    gbc_btnNewButton_1.gridy = 0;
    contentPane.add(btnNewButton_1, gbc_btnNewButton_1);

    scrollPane = new JScrollPane();
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = 5;
    gbc.insets = new Insets(0, 0, 5, 0);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 1;
    contentPane.add(scrollPane, gbc);

    photosPanel = new JPanel();
    photosPanel.setAlignmentY(Component.TOP_ALIGNMENT);
    photosPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    scrollPane.setViewportView(photosPanel);
    FlowLayout f = new FlowLayout(FlowLayout.CENTER, 5, 5);
    f.setAlignment(FlowLayout.LEFT);
    photosPanel.setLayout(f);

    JButton btnBack = new JButton("Back");
    btnBack.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            goBackToAlbumsScreen();
          }
        });
    GridBagConstraints gbc_btnBack = new GridBagConstraints();
    gbc_btnBack.insets = new Insets(0, 0, 0, 5);
    gbc_btnBack.gridx = 0;
    gbc_btnBack.gridy = 2;
    contentPane.add(btnBack, gbc_btnBack);

    JButton btnAddPhoto = new JButton("Add Photo");
    btnAddPhoto.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            showNewPhotoPopup();
          }
        });

    JButton btnDeletePhoto = new JButton("Remove Photo");
    btnDeletePhoto.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            deleteSelectedPhoto();
          }
        });
    GridBagConstraints gbc_btnDeletePhoto = new GridBagConstraints();
    gbc_btnDeletePhoto.insets = new Insets(0, 0, 0, 5);
    gbc_btnDeletePhoto.gridx = 3;
    gbc_btnDeletePhoto.gridy = 2;
    contentPane.add(btnDeletePhoto, gbc_btnDeletePhoto);
    GridBagConstraints gbc_btnAddPhoto = new GridBagConstraints();
    gbc_btnAddPhoto.gridx = 4;
    gbc_btnAddPhoto.gridy = 2;
    contentPane.add(btnAddPhoto, gbc_btnAddPhoto);
    updatePhotos();
  }
Esempio n. 21
0
  public FindReplaceDialog(RobocodeEditor owner) {
    super(owner, false);
    editor = owner;

    GroupLayout layout = new GroupLayout(getContentPane());

    getContentPane().setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    JPanel optionsPanel = new JPanel();

    optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS));
    optionsPanel.setBorder(
        BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Options"));
    optionsPanel.add(getCaseSensitiveCheckBox());
    optionsPanel.add(getWholeWordCheckBox());
    optionsPanel.setAlignmentY(TOP_ALIGNMENT);

    JPanel usePanel = new JPanel();

    usePanel.setLayout(new BoxLayout(usePanel, BoxLayout.Y_AXIS));
    usePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Use"));
    usePanel.add(getLiteralButton());
    usePanel.add(getWildCardsButton());
    usePanel.add(getRegexButton());
    usePanel.setAlignmentY(TOP_ALIGNMENT);

    ButtonGroup buttonGroup = new ButtonGroup();

    buttonGroup.add(getLiteralButton());
    buttonGroup.add(getWildCardsButton());
    buttonGroup.add(getRegexButton());

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(LEADING)
                    .addGroup(
                        layout
                            .createSequentialGroup()
                            .addComponent(getFindLabel())
                            .addComponent(getFindTextField()))
                    .addGroup(
                        layout
                            .createSequentialGroup()
                            .addComponent(getReplaceLabel())
                            .addComponent(getReplaceTextField()))
                    .addGroup(
                        layout
                            .createSequentialGroup()
                            .addComponent(optionsPanel)
                            .addComponent(usePanel)))
            .addGroup(
                layout
                    .createParallelGroup(LEADING)
                    .addComponent(getFindNextButton())
                    .addComponent(getReplaceFindButton())
                    .addComponent(getReplaceButton())
                    .addComponent(getReplaceAllButton())
                    .addComponent(getCloseButton())));

    layout.linkSize(SwingConstants.HORIZONTAL, getFindLabel(), getReplaceLabel());
    layout.linkSize(
        SwingConstants.HORIZONTAL,
        getFindNextButton(),
        getReplaceFindButton(),
        getReplaceButton(),
        getReplaceAllButton(),
        getCloseButton());

    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(BASELINE)
                    .addComponent(getFindLabel())
                    .addComponent(getFindTextField())
                    .addComponent(getFindNextButton()))
            .addGroup(
                layout
                    .createParallelGroup(BASELINE)
                    .addComponent(getReplaceLabel())
                    .addComponent(getReplaceTextField())
                    .addComponent(getReplaceButton()))
            .addGroup(
                layout
                    .createParallelGroup(BASELINE)
                    .addComponent(optionsPanel)
                    .addComponent(usePanel)
                    .addGroup(
                        layout
                            .createSequentialGroup()
                            .addComponent(getReplaceFindButton())
                            .addComponent(getReplaceAllButton())
                            .addComponent(getCloseButton()))));

    pack();
    setResizable(false);
  }
Esempio n. 22
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;
  }
  /** Create the frame. */
  public ScenarioOptionsGUI() {
    ScenarioInformation info = ScenarioInformation.getInstance();

    setTitle(info.getmScenarioName() + " Options");
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    setBounds(100, 100, 518, 368);
    JPanel contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new BorderLayout(0, 0));

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    contentPane.add(tabbedPane);

    JPanel panelGeneral = new JPanel();
    panelGeneral.setAlignmentY(Component.TOP_ALIGNMENT);
    tabbedPane.addTab("General", null, panelGeneral, null);
    GridBagLayout gbl_panelGeneral = new GridBagLayout();
    gbl_panelGeneral.columnWidths = new int[] {0, 46, 0, 0};
    gbl_panelGeneral.rowHeights = new int[] {20, 20, 20, 20, 0};
    gbl_panelGeneral.columnWeights = new double[] {0.0, 0.0, 1.0, Double.MIN_VALUE};
    gbl_panelGeneral.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    panelGeneral.setLayout(gbl_panelGeneral);

    JLabel lblNewLabel = new JLabel("Time per GameTick in s:");
    GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
    gbc_lblNewLabel.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
    gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
    gbc_lblNewLabel.gridx = 0;
    gbc_lblNewLabel.gridy = 0;
    panelGeneral.add(lblNewLabel, gbc_lblNewLabel);
    lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);

    mTextFieldGameTickTime = new JTextField();
    GridBagConstraints gbc_mTextFieldGameTickTime = new GridBagConstraints();
    gbc_mTextFieldGameTickTime.fill = GridBagConstraints.HORIZONTAL;
    gbc_mTextFieldGameTickTime.insets = new Insets(0, 0, 5, 5);
    gbc_mTextFieldGameTickTime.gridx = 1;
    gbc_mTextFieldGameTickTime.gridy = 0;
    panelGeneral.add(mTextFieldGameTickTime, gbc_mTextFieldGameTickTime);
    mTextFieldGameTickTime.setColumns(10);
    mTextFieldGameTickTime.setText(
        Double.toString(ScenarioInformation.getInstance().getGameTickTime()));

    JLabel lblNewLabel_1 = new JLabel("Max. Ball Movement per GameTick in % of PlayField:");
    lblNewLabel_1.setHorizontalAlignment(SwingConstants.RIGHT);
    lblNewLabel_1.setEnabled(false);
    GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
    gbc_lblNewLabel_1.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
    gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
    gbc_lblNewLabel_1.gridx = 0;
    gbc_lblNewLabel_1.gridy = 1;
    panelGeneral.add(lblNewLabel_1, gbc_lblNewLabel_1);

    mTextFieldBallMovementMax = new JTextField();
    mTextFieldBallMovementMax.setEnabled(false);
    GridBagConstraints gbc_mTextFieldBallMovementMax = new GridBagConstraints();
    gbc_mTextFieldBallMovementMax.fill = GridBagConstraints.HORIZONTAL;
    gbc_mTextFieldBallMovementMax.insets = new Insets(0, 0, 5, 5);
    gbc_mTextFieldBallMovementMax.gridx = 1;
    gbc_mTextFieldBallMovementMax.gridy = 1;
    panelGeneral.add(mTextFieldBallMovementMax, gbc_mTextFieldBallMovementMax);
    mTextFieldBallMovementMax.setColumns(10);

    JLabel lblMaxAbsoluteHeight = new JLabel("Height of PlayField in % of Width:");
    lblMaxAbsoluteHeight.setHorizontalAlignment(SwingConstants.RIGHT);
    GridBagConstraints gbc_lblMaxAbsoluteHeight = new GridBagConstraints();
    gbc_lblMaxAbsoluteHeight.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblMaxAbsoluteHeight.anchor = GridBagConstraints.EAST;
    gbc_lblMaxAbsoluteHeight.insets = new Insets(0, 0, 5, 5);
    gbc_lblMaxAbsoluteHeight.gridx = 0;
    gbc_lblMaxAbsoluteHeight.gridy = 2;
    panelGeneral.add(lblMaxAbsoluteHeight, gbc_lblMaxAbsoluteHeight);

    mTextFieldFieldHeight = new JTextField();
    GridBagConstraints gbc_mTextFieldFieldHeight = new GridBagConstraints();
    gbc_mTextFieldFieldHeight.fill = GridBagConstraints.HORIZONTAL;
    gbc_mTextFieldFieldHeight.insets = new Insets(0, 0, 5, 5);
    gbc_mTextFieldFieldHeight.gridx = 1;
    gbc_mTextFieldFieldHeight.gridy = 2;
    panelGeneral.add(mTextFieldFieldHeight, gbc_mTextFieldFieldHeight);
    mTextFieldFieldHeight.setColumns(10);
    mTextFieldFieldHeight.setText(Double.toString(ScenarioInformation.getInstance().getYFactor()));

    JLabel lblMaxAbsoluteWidht = new JLabel("Max. absolute Width of PlayField in Points:");
    lblMaxAbsoluteWidht.setHorizontalAlignment(SwingConstants.RIGHT);
    GridBagConstraints gbc_lblMaxAbsoluteWidht = new GridBagConstraints();
    gbc_lblMaxAbsoluteWidht.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblMaxAbsoluteWidht.anchor = GridBagConstraints.EAST;
    gbc_lblMaxAbsoluteWidht.insets = new Insets(0, 0, 0, 5);
    gbc_lblMaxAbsoluteWidht.gridx = 0;
    gbc_lblMaxAbsoluteWidht.gridy = 3;
    panelGeneral.add(lblMaxAbsoluteWidht, gbc_lblMaxAbsoluteWidht);

    mTextFieldFieldWidth = new JTextField();
    GridBagConstraints gbc_mTextFieldFieldWidth = new GridBagConstraints();
    gbc_mTextFieldFieldWidth.insets = new Insets(0, 0, 0, 5);
    gbc_mTextFieldFieldWidth.fill = GridBagConstraints.HORIZONTAL;
    gbc_mTextFieldFieldWidth.gridx = 1;
    gbc_mTextFieldFieldWidth.gridy = 3;
    panelGeneral.add(mTextFieldFieldWidth, gbc_mTextFieldFieldWidth);
    mTextFieldFieldWidth.setColumns(10);
    mTextFieldFieldWidth.setText(Double.toString(ScenarioInformation.getInstance().getMaxValue()));

    JPanel panelSimulation = new JPanel();
    tabbedPane.addTab("Simulation", null, panelSimulation, null);
    GridBagLayout gbl_panelSimulation = new GridBagLayout();
    gbl_panelSimulation.columnWidths = new int[] {0, 0, 0, 0};
    gbl_panelSimulation.rowHeights = new int[] {23, 0, 0, 0, 0, 0};
    gbl_panelSimulation.columnWeights = new double[] {1.0, 1.0, 1.0, Double.MIN_VALUE};
    gbl_panelSimulation.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    panelSimulation.setLayout(gbl_panelSimulation);

    chckbxSimulation = new JCheckBox("Simulation");
    chckbxSimulation.setSelected(Core.getInstance().isSimulation());
    GridBagConstraints gbc_chckbxSimulation = new GridBagConstraints();
    gbc_chckbxSimulation.gridwidth = 2;
    gbc_chckbxSimulation.anchor = GridBagConstraints.NORTHWEST;
    gbc_chckbxSimulation.insets = new Insets(0, 0, 5, 5);
    gbc_chckbxSimulation.gridx = 0;
    gbc_chckbxSimulation.gridy = 0;
    panelSimulation.add(chckbxSimulation, gbc_chckbxSimulation);

    JLabel lblMaxBotMovement = new JLabel("Max. Bot Movement per Tick in % of PlayField:");
    GridBagConstraints gbc_lblMaxBotMovement = new GridBagConstraints();
    gbc_lblMaxBotMovement.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblMaxBotMovement.insets = new Insets(0, 0, 5, 5);
    gbc_lblMaxBotMovement.gridx = 0;
    gbc_lblMaxBotMovement.gridy = 1;
    panelSimulation.add(lblMaxBotMovement, gbc_lblMaxBotMovement);
    lblMaxBotMovement.setHorizontalAlignment(SwingConstants.RIGHT);

    mTextFieldBotMaxMovement = new JTextField();
    GridBagConstraints gbc_mTextFieldBotMaxMovement = new GridBagConstraints();
    gbc_mTextFieldBotMaxMovement.anchor = GridBagConstraints.WEST;
    gbc_mTextFieldBotMaxMovement.insets = new Insets(0, 0, 5, 5);
    gbc_mTextFieldBotMaxMovement.gridx = 1;
    gbc_mTextFieldBotMaxMovement.gridy = 1;
    panelSimulation.add(mTextFieldBotMaxMovement, gbc_mTextFieldBotMaxMovement);
    mTextFieldBotMaxMovement.setText(
        Double.toString(ScenarioInformation.getInstance().getSimulationBotSpeed()));
    mTextFieldBotMaxMovement.setColumns(10);

    JLabel lblNewLabel_2 = new JLabel("Chance to \"lose\" Bot:");
    GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
    gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST;
    gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
    gbc_lblNewLabel_2.gridx = 0;
    gbc_lblNewLabel_2.gridy = 2;
    panelSimulation.add(lblNewLabel_2, gbc_lblNewLabel_2);

    mTextFieldChanceForNoRecognition = new JTextField();
    GridBagConstraints gbc_mTextFieldChanceForNoRecognition = new GridBagConstraints();
    gbc_mTextFieldChanceForNoRecognition.anchor = GridBagConstraints.WEST;
    gbc_mTextFieldChanceForNoRecognition.insets = new Insets(0, 0, 5, 5);
    gbc_mTextFieldChanceForNoRecognition.gridx = 1;
    gbc_mTextFieldChanceForNoRecognition.gridy = 2;
    panelSimulation.add(mTextFieldChanceForNoRecognition, gbc_mTextFieldChanceForNoRecognition);
    mTextFieldChanceForNoRecognition.setText(
        Double.toString(ScenarioInformation.getInstance().getChanceToNoIdentification()));
    mTextFieldChanceForNoRecognition.setColumns(10);

    JLabel lblRightWheelError = new JLabel("Right wheel error:");
    GridBagConstraints gbc_lblRightWheelError = new GridBagConstraints();
    gbc_lblRightWheelError.insets = new Insets(0, 0, 5, 5);
    gbc_lblRightWheelError.anchor = GridBagConstraints.EAST;
    gbc_lblRightWheelError.gridx = 0;
    gbc_lblRightWheelError.gridy = 3;
    panelSimulation.add(lblRightWheelError, gbc_lblRightWheelError);

    mTextFieldRightWheelError = new JTextField();
    GridBagConstraints gbc_mTextFieldRightWheelError = new GridBagConstraints();
    gbc_mTextFieldRightWheelError.anchor = GridBagConstraints.WEST;
    gbc_mTextFieldRightWheelError.insets = new Insets(0, 0, 5, 5);
    gbc_mTextFieldRightWheelError.gridx = 1;
    gbc_mTextFieldRightWheelError.gridy = 3;
    panelSimulation.add(mTextFieldRightWheelError, gbc_mTextFieldRightWheelError);
    mTextFieldRightWheelError.setText(
        Double.toString(ScenarioInformation.getInstance().getRightWheelError()));
    mTextFieldRightWheelError.setColumns(10);

    JLabel lblLeftWheelError = new JLabel("Left wheel error:");
    GridBagConstraints gbc_lblLeftWheelError = new GridBagConstraints();
    gbc_lblLeftWheelError.anchor = GridBagConstraints.EAST;
    gbc_lblLeftWheelError.insets = new Insets(0, 0, 0, 5);
    gbc_lblLeftWheelError.gridx = 0;
    gbc_lblLeftWheelError.gridy = 4;
    panelSimulation.add(lblLeftWheelError, gbc_lblLeftWheelError);

    mTextFieldLeftWheelError = new JTextField();
    GridBagConstraints gbc_mTextFieldLeftWheelError = new GridBagConstraints();
    gbc_mTextFieldLeftWheelError.anchor = GridBagConstraints.WEST;
    gbc_mTextFieldLeftWheelError.insets = new Insets(0, 0, 0, 5);
    gbc_mTextFieldLeftWheelError.gridx = 1;
    gbc_mTextFieldLeftWheelError.gridy = 4;
    panelSimulation.add(mTextFieldLeftWheelError, gbc_mTextFieldLeftWheelError);
    mTextFieldLeftWheelError.setText(
        Double.toString(ScenarioInformation.getInstance().getLeftWheelError()));
    mTextFieldLeftWheelError.setColumns(10);

    JPanel panelPlayModes = new JPanel();
    tabbedPane.addTab("PlayModes", null, panelPlayModes, null);
    GridBagLayout gbl_panelPlayModes = new GridBagLayout();
    gbl_panelPlayModes.columnWidths = new int[] {413, 0, 0};
    gbl_panelPlayModes.rowHeights = new int[] {23, 0};
    gbl_panelPlayModes.columnWeights = new double[] {0.0, 1.0, Double.MIN_VALUE};
    gbl_panelPlayModes.rowWeights = new double[] {0.0, Double.MIN_VALUE};
    panelPlayModes.setLayout(gbl_panelPlayModes);

    chckbxAutomaticGame = new JCheckBox("Automatic Game");
    chckbxAutomaticGame.setSelected(Core.getInstance().isAutomaticGame());
    GridBagConstraints gbc_chckbxAutomaticGame = new GridBagConstraints();
    gbc_chckbxAutomaticGame.insets = new Insets(0, 0, 0, 5);
    gbc_chckbxAutomaticGame.anchor = GridBagConstraints.NORTH;
    gbc_chckbxAutomaticGame.fill = GridBagConstraints.HORIZONTAL;
    gbc_chckbxAutomaticGame.gridx = 0;
    gbc_chckbxAutomaticGame.gridy = 0;
    panelPlayModes.add(chckbxAutomaticGame, gbc_chckbxAutomaticGame);

    JPanel panel_2 = new JPanel();
    FlowLayout flowLayout = (FlowLayout) panel_2.getLayout();
    flowLayout.setAlignment(FlowLayout.RIGHT);
    contentPane.add(panel_2, BorderLayout.SOUTH);

    JButton vBtnOk = new JButton("Ok");
    vBtnOk.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveOptions();
            dispose();
          }
        });
    panel_2.add(vBtnOk);

    JButton bBtnApply = new JButton("Apply");
    bBtnApply.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveOptions();
          }
        });
    panel_2.add(bBtnApply);

    JButton vBtnCancel = new JButton("Cancel");
    vBtnCancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    panel_2.add(vBtnCancel);
  }
  public Displayer(Player x, int num) {
    super("Player " + num + " Information");
    playernum = num;
    this.x = x;

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

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

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

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

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

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

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

    propertydisplay.addItemListener(this);

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

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

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

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

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

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

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

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

    add(p);
    setVisible(true);

    timer.setActionCommand("timing");
    timer.setInitialDelay(500);
    timer.start();
  }
Esempio n. 25
0
  /**
   * run 'java FlowTest middle_latitude' to test with (lat, lon) run 'java FlowTest middle_latitude
   * x' to test with (lon, lat) adjust middle_latitude for south or north
   */
  public static void main(String args[]) throws VisADException, RemoteException {
    double mid_lat = -10.0;
    if (args.length > 0) {
      try {
        mid_lat = Double.valueOf(args[0]).doubleValue();
      } catch (NumberFormatException e) {
      }
    }
    boolean swap = (args.length > 1);
    RealType lat = RealType.Latitude;
    RealType lon = RealType.Longitude;
    RealType[] types;
    if (swap) {
      types = new RealType[] {lon, lat};
    } else {
      types = new RealType[] {lat, lon};
    }
    RealTupleType earth_location = new RealTupleType(types);
    System.out.println("earth_location = " + earth_location + " mid_lat = " + mid_lat);

    RealType flowx = RealType.getRealType("flowx", CommonUnit.meterPerSecond);
    RealType flowy = RealType.getRealType("flowy", CommonUnit.meterPerSecond);
    RealType red = RealType.getRealType("red");
    RealType green = RealType.getRealType("green");
    EarthVectorType flowxy = new EarthVectorType(flowx, flowy);
    TupleType range = null;

    range = new TupleType(new MathType[] {flowxy, red, green});
    FunctionType flow_field = new FunctionType(earth_location, range);

    DisplayImpl display = new DisplayImplJ3D("display1", new TwoDDisplayRendererJ3D());
    ScalarMap xmap = new ScalarMap(lon, Display.XAxis);
    display.addMap(xmap);
    ScalarMap ymap = new ScalarMap(lat, Display.YAxis);
    display.addMap(ymap);
    ScalarMap flowx_map = new ScalarMap(flowx, Display.Flow1X);
    display.addMap(flowx_map);
    flowx_map.setRange(-10.0, 10.0);
    ScalarMap flowy_map = new ScalarMap(flowy, Display.Flow1Y);
    display.addMap(flowy_map);
    flowy_map.setRange(-10.0, 10.0);
    FlowControl flow_control = (FlowControl) flowy_map.getControl();
    flow_control.setFlowScale(0.05f);
    display.addMap(new ScalarMap(red, Display.Red));
    display.addMap(new ScalarMap(green, Display.Green));
    display.addMap(new ConstantMap(1.0, Display.Blue));

    double lonlow = -10.0;
    double lonhi = 10.0;
    double latlow = mid_lat - 10.0;
    double lathi = mid_lat + 10.0;
    Linear2DSet set;
    if (swap) {
      set = new Linear2DSet(earth_location, lonlow, lonhi, N, latlow, lathi, N);
    } else {
      set = new Linear2DSet(earth_location, latlow, lathi, N, lonlow, lonhi, N);
    }
    double[][] values = new double[4][N * N];
    int m = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        int k = i;
        int l = j;
        if (swap) {
          k = j;
          l = i;
        }
        double u = (N - 1.0) / 2.0 - l;
        double v = k - (N - 1.0) / 2.0;
        // double u = 2.0 * k / (N - 1.0) - 1.0;
        // double v = 2.0 * l / (N - 1.0);
        double fx = 6.0 * u;
        double fy = 6.0 * v;
        values[0][m] = fx;
        values[1][m] = fy;
        values[2][m] = u;
        values[3][m] = v;
        m++;
      }
    }
    FlatField field = new FlatField(flow_field, set);
    field.setSamples(values);
    DataReferenceImpl ref = new DataReferenceImpl("ref");
    ref.setData(field);
    display.addReference(ref);

    // create JFrame (i.e., a window) for display and slider
    JFrame frame = new JFrame("test FlowTest");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    // create JPanel in JFrame
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setAlignmentY(JPanel.TOP_ALIGNMENT);
    panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
    frame.getContentPane().add(panel);

    // add display to JPanel
    panel.add(display.getComponent());

    // set size of JFrame and make it visible
    frame.setSize(500, 500);
    frame.setVisible(true);
  }
Esempio n. 26
0
  /** test BarbManipulationRendererJ3D */
  public static void main(String args[]) throws VisADException, RemoteException {

    System.out.println("BMR.main()");

    // construct RealTypes for wind record components
    RealType lat = RealType.Latitude;
    RealType lon = RealType.Longitude;
    RealType windx = RealType.getRealType("windx", CommonUnit.meterPerSecond);
    RealType windy = RealType.getRealType("windy", CommonUnit.meterPerSecond);
    RealType red = RealType.getRealType("red");
    RealType green = RealType.getRealType("green");

    // EarthVectorType extends RealTupleType and says that its
    // components are vectors in m/s with components parallel
    // to Longitude (positive east) and Latitude (positive north)
    EarthVectorType windxy = new EarthVectorType(windx, windy);

    RealType wind_dir = RealType.getRealType("wind_dir", CommonUnit.degree);
    RealType wind_speed = RealType.getRealType("wind_speed", CommonUnit.meterPerSecond);
    RealTupleType windds = null;
    if (args.length > 0) {
      System.out.println("polar winds");
      windds =
          new RealTupleType(
              new RealType[] {wind_dir, wind_speed}, new WindPolarCoordinateSystem(windxy), null);
    }

    // construct Java3D display and mappings that govern
    // how wind records are displayed
    DisplayImpl display = new DisplayImplJ3D("display1", new TwoDDisplayRendererJ3D());
    ScalarMap lonmap = new ScalarMap(lon, Display.XAxis);
    display.addMap(lonmap);
    ScalarMap latmap = new ScalarMap(lat, Display.YAxis);
    display.addMap(latmap);

    FlowControl flow_control;
    if (args.length > 0) {
      ScalarMap winds_map = new ScalarMap(wind_speed, Display.Flow1Radial);
      display.addMap(winds_map);
      winds_map.setRange(0.0, 1.0); // do this for barb rendering
      ScalarMap windd_map = new ScalarMap(wind_dir, Display.Flow1Azimuth);
      display.addMap(windd_map);
      windd_map.setRange(0.0, 360.0); // do this for barb rendering
      flow_control = (FlowControl) windd_map.getControl();
      flow_control.setFlowScale(0.15f); // this controls size of barbs
    } else {
      ScalarMap windx_map = new ScalarMap(windx, Display.Flow1X);
      display.addMap(windx_map);
      windx_map.setRange(-1.0, 1.0); // do this for barb rendering
      ScalarMap windy_map = new ScalarMap(windy, Display.Flow1Y);
      display.addMap(windy_map);
      windy_map.setRange(-1.0, 1.0); // do this for barb rendering
      flow_control = (FlowControl) windy_map.getControl();
      flow_control.setFlowScale(0.15f); // this controls size of barbs
    }

    display.addMap(new ScalarMap(red, Display.Red));
    display.addMap(new ScalarMap(green, Display.Green));
    display.addMap(new ConstantMap(1.0, Display.Blue));

    DataReferenceImpl[] refs = new DataReferenceImpl[N * N];
    int k = 0;
    // create an array of N by N winds
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        double u = 2.0 * i / (N - 1.0) - 1.0;
        double v = 2.0 * j / (N - 1.0) - 1.0;

        // each wind record is a Tuple (lon, lat, (windx, windy), red, green)
        // set colors by wind components, just for grins
        Tuple tuple;
        double fx = 30.0 * u;
        double fy = 30.0 * v;
        if (args.length > 0) {
          double fd = Data.RADIANS_TO_DEGREES * Math.atan2(-fx, -fy);
          double fs = Math.sqrt(fx * fx + fy * fy);
          tuple =
              new Tuple(
                  new Data[] {
                    new Real(lon, 10.0 * u),
                    new Real(lat, 10.0 * v - 40.0),
                    new RealTuple(windds, new double[] {fd, fs}),
                    new Real(red, u),
                    new Real(green, v)
                  });
        } else {
          tuple =
              new Tuple(
                  new Data[] {
                    new Real(lon, 10.0 * u),
                    new Real(lat, 10.0 * v - 40.0),
                    new RealTuple(windxy, new double[] {fx, fy}),
                    new Real(red, u),
                    new Real(green, v)
                  });
        }

        // construct reference for wind record
        refs[k] = new DataReferenceImpl("ref_" + k);
        refs[k].setData(tuple);

        // link wind record to display via BarbManipulationRendererJ3D
        // so user can change barb by dragging it
        // drag with right mouse button and shift to change direction
        // drag with right mouse button and no shift to change speed
        BarbManipulationRendererJ3D renderer = new BarbManipulationRendererJ3D();
        renderer.setKnotsConvert(true);
        display.addReferences(renderer, refs[k]);

        // link wind record to a CellImpl that will listen for changes
        // and print them
        WindGetterJ3D cell = new WindGetterJ3D(flow_control, refs[k]);
        cell.addReference(refs[k]);

        k++;
      }
    }

    // instead of linking the wind record "DataReferenceImpl refs" to
    // the WindGetterJ3Ds, you can have some user interface event (e.g.,
    // the user clicks on "DONE") trigger code that does a getData() on
    // all the refs and stores the records in a file.

    // create JFrame (i.e., a window) for display and slider
    JFrame frame = new JFrame("test BarbManipulationRendererJ3D");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    // create JPanel in JFrame
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setAlignmentY(JPanel.TOP_ALIGNMENT);
    panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
    frame.getContentPane().add(panel);

    // add display to JPanel
    panel.add(display.getComponent());

    // set size of JFrame and make it visible
    frame.setSize(500, 500);
    frame.setVisible(true);
  }
Esempio n. 27
0
  private void initUI() {
    setResizable(false);
    setTitle("Fyle - Login");
    setSize(600, 600);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    loginButton = new ButtonImpl("Login");
    regButton = new ButtonImpl("Register");
    loginUsername = new TextFieldImpl(12);
    loginUsername.setDocument(new TextFieldLimit(16));
    loginUsername.setMaximumSize(loginUsername.getPreferredSize());
    loginButton.setMaximumSize(loginButton.getPreferredSize());
    loginPassword = new PasswordFieldImpl(12);
    loginPassword.setDocument(new TextFieldLimit(128));
    loginPassword.setMaximumSize(loginPassword.getPreferredSize());
    regPass = new PasswordFieldImpl(12);
    regPass.setDocument(new TextFieldLimit(128));
    regPass.setMaximumSize(regPass.getPreferredSize());
    regRepPass = new PasswordFieldImpl(12);
    regRepPass.setDocument(new TextFieldLimit(128));
    regRepPass.setMaximumSize(regRepPass.getPreferredSize());
    regUsername = new TextFieldImpl(12);
    regUsername.setDocument(new TextFieldLimit(16));
    regUsername.setMaximumSize(regUsername.getPreferredSize());
    regEmail = new TextFieldImpl(12);
    regEmail.setDocument(new TextFieldLimit(254));
    regEmail.setMaximumSize(regEmail.getPreferredSize());
    logUserLabel = new JLabel("Username:"******"Password:"******"Password:"******"Repeat password:"******"Email:");
    regUserLabel = new JLabel("Username:"******"Status: ");
    statusLabel = new StatusLabelImpl("");
    JPanel statusPanel = new JPanel();
    statusPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    statusPanel.add(statustxtLabel);
    statusPanel.add(statusLabel);

    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    add(formPanel);
    add(statusPanel);
    pack();
  }
Esempio n. 28
0
  public JPanel getWindowLevelPanel() {

    final JPanel winLevelPanel = new JPanel();
    winLevelPanel.setAlignmentY(Component.TOP_ALIGNMENT);
    winLevelPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    winLevelPanel.setLayout(new BoxLayout(winLevelPanel, BoxLayout.Y_AXIS));
    winLevelPanel.setBorder(
        BorderFactory.createCompoundBorder(
            spaceY,
            new TitledBorder(
                null,
                Messages.getString("ImageTool.wl"), // $NON-NLS-1$
                TitledBorder.DEFAULT_JUSTIFICATION,
                TitledBorder.DEFAULT_POSITION,
                TITLE_FONT,
                TITLE_COLOR)));
    ActionState winAction = EventManager.getInstance().getAction(ActionW.WINDOW);
    if (winAction instanceof SliderChangeListener) {
      final JSliderW windowSlider = ((SliderChangeListener) winAction).createSlider(4, true);
      // windowSlider.setMajorTickSpacing((largestWindow - smallestWindow) / 4);
      JMVUtils.setPreferredWidth(windowSlider, 100);
      winLevelPanel.add(windowSlider.getParent());
    }
    ActionState levelAction = EventManager.getInstance().getAction(ActionW.LEVEL);
    if (levelAction instanceof SliderChangeListener) {
      final JSliderW levelSlider = ((SliderChangeListener) levelAction).createSlider(4, true);
      levelSlider.setMajorTickSpacing(
          (ImageViewerEventManager.LEVEL_LARGEST - ImageViewerEventManager.LEVEL_SMALLEST) / 4);
      JMVUtils.setPreferredWidth(levelSlider, 100);
      winLevelPanel.add(levelSlider.getParent());
    }
    ActionState presetAction = EventManager.getInstance().getAction(ActionW.PRESET);
    if (presetAction instanceof ComboItemListener) {
      final JPanel panel_3 = new JPanel();
      panel_3.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 3));
      final JLabel presetsLabel = new JLabel();
      panel_3.add(presetsLabel);
      presetsLabel.setText(
          Messages.getString("ImageTool.preset") + StringUtil.COLON); // $NON-NLS-1$
      final JComboBox presetComboBox = ((ComboItemListener) presetAction).createCombo(160);
      presetComboBox.setMaximumRowCount(10);
      panel_3.add(presetComboBox);
      winLevelPanel.add(panel_3);
    }
    ActionState lutAction = EventManager.getInstance().getAction(ActionW.LUT);
    if (lutAction instanceof ComboItemListener) {
      final JPanel panel_4 = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 3));
      final JLabel lutLabel = new JLabel();
      lutLabel.setText(Messages.getString("ImageTool.lut") + StringUtil.COLON); // $NON-NLS-1$
      panel_4.add(lutLabel);
      final JComboBox lutcomboBox = ((ComboItemListener) lutAction).createCombo(140);
      panel_4.add(lutcomboBox);
      ActionState invlutAction = EventManager.getInstance().getAction(ActionW.INVERT_LUT);
      if (invlutAction instanceof ToggleButtonListener) {
        panel_4.add(
            ((ToggleButtonListener) invlutAction)
                .createCheckBox(Messages.getString("ImageTool.inverse"))); // $NON-NLS-1$
      }
      winLevelPanel.add(panel_4);
    }
    ActionState filterAction = EventManager.getInstance().getAction(ActionW.FILTER);
    if (filterAction instanceof ComboItemListener) {
      final JPanel panel_4 = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 3));
      final JLabel lutLabel = new JLabel();
      lutLabel.setText(Messages.getString("ImageTool.filter")); // $NON-NLS-1$
      panel_4.add(lutLabel);
      final JComboBox filtercomboBox = ((ComboItemListener) filterAction).createCombo(160);
      panel_4.add(filtercomboBox);
      winLevelPanel.add(panel_4);
    }
    return winLevelPanel;
  }
  /**
   * Make a GUI for the battleship game.
   *
   * @param game Game object that keeps up with the current state of the game.
   */
  public BattleshipGUI(Battleship game) {
    this.game = game;

    this.game = game;
    // Ships are visible on the human grid but not on the computer grid
    // (last argument)
    humanGrid = new Grid(game.getHumanBoard(), this, true);
    computerGrid = new Grid(game.getComputerBoard(), this, false);
    setTitle("Battleship Game");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLayout(new BorderLayout());

    // Add a message field centered below the game
    Box gamePanel = new Box(BoxLayout.X_AXIS);
    add(gamePanel, BorderLayout.CENTER);
    message = new JLabel("Game begins", JLabel.CENTER);
    message.setFont(DEFAULT_FONT);
    add(message, BorderLayout.SOUTH);

    // Add human and computer panels to the game; the human panel has a
    // title, grid, and buttons; the computer panel has only a title and a
    // grid
    JPanel human = new JPanel();
    human.setLayout(new BoxLayout(human, BoxLayout.Y_AXIS));
    JPanel computer = new JPanel();
    computer.setLayout(new BoxLayout(computer, BoxLayout.Y_AXIS));
    human.setAlignmentY(Component.TOP_ALIGNMENT);
    gamePanel.add(human);
    gamePanel.add(Box.createRigidArea(new Dimension(5, 0)));
    computer.setAlignmentY(Component.TOP_ALIGNMENT);
    gamePanel.add(computer);

    // Add three parts to the human panel
    JLabel humanLabel = new JLabel("Human", JLabel.CENTER);
    humanLabel.setFont(DEFAULT_FONT);
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    human.add(humanLabel);
    human.add(humanGrid);
    human.add(buttonPanel);

    // Set up the buttons
    hButton = new JButton("Horizontal");
    hButton.setFont(DEFAULT_FONT);
    hButton.addActionListener(this);
    vButton = new JButton("Vertical");
    vButton.setFont(DEFAULT_FONT);
    vButton.addActionListener(this);
    buttonPanel.add(hButton);
    buttonPanel.add(vButton);

    // Add two parts to the computer panel
    JLabel computerLabel = new JLabel("Computer", JLabel.CENTER);
    computerLabel.setFont(DEFAULT_FONT);
    computer.add(computerLabel);
    computer.add(computerGrid);

    updateStatus();

    pack();
    setVisible(true);
  }
  @Override
  public void propertyChange(PropertyChangeEvent event) {
    System.out.println("ktos mnie zawolal: " + event);
    tabbedPane.removeAll();

    if (event.getNewValue() instanceof XmlDocument) {
      final XmlDocument xmlDocument = (XmlDocument) event.getNewValue();

      JPanel generalPanel = new JPanel();

      GridBagLayout gridBagLayout = new GridBagLayout();
      generalPanel.setAlignmentY(Component.TOP_ALIGNMENT);
      generalPanel.setLayout(gridBagLayout);

      GridBagConstraints c = new GridBagConstraints();
      c.fill = GridBagConstraints.HORIZONTAL;
      c.anchor = GridBagConstraints.LINE_START;
      c.gridx = 0;
      c.gridy = 0;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(new JLabel("Root element name: "), c);

      final JTextField rootElementName =
          new JTextField(
              xmlDocument.getRootElement() != null ? xmlDocument.getRootElement().getName() : "");
      rootElementName.addFocusListener(
          new FocusListener() {

            @Override
            public void focusGained(FocusEvent e) {}

            @Override
            public void focusLost(FocusEvent e) {
              xmlDocument.getRootElement().setName(rootElementName.getText());
            }
          });

      c.gridx = 1;
      c.gridy = 0;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(rootElementName, c);

      c.gridx = 0;
      c.gridy = 1;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(new JLabel("Encoding: "), c);

      final JTextField encoding =
          new JTextField(xmlDocument.getEncoding() != null ? xmlDocument.getEncoding() : "");
      encoding.addFocusListener(
          new FocusListener() {

            @Override
            public void focusGained(FocusEvent e) {}

            @Override
            public void focusLost(FocusEvent e) {
              xmlDocument.setEncoding(encoding.getText());
            }
          });

      c.gridx = 1;
      c.gridy = 1;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(encoding, c);

      c.gridx = 0;
      c.gridy = 2;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(new JLabel("Version: "), c);

      final JTextField version =
          new JTextField(xmlDocument.getVersion() != null ? xmlDocument.getVersion() : "");
      version.addFocusListener(
          new FocusListener() {

            @Override
            public void focusGained(FocusEvent e) {}

            @Override
            public void focusLost(FocusEvent e) {
              xmlDocument.setVersion(version.getText());
            }
          });

      c.gridx = 1;
      c.gridy = 2;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(version, c);

      c.gridx = 0;
      c.gridy = 3;
      c.gridwidth = 1;
      c.weighty = 1;
      generalPanel.add(new JPanel(), c);

      tabbedPane.addTab("General", null, generalPanel, "General options");

    } else if (event.getNewValue() instanceof XmlTag) {
      final XmlTag xmlTag = (XmlTag) event.getNewValue();
      JPanel generalPanel = new JPanel();

      GridBagLayout gridBagLayout = new GridBagLayout();
      generalPanel.setAlignmentY(Component.TOP_ALIGNMENT);
      generalPanel.setLayout(gridBagLayout);

      GridBagConstraints c = new GridBagConstraints();
      c.fill = GridBagConstraints.HORIZONTAL;
      c.anchor = GridBagConstraints.LINE_START;
      c.gridx = 0;
      c.gridy = 0;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(new JLabel("Tag name: "), c);

      final JTextField tagName = new JTextField(xmlTag.getName());
      tagName.addFocusListener(
          new FocusListener() {

            @Override
            public void focusGained(FocusEvent e) {}

            @Override
            public void focusLost(FocusEvent e) {
              xmlTag.setName(tagName.getText());
            }
          });

      c.gridx = 1;
      c.gridy = 0;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(tagName, c);

      c.gridx = 0;
      c.gridy = 1;
      c.gridwidth = 2;
      c.weighty = 1;
      generalPanel.add(new JPanel(), c);

      tabbedPane.addTab("General", null, generalPanel, "General options");

      AttributesModel attributesModel = new AttributesModel(xmlTag);

      JTable attributesTable = new JTable(attributesModel);
      TableColumn columnName = attributesTable.getColumn("Name");
      columnName.setWidth(140);
      TableColumn columnValue = attributesTable.getColumn("Value");
      columnValue.setWidth(140);
      JPanel attrPanel = new JPanel(new BorderLayout());
      attrPanel.add(attributesTable.getTableHeader(), BorderLayout.PAGE_START);
      JScrollPane scrollPane = new JScrollPane(attributesTable);
      attrPanel.add(scrollPane, BorderLayout.CENTER);

      Schema schema = xmlTag.getSchema();
      String path = xmlTag.getPath();

      AvailableAttributesFinder aaf = new AvailableAttributesFinder(schema.getContent());
      Map<String, Boolean> availableAttributes = aaf.getAvailableAttributesForNode(path);

      attributesTable.addMouseListener(
          new AttributeTableClickListener(
              attributesTable, true, xmlTag.getSchemaType(), availableAttributes));
      scrollPane.addMouseListener(
          new AttributeTableClickListener(
              attributesTable, false, xmlTag.getSchemaType(), availableAttributes));

      tabbedPane.addTab("Attributes", null, attrPanel, "Attributes of this element");
      String text = ((XmlTag) event.getNewValue()).toString(0);

      JPanel textPanel = new JPanel();
      textPanel.setLayout(new GridLayout(0, 1));
      JTextArea textArea = new JTextArea(text);
      textArea.setEditable(false);
      textPanel.add(textArea);

      tabbedPane.addTab("Text", null, textPanel, "The text in the element");
    } else if (event.getNewValue() instanceof mxCell && ((mxCell) event.getNewValue()).isEdge()) {
      mxCell cell = (mxCell) event.getNewValue();
      mxICell source = cell.getSource();
      mxICell target = cell.getTarget();
      if (source != null
          && target != null
          && source.getParent() != null
          && target.getParent() != null) {
        XmlTag sourceTag = (XmlTag) source.getParent().getValue();
        XmlTag targetTag = (XmlTag) target.getParent().getValue();

        System.out.println(sourceTag + " -> " + targetTag);

        JPanel generalPanel = new JPanel();

        GridBagLayout gridBagLayout = new GridBagLayout();
        generalPanel.setAlignmentY(Component.TOP_ALIGNMENT);
        generalPanel.setLayout(gridBagLayout);

        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.HORIZONTAL;
        c.anchor = GridBagConstraints.LINE_START;
        c.gridx = 0;
        c.gridy = 0;
        c.weightx = 1;
        c.weighty = 0.3;
        generalPanel.add(new JLabel("Source tag name: "), c);

        final JTextField sourceTagName =
            new JTextField(sourceTag.getName() != null ? sourceTag.getName() : "");
        sourceTagName.setEditable(false);

        c.gridx = 1;
        c.gridy = 0;
        c.weightx = 1;
        c.weighty = 0.3;
        generalPanel.add(sourceTagName, c);

        c.gridx = 0;
        c.gridy = 1;
        c.weightx = 1;
        c.weighty = 0.3;
        generalPanel.add(new JLabel("Target tag name: "), c);

        final JTextField targetTagName =
            new JTextField(targetTag.getName() != null ? targetTag.getName() : "");
        targetTagName.setEditable(false);

        c.gridx = 1;
        c.gridy = 1;
        c.weightx = 1;
        c.weighty = 0.3;
        generalPanel.add(targetTagName, c);

        c.gridx = 0;
        c.gridy = 2;
        c.gridwidth = 1;
        c.weighty = 1;
        generalPanel.add(new JPanel(), c);

        tabbedPane.addTab("General", null, generalPanel, "General options");
      }
    }
  }