public FeaturePaletteScrollPane() {
    this.setBorder(BorderFactory.createTitledBorder("Feature Palette"));
    panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    setViewportView(panel);
    componentName = new JLabel("Component: ");
    componentName.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    componentName.setMinimumSize(new Dimension(200, 20));
    componentName.setMaximumSize(new Dimension(200, 20));
    cmbFeatures = new JComboBox();
    cmbFeatures.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    cmbFeatures.setMinimumSize(new Dimension(200, 20));
    cmbFeatures.setMaximumSize(new Dimension(200, 20));
    cmbValues = new JComboBox();
    cmbValues.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    cmbValues.setMinimumSize(new Dimension(200, 20));
    cmbValues.setMaximumSize(new Dimension(200, 20));
    resetButton = new JButton("Set ALL Features to Default");
    resetButton.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    resetButton.setMinimumSize(new Dimension(200, 20));
    resetButton.setMaximumSize(new Dimension(200, 20));
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    double width = screenSize.getWidth();
    double height = screenSize.getHeight();
    int palettewidth = (int) (width * 0.4);
    int paletteheight = (int) (height * 0.25);
    this.setPreferredSize(new Dimension(palettewidth, paletteheight));
    JLabel blankLabel = new JLabel("");
    blankLabel.setMinimumSize(new Dimension(200, 20));
    blankLabel.setMaximumSize(new Dimension(200, 20));
    blankLabel.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    JLabel blankLabel2 = new JLabel("");
    blankLabel2.setMinimumSize(new Dimension(200, 20));
    blankLabel2.setMaximumSize(new Dimension(200, 20));
    blankLabel2.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    JLabel blankLabel3 = new JLabel("");
    blankLabel3.setMinimumSize(new Dimension(200, 10));
    blankLabel3.setMaximumSize(new Dimension(200, 10));
    blankLabel3.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
    panel.add(componentName);
    panel.add(blankLabel);
    panel.add(cmbFeatures);
    panel.add(blankLabel3);
    panel.add(cmbValues);
    panel.add(blankLabel2);
    panel.add(resetButton);

    initComponents();
  }
Exemple #2
0
  public ComboBoxDemo2() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    String[] patternExamples = {
      "dd MMMMM yyyy",
      "dd.MM.yy",
      "MM/dd/yy",
      "yyyy.MM.dd G 'at' hh:mm:ss z",
      "EEE, MMM d, ''yy",
      "h:mm a",
      "H:mm:ss:SSS",
      "K:mm a,z",
      "yyyy.MMMMM.dd GGG hh:mm aaa"
    };

    currentPattern = patternExamples[0];

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setEditable(true);
    patternList.addActionListener(this);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == LEFT
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything.
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternPanel.add(patternList);

    JPanel resultPanel = new JPanel(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

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

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
  } // constructor
  public FindProf() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Search your campus!");
    JLabel patternLabel2 = new JLabel("");

    patternList = new JComboBox<Object>(searchNames);
    patternList.setEditable(true);
    patternList.setMaximumRowCount(5);
    patternList.addActionListener(this);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Building Initials & Room Number:", JLabel.LEADING); // == LEFT
    result = new JLabel(" ");
    result.setHorizontalAlignment(SwingConstants.CENTER);
    result.setForeground(Color.black);
    result.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything.
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternPanel.add(patternList);

    JPanel resultPanel = new JPanel(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

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

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  } // constructor
  private void initPanel() {
    final JLabel qualityLabel = new JLabel("Preferred video quality:");
    final JComboBox<VideoQuality> qualityList =
        new JComboBox<VideoQuality>(VideoQuality.getItems());
    qualityLabel.setLabelFor(qualityList);
    qualityLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    qualityList.setAlignmentX(Component.LEFT_ALIGNMENT);
    qualityList.setSelectedItem(config.getVideoQuality());

    qualityList.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            config.setVideoQuality((VideoQuality) qualityList.getSelectedItem());
          }
        });

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(qualityLabel);
    add(qualityList);
    add(Box.createRigidArea(new Dimension(0, 15)));
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
  }
  private JPanel createAttributePanel() {
    JPanel attributePanel = new JPanel();
    attributePanel.setLayout(new BoxLayout(attributePanel, BoxLayout.Y_AXIS));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    return attributePanel;
  }
Exemple #6
0
  private void createStreamingButtons(JPanel panel) {
    JPanel subPanel = new JPanel();
    subPanel.setLayout(new BoxLayout(subPanel, BoxLayout.PAGE_AXIS));
    panel.add(subPanel);

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

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

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

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

    subPanel.add(streamComboBox);

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

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

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

            if (saveFramePath == null) return;

            isStreaming = !isStreaming;

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

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

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

            if (e.getStateChange() == ItemEvent.SELECTED) {
              isSavingStream = true;
            } else if (e.getStateChange() == ItemEvent.DESELECTED) {
              isSavingStream = false;
            }
          }
        });
    subPanel.add(saveStreamBox);
  }
  public GridLayoutExample() {
    guiFrame = new JFrame();

    // make sure the program exits when the frame closes
    guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    guiFrame.setTitle("FlowLayout Example");
    guiFrame.setSize(300, 300);

    // This will center the JFrame in the middle of the screen
    guiFrame.setLocationRelativeTo(null);

    numberPressed = new JTextField();
    numberPressed.setHorizontalAlignment(JTextField.RIGHT);

    guiFrame.add(numberPressed, BorderLayout.NORTH);

    JPanel optionPanel = new JPanel();
    Border outline = BorderFactory.createLineBorder(Color.black);
    optionPanel.setBorder(outline);

    // Use a BoxLayout to position of the option components
    // in the optionPanel in a column
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));

    JButton changeLayout = new JButton("Change Layout");
    changeLayout.setActionCommand("Change Layout");
    changeLayout.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            // When the "Change Layout" button is clicked
            // the GridLayout of the buttonPanel is changed
            // based on the grid size and spacing values chosen
            GridLayout grid = new GridLayout(3, 4);
            if (rowcol.getSelectedItem().equals("2,5")) {
              grid.setRows(2);
              grid.setColumns(5);
            } else if (rowcol.getSelectedItem().equals("3,4")) {
              grid.setRows(3);
              grid.setColumns(4);
            } else {
              grid.setRows(4);
              grid.setColumns(3);
            }

            grid.setHgap((Integer) hGap.getSelectedItem());
            grid.setVgap((Integer) vGap.getSelectedItem());
            buttonPanel.setLayout(grid);
            buttonPanel.revalidate();
          }
        });

    Integer[] options = {0, 5, 10, 15};
    hGap = new JComboBox(options);
    hGap.setSelectedIndex(0);
    vGap = new JComboBox(options);
    vGap.setSelectedIndex(0);

    String[] rowscols = {"2,5", "3,4", "4,3"};
    rowcol = new JComboBox(rowscols);
    rowcol.setSelectedIndex(1);

    // Use a dimension object to limit the size of
    // the combo boxes
    Dimension comboSize = new Dimension(100, 100);
    hGap.setMaximumSize(comboSize);
    vGap.setMaximumSize(comboSize);
    rowcol.setMaximumSize(comboSize);

    // Use the setAlignmentX method to push the components
    // to the left edge of the optionPanel
    hGap.setAlignmentX(Component.LEFT_ALIGNMENT);
    vGap.setAlignmentX(Component.LEFT_ALIGNMENT);
    rowcol.setAlignmentX(Component.LEFT_ALIGNMENT);

    JLabel horizontalGap = new JLabel("Horizontal Gap:");
    JLabel verticalGap = new JLabel("Vertical Gap:");
    JLabel gridSize = new JLabel("Grid Size:");

    optionPanel.add(gridSize);
    optionPanel.add(rowcol);
    optionPanel.add(horizontalGap);
    optionPanel.add(hGap);
    optionPanel.add(verticalGap);
    optionPanel.add(vGap);
    optionPanel.add(changeLayout);
    guiFrame.add(optionPanel, BorderLayout.WEST);

    buttonPanel = new JPanel();

    // Make a Grid that has three rows and four columns
    buttonPanel.setLayout(new GridLayout(3, 4));

    guiFrame.add(buttonPanel, BorderLayout.CENTER);

    // Add the number buttons
    for (int i = 1; i < 11; i++) {
      addButton(buttonPanel, String.valueOf(i));
    }

    guiFrame.setVisible(true);
  }
Exemple #8
0
  public DownloadPictures(ArrayList<CardDownloadData> cards) {
    this.cards = cards;

    bar = new JProgressBar(this);

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

    p0.add(Box.createVerticalStrut(5));
    jLabel1 = new JLabel();
    jLabel1.setText("Please select server:");

    jLabel1.setAlignmentX(Component.LEFT_ALIGNMENT);

    p0.add(jLabel1);
    p0.add(Box.createVerticalStrut(5));
    ComboBoxModel jComboBox1Model =
        new DefaultComboBoxModel(
            new String[] {
              "magiccards.info",
              "wizards.com",
              "mythicspoiler.com",
              "tokens.mtg.onl", // "mtgimage.com (HQ)",
              // "mtgathering.ru HQ",
              // "mtgathering.ru MQ",
              // "mtgathering.ru LQ",
            });
    jComboBox1 = new JComboBox();

    cardImageSource = MagicCardsImageSource.getInstance();

    jComboBox1.setModel(jComboBox1Model);
    jComboBox1.setAlignmentX(Component.LEFT_ALIGNMENT);
    jComboBox1.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            switch (cb.getSelectedIndex()) {
              case 0:
                cardImageSource = MagicCardsImageSource.getInstance();
                break;
              case 1:
                cardImageSource = WizardCardsImageSource.getInstance();
                break;
              case 2:
                cardImageSource = MythicspoilerComSource.getInstance();
                break;
              case 3:
                cardImageSource = TokensMtgImageSource.getInstance();
                break;
            }
            int count = DownloadPictures.this.cards.size();
            float mb = (count * cardImageSource.getAverageSize()) / 1024;
            bar.setString(
                String.format(
                    cardIndex == count
                        ? "%d of %d cards finished! Please close!"
                        : "%d of %d cards finished! Please wait! [%.1f Mb]",
                    0,
                    count,
                    mb));
          }
        });
    p0.add(jComboBox1);
    p0.add(Box.createVerticalStrut(5));

    // Start
    startDownloadButton = new JButton("Start download");
    startDownloadButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            new Thread(DownloadPictures.this).start();
            startDownloadButton.setEnabled(false);
            checkBox.setEnabled(false);
          }
        });
    p0.add(Box.createVerticalStrut(5));

    // Progress
    p0.add(bar);
    bar.setStringPainted(true);
    int count = cards.size();
    float mb = (count * cardImageSource.getAverageSize()) / 1024;
    bar.setString(
        String.format(
            cardIndex == cards.size()
                ? "%d of %d cards finished! Please close!"
                : "%d of %d cards finished! Please wait! [%.1f Mb]",
            0,
            cards.size(),
            mb));
    Dimension d = bar.getPreferredSize();
    d.width = 300;
    bar.setPreferredSize(d);

    p0.add(Box.createVerticalStrut(5));
    checkBox = new JCheckBox("Download images for Standard (Type2) only");
    p0.add(checkBox);
    p0.add(Box.createVerticalStrut(5));

    checkBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            ArrayList<CardDownloadData> cardsToDownload = DownloadPictures.this.cards;
            if (checkBox.isSelected()) {
              DownloadPictures.this.type2cards = new ArrayList<>();
              for (CardDownloadData data : DownloadPictures.this.cards) {
                if (data.isType2() || data.isToken()) {
                  DownloadPictures.this.type2cards.add(data);
                }
              }
              cardsToDownload = DownloadPictures.this.type2cards;
            }
            int count = cardsToDownload.size();
            float mb = (count * cardImageSource.getAverageSize()) / 1024;
            bar.setString(
                String.format(
                    cardIndex == count
                        ? "%d of %d cards finished! Please close!"
                        : "%d of %d cards finished! Please wait! [%.1f Mb]",
                    0,
                    count,
                    mb));
          }
        });

    // JOptionPane
    Object[] options = {startDownloadButton, closeButton = new JButton("Cancel")};
    dlg =
        new JOptionPane(
            p0, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, options[1]);
  }
 /**
  * Constructor to setup GUI components and event handling; Pre: name, author and theme should not
  * be null, avg and pop should not be 0; Post: the user will successfully rate the book.
  *
  * @param bookName is the name of the book.
  * @param author is the author of the book.
  * @param genre is the genre of the book.
  * @param avg is the average score of the book.
  * @param pop is the population of people that have rated the book.
  */
 public GUIBookRating(String bookName, String author, String genre, int avg, int pop) {
   frame = new JFrame("Book Rating");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   contentPane = new JPanel();
   contentPane.setLayout(
       new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); // To use BoxLayout to keep items in order
   contentPane.setBorder(
       BorderFactory.createEmptyBorder(10, 10, 10, 10)); // To create an empty border around items
   label = new JLabel("Please give rank to the book " + bookName + ":");
   label.setFont(f); // To keep the font of texts on items the same
   label.setAlignmentX(
       JLabel.CENTER_ALIGNMENT); // To line the items up at the centre of the window
   label.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   submit = new JButton("Submit");
   submit.setFont(f);
   submit.setAlignmentX(JLabel.CENTER_ALIGNMENT);
   submit.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   rankStop = new JButton("Not Now");
   rankStop.setFont(f);
   rankStop.setAlignmentX(JLabel.CENTER_ALIGNMENT);
   rankStop.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   String[] list = {
     "1 Awful >_<", "2 Bad T_T", "3 So So -_-", "4 Good ^_^", "5 Perfect ^3^"
   }; // To create a list for user to choose rate from 1 to 5
   ratingList = new JComboBox(list);
   ratingList.setAlignmentX(JComboBox.CENTER_ALIGNMENT);
   ratingList.setSelectedIndex(0); // Set the original rate to be 1
   submit.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           String rankGet = (String) ratingList.getSelectedItem();
           /*To transfer the rate user chosen in the combobox to the number of rankings in the database*/
           if (rankGet.equalsIgnoreCase("1 Awful >_<")) {
             engine.rankGive(bookName, 1);
             GUILogOut out =
                 new GUILogOut(
                     String.valueOf(1), String.valueOf(avg), engine.customerBasedRec(bookName));
           } else if (rankGet.equalsIgnoreCase("2 Bad T_T")) {
             engine.rankGive(bookName, 2);
             GUILogOut out =
                 new GUILogOut(
                     String.valueOf(2), String.valueOf(avg), engine.customerBasedRec(bookName));
           } else if (rankGet.equalsIgnoreCase("3 So So -_-")) {
             engine.rankGive(bookName, 3);
             GUILogOut out =
                 new GUILogOut(
                     String.valueOf(3), String.valueOf(avg), engine.customerBasedRec(bookName));
           } else if (rankGet.equalsIgnoreCase("4 Good ^_^")) {
             engine.rankGive(bookName, 4);
             GUILogOut out =
                 new GUILogOut(
                     String.valueOf(4), String.valueOf(avg), engine.bookBasedRec(bookName));
           } else {
             engine.rankGive(bookName, 5);
             GUILogOut out =
                 new GUILogOut(
                     String.valueOf(5), String.valueOf(avg), engine.bookBasedRec(bookName));
           }
           frame.setVisible(false); // Close the window after going to the next step
         }
       });
   rankStop.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           GUIBookInfo info =
               new GUIBookInfo(
                   bookName,
                   author,
                   genre,
                   avg,
                   pop,
                   custrating); // To review the information of the book if the user do not want to
                                // rate the book
           frame.setVisible(false);
         }
       });
   contentPane.add(label);
   contentPane.add(ratingList);
   contentPane.add(submit);
   contentPane.add(rankStop);
   frame.setContentPane(contentPane);
   frame.pack();
   frame.setVisible(true); // Open the pop-up window
   frame.setLocationRelativeTo(
       null); // Set the location of the pop-up window at the centre of the window of computer
 }
  @Override
  public void actionPerformed(ActionEvent e) {

    currentOnto = owlManager.getActiveOntology();
    currentModel = modelManager.getActiveOBDAModel();

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    JLabel dsource = new JLabel("Choose a datasource to bootstrap: ");
    dsource.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(dsource);
    List<String> options = new ArrayList<String>();
    for (OBDADataSource source : currentModel.getSources())
      options.add(source.getSourceID().toString());
    JComboBox combo = new JComboBox(options.toArray());
    combo.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(combo);
    Dimension minsize = new Dimension(10, 10);
    panel.add(new Box.Filler(minsize, minsize, minsize));
    JLabel ouri =
        new JLabel("Base URI - the prefix to be used for all generated classes and properties: ");
    ouri.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(ouri);
    JTextField base_uri = new JTextField();
    base_uri.setText(currentModel.getPrefixManager().getDefaultPrefix().replace("#", "/"));
    base_uri.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(base_uri);
    int res =
        JOptionPane.showOptionDialog(
            workspace,
            panel,
            "Bootstrapping",
            JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            null,
            null);
    if (res == JOptionPane.OK_OPTION) {
      int index = combo.getSelectedIndex();
      currentSource = currentModel.getSources().get(index);
      if (currentSource != null) {
        this.baseUri = base_uri.getText().trim();
        if (baseUri.contains("#")) {
          JOptionPane.showMessageDialog(workspace, "Base Uri cannot contain the character '#'");
          throw new RuntimeException("Base URI " + baseUri + " contains '#' character!");
        } else {
          Thread th =
              new Thread(
                  new Runnable() {
                    @Override
                    public void run() {
                      try {
                        OBDAProgessMonitor monitor =
                            new OBDAProgessMonitor("Bootstrapping ontology and mappings...");
                        BootstrapperThread t = new BootstrapperThread();
                        monitor.addProgressListener(t);
                        monitor.start();
                        t.run(baseUri, currentOnto, currentModel, currentSource);
                        currentModel.fireSourceParametersUpdated();
                        monitor.stop();
                        JOptionPane.showMessageDialog(
                            workspace,
                            "Task is completed.",
                            "Done",
                            JOptionPane.INFORMATION_MESSAGE);
                      } catch (Exception e) {
                        log.error(e.getMessage(), e);
                        JOptionPane.showMessageDialog(
                            null, "Error occured during bootstrapping data source.");
                      }
                    }
                  });
          th.start();
        }
      }
    }
  }