예제 #1
0
  /**
   * Build a list of installed plugins.
   *
   * @return a list of plugin names and version numbers.
   */
  public static EventList<NameAndVersion> findInstalledPlugins() {
    EventList<NameAndVersion> plugins = new BasicEventList<NameAndVersion>();
    if (!PluginCore.userPluginDir.exists()) return plugins;
    String[] files =
        PluginCore.userPluginDir.list(
            new FilenameFilter() {
              public boolean accept(File dir, String name) {
                return name.endsWith(".jar");
              }
            });

    HashMap<String, PluginDescriptor> urls = new HashMap<String, PluginDescriptor>();
    Collection<PluginDescriptor> descriptors =
        PluginCore.getManager().getRegistry().getPluginDescriptors();
    for (PluginDescriptor desc : descriptors) {
      if ((desc.getPluginClassName() == null)
          || !desc.getPluginClassName().equals("net.sf.jabref.plugin.core.JabRefPlugin")) {
        urls.put(desc.getId(), desc);
      }
    }

    for (String file1 : files) {
      File file = new File(PluginCore.userPluginDir, file1);
      String[] nav = getNameAndVersion(file);
      if (nav != null) {
        VersionNumber vn = nav[1] != null ? new VersionNumber(nav[1]) : null;
        NameAndVersion nameAndVersion = new NameAndVersion(nav[0], vn, true, file);
        for (Iterator<String> it = urls.keySet().iterator(); it.hasNext(); ) {
          String loc = it.next();
          if (loc.contains(nav[0])) {
            PluginDescriptor desc = urls.get(loc);
            // System.out.println("Accounted for: "+desc.getId()+" "+desc.getVersion().toString());
            if (!PluginCore.getManager().isPluginEnabled(urls.get(loc)))
              nameAndVersion.setStatus(BAD);
            else nameAndVersion.setStatus(LOADED);
            it.remove();
          }
        }
        plugins.add(nameAndVersion);
      }
    }

    for (String url : urls.keySet()) {
      PluginDescriptor desc = urls.get(url);
      File location = new File(desc.getLocation().getFile());
      if (location.getPath().contains(PluginCore.userPluginDir.getPath()))
        continue; // This must be a loaded user dir plugin that's been deleted.
      // System.out.println("File: "+desc.getLocation().getFile());
      NameAndVersion nameAndVersion =
          new NameAndVersion(
              desc.getId(), new VersionNumber(desc.getVersion().toString()), false, location);
      if (!PluginCore.getManager().isPluginEnabled(urls.get(url))) nameAndVersion.setStatus(BAD);
      else nameAndVersion.setStatus(LOADED);
      plugins.add(nameAndVersion);
    }
    return plugins;
  }
예제 #2
0
 // Sorts labels from the mapping.  We may get rid of this later perhaps.
 String[] revisedLabels(HashMap map) {
   // Sort labels
   String[] labels = new String[map.size()];
   labels = (String[]) (map.keySet().toArray(labels));
   Arrays.sort(labels);
   return labels;
 }
예제 #3
0
  public void save() {
    for (String key : fields.keySet()) {
      JComponent comp = fields.get(key);

      if (comp instanceof JTextField) {
        JTextField c = (JTextField) comp;

        if (c.getText().trim().equals("")) {
          sketch.configFile.unset(key);
        } else {
          sketch.configFile.set(key, c.getText());
        }
      } else if (comp instanceof JTextArea) {
        JTextArea c = (JTextArea) comp;

        if (c.getText().trim().equals("")) {
          sketch.configFile.unset(key);
        } else {
          sketch.configFile.set(key, c.getText());
        }
      }
    }

    sketch.saveConfig();
  }
예제 #4
0
    /** Displays the labels and the values for the panel. */
    protected void displayPnlFields(HashMap hmPnl) {
      if (hmPnl == null || hmPnl.isEmpty()) return;

      Iterator keySetItr = hmPnl.keySet().iterator();
      String strLabel = "";
      String strValue = "";

      // if the file is empty, then create an empty set of textfields.
      if (hmPnl == null || hmPnl.isEmpty()) {
        displayNewTxf("", "");
        return;
      }

      Container container = getParent();
      if (container != null) container.setVisible(false);
      try {
        // Get each set of label and value, and display them.
        while (keySetItr.hasNext()) {
          strLabel = (String) keySetItr.next();
          strValue = (String) hmPnl.get(strLabel);

          displayNewTxf(strLabel, strValue);
        }

        if (container != null) container.setVisible(true);
        revalidate();
        repaint();
      } catch (Exception e) {
        Messages.writeStackTrace(e);
        // e.printStackTrace();
        Messages.postDebug(e.toString());
      }
    }
 public XYSeries getXYSeries(String rowname, long factor) {
   XYSeries mydataset = new XYSeries(rowname);
   for (Integer key : ysum.keySet()) {
     Double value = ysum.get(key) / (double) count.get(key);
     Double point = (double) xsum.get(key) / (double) count.get(key);
     mydataset.add(point / factor, value);
   }
   return mydataset;
 }
 public YIntervalSeries getYIntervalSeries(String rowname, long factor) {
   YIntervalSeries mydataset = new YIntervalSeries(rowname);
   double sdcount = 0;
   double total = 0;
   Vector<Double> totalvalues = new Vector<Double>();
   double avgtotal = 0;
   double minus = 0;
   double plus = 0;
   double zero = 0;
   for (Integer key : ysum.keySet()) {
     Double value = ysum.get(key) / (double) count.get(key);
     Double point = (double) xsum.get(key) / (double) count.get(key);
     Vector<Double> listofvalues = values.get(key);
     double sumofdiff = 0.0;
     for (Double onevalue : listofvalues) {
       sumofdiff += Math.pow(onevalue - value, 2);
       sdcount++;
       total += Math.pow(onevalue, 2);
       avgtotal += onevalue;
       totalvalues.add(onevalue);
       if (onevalue == 1) {
         plus++;
       }
       ;
       if (onevalue == -1) {
         minus++;
       }
       ;
       if (onevalue == 0) {
         zero++;
       }
       ;
     }
     double sd = Math.sqrt(sumofdiff / count.get(key));
     // mydataset.add(point/factor, value,value+sd,value-sd);
     // mydataset.add(point/factor, value,value,value);
     mydataset.add(
         point / factor,
         value,
         value + 1.96 * (sd / Math.sqrt(count.get(key))),
         value - 1.96 * (sd / Math.sqrt(count.get(key))));
   }
   double sdtotal = 0;
   double avgsd = total / sdcount;
   double test = 0;
   for (Double onevalue : totalvalues) {
     sdtotal += Math.pow(Math.pow(onevalue, 2) - (total / sdcount), 2);
     test += onevalue;
   }
   // System.out.println(rowname+" mean square: "+avgsd+"
   // +/-95%:"+1.96*Math.sqrt(sdtotal/sdcount)/Math.sqrt(sdcount));
   // System.out.println("total -1:"+minus+" total +1:"+plus+" zero: "+zero
   // +" total:"+sdcount);
   return mydataset;
 }
예제 #7
0
 public void setShowNames(boolean b) {
   if (shownames == b) return;
   shownames = b;
   Iterator it = buttons.keySet().iterator();
   while (it.hasNext()) {
     String command = (String) it.next();
     JButton button = (JButton) buttons.get(command);
     button.setText((shownames) ? command : "");
     button.setToolTipText((!shownames) ? command : "");
   }
   setButtonsSize();
 }
예제 #8
0
  private void initMatches() {
    matchesKeys.put(STRING_LITERAL, "");
    matchesKeys.put("Any number", "[0-9]+");
    matchesKeys.put("Anything", ".*");
    matchesKeys.put("Start", "^");
    matchesKeys.put("End", "$");
    matchesKeys.put("Single path component", "[^/]+");

    for (Iterator it = matchesKeys.keySet().iterator(); it.hasNext(); ) {
      matchComboBox.addItem(it.next());
    }
  }
  private void applyChanges() {
    boolean changedFieldSet = false; // Watch if we need to rebuild entry editors

    // First remove the mappings for fields that have been deleted.
    // If these were re-added, they will be added below, so it doesn't
    // cause any harm to remove them here.
    for (Iterator<String> i = removedFields.iterator(); i.hasNext(); ) {
      String fieldName = i.next();
      metaData.remove(Globals.SELECTOR_META_PREFIX + fieldName);
      changedFieldSet = true;
    }

    // Cycle through all fields that we have created listmodels for:
    loop:
    for (Iterator<String> i = wordListModels.keySet().iterator(); i.hasNext(); ) {
      // For each field name, store the values:
      String fieldName = i.next();
      if ((fieldName == null) || FIELD_FIRST_LINE.equals(fieldName)) continue loop;
      DefaultListModel lm = wordListModels.get(fieldName);
      int start = 0;
      // Avoid storing the <new word> marker if it is there:
      if (lm.size() > 0)
        while ((start < lm.size()) && (lm.get(start)).equals(WORD_FIRSTLINE_TEXT)) start++;
      Vector<String> data = metaData.getData(Globals.SELECTOR_META_PREFIX + fieldName);
      boolean newField = false;
      if (data == null) {
        newField = true;
        data = new Vector<String>();
        changedFieldSet = true;

      } else data.clear();
      for (int wrd = start; wrd < lm.size(); wrd++) {
        String word = (String) lm.get(wrd);
        data.add(word);
      }
      if (newField) metaData.putData(Globals.SELECTOR_META_PREFIX + fieldName, data);
    }

    // System.out.println("TODO: remove metadata for removed selector field.");
    panel.markNonUndoableBaseChanged();

    // Update all selectors in the current BasePanel.
    if (changedFieldSet) {
      panel.rebuildAllEntryEditors();
    } else {
      panel.updateAllContentSelectors();
    }
    panel.addContentSelectorValuesToAutoCompleters();
  }
예제 #10
0
 public Object[] getElementsByName(
     final String id, final boolean checkBoxState, final String pattern) {
   final HashMap<AnAction, String> map = new HashMap<AnAction, String>();
   final ActionGroup mainMenu =
       (ActionGroup) myActionManager.getActionOrStub(IdeActions.GROUP_MAIN_MENU);
   collectActions(id, map, mainMenu, mainMenu.getTemplatePresentation().getText());
   if (checkBoxState) {
     final Set<String> ids = ((ActionManagerImpl) myActionManager).getActionIds();
     for (AnAction action : map.keySet()) { // do not add already included actions
       ids.remove(getActionId(action));
     }
     if (ids.contains(id)) {
       final AnAction anAction = myActionManager.getAction(id);
       if (!(anAction instanceof ActionGroup)) {
         map.put(anAction, null);
       }
     }
   }
   return map.entrySet().toArray(new Map.Entry[map.size()]);
 }
예제 #11
0
  private void cmbTagsActionPerformed(ActionEvent e) {

    if (!editmode) return;

    if (txtTags.getText().isEmpty()) return;
    if (txtTags.getText().length() > 100) return;

    final String enteredText = SYSTools.tidy(txtTags.getText()).toLowerCase();

    if (!addNewTags && !mapAllTags.containsKey(enteredText)) return;

    if (!mapAllTags.containsKey(enteredText)) {
      Commontags myNewCommontag = new Commontags(SYSTools.tidy(enteredText));
      mapAllTags.put(enteredText, myNewCommontag);
      ac.uninstallListeners();
      ac = new AutoCompletion(txtTags, mapAllTags.keySet().toArray(new String[] {}));
      ac.setStrict(false);
      ac.setStrictCompletion(false);
    }

    if (!listSelectedTags.contains(mapAllTags.get(enteredText))) {
      listSelectedTags.add(mapAllTags.get(enteredText));

      SwingUtilities.invokeLater(
          () -> {
            if (listSelectedTags.size() % MAXLINE == 0) {
              add(createButton(mapAllTags.get(enteredText)), RiverLayout.LINE_BREAK);
            } else {
              add(createButton(mapAllTags.get(enteredText)), RiverLayout.LEFT);
            }

            txtTags.setText("");
            revalidate();
            repaint();
            notifyListeners(mapAllTags.get(enteredText));
          });
    }
  }
예제 #12
0
  /**
   * Helper function to display a Swing window with a tree representation of the specified list of
   * joins. See {@link #orderJoins}, which may want to call this when the analyze flag is true.
   *
   * @param js the join plan to visualize
   * @param pc the PlanCache accumulated whild building the optimal plan
   * @param stats table statistics for base tables
   * @param selectivities the selectivities of the filters over each of the tables (where tables are
   *     indentified by their alias or name if no alias is given)
   */
  private void printJoins(
      Vector<LogicalJoinNode> js,
      PlanCache pc,
      HashMap<String, TableStats> stats,
      HashMap<String, Double> selectivities) {

    JFrame f = new JFrame("Join Plan for " + p.getQuery());

    // Set the default close operation for the window,
    // or else the program won't exit when clicking close button
    f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    f.setVisible(true);

    f.setSize(300, 500);

    HashMap<String, DefaultMutableTreeNode> m = new HashMap<String, DefaultMutableTreeNode>();

    // int numTabs = 0;

    // int k;
    DefaultMutableTreeNode root = null, treetop = null;
    HashSet<LogicalJoinNode> pathSoFar = new HashSet<LogicalJoinNode>();
    boolean neither;

    System.out.println(js);
    for (LogicalJoinNode j : js) {
      pathSoFar.add(j);
      System.out.println("PATH SO FAR = " + pathSoFar);

      String table1Name = Database.getCatalog().getTableName(this.p.getTableId(j.t1Alias));
      String table2Name = Database.getCatalog().getTableName(this.p.getTableId(j.t2Alias));

      // Double c = pc.getCost(pathSoFar);
      neither = true;

      root =
          new DefaultMutableTreeNode(
              "Join "
                  + j
                  + " (Cost ="
                  + pc.getCost(pathSoFar)
                  + ", card = "
                  + pc.getCard(pathSoFar)
                  + ")");
      DefaultMutableTreeNode n = m.get(j.t1Alias);
      if (n == null) { // never seen this table before
        n =
            new DefaultMutableTreeNode(
                j.t1Alias
                    + " (Cost = "
                    + stats.get(table1Name).estimateScanCost()
                    + ", card = "
                    + stats.get(table1Name).estimateTableCardinality(selectivities.get(j.t1Alias))
                    + ")");
        root.add(n);
      } else {
        // make left child root n
        root.add(n);
        neither = false;
      }
      m.put(j.t1Alias, root);

      n = m.get(j.t2Alias);
      if (n == null) { // never seen this table before

        n =
            new DefaultMutableTreeNode(
                j.t2Alias == null
                    ? "Subplan"
                    : (j.t2Alias
                        + " (Cost = "
                        + stats.get(table2Name).estimateScanCost()
                        + ", card = "
                        + stats
                            .get(table2Name)
                            .estimateTableCardinality(selectivities.get(j.t2Alias))
                        + ")"));
        root.add(n);
      } else {
        // make right child root n
        root.add(n);
        neither = false;
      }
      m.put(j.t2Alias, root);

      // unless this table doesn't join with other tables,
      // all tables are accessed from root
      if (!neither) {
        for (String key : m.keySet()) {
          m.put(key, root);
        }
      }

      treetop = root;
    }

    JTree tree = new JTree(treetop);
    JScrollPane treeView = new JScrollPane(tree);

    tree.setShowsRootHandles(true);

    // Set the icon for leaf nodes.
    ImageIcon leafIcon = new ImageIcon("join.jpg");
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    renderer.setOpenIcon(leafIcon);
    renderer.setClosedIcon(leafIcon);

    tree.setCellRenderer(renderer);

    f.setSize(300, 500);

    f.add(treeView);
    for (int i = 0; i < tree.getRowCount(); i++) {
      tree.expandRow(i);
    }

    if (js.size() == 0) {
      f.add(new JLabel("No joins in plan."));
    }

    f.pack();
  }
예제 #13
0
  private void initPanel() {

    mapButtons = new HashMap<>();

    for (Commontags commontags : CommontagsTools.getAll()) {
      mapAllTags.put(commontags.getText(), commontags);
    }

    int tagnum = 1;
    for (Commontags selectedTags : listSelectedTags) {
      if (tagnum % MAXLINE == 0) {
        add(createButton(selectedTags), RiverLayout.LINE_BREAK);
      } else {
        add(createButton(selectedTags), RiverLayout.LEFT);
      }
      tagnum++;
    }

    if (editmode) {
      txtTags = new JTextField(10);

      SelectAllUtils.install(txtTags);
      ac = new AutoCompletion(txtTags, mapAllTags.keySet().toArray(new String[] {}));

      ac.setStrict(false);
      ac.setStrictCompletion(false);
      txtTags.addActionListener(e -> cmbTagsActionPerformed(e));

      txtTags.addFocusListener(
          new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
              cmbTagsActionPerformed(null);
            }
          });

      txtTags.addKeyListener(
          new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent e) {
              char c = e.getKeyChar();
              if (Character.isAlphabetic(c) || Character.isDigit(c)) {
                super.keyTyped(e);
              } else {
                e.consume();
              }
            }
          });

      add(txtTags);

      btnPickTags =
          GUITools.getTinyButton("opde.tags.pnlcommontags.allTags", SYSConst.icon22checkbox);
      btnPickTags.setPressedIcon(SYSConst.icon22Pressed);
      btnPickTags.addActionListener(
          e -> {
            final JidePopup popup = new JidePopup();
            JPanel pnl = new JPanel(new BorderLayout());
            pnl.add(new JScrollPane(getClickableTagsPanel()), BorderLayout.CENTER);
            //                        JButton btnApply = new JButton(SYSConst.icon22apply);
            //                        pnl.add(btnApply, BorderLayout.SOUTH);
            //
            //                        btnApply.addActionListener(new ActionListener() {
            //                            @Override
            //                            public void actionPerformed(ActionEvent ae) {
            //                                popup.hidePopup();
            //                            }
            //                        });

            popup.setMovable(false);
            popup
                .getContentPane()
                .setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));
            popup.setOwner(btnPickTags);
            popup.removeExcludedComponent(btnPickTags);
            pnl.setPreferredSize(new Dimension(400, 200));
            popup.getContentPane().add(pnl);
            popup.setDefaultFocusComponent(pnl);

            popup.addPopupMenuListener(
                new PopupMenuListener() {
                  @Override
                  public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                    OPDE.debug("popupMenuWillBecomeVisible");
                  }

                  @Override
                  public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                    SwingUtilities.invokeLater(
                        () -> {
                          removeAll();

                          add(txtTags);
                          if (btnPickTags != null) {
                            add(btnPickTags);
                          }
                          int tagnum1 = 1;

                          for (JButton btn : mapButtons.values()) {
                            if (tagnum1 % MAXLINE == 0) {
                              add(btn, RiverLayout.LINE_BREAK);
                            } else {
                              add(btn, RiverLayout.LEFT);
                            }
                            tagnum1++;
                          }

                          revalidate();
                          repaint();
                        });
                  }

                  @Override
                  public void popupMenuCanceled(PopupMenuEvent e) {
                    OPDE.debug("popupMenuCanceled");
                  }
                });

            GUITools.showPopup(popup, SwingConstants.WEST);
          });

      add(btnPickTags);
    }
  }
 private void setComboboxModel(
     final JComboBox comboBox,
     final VirtualFile initialTargetDirectorySourceRoot,
     final VirtualFile oldSelection,
     final ProjectFileIndex fileIndex,
     final VirtualFile[] sourceRoots,
     final Project project,
     final boolean forceIncludeAll,
     final Pass<String> updateErrorMessage) {
   final LinkedHashSet<PsiDirectory> targetDirectories = new LinkedHashSet<PsiDirectory>();
   final HashMap<PsiDirectory, String> pathsToCreate = new HashMap<PsiDirectory, String>();
   MoveClassesOrPackagesUtil.buildDirectoryList(
       new PackageWrapper(PsiManager.getInstance(project), getTargetPackage()),
       sourceRoots,
       targetDirectories,
       pathsToCreate);
   if (!forceIncludeAll && targetDirectories.size() > pathsToCreate.size()) {
     targetDirectories.removeAll(pathsToCreate.keySet());
   }
   final ArrayList<DirectoryChooser.ItemWrapper> items =
       new ArrayList<DirectoryChooser.ItemWrapper>();
   DirectoryChooser.ItemWrapper initial = null;
   DirectoryChooser.ItemWrapper oldOne = null;
   for (PsiDirectory targetDirectory : targetDirectories) {
     DirectoryChooser.ItemWrapper itemWrapper =
         new DirectoryChooser.ItemWrapper(targetDirectory, pathsToCreate.get(targetDirectory));
     items.add(itemWrapper);
     final VirtualFile sourceRootForFile =
         fileIndex.getSourceRootForFile(targetDirectory.getVirtualFile());
     if (sourceRootForFile == initialTargetDirectorySourceRoot) {
       initial = itemWrapper;
     } else if (sourceRootForFile == oldSelection) {
       oldOne = itemWrapper;
     }
   }
   items.add(NULL_WRAPPER);
   final DirectoryChooser.ItemWrapper selection =
       chooseSelection(initialTargetDirectorySourceRoot, fileIndex, items, initial, oldOne);
   final ComboBoxModel model = comboBox.getModel();
   if (model instanceof CollectionComboBoxModel) {
     boolean sameModel = model.getSize() == items.size();
     if (sameModel) {
       for (int i = 0; i < items.size(); i++) {
         final DirectoryChooser.ItemWrapper oldItem =
             (DirectoryChooser.ItemWrapper) model.getElementAt(i);
         final DirectoryChooser.ItemWrapper itemWrapper = items.get(i);
         if (!areItemsEquivalent(oldItem, itemWrapper)) {
           sameModel = false;
           break;
         }
       }
     }
     if (sameModel) {
       if (areItemsEquivalent(
           (DirectoryChooser.ItemWrapper) comboBox.getSelectedItem(), selection)) {
         return;
       }
     }
   }
   updateErrorMessage(updateErrorMessage, fileIndex, selection);
   Collections.sort(
       items,
       new Comparator<DirectoryChooser.ItemWrapper>() {
         @Override
         public int compare(DirectoryChooser.ItemWrapper o1, DirectoryChooser.ItemWrapper o2) {
           if (o1 == NULL_WRAPPER) return -1;
           if (o2 == NULL_WRAPPER) return 1;
           return o1.getRelativeToProjectPath().compareToIgnoreCase(o2.getRelativeToProjectPath());
         }
       });
   comboBox.setModel(new CollectionComboBoxModel(items, selection));
 }
예제 #15
0
파일: Game.java 프로젝트: FransM22/GipfGame
  /**
   * This method finds the ordering of all the line segments that are removable from the current
   * board state in the current turn for each player.
   *
   * @param pieceMap
   * @param currentPlayerColor
   * @return An example output could be: {set: ["white", "segment from a to b"] ["white", "segment
   *     from b to c"] ["black", "segment from x to y"] ["black", "segment from z to a"; after that
   *     "white", "segment from a to b"] ["black", "segment from d to f"] }
   */
  private Set<List<Pair<PieceColor, Line.Segment>>> getRemovableLineOrderingsSetFromGipfBoard(
      Map<Position, Piece> pieceMap, PieceColor currentPlayerColor) {
    Set<List<Pair<PieceColor, Line.Segment>>> removableLineSetOrderingsFromGipfboard =
        new HashSet<>();
    PieceColor opponentColor = currentPlayerColor == WHITE ? BLACK : WHITE;

    Set<Line.Segment> removableLineSegmentsCurrentPlayer =
        getRemovableLineSegments(pieceMap, currentPlayerColor);

    // This loop checks for all line segments that can be removed by the current player.
    for (Line.Segment lineSegment : removableLineSegmentsCurrentPlayer) {
      // Create a copy of the piecemap where the removed segment is removed
      HashMap<Position, Piece> segmentRemovedPieceMap = new HashMap<>(pieceMap);
      segmentRemovedPieceMap
          .keySet()
          .removeAll(lineSegment.getOccupiedPositions(segmentRemovedPieceMap));

      List<Pair<PieceColor, Line.Segment>> removableLineSegmentOrdering =
          Collections.singletonList(new Pair<>(currentPlayerColor, lineSegment));

      // - I have to use removableLineSegmentList because the removableLineSegmentOrdering is
      // already in use.
      // - If the current player can remove at least 1 more segment, the board state that results
      // will be checked
      //   after that for more subsequent segments that can be removed
      Set<List<Pair<PieceColor, Line.Segment>>> removableLineSetOrderingsCurrentPlayer =
          getRemovableLineOrderingsSetFromGipfBoard(segmentRemovedPieceMap, currentPlayerColor);

      if (removableLineSetOrderingsCurrentPlayer.size() > 0) {
        for (List<Pair<PieceColor, Line.Segment>> removableLineSegmentList :
            removableLineSetOrderingsCurrentPlayer) {
          List<Pair<PieceColor, Line.Segment>> ordering =
              new ArrayList<>(removableLineSegmentOrdering);

          ordering.addAll(removableLineSegmentList);
          removableLineSetOrderingsFromGipfboard.add(ordering);
        }
      } else {
        removableLineSetOrderingsFromGipfboard.add(removableLineSegmentOrdering);
      }

      // Now check for the line segments removable by the opponent
      // Because if this code is ran, the current player can remove line segments. If this is the
      // case, the current player
      // must remove line segments before the opponent gets its turn.
      for (Line.Segment lineSegmenRemovableByOpponent :
          getRemovableLineSegments(segmentRemovedPieceMap, opponentColor)) {
        // See for the comments in the similar lines above
        HashMap<Position, Piece> opponentSegmentRemovedPieceMap =
            new HashMap<>(segmentRemovedPieceMap);
        opponentSegmentRemovedPieceMap
            .keySet()
            .removeAll(
                lineSegmenRemovableByOpponent.getOccupiedPositions(opponentSegmentRemovedPieceMap));

        List<Pair<PieceColor, Line.Segment>> opponentRemovableLineSegmentOrdering =
            Collections.singletonList(new Pair<>(opponentColor, lineSegmenRemovableByOpponent));

        Set<List<Pair<PieceColor, Line.Segment>>> removableLineSetOrderingsOpponent =
            getRemovableLineOrderingsSetFromGipfBoard(
                opponentSegmentRemovedPieceMap, opponentColor);

        if (removableLineSetOrderingsOpponent.size() > 0) {
          for (List<Pair<PieceColor, Line.Segment>> removableLineSegmentOpponentList :
              removableLineSetOrderingsOpponent) {
            List<Pair<PieceColor, Line.Segment>> ordering =
                new ArrayList<>(opponentRemovableLineSegmentOrdering);

            ordering.addAll(removableLineSegmentOpponentList);
            removableLineSetOrderingsFromGipfboard.add(ordering);
          }
        } else {
          removableLineSetOrderingsFromGipfboard.add(opponentRemovableLineSegmentOrdering);
        }
      }
    }
    if (removableLineSegmentsCurrentPlayer.size() == 0) {
      // The current player can't remove any line segments, so the opponent can try to remove line
      // segments
      for (Line.Segment lineSegment : getRemovableLineSegments(pieceMap, opponentColor)) {
        // See for the comments the similar lines above
        HashMap<Position, Piece> segmentRemovedPieceMap = new HashMap<>(pieceMap);
        segmentRemovedPieceMap
            .keySet()
            .removeAll(lineSegment.getOccupiedPositions(segmentRemovedPieceMap));

        List<Pair<PieceColor, Line.Segment>> removableLineSegmentOrdering =
            Collections.singletonList(new Pair<>(opponentColor, lineSegment));

        Set<List<Pair<PieceColor, Line.Segment>>> removableLineSetOrderingsOpponent =
            getRemovableLineOrderingsSetFromGipfBoard(segmentRemovedPieceMap, opponentColor);

        if (removableLineSetOrderingsOpponent.size() > 0) {
          for (List<Pair<PieceColor, Line.Segment>> removableLineSegmentList :
              removableLineSetOrderingsOpponent) {
            List<Pair<PieceColor, Line.Segment>> ordering =
                new ArrayList<>(removableLineSegmentOrdering);

            ordering.addAll(removableLineSegmentList);
            removableLineSetOrderingsFromGipfboard.add(ordering);
          }
        } else {
          removableLineSetOrderingsFromGipfboard.add(removableLineSegmentOrdering);
        }
      }
    }

    return removableLineSetOrderingsFromGipfboard;
  }