Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add swiss method in team pairing screen
  • Loading branch information
Bojo38 committed Sep 4, 2018
1 parent 4f1fbc6 commit 1746410
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/tourma/JdgChangePairing.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,22 @@ private void jbtOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:e
if (m instanceof TeamMatch) {
Team t1 = (Team) mPlayersTmp.get(2 * i);
Team t2 = (Team) mPlayersTmp.get(2 * i + 1);

ArrayList<Coach> list1=new ArrayList<>();
ArrayList<Coach> list2=new ArrayList<>();

if ((m.getCompetitor1() != t1)
|| (m.getCompetitor2() != t2)) {
// Remove matchs from coachs
for (int j = 0; j < ((TeamMatch) m).getMatchCount(); j++) {
CoachMatch cm = ((TeamMatch) m).getMatch(j);
for (int k = 0; k < ((IContainCoachs) m.getCompetitor1()).getCoachsCount(); k++) {
Coach c = ((IContainCoachs) m.getCompetitor1()).getCoach(k);
Coach c = ((IContainCoachs) m.getCompetitor1()).getCoach(k);
c.removeMatch(cm);
}

for (int k = 0; k < ((IContainCoachs) m.getCompetitor2()).getCoachsCount(); k++) {
Coach c = ((IContainCoachs) m.getCompetitor2()).getCoach(k);
Coach c = ((IContainCoachs) m.getCompetitor2()).getCoach(k);
c.removeMatch(cm);
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/tourma/JdgPairing.form
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-19,0,0,1,-112"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-19,0,0,2,13"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
Expand Down Expand Up @@ -164,6 +164,19 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtRemoveActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jbtSwiss">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/tourma/images/swiss.png"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="tourma/languages/language.properties" key="Swiss" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtSwissActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jbtRandom">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
Expand Down
57 changes: 57 additions & 0 deletions src/tourma/JdgPairing.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import tourma.data.Round;
import tourma.data.Team;
import tourma.data.TeamMatch;
import tourma.data.Tournament;
import tourma.languages.Translate;
import tourma.tableModel.MjtMatches;
import tourma.tableModel.MjtRankingIndiv;
import tourma.utility.StringConstants;

/**
Expand Down Expand Up @@ -126,6 +128,7 @@ private void initComponents() {
jPanel4 = new javax.swing.JPanel();
jbtAdd = new javax.swing.JButton();
jbtRemove = new javax.swing.JButton();
jbtSwiss = new javax.swing.JButton();
jbtRandom = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
Expand Down Expand Up @@ -187,6 +190,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
});
jPanel4.add(jbtRemove);

jbtSwiss.setIcon(new javax.swing.ImageIcon(getClass().getResource("/tourma/images/swiss.png"))); // NOI18N
jbtSwiss.setText(bundle.getString("Swiss")); // NOI18N
jbtSwiss.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtSwissActionPerformed(evt);
}
});
jPanel4.add(jbtSwiss);

jbtRandom.setIcon(new javax.swing.ImageIcon(getClass().getResource("/tourma/images/Dice.png"))); // NOI18N
jbtRandom.setText(bundle.getString("Random")); // NOI18N
jbtRandom.addActionListener(new java.awt.event.ActionListener() {
Expand Down Expand Up @@ -258,6 +270,50 @@ private void jbtRandomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR
update();
}//GEN-LAST:event_jbtRandomActionPerformed

private void jbtSwissActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtSwissActionPerformed

// Sort items by ranking
ArrayList<Coach> list1=new ArrayList<>();
ArrayList<Coach> list2=new ArrayList<>();
for (String item:mItems1)
{
list1.add(mCoachs.get(item));
}
for (String item:mItems2)
{
list2.add(mCoachs.get(item));
}
MjtRankingIndiv indivR1=new MjtRankingIndiv(Tournament.getTournament().getRoundIndex(mRound), list1, true, false);
MjtRankingIndiv indivR2=new MjtRankingIndiv(Tournament.getTournament().getRoundIndex(mRound), list2, true, false);

list1=new ArrayList<>();
list2=new ArrayList<>();

for (int i=0; i<indivR1.getRowCount(); i++)
{
list1.add((Coach)indivR1.getSortedObject(i).getObject());
}

for (int i=0; i<indivR2.getRowCount(); i++)
{
list2.add((Coach)indivR2.getSortedObject(i).getObject());
}

while ((list1.size() > 0) && (list2.size() > 0)) {

final CoachMatch m = new CoachMatch(mRound);
m.setCompetitor1(list1.get(0));
m.setCompetitor2(list2.get(0));
mMatchs.add(m);
list1.remove(0);
list2.remove(0);
}
mItems1.clear();
mItems2.clear();

update();
}//GEN-LAST:event_jbtSwissActionPerformed

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel2;
Expand All @@ -268,6 +324,7 @@ private void jbtRandomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR
private javax.swing.JButton jbtOK;
private javax.swing.JButton jbtRandom;
private javax.swing.JButton jbtRemove;
private javax.swing.JButton jbtSwiss;
private javax.swing.JComboBox jcbTeam1;
private javax.swing.JComboBox jcbTeam2;
private javax.swing.JTable jtbMatches;
Expand Down
2 changes: 1 addition & 1 deletion src/tourma/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,7 @@ private void jmiChangePairingActionPerformed(java.awt.event.ActionEvent evt) {//

if (jpnContent instanceof JPNRound) {
JPNRound jpnr = (JPNRound) jpnContent;
Round round = jpnr.getRound();
Round round = jpnr.getRound();
final JdgChangePairing jdg = new JdgChangePairing(MainFrame.getMainFrame(), true, round);
jdg.setVisible(true);
jpnr.update();
Expand Down
Binary file added src/tourma/images/swiss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/tourma/languages/language.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1103,4 +1103,5 @@ PapaSkullbones=Papa Skullbones, Chaos chaman
GalandrlSilverwater=Galandril Silverwater, Elfic cheerleader
KrotShockwhisker=Krot Shockwhisker, skaven engineer
PrintAll=Print All
PDFExportAll= Export all as PDF
PDFExportAll= Export all as PDF
Swiss=Swiss

0 comments on commit 1746410

Please sign in to comment.