/**
   * Creates the Factor definition subform
   *
   * @return - JPanel containing the Factor definition subform.
   */
  private Container createTransposedView() {

    Box subformContainer = Box.createVerticalBox();

    transposedSpreadsheetSubform =
        new TransposedSubForm(
            "spreadsheet data",
            FieldTypes.ROW,
            transposedSpreadsheetModel.getFields(),
            transposedSpreadsheetModel.getNumberOfRecords(),
            width,
            height,
            transposedSpreadsheetModel.getData(),
            transposedSpreadsheetModel.getSpreadsheet().getDataEntryEnv());

    transposedSpreadsheetSubform.createGUI();

    transposedSpreadsheetSubform.addPropertyChangeListener(
        "rowAdded",
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            updateInformation();
          }
        });

    subformContainer.add(Box.createVerticalStrut(15));
    subformContainer.add(transposedSpreadsheetSubform);
    subformContainer.add(Box.createVerticalStrut(15));

    return subformContainer;
  }
Example #2
0
 private void jbInit() throws Exception {
   box1 = Box.createVerticalBox();
   this.getContentPane().setLayout(borderLayout1);
   close.setText("Close");
   close.addActionListener(new CellHelpWindow_close_actionAdapter(this));
   jLabel1.setText("Recommendation");
   jLabel2.setText("Description");
   jPanel1.setLayout(borderLayout2);
   jPanel2.setLayout(borderLayout3);
   description.setText("jTextPane1");
   description.setContentType("text/html");
   scp1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   scp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
   scp1.setToolTipText("");
   recom.setText("");
   recom.setContentType("text/html");
   this.getContentPane().add(box1, BorderLayout.CENTER);
   box1.add(jPanel1, null);
   box1.add(jPanel2, null);
   this.getContentPane().add(jPanel3, BorderLayout.SOUTH);
   jPanel3.add(close, null);
   jPanel2.add(jLabel1, BorderLayout.NORTH);
   jPanel2.add(scp2, BorderLayout.CENTER);
   scp2.getViewport().add(recom, null);
   jPanel2.add(scp2, BorderLayout.CENTER);
   jPanel1.add(jLabel2, BorderLayout.NORTH);
   jPanel1.add(scp1, BorderLayout.CENTER);
   scp1.getViewport().add(description, null);
 }
/**
 * Description: <br>
 * Copyright (C), 2005-2008, Yeeku.H.Lee <br>
 * This program is protected by copyright laws. <br>
 * Program Name: <br>
 * Date:
 *
 * @author Yeeku.H.Lee [email protected]
 * @version 1.0
 */
public class TestBoxSpace {
  private Frame f = new Frame("测试");
  // 定义水平摆放组件的Box对象
  private Box horizontal = Box.createHorizontalBox();
  // 定义垂直摆放组件的Box对象
  private Box vertical = Box.createVerticalBox();

  public void init() {
    horizontal.add(new Button("水平按钮一"));
    horizontal.add(Box.createHorizontalGlue());
    horizontal.add(new Button("水平按钮二"));
    // 水平方向不可拉伸的间距,其宽度为10px
    horizontal.add(Box.createHorizontalStrut(10));
    horizontal.add(new Button("水平按钮三"));
    vertical.add(new Button("垂直按钮一"));
    vertical.add(Box.createVerticalGlue());
    vertical.add(new Button("垂直按钮二"));
    // 垂直方向不可拉伸的间距,其高度为10px
    vertical.add(Box.createVerticalStrut(10));
    vertical.add(new Button("垂直按钮三"));
    f.add(horizontal, BorderLayout.NORTH);
    f.add(vertical);
    f.pack();
    f.setVisible(true);
  }

  public static void main(String[] args) {
    new TestBoxSpace().init();
  }
}
Example #4
0
 public void init(List<T> sources) {
   this.sources = sources;
   consoles = new HashMap<T, ConsolePanel>();
   singleNodeGUIS = new ArrayList<JComponent>();
   // setPreferredSize(new Dimension(1000,700));
   JSplitPane[] leftAndRight =
       new JSplitPane[] {
         new JSplitPane(JSplitPane.VERTICAL_SPLIT), new JSplitPane(JSplitPane.VERTICAL_SPLIT)
       };
   for (int i = 0; i < sources.size(); i++) {
     T t = sources.get(i);
     Box box = Box.createVerticalBox();
     ConsolePanel console = createConsole();
     consoles.put(t, console);
     JScrollPane jsp = new JScrollPane(console);
     jsp.setMinimumSize(new Dimension(600, 300));
     jsp.setPreferredSize(new Dimension(600, 300));
     jsp.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
     box.add(jsp);
     // box.add(Box.createVerticalGlue());
     box.add(createInputTF(t));
     box.add(Box.createVerticalStrut(3));
     box.setBorder(BorderFactory.createTitledBorder(String.valueOf(t)));
     singleNodeGUIS.add(box);
     leftAndRight[i / 2].add(box);
   }
   add(leftAndRight[0]);
   add(leftAndRight[1]);
 }
Example #5
0
  /**
   * Creates a dialog that is showing the histogram for the given node (if null one is selected for
   * you)
   */
  private JPanel createNormalityTestDialog(Node selected) {
    DataSet dataSet = (DataSet) dataEditor.getSelectedDataModel();

    QQPlot qqPlot = new QQPlot(dataSet, selected);
    NormalityTestEditorPanel editorPanel = new NormalityTestEditorPanel(qqPlot, dataSet);

    JTextArea display =
        new JTextArea(
            NormalityTests.runNormalityTests(
                dataSet, (ContinuousVariable) qqPlot.getSelectedVariable()),
            20,
            65);
    display.setEditable(false);
    editorPanel.addPropertyChangeListener(new NormalityTestListener(display));

    Box box = Box.createHorizontalBox();
    box.add(display);

    box.add(Box.createHorizontalStrut(3));
    box.add(editorPanel);
    box.add(Box.createHorizontalStrut(5));
    box.add(Box.createHorizontalGlue());

    Box vBox = Box.createVerticalBox();
    vBox.add(Box.createVerticalStrut(15));
    vBox.add(box);
    vBox.add(Box.createVerticalStrut(5));

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(vBox, BorderLayout.CENTER);

    return panel;
  }
  /** Performs the action of loading a session from a file. */
  public void actionPerformed(ActionEvent e) {
    DataModel dataModel = getDataEditor().getSelectedDataModel();

    if (!(dataModel instanceof DataSet)) {
      JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Must be a tabular data set.");
      return;
    }

    this.dataSet = (DataSet) dataModel;

    SpinnerNumberModel spinnerNumberModel = new SpinnerNumberModel(getNumLags(), 0, 20, 1);
    JSpinner jSpinner = new JSpinner(spinnerNumberModel);
    jSpinner.setPreferredSize(jSpinner.getPreferredSize());

    spinnerNumberModel.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            SpinnerNumberModel model = (SpinnerNumberModel) e.getSource();
            setNumLags(model.getNumber().intValue());
          }
        });

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    Box b = Box.createVerticalBox();
    Box b1 = Box.createHorizontalBox();
    b1.add(new JLabel("Number of time lags: "));
    b1.add(Box.createHorizontalGlue());
    b1.add(Box.createHorizontalStrut(15));
    b1.add(jSpinner);
    b1.setBorder(new EmptyBorder(10, 10, 10, 10));
    b.add(b1);

    panel.add(b, BorderLayout.CENTER);

    EditorWindow editorWindow = new EditorWindow(panel, "Create time series data", "Save", true);
    DesktopController.getInstance().addEditorWindow(editorWindow);
    editorWindow.setVisible(true);

    editorWindow.addInternalFrameListener(
        new InternalFrameAdapter() {
          public void internalFrameClosed(InternalFrameEvent e) {
            EditorWindow window = (EditorWindow) e.getSource();

            if (!window.isCanceled()) {
              if (dataSet.isContinuous()) {
                createContinuousTimeSeriesData();
              } else if (dataSet.isDiscrete()) {
                createDiscreteTimeSeriesData();
              } else {
                JOptionPane.showMessageDialog(
                    JOptionUtils.centeringComp(),
                    "Data set must be either continuous or discrete.");
              }
            }
          }
        });
  }
Example #7
0
  /** 生成面板内容 */
  private void createContent() {
    contentPanel = new JPanel(new BorderLayout());
    panel.add(contentPanel, BorderLayout.CENTER);

    Box message = Box.createVerticalBox();
    message.setBorder(BorderFactory.createEtchedBorder());

    dateImg = new JLabel(new ImageIcon(TMFrame.class.getResource("/images/calendar.gif")));
    String today = Today.getYear() + "年" + Today.getMonth() + "月" + Today.getDate() + "日";
    date = new JLabel(today);
    date.setFont(font);
    week = new JLabel(Today.getWeek());
    week.setFont(font);
    nameImg = new JLabel(new ImageIcon(TMFrame.class.getResource("/images/role.png")));
    name = new JLabel(staffInfo.getStaffName());
    name.setFont(font);
    role = new JLabel("总经理");
    role.setFont(font);

    Box messageTop = Box.createVerticalBox();
    Box messageCenter = Box.createHorizontalBox();
    Box messageBottom = Box.createVerticalBox();

    messageTop.add(Box.createVerticalStrut(1));
    messageCenter.add(Box.createHorizontalStrut(5));
    messageCenter.add(dateImg);
    messageCenter.add(Box.createHorizontalStrut(2));
    messageCenter.add(date);
    messageCenter.add(Box.createHorizontalStrut(20));
    messageCenter.add(week);
    messageCenter.add(Box.createHorizontalStrut(50));
    messageCenter.add(nameImg);
    messageCenter.add(Box.createHorizontalStrut(2));
    messageCenter.add(name);
    messageCenter.add(Box.createHorizontalStrut(20));
    messageCenter.add(role);
    messageCenter.add(Box.createHorizontalGlue());
    messageBottom.add(Box.createVerticalStrut(1));

    message.add(messageTop);
    message.add(messageCenter);
    message.add(messageBottom);
    contentPanel.add(message, BorderLayout.NORTH);
  }
 // Center given button in a box, centered vertically and 6 pixels on left and right
 private Box createBoxForButton(JButton button) {
   Box buttonRow = Box.createHorizontalBox();
   buttonRow.add(Box.createHorizontalStrut(6));
   buttonRow.add(button);
   buttonRow.add(Box.createHorizontalStrut(6));
   Box buttonBox = Box.createVerticalBox();
   buttonBox.add(Box.createVerticalGlue());
   buttonBox.add(buttonRow);
   buttonBox.add(Box.createVerticalGlue());
   return buttonBox;
 }
  // Method to build the dialog box for help.
  private void buildDialogBox() {
    // Set the JDialog window properties.
    setTitle("Stack Trace Detail");
    setResizable(false);
    setSize(dialogWidth, dialogHeight);

    // Append the stack trace output to the display area.
    displayArea.append(eStackTrace);

    // Create horizontal and vertical scrollbars for box.
    displayBox = Box.createHorizontalBox();
    displayBox = Box.createVerticalBox();

    // Add a JScrollPane to the Box.
    displayBox.add(new JScrollPane(displayArea));

    // Define behaviors of container.
    c.setLayout(null);
    c.add(displayBox);
    c.add(okButton);

    // Set scroll pane bounds.
    displayBox.setBounds(
        (dialogWidth / 2) - ((displayAreaWidth / 2) + 2),
        (top + (offsetMargin / 2)),
        displayAreaWidth,
        displayAreaHeight);

    // Set the behaviors, bounds and action listener for the button.
    okButton.setBounds(
        (dialogWidth / 2) - (buttonWidth / 2),
        (displayAreaHeight + offsetMargin),
        buttonWidth,
        buttonHeight);

    // Set the font to the platform default Font for the object with the
    // properties of bold and font size of 11.
    okButton.setFont(new Font(okButton.getFont().getName(), Font.BOLD, 11));

    // The class implements the ActionListener interface and therefore
    // provides an implementation of the actionPerformed() method.  When a
    // class implements ActionListener, the instance handler returns an
    // ActionListener.  The ActionListener then performs actionPerformed()
    // method on an ActionEvent.
    okButton.addActionListener(this);

    // Set the screen and display dialog window in relation to screen size.
    setLocation((dim.width / 2) - (dialogWidth / 2), (dim.height / 2) - (dialogHeight / 2));

    // Display JDialog.
    show();
  } // End of buildDialogBox method.
Example #10
0
public class AttributesPanel extends JComponent {
  private boolean settingcollection = false;
  private Box box = Box.createVerticalBox();

  Vector tobeduplicated = new Vector();

  public AttributesPanel() {
    this.setLayout(new BorderLayout());
    super.add(box, BorderLayout.CENTER);
  }

  public void setEntity(java.lang.Object ent) {
    Method[] methods = ent.getClass().getDeclaredMethods();
    box.removeAll();
    for (Method m : methods) {
      if (m.getName().toLowerCase().startsWith("get")) {
        String attName = m.getName().substring(3);
        Object result;
        try {
          result = m.invoke(ent, new Object[] {});
          String value = "null";
          if (result != null) value = result.toString();
          JPanel attPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
          attPane.add(new JLabel(attName + " : " + m.getReturnType().getName() + " = " + value));
          box.add(attPane);
        } catch (IllegalArgumentException e) {

          e.printStackTrace();
        } catch (IllegalAccessException e) {

          e.printStackTrace();
        } catch (InvocationTargetException e) {

          e.printStackTrace();
        }
      }
    }
  }

  public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException {

    JFrame jf = new JFrame();

    AttributesPanel colpal = new AttributesPanel();
    colpal.setEntity(new FrameFact("hola"));
    colpal.setEntity(new FrameFact("hola"));
    jf.getContentPane().add(colpal);
    jf.pack();
    jf.show();
    jf.pack();
  }
}
Example #11
0
    AddEntityUI() {

      super(disp.getJFrame(), "Add Physics Entity");
      Box box = Box.createVerticalBox();
      box.setBorder(PANE_BORDER);
      int i = 0;
      for (EntityProperty prop : EntityProperty.values()) {
        JLabel label = new JLabel(prop.label);
        Component option = null;
        if (prop.type == FLOAT || prop.type == STRING || prop.type == VECTOR) {
          option = new JTextField(FIELD_SIZE);
          switch (prop) {
            case MASS:
              ((JTextField) option).setText(DEF_MASS);
              break;
            case VELOCITY:
              ((JTextField) option).setText(DEF_VEL);
              break;
            case COLL_FACTOR:
              ((JTextField) option).setText(DEF_CF);
              break;
            case SIZE:
              ((JTextField) option).setText(DEF_SIZE);
          }
        } else if (prop.type == BOOLEAN) {
          option = new JCheckBox();
        }
        options[i++] = option;

        JPanel panel = new JPanel(new BorderLayout());
        panel.add(BorderLayout.WEST, label);
        JPanel optPan = new JPanel();
        optPan.add(option);
        panel.add(BorderLayout.EAST, optPan);
        box.add(panel);
      }
      add(BorderLayout.CENTER, box);
      JPanel btnPanel = new JPanel();
      JButton add = new JButton("Confirm");
      add.addActionListener(new ProcessAddEntity());
      JButton cancel = new JButton("Cancel");
      OnCloseListener closeListener = new OnCloseListener();
      cancel.addActionListener(closeListener);
      cancel.setPreferredSize(add.getPreferredSize());
      btnPanel.add(add);
      btnPanel.add(cancel);
      add(BorderLayout.SOUTH, btnPanel);
      pack();
      setLocationRelativeTo(null);
      addWindowListener(closeListener);
    }
Example #12
0
  private JPanel getParamsPanel() {
    JPanel paramsPanel = new JPanel();

    Box b2 = Box.createVerticalBox();

    JComponent indTestParamBox = getIndTestParamBox();
    if (indTestParamBox != null) {
      b2.add(indTestParamBox);
    }

    paramsPanel.add(b2);
    paramsPanel.setBorder(new TitledBorder("Parameters"));
    return paramsPanel;
  }
  private void init() {
    setLayout(new BorderLayout(0, 5));
    setBorder(makeBorder());

    Box box = Box.createVerticalBox();
    box.add(makeTitlePanel());
    box.add(createResetPanel());
    box.add(createParameterPanel());
    box.add(createFilenamePanel());
    add(box, BorderLayout.NORTH);

    JPanel panel = createScriptPanel();
    add(panel, BorderLayout.CENTER);
    // Don't let the input field shrink too much
    add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST);
  }
  /**
   * Create the GUI and show it. For thread safety, this method should be invoked from the
   * event-dispatching thread.
   */
  private static void createAndShowGUI() {
    //        String[] labels = {"Name: ", "Fax: ", "Email: ", "Address: "};
    //        int numPairs = labels.length;
    //
    //        //Create and populate the panel.
    JPanel p = new JPanel(new SpringLayout());
    //        for (int i = 0; i < numPairs; i++) {
    //            JLabel l = new JLabel(labels[i], JLabel.TRAILING);
    //            p.add(l);
    //            JTextField textField = new JTextField(10);
    //            l.setLabelFor(textField);
    //            p.add(textField);
    //        }

    p.add(new JLabel("aaaa"));
    p.add(new JTextField("aaaa"));
    p.add(new JLabel("bbbb"));
    p.add(new JTextField("bbbb"));

    p.add(Box.createHorizontalBox());
    p.add(Box.createVerticalBox());
    p.add(new JLabel("cccc"));
    p.add(new JTextField("cccc"));

    // Lay out the panel.
    SpringUtilities.makeCompactGrid(
        p, 2, 4, // rows, cols
        6, 6, // initX, initY
        6, 6); // xPad, yPad
    //        SpringUtilities.makeGrid(p,
    //                                        numPairs/2, 4, //rows, cols
    //                                        6, 6,        //initX, initY
    //                                        6, 6);       //xPad, yPad

    // Create and set up the window.
    JFrame frame = new JFrame("SpringForm");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Set up the content pane.
    p.setOpaque(true); // content panes must be opaque
    frame.setContentPane(p);

    // Display the window.
    frame.pack();
    frame.setVisible(true);
  }
  private JPanel createSelectOutputDirectoryUI() {

    JPanel container = new JPanel(new BorderLayout());
    setupFileChooser();

    outputFileLocation = new FileSelectionPanel("", fileChooser);

    Box fileLocationContainer = Box.createVerticalBox();
    fileLocationContainer.add(
        UIHelper.wrapComponentInPanel(new JLabel(chooseOutputLocation, JLabel.LEFT)));
    fileLocationContainer.add(Box.createVerticalStrut(5));
    fileLocationContainer.add(outputFileLocation);

    container.add(fileLocationContainer, BorderLayout.NORTH);

    return container;
  }
Example #16
0
 private JComponent createToolPanel() {
   JComponent box = Box.createVerticalBox();
   JCheckBox button = new JCheckBox(disablingItem.getText());
   button.setModel(disablingItem.getModel());
   box.add(Box.createGlue());
   box.add(button);
   box.add(Box.createGlue());
   JRadioButton blur = new JRadioButton(blurItem.getText());
   blur.setModel(blurItem.getModel());
   box.add(blur);
   JRadioButton emboss = new JRadioButton(embossItem.getText());
   emboss.setModel(embossItem.getModel());
   box.add(emboss);
   JRadioButton translucent = new JRadioButton(busyPainterItem.getText());
   translucent.setModel(busyPainterItem.getModel());
   box.add(translucent);
   box.add(Box.createGlue());
   return box;
 }
  public java.awt.Container createControlPanel() {
    java.awt.Container panel2 = Box.createVerticalBox();
    panel2 = super.createControlPanel();

    brainPlay = new JCheckBox("Brain Play", false);
    if (testMode) brainPlay.setSelected(true);
    panel2.add(brainPlay);

    JPanel row2 = new JPanel();

    // ADVERSARY slider
    row2.add(Box.createVerticalStrut(12));
    row2.add(new JLabel("Adversary:"));

    adversary = new JSlider(0, 100, 0); // min, max, current
    adversary.setPreferredSize(new Dimension(100, 15));
    row2.add(adversary);

    JPanel text = new JPanel();
    text.add(adStat = new JLabel(adversaryOff));
    panel2.add(text);

    panel2.add(row2);

    JPanel row3 = new JPanel();

    // Mr. Happy slider
    row3.add(Box.createVerticalStrut(12));
    row3.add(new JLabel("CELAB"));

    happy = new JSlider(0, 100, 0); // min, max, current
    happy.setPreferredSize(new Dimension(100, 15));
    row3.add(happy);

    JPanel text2 = new JPanel();
    text2.add(adHappy = new JLabel(happyOff));
    panel2.add(text2);

    panel2.add(row3);

    return (panel2);
  }
Example #18
0
  /**
   * Creates a dialog that is showing the histogram for the given node (if null one is selected for
   * you)
   */
  private JPanel createScatterPlotDialog(
      ContinuousVariable yVariable, ContinuousVariable xVariable) {
    String dialogTitle = "Scatter Plots";
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    DataSet dataSet = (DataSet) dataEditor.getSelectedDataModel();

    ScatterPlotOld scatterPlot = new ScatterPlotOld(dataSet, yVariable, xVariable);
    ScatterPlotEditorPanel editorPanel = new ScatterPlotEditorPanel(scatterPlot, dataSet);
    ScatterPlotDisplayPanelOld display = new ScatterPlotDisplayPanelOld(scatterPlot);
    editorPanel.addPropertyChangeListener(new ScatterPlotListener(display));

    JMenuBar bar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.add(new JMenuItem(new SaveComponentImage(display, "Save Scatter Plot")));
    bar.add(menu);

    Box box = Box.createHorizontalBox();
    box.add(display);

    box.add(Box.createHorizontalStrut(3));
    box.add(editorPanel);
    box.add(Box.createHorizontalStrut(5));
    box.add(Box.createHorizontalGlue());

    Box vBox = Box.createVerticalBox();
    vBox.add(Box.createVerticalStrut(15));
    vBox.add(box);
    vBox.add(Box.createVerticalStrut(5));

    panel.add(bar, BorderLayout.NORTH);
    panel.add(vBox, BorderLayout.CENTER);

    //        dialog.getContentPane().add(bar, BorderLayout.NORTH);
    //        dialog.getContentPane().add(vBox, BorderLayout.CENTER);
    //        return dialog;
    return panel;
  }
Example #19
0
  public MainPanel() {
    super(new BorderLayout());
    l1.setToolTipText("Test1");
    l2.setToolTipText("Test2");
    l3.setToolTipText("<html><img src='" + url + "'>Test3</html>");

    JPanel p1 = new JPanel(new BorderLayout());
    p1.setBorder(BorderFactory.createTitledBorder("javax.swing.Timer"));
    p1.add(l1);
    JPanel p2 = new JPanel(new BorderLayout());
    p2.setBorder(BorderFactory.createTitledBorder("Animated Gif"));
    p2.add(l2, BorderLayout.NORTH);
    p2.add(l3, BorderLayout.SOUTH);

    Box box = Box.createVerticalBox();
    box.add(p1);
    box.add(Box.createVerticalStrut(20));
    box.add(p2);
    box.add(Box.createVerticalGlue());
    add(box);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setPreferredSize(new Dimension(320, 240));
  }
Example #20
0
  public BnfIntroduceRulePopup(Project project, Editor editor, BnfRule rule, BnfExpression expr) {
    super(rule, editor, project, "Introduce Rule", new BnfExpression[0], expr);

    myCheckBox.setSelected(true);
    myCheckBox.setMnemonic('p');

    myPanel.setBorder(null);
    myPanel.add(
        myCheckBox,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1,
            0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    myPanel.add(
        Box.createVerticalBox(),
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            1,
            1,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
  }
Example #21
0
  public MainPanel() {
    super(new BorderLayout());
    setSilderUI(slider1);
    setSilderUI(slider2);

    Box box1 = Box.createHorizontalBox();
    box1.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    box1.add(new JSlider(SwingConstants.VERTICAL, 0, 1000, 100));
    box1.add(Box.createHorizontalStrut(20));
    box1.add(slider1);
    box1.add(Box.createHorizontalGlue());

    Box box2 = Box.createVerticalBox();
    box2.setBorder(BorderFactory.createEmptyBorder(20, 0, 20, 20));
    box2.add(makeTitledPanel("Default", new JSlider(0, 1000, 100)));
    box2.add(Box.createVerticalStrut(20));
    box2.add(makeTitledPanel("Jump to clicked position", slider2));
    box2.add(Box.createVerticalGlue());

    add(box1, BorderLayout.WEST);
    add(box2);
    // setBorder(BorderFactory.createEmptyBorder(5, 20, 5, 10));
    setPreferredSize(new Dimension(320, 240));
  }
  private void buildKitData(Kits selectedKit) {
    final int ST_SPACE = 25;
    kitDataPanel.removeAll();
    Box container = Box.createVerticalBox();
    setComponentSize(container, 400, PAGE_HEIGHT);
    JLabel kitID = new JLabel(Integer.toString(selectedKit.getKitID()));
    JLabel kitName = new JLabel(selectedKit.getName());
    JLabel kitDesc = new JLabel(selectedKit.getDescription());
    JLabel lp = new JLabel("----- Listed Parts -----");

    // align elements to the left collum
    // all the arguments can be left as KitID.LEFT because we only need any instance of a JComponent
    // to use the LEFT keyword
    kitID.setHorizontalAlignment(kitID.LEFT);
    kitName.setHorizontalAlignment(kitID.LEFT);
    kitDesc.setHorizontalAlignment(kitID.LEFT);
    lp.setHorizontalAlignment(kitID.LEFT);

    // add elements to container
    container.add(kitID);
    container.add(kitName);
    container.add(kitDesc);
    container.add(Box.createVerticalStrut(ST_SPACE));
    container.add(lp);

    // add part data
    TreeMap<Integer, Parts> kitParts = selectedKit.getListOfParts();
    for (Integer i : kitParts.keySet()) {
      Parts selectedPart = kitParts.get(i);
      Box holder = Box.createHorizontalBox();
      Box section1 = Box.createVerticalBox();
      Box section2 = Box.createVerticalBox();
      int imageIndex = selectedPart.getImageIndex();
      String PID = Integer.toString(selectedPart.getPartNumber());
      String PName = selectedPart.getName();
      String PDesc = selectedPart.getDesc();

      setComponentSize(holder, 400, 60);

      // add elements to section1
      section1.add(new JLabel("Part " + i));
      section1.add(new JLabel(images.getIcon(imageIndex - 1)));

      // add elements to section2
      section2.add(new JLabel("Part #: " + PID));
      section2.add(new JLabel("Part name: " + PName));
      section2.add(new JLabel("Part desc: " + PDesc));

      // add sections to holder
      holder.add(section1);
      holder.add(Box.createHorizontalStrut(ST_SPACE));
      holder.add(section2);

      // add holder to container
      container.add(holder);
    }

    // add the build items to the container
    buildQuantity = new JTextField("Enter number of kits to build");
    build = new JButton("Add to build queue");
    setComponentSize(buildQuantity, 400, 20);
    setComponentSize(buildQuantity, 400, 20);
    build.addActionListener(this);
    container.add(buildQuantity);
    container.add(build);

    // add container to kitDataPanel
    kitDataPanel.add(container);
    kitDataPanel.revalidate();
  }
  /**
   * Creates the appropriate object to represent <code>msg</code> and places it into <code>container
   * </code>. If <code>msg</code> is an instance of Component, it is added directly, if it is an
   * Icon, a JLabel is created to represent it, otherwise a JLabel is created for the string, if
   * <code>d</code> is an Object[], this method will be recursively invoked for the children. <code>
   * internallyCreated</code> is true if Objc is an instance of Component and was created internally
   * by this method (this is used to correctly set hasCustomComponents only if !internallyCreated).
   */
  protected void addMessageComponents(
      Container container,
      GridBagConstraints cons,
      Object msg,
      int maxll,
      boolean internallyCreated) {
    if (msg == null) {
      return;
    }
    if (msg instanceof Component) {
      // To workaround problem where Gridbad will set child
      // to its minimum size if its preferred size will not fit
      // within allocated cells
      if (msg instanceof JScrollPane || msg instanceof JPanel) {
        cons.fill = GridBagConstraints.BOTH;
        cons.weighty = 1;
      } else {
        cons.fill = GridBagConstraints.HORIZONTAL;
      }
      cons.weightx = 1;

      container.add((Component) msg, cons);
      cons.weightx = 0;
      cons.weighty = 0;
      cons.fill = GridBagConstraints.NONE;
      cons.gridy++;
      if (!internallyCreated) {
        hasCustomComponents = true;
      }

    } else if (msg instanceof Object[]) {
      Object[] msgs = (Object[]) msg;
      for (Object o : msgs) {
        addMessageComponents(container, cons, o, maxll, false);
      }

    } else if (msg instanceof Icon) {
      JLabel label = new JLabel((Icon) msg, SwingConstants.CENTER);
      configureMessageLabel(label);
      addMessageComponents(container, cons, label, maxll, true);

    } else {
      String s = msg.toString();
      int len = s.length();
      if (len <= 0) {
        return;
      }
      int nl;
      int nll = 0;

      if ((nl = s.indexOf(newline)) >= 0) {
        nll = newline.length();
      } else if ((nl = s.indexOf("\r\n")) >= 0) {
        nll = 2;
      } else if ((nl = s.indexOf('\n')) >= 0) {
        nll = 1;
      }
      if (nl >= 0) {
        // break up newlines
        if (nl == 0) {
          JPanel breakPanel =
              new JPanel() {
                public Dimension getPreferredSize() {
                  Font f = getFont();

                  if (f != null) {
                    return new Dimension(1, f.getSize() + 2);
                  }
                  return new Dimension(0, 0);
                }
              };
          breakPanel.setName("OptionPane.break");
          addMessageComponents(container, cons, breakPanel, maxll, true);
        } else {
          addMessageComponents(container, cons, s.substring(0, nl), maxll, false);
        }
        addMessageComponents(container, cons, s.substring(nl + nll), maxll, false);

      } else if (len > maxll) {
        Container c = Box.createVerticalBox();
        c.setName("OptionPane.verticalBox");
        burstStringInto(c, s, maxll);
        addMessageComponents(container, cons, c, maxll, true);

      } else {
        JLabel label;
        label = new JLabel(s, JLabel.LEADING);
        label.setName("OptionPane.label");
        configureMessageLabel(label);
        addMessageComponents(container, cons, label, maxll, true);
      }
    }
  }
Example #24
0
  /** Install the Rotate-Button into the toolbar */
  private void installRotateButton() {
    URL imgURL = ClassLoader.getSystemResource("ch/tbe/pics/rotate.gif");
    ImageIcon rotateIcon = new ImageIcon(imgURL);
    rotate = new JButton(rotateIcon);
    rotate.setEnabled(false);
    rotatePanel = new JToolBar();
    rotatePanel.setOrientation(1);
    rotatePanel.setLayout(new BorderLayout(0, 1));
    rotateSlider = new JSlider();
    rotateSlider.setMaximum(359);
    rotateSlider.setMinimum(0);
    rotateSlider.setMaximumSize(new Dimension(100, 100));
    rotateSlider.setOrientation(1);
    Box box = Box.createVerticalBox();

    sliderValue.setPreferredSize(new Dimension(30, 20));

    rotateSlider.setAlignmentY(Component.TOP_ALIGNMENT);
    box.add(sliderValue);
    box.add(rotateSlider);
    sliderValue.setAlignmentY(Component.TOP_ALIGNMENT);
    rotatePanel.add(box, BorderLayout.NORTH);

    sliderValue.addFocusListener(
        new FocusListener() {

          private int oldValue = 0;

          public void focusGained(FocusEvent arg0) {
            oldValue = Integer.parseInt(sliderValue.getText());
          }

          public void focusLost(FocusEvent arg0) {
            int newValue = 0;
            try {
              newValue = Integer.parseInt(sliderValue.getText());
            } catch (Exception ex) {
              sliderValue.setText(Integer.toString(oldValue));
            }
            if (newValue >= 0 && newValue <= 359) {

              RotateCommand rc = new RotateCommand(board.getSelectedItems());
              ArrayList<Command> actCommands = new ArrayList<Command>();
              actCommands.add(rc);
              TBE.getInstance().addCommands(actCommands);
              rotateSlider.setValue(newValue);
            } else {
              sliderValue.setText(Integer.toString(oldValue));
            }
          }
        });

    rotateSlider.addChangeListener(
        new ChangeListener() {

          public void stateChanged(ChangeEvent arg0) {

            if (board.getSelectionCount() == 1
                && board.getSelectionCells()[0] instanceof ShapeItem) {
              sliderValue.setText(Integer.toString(rotateSlider.getValue()));
              ShapeItem s = (ShapeItem) board.getSelectionCells()[0];
              board.removeItem(new ItemComponent[] {s});
              s.setRotation(rotateSlider.getValue());
              board.addItem(s);
            }
          }
        });
    rotateSlider.addMouseListener(
        new MouseAdapter() {

          private int value;

          public void mousePressed(MouseEvent e) {
            value = rotateSlider.getValue();
          }

          public void mouseReleased(MouseEvent e) {
            if (value != rotateSlider.getValue()) {
              RotateCommand rc = new RotateCommand(board.getSelectedItems());
              ArrayList<Command> actCommands = new ArrayList<Command>();
              actCommands.add(rc);
              TBE.getInstance().addCommands(actCommands);
              rc.setRotation(value);
            }
          }
        });

    rotate.setToolTipText(workingViewLabels.getString("rotate"));

    rotate.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (board.getSelectionCount() == 1
                && board.getSelectedItems()[0] instanceof ShapeItem) {
              rotateSlider.setValue(((ShapeItem) board.getSelectedItems()[0]).getRotation());
            }
            rotatePanel.setVisible(!rotatePanel.isVisible());
            showRotate = !showRotate;
          }
        });

    rotate.setContentAreaFilled(false);
    rotate.setBorderPainted(false);
    toolbar.add(rotate);
    rotatePanel.setVisible(false);
    this.add(rotatePanel, BorderLayout.EAST);
  }
Example #25
0
  public LingDisplay(final Ling.StoredGraphs storedGraphs) {
    this.storedGraphs = storedGraphs;

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

    subsetIndices = getStableIndices(storedGraphs);

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

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

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

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

    b.add(b1);

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

    setLayout(new BorderLayout());
    //        add(menuBar(), BorderLayout.NORTH);
    add(b, BorderLayout.CENTER);
  }
  public CPLayersPalette(CPCommonController controller) {
    super(controller);

    title = "Layers";

    // Widgets creation

    Image icons = controller.loadImage("smallicons.png");

    addButton = new CPIconButton(icons, 16, 16, 0, 1);
    addButton.addController(this);
    addButton.setCPActionCommand(CPCommandId.AddLayer);

    removeButton = new CPIconButton(icons, 16, 16, 1, 1);
    removeButton.addController(this);
    removeButton.setCPActionCommand(CPCommandId.RemoveLayer);

    alphaSlider = new CPAlphaSlider();

    blendCombo = new JComboBox<String>(modeNames);
    blendCombo.addActionListener(this);

    lw = new CPLayerWidget();
    renameField = new CPRenameField();
    lw.add(renameField);
    scrollPane = new JScrollPane(lw);

    cbSampleAllLayers = new JCheckBox("Sample All Layers");
    cbSampleAllLayers.setSelected(controller.artwork.isSampleAllLayers());
    cbSampleAllLayers.addItemListener(this);

    cbLockAlpha = new JCheckBox("Lock Alpha");
    cbLockAlpha.setSelected(controller.artwork.isLockAlpha());
    cbLockAlpha.addItemListener(this);

    // Layout

    // Add/Remove Layer
    Box hb = Box.createHorizontalBox();
    hb.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    hb.add(addButton);
    hb.add(Box.createRigidArea(new Dimension(5, 0)));
    hb.add(removeButton);
    hb.add(Box.createHorizontalGlue());

    // blend mode
    blendCombo.setPreferredSize(new Dimension(100, 16));

    Box hb2 = Box.createHorizontalBox();
    hb2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    hb2.add(blendCombo);
    hb2.add(Box.createHorizontalGlue());

    // layer opacity
    alphaSlider.setPreferredSize(new Dimension(100, 16));
    alphaSlider.setMaximumSize(new Dimension(100, 16));

    Box hb3 = Box.createHorizontalBox();
    hb3.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    hb3.add(alphaSlider);
    hb3.add(Box.createRigidArea(new Dimension(0, 16)));
    hb3.add(Box.createHorizontalGlue());

    Box hb4 = Box.createHorizontalBox();
    hb4.add(cbSampleAllLayers);
    hb4.add(Box.createHorizontalGlue());

    Box hb5 = Box.createHorizontalBox();
    hb5.add(cbLockAlpha);
    hb5.add(Box.createHorizontalGlue());

    Box vb = Box.createVerticalBox();
    vb.add(hb2);
    vb.add(hb3);
    vb.add(hb4);
    vb.add(hb5);

    setLayout(new BorderLayout());
    add(scrollPane, BorderLayout.CENTER);
    add(vb, BorderLayout.PAGE_START);
    add(hb, BorderLayout.PAGE_END);

    // Set initial values
    CPArtwork artwork = controller.getArtwork();
    alphaSlider.setValue(artwork.getActiveLayer().getAlpha());

    // add listeners

    addListener();
    // validate();
    // pack();
  }
  public storiconoleggio() {

    storico = new JFrame("Storico cliente:");
    storico.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    storico.setVisible(true);

    operazioni = new JPanel();
    operazioni.setLayout(new BoxLayout(operazioni, BoxLayout.Y_AXIS));

    sotto = new JPanel();

    gruppo = Box.createVerticalBox();

    indietro = new JButton("Indietro");

    ascoltatore = new listenernolcli();

    Object righe[][] = {
      {"# Noleggio", "ID Bagnino", "# Ombrellone", "Data Noleggio", "Num. Lettini", "ID Cliente"}
    };
    Object colonne[] = {"", "", "", "", "", ""};
    JTable tabella = new JTable(righe, colonne);

    try {
      String url = "jdbc:mysql://127.0.0.1:3306/lido";
      String userid = "root";
      String paswordd = "root";
      con = DriverManager.getConnection(url, userid, paswordd);
      requete = con.createStatement();
      rs =
          requete.executeQuery(
              "SELECT * FROM lido.bagnino_noleggia_ombrellone WHERE cliente_idcliente ="
                  + login.getNomeUtente());
      ResultSetMetaData md = rs.getMetaData();
      int columnCount = md.getColumnCount();

      Vector columns = new Vector(columnCount);

      for (int i = 1; i <= columnCount; i++) columns.add(md.getColumnName(i));
      Vector data = new Vector();
      Vector row;

      while (rs.next()) {
        row = new Vector(columnCount);
        for (int i = 1; i <= columnCount; i++) {
          row.add(rs.getString(i));
        }
        data.add(row);
      }
      table = new JTable(data, columns);
      table.setPreferredScrollableViewportSize(new Dimension(500, 70));
      table.setFillsViewportHeight(true);
      table.setVisible(true);
      table.validate();

    } catch (SQLException sqle) {

      System.out.println(sqle);
      sqle.printStackTrace();
    }

    indietro.addActionListener(ascoltatore);

    operazioni.add(tabella);
    operazioni.add(table);

    sotto.add(indietro);

    gruppo.add(operazioni);
    gruppo.add(sotto);
    storico.add(gruppo);
    storico.pack();
  }
Example #28
0
/**
 * Provides a view that displays all of the available ports.
 *
 * @author Christopher Miles
 * @version 1.0
 */
public class PortListView extends JPanel {

  /** Logger instance. */
  private Logger logger = Logger.getLogger(this.getClass());

  /** Model for this view. */
  private PortListModel model;

  /** Column headers. */
  private final String[] columnHeaders = new String[] {"Port"};

  /** Box to hold the port controllers. */
  private final Box boxControllers = Box.createVerticalBox();

  // gui objects
  private JLabel textfieldHeading;
  private JLabel textfieldSubhead1;
  private JScrollPane scrollpanePorts;
  private JButton buttonAddTestPort;
  private JButton buttonOkay;
  private JPanel panelMain;
  private JPanel panelPorts;

  public PortListView(PortListModel model) {

    super();

    // save a reference
    this.model = model;

    setupPanel();

    initializeListeners();
  }

  public void addNewPortController(final PortInfoView portcontroller) {

    // add the row to the table
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {

            logger.debug("Adding portcontroller");

            if (boxControllers.getComponentCount() > 0) {
              boxControllers.remove(boxControllers.getComponentCount() - 1);
            }

            boxControllers.add(portcontroller);
            revalidate();
          }
        });

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {

            boxControllers.add(Box.createVerticalGlue());
          }
        });
  }

  // private methods

  private void populatePortTable(List ports) {

    logger.debug("Filling port table");
    // get an array of ports
    final PortInfoController[] portcontrollers =
        (PortInfoController[]) ports.toArray(new PortInfoController[ports.size()]);

    // setup the panel
    boxControllers.removeAll();

    // add the ports to the data array
    for (int index = 0; index < portcontrollers.length; index++) {

      final int indexFinal = index;
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {

              boxControllers.add(portcontrollers[indexFinal].getView());
            }
          });
    }

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {

            boxControllers.add(Box.createVerticalGlue());
          }
        });
  }

  private void initializeListeners() {

    initializeModelListeners();
    initializeFieldListeners();
  }

  private void initializeFieldListeners() {

    buttonOkay.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (model.getListenerOkay() != null) {
              model.getListenerOkay().actionPerformed(e);
            }
          }
        });

    buttonAddTestPort.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            if (model.getListenerAddTestPort() != null) {
              model.getListenerAddTestPort().actionPerformed(event);
            }
          }
        });
  }

  private void initializeModelListeners() {

    model.addPropertyChangeListener(
        "ports",
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent event) {

            populatePortTable((List) event.getNewValue());
          }
        });
  }

  private void setupPanel() {

    panelPorts.setLayout(new GridLayout(1, 1));
    panelPorts.setOpaque(false);
    panelPorts.add(boxControllers);

    setLayout(new GridLayout(1, 1));
    add(panelMain);

    textfieldHeading.setFont(textfieldHeading.getFont().deriveFont(Font.BOLD, 18));
    textfieldSubhead1.setFont(textfieldHeading.getFont().deriveFont(Font.PLAIN, 10));
  }

  {
    // GUI initializer generated by IntelliJ IDEA GUI Designer
    // >>> IMPORTANT!! <<<
    // DO NOT EDIT OR ADD ANY CODE HERE!
    $$$setupUI$$$();
  }

  /**
   * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR
   * call it in your code!
   *
   * @noinspection ALL
   */
  private void $$$setupUI$$$() {
    panelMain = new JPanel();
    panelMain.setLayout(
        new com.intellij.uiDesigner.core.GridLayoutManager(4, 1, new Insets(5, 5, 5, 5), -1, -1));
    textfieldHeading = new JLabel();
    textfieldHeading.setText("Select Ports to Monitor");
    panelMain.add(
        textfieldHeading,
        new com.intellij.uiDesigner.core.GridConstraints(
            0,
            0,
            1,
            1,
            com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
            com.intellij.uiDesigner.core.GridConstraints.FILL_NONE,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
            null,
            null,
            null,
            0,
            false));
    final JPanel panel1 = new JPanel();
    panel1.setLayout(
        new com.intellij.uiDesigner.core.GridLayoutManager(1, 1, new Insets(5, 0, 0, 0), -1, -1));
    panelMain.add(
        panel1,
        new com.intellij.uiDesigner.core.GridConstraints(
            1,
            0,
            1,
            1,
            com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
            com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
                | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
            1,
            null,
            null,
            null,
            0,
            false));
    textfieldSubhead1 = new JLabel();
    textfieldSubhead1.setText("Check the box to monitor the port. ");
    panel1.add(
        textfieldSubhead1,
        new com.intellij.uiDesigner.core.GridConstraints(
            0,
            0,
            1,
            1,
            com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
            com.intellij.uiDesigner.core.GridConstraints.FILL_NONE,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
            null,
            null,
            null,
            0,
            false));
    final JPanel panel2 = new JPanel();
    panel2.setLayout(
        new com.intellij.uiDesigner.core.GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
    panelMain.add(
        panel2,
        new com.intellij.uiDesigner.core.GridConstraints(
            2,
            0,
            1,
            1,
            com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
            com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
                | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
                | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
            null,
            null,
            null,
            0,
            false));
    buttonAddTestPort = new JButton();
    buttonAddTestPort.setText("Add a test port");
    panel2.add(
        buttonAddTestPort,
        new com.intellij.uiDesigner.core.GridConstraints(
            1,
            0,
            1,
            1,
            com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
            com.intellij.uiDesigner.core.GridConstraints.FILL_NONE,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
            null,
            null,
            null,
            0,
            false));
    scrollpanePorts = new JScrollPane();
    scrollpanePorts.setVerticalScrollBarPolicy(22);
    panel2.add(
        scrollpanePorts,
        new com.intellij.uiDesigner.core.GridConstraints(
            0,
            0,
            1,
            1,
            com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER,
            com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
                | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
                | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW,
            new Dimension(-1, 225),
            null,
            null,
            0,
            false));
    panelPorts = new JPanel();
    scrollpanePorts.setViewportView(panelPorts);
    buttonOkay = new JButton();
    buttonOkay.setText("Okay");
    panelMain.add(
        buttonOkay,
        new com.intellij.uiDesigner.core.GridConstraints(
            3,
            0,
            1,
            1,
            com.intellij.uiDesigner.core.GridConstraints.ANCHOR_EAST,
            com.intellij.uiDesigner.core.GridConstraints.FILL_NONE,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
                | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
            com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
            null,
            null,
            null,
            0,
            false));
  }

  /** @noinspection ALL */
  public JComponent $$$getRootComponent$$$() {
    return panelMain;
  }
}
Example #29
0
  /**
   * This method represents the window in which the preferred parameters for the obix components can
   * be chosen.
   *
   * @param chosenComponents The list of {@link ObixObject} which have been chosen in the previous
   *     window.
   * @return The container in which the preferred parameters for the obix components can be chosen.
   */
  private Container chooseParameters(List<ObixObject> chosenComponents) {
    Container pane = new Container();
    pane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    pane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    Font titelF = new Font("Courier", Font.BOLD, 30);
    title = new JLabel("Please choose the appropriate Parameters for the datapoints");
    title.setFont(titelF);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = 10;
    c.gridx = 0;
    c.gridy = 0;
    pane.add(title, c);

    List<String> parametersList = Configurator.getInstance().getAvailableParameterTypes();
    String[] parameterTypes = new String[parametersList.size()];
    parameterTypes = parametersList.toArray(parameterTypes);

    for (ObixObject o : chosenComponents) {
      c.gridy++;
      c.insets = new Insets(30, 10, 0, 0);

      JLabel uriLabel = new JLabel(o.getObixUri());
      uriLabel.setFont(new Font("Courier", Font.ITALIC, 15));
      c.gridx = 0;
      c.gridwidth = 10;
      pane.add(uriLabel, c);

      c.gridwidth = 1;
      c.insets = new Insets(10, 10, 0, 0);

      JLabel parameter1Label = new JLabel("Parameter 1 Type:");
      c.gridy++;
      pane.add(parameter1Label, c);

      JLabel parameter1ObixUnitLabel = new JLabel("OBIX unit: " + o.getObixUnitUri());
      c.gridx++;
      pane.add(parameter1ObixUnitLabel, c);

      JComboBox parameter1comboBox = new JComboBox(parameterTypes);
      c.gridx++;
      pane.add(parameter1comboBox, c);

      JButton param1AddStateButton = new JButton("Add State");
      Box vBox1 = Box.createVerticalBox();
      vBox1.setBorder(BorderFactory.createLineBorder(Color.black));

      JLabel parameter1UnitLabel = new JLabel("Set Parameter 1 Unit:");
      c.gridx++;
      pane.add(parameter1UnitLabel, c);

      JTextField parameter1UnitTextField = new JTextField(o.getParameter1().getParameterUnit());
      parameter1UnitTextField.setPreferredSize(new Dimension(500, 20));
      parameter1UnitTextField.setMinimumSize(new Dimension(500, 20));
      c.gridx++;
      pane.add(parameter1UnitTextField, c);

      JLabel parameter1ValueTypeLabel =
          new JLabel("valueType: " + o.getParameter1().getValueType());
      c.gridx++;
      pane.add(parameter1ValueTypeLabel, c);

      int param1UnitLabelxPosition = c.gridx;
      int param1UnitLabelyPosition = c.gridy;

      for (StateDescription s : o.getParameter1().getStateDescriptions()) {
        JLabel stateNameLabel = new JLabel("State Name: ");
        JTextField stateNameTextfield = new JTextField(20);
        stateNameTextfield.setText(s.getName().getName());
        vBox1.add(stateNameLabel);
        vBox1.add(stateNameTextfield);

        JLabel stateValueLabel = new JLabel("State Value: ");
        JTextField stateValueTextfield = new JTextField(20);
        stateValueTextfield.setText(s.getValue().getValue());
        vBox1.add(stateValueLabel);
        vBox1.add(stateValueTextfield);

        JLabel stateURILabel = new JLabel("State URI: ");
        JTextField stateURITextfield = new JTextField(20);
        stateURITextfield.setText(s.getStateDescriptionUri());
        vBox1.add(stateURILabel);
        vBox1.add(stateURITextfield);

        JButton deleteStateButton = new JButton("Delete State");
        vBox1.add(deleteStateButton);

        JSeparator horizontalLine = new JSeparator(JSeparator.HORIZONTAL);
        vBox1.add(horizontalLine);
        vBox1.add(horizontalLine);

        StateRepresentation stateRepresentation =
            (new StateRepresentation(
                param1AddStateButton,
                deleteStateButton,
                stateNameLabel,
                stateNameTextfield,
                stateValueLabel,
                stateValueTextfield,
                stateURILabel,
                stateURITextfield,
                horizontalLine,
                vBox1,
                o.getParameter1()));

        addDeleteStateListener(stateRepresentation);
        listOfStateRepresentations.add(stateRepresentation);

        pane.revalidate();
        pane.repaint();
      }

      addParameterBoxListener(
          parameter1comboBox,
          param1UnitLabelxPosition,
          param1UnitLabelyPosition,
          parameter1UnitLabel,
          parameter1UnitTextField,
          pane,
          param1AddStateButton,
          vBox1);

      /** Add state to parameter 1 function listener */
      param1AddStateButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              JLabel stateNameLabel = new JLabel("State Name: ");
              JTextField stateNameTextfield = new JTextField(20);
              vBox1.add(stateNameLabel);
              vBox1.add(stateNameTextfield);
              JLabel stateValueLabel = new JLabel("State Value: ");

              JTextField stateValueTextfield = new JTextField(20);
              vBox1.add(stateValueLabel);
              vBox1.add(stateValueTextfield);

              JLabel stateURILabel = new JLabel("State URI: ");
              JTextField stateURITextfield = new JTextField(20);
              vBox1.add(stateURILabel);
              vBox1.add(stateURITextfield);

              JButton deleteStateButton = new JButton("Delete State");
              vBox1.add(deleteStateButton);

              JSeparator horizontalLine = new JSeparator(JSeparator.HORIZONTAL);
              vBox1.add(horizontalLine);
              vBox1.add(horizontalLine);

              StateRepresentation stateRepresentation =
                  (new StateRepresentation(
                      param1AddStateButton,
                      deleteStateButton,
                      stateNameLabel,
                      stateNameTextfield,
                      stateValueLabel,
                      stateValueTextfield,
                      stateURILabel,
                      stateURITextfield,
                      horizontalLine,
                      vBox1,
                      o.getParameter1()));

              addDeleteStateListener(stateRepresentation);
              listOfStateRepresentations.add(stateRepresentation);
              pane.revalidate();
              pane.repaint();
            }
          });

      c.gridy++;
      c.gridx = 0;
      JLabel parameter2Label = new JLabel("Parameter 2 Type:");
      pane.add(parameter2Label, c);

      JComboBox parameter2comboBox = new JComboBox(parameterTypes);
      c.gridx++;
      c.gridx++;
      pane.add(parameter2comboBox, c);

      JLabel parameter2UnitLabel = new JLabel("Set Parameter 2 Unit: ");
      c.gridx++;
      pane.add(parameter2UnitLabel, c);

      JTextField parameter2UnitTextField = new JTextField(o.getParameter2().getParameterUnit());
      parameter2UnitTextField.setPreferredSize(new Dimension(500, 20));
      parameter2UnitTextField.setMinimumSize(new Dimension(500, 20));
      c.gridx++;
      pane.add(parameter2UnitTextField, c);

      JLabel parameter2ValueTypeLabel =
          new JLabel("valueType: " + o.getParameter2().getValueType());
      c.gridx++;
      pane.add(parameter2ValueTypeLabel, c);

      JButton param2AddStateButton = new JButton("Add State");
      Box vBox2 = Box.createVerticalBox();
      vBox2.setBorder(BorderFactory.createLineBorder(Color.black));

      int param2UnitLabelxPosition = c.gridx;
      int param2UnitLabelyPosition = c.gridy;

      addParameterBoxListener(
          parameter2comboBox,
          param2UnitLabelxPosition,
          param2UnitLabelyPosition,
          parameter2UnitLabel,
          parameter2UnitTextField,
          pane,
          param2AddStateButton,
          vBox2);

      /** Add state to parameter 2 function listener */
      param2AddStateButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              JLabel stateNameLabel = new JLabel("State Name: ");
              JTextField stateNameTextfield = new JTextField(20);
              vBox2.add(stateNameLabel);
              vBox2.add(stateNameTextfield);
              JLabel stateValueLabel = new JLabel("State Value: ");

              JTextField stateValueTextfield = new JTextField(20);
              vBox2.add(stateValueLabel);
              vBox2.add(stateValueTextfield);

              JLabel stateURILabel = new JLabel("State URI: ");
              JTextField stateURITextfield = new JTextField(20);
              vBox2.add(stateURILabel);
              vBox2.add(stateURITextfield);

              JButton deleteStateButton = new JButton("Delete State");
              vBox2.add(deleteStateButton);

              JSeparator horizontalLine = new JSeparator(JSeparator.HORIZONTAL);
              vBox2.add(horizontalLine);
              vBox2.add(horizontalLine);

              StateRepresentation stateRepresentation =
                  (new StateRepresentation(
                      param2AddStateButton,
                      deleteStateButton,
                      stateNameLabel,
                      stateNameTextfield,
                      stateValueLabel,
                      stateValueTextfield,
                      stateURILabel,
                      stateURITextfield,
                      horizontalLine,
                      vBox2,
                      o.getParameter2()));

              addDeleteStateListener(stateRepresentation);
              listOfStateRepresentations.add(stateRepresentation);

              pane.revalidate();
              pane.repaint();
            }
          });

      parameter1comboBox.setSelectedItem(o.getParameter1().getParameterType());
      parameter2comboBox.setSelectedItem(o.getParameter2().getParameterType());

      representationRows.add(
          new RepresentationRow(
              o,
              parameter1comboBox,
              parameter2comboBox,
              parameter1UnitTextField,
              parameter2UnitTextField));
    }

    JButton acceptButton = new JButton("Accept");
    c.insets = new Insets(50, 0, 0, 0);
    c.gridwidth = 10;
    c.gridx = 0;
    c.gridy++;
    pane.add(acceptButton, c);

    /** Accept button listener */
    Action acceptAction =
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            for (StateRepresentation s : listOfStateRepresentations) {
              if (s.getStateNameTextField().getText().isEmpty()
                  || s.getStateUriTextField().getText().isEmpty()
                  || s.getStateValueTextField().getText().isEmpty()) {
                JOptionPane.showMessageDialog(
                    null,
                    "Each state parameter field must contain a text! "
                        + "There are some empty parameter fields, please change them before proceeding.");
                return;
              }
            }

            for (ObixObject o : chosenComponents) {
              o.getParameter1().getStateDescriptions().clear();
              o.getParameter2().getStateDescriptions().clear();
            }

            for (StateRepresentation s : listOfStateRepresentations) {
              // Save created State
              ArrayList<String> types = new ArrayList<String>();
              types.add("&colibri;AbsoluteState");
              types.add("&colibri;DiscreteState");

              Value val = new Value();
              val.setValue(s.getStateValueTextField().getText());
              val.setDatatype(s.getParameter().getValueType());

              Name name = new Name();
              name.setName(s.getStateNameTextField().getText());

              StateDescription state =
                  new StateDescription(s.getStateUriTextField().getText(), types, val, name);

              s.getParameter().addStateDescription(state);
            }
            List<ObixObject> chosenObjects = Collections.synchronizedList(new ArrayList<>());
            for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
              r.getObixObject()
                  .getParameter1()
                  .setParameterType((String) r.getParam1TypeComboBox().getSelectedItem());
              r.getObixObject()
                  .getParameter2()
                  .setParameterType((String) r.getParam2TypeComboBox().getSelectedItem());
              chosenObjects.add(r.getObixObject());
              if (!r.getParam1UnitTextField().getText().isEmpty()) {
                r.getObixObject()
                    .getParameter1()
                    .setParameterUnit(r.getParam1UnitTextField().getText());
              }
              if (!r.getParam2UnitTextField().getText().isEmpty()) {
                r.getObixObject()
                    .getParameter2()
                    .setParameterUnit(r.getParam2UnitTextField().getText());
              }
            }
            representationRows.clear();
            cards.removeAll();
            JScrollPane scrollPane = new JScrollPane(interactionWindow(chosenObjects));
            scrollPane.getVerticalScrollBar().setUnitIncrement(16);
            scrollPane.setBorder(new EmptyBorder(20, 20, 20, 20));
            cards.add(scrollPane);
            // Display the window.
            mainFrame.pack();
          }
        };
    acceptButton.addActionListener(acceptAction);

    return pane;
  }
Example #30
0
 /** Fills the panel with event specific fields. */
 protected void fillPanel() {
   JLabel l;
   Box fdp = Box.createVerticalBox();
   fdp.setBorder(BorderFactory.createTitledBorder("Fundamental Diagram"));
   fdChart = makeFDChart();
   ChartPanel cp = new ChartPanel(fdChart);
   cp.setMinimumDrawWidth(100);
   cp.setMinimumDrawHeight(60);
   cp.setPreferredSize(new Dimension(250, 80));
   fdp.add(new JScrollPane(cp));
   JPanel prmp = new JPanel(new SpringLayout());
   l = new JLabel("Capacity:", JLabel.TRAILING);
   prmp.add(l);
   spinMaxFlow = new JSpinner(new SpinnerNumberModel(mf, 0, 99999, 1.0));
   spinMaxFlow.setEditor(new JSpinner.NumberEditor(spinMaxFlow, "####0.00"));
   spinMaxFlow.addChangeListener(this);
   spinMaxFlow.setName(nmSpinMaxFlow);
   l.setLabelFor(spinMaxFlow);
   prmp.add(spinMaxFlow);
   l = new JLabel("Cap.Drop:", JLabel.TRAILING);
   prmp.add(l);
   spinCapDrop = new JSpinner(new SpinnerNumberModel(drp, 0, 99999, 1.0));
   spinCapDrop.setEditor(new JSpinner.NumberEditor(spinCapDrop, "####0.00"));
   spinCapDrop.addChangeListener(this);
   spinCapDrop.setName(nmSpinCapDrop);
   l.setLabelFor(spinCapDrop);
   prmp.add(spinCapDrop);
   l = new JLabel("C.Density:", JLabel.TRAILING);
   prmp.add(l);
   spinCritDen = new JSpinner(new SpinnerNumberModel(cd, 0, 99999, 1.0));
   spinCritDen.setEditor(new JSpinner.NumberEditor(spinCritDen, "####0.00"));
   spinCritDen.addChangeListener(this);
   spinCritDen.setName(nmSpinCritDen);
   l.setLabelFor(spinCritDen);
   prmp.add(spinCritDen);
   l = new JLabel("  V:", JLabel.TRAILING);
   prmp.add(l);
   spinVff = new JSpinner(new SpinnerNumberModel(mf / cd, 0, 200, 1.0));
   spinVff.setEditor(new JSpinner.NumberEditor(spinVff, "#0.00"));
   spinVff.addChangeListener(this);
   spinVff.setName(nmSpinVff);
   l.setLabelFor(spinVff);
   prmp.add(spinVff);
   l = new JLabel("J.Density:", JLabel.TRAILING);
   prmp.add(l);
   spinJamDen = new JSpinner(new SpinnerNumberModel(jd, 0, 99999, 1.0));
   spinJamDen.setEditor(new JSpinner.NumberEditor(spinJamDen, "####0.00"));
   spinJamDen.addChangeListener(this);
   spinJamDen.setName(nmSpinJamDen);
   l.setLabelFor(spinJamDen);
   prmp.add(spinJamDen);
   l = new JLabel("  W:", JLabel.TRAILING);
   prmp.add(l);
   if (jd == cd) jd = cd + 1;
   int ulim = (int) Math.max(Math.ceil(mf / (jd - cd)), 999);
   spinWc = new JSpinner(new SpinnerNumberModel(mf / (jd - cd), 0, ulim, 1.0));
   spinWc.setEditor(new JSpinner.NumberEditor(spinWc, "#0.00"));
   spinWc.addChangeListener(this);
   spinWc.setName(nmSpinWc);
   l.setLabelFor(spinWc);
   prmp.add(spinWc);
   SpringUtilities.makeCompactGrid(prmp, 3, 4, 2, 2, 2, 2);
   fdp.add(prmp);
   // add(new JScrollPane(fdp));
   add(fdp);
   return;
 }