Example #1
0
 private void btn_Solve2ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btn_Solve2ActionPerformed
   if (nextMove > 0 && nextMove <= moveList.size()) {
     nextMove--;
     int move = moveList.get(nextMove);
     for (int j = 4; j > (move % 3) + 1; j--) {
       cube = model.DoMove(cube, TurnAxis.values()[(int) (move / 3)]);
     }
     updateC();
   }
 } // GEN-LAST:event_btn_Solve2ActionPerformed
Example #2
0
 private void btn_Solve1ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btn_Solve1ActionPerformed
   if (nextMove >= 0 && nextMove < moveList.size()) {
     int move = moveList.get(nextMove);
     for (int j = 0; j < (move % 3) + 1; j++) {
       cube = model.DoMove(cube, TurnAxis.values()[(int) (move / 3)]);
     }
     nextMove++;
     updateC();
   }
 } // GEN-LAST:event_btn_Solve1ActionPerformed
Example #3
0
 private void jButton7ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton7ActionPerformed
   cube = model.DoMove(cube, TurnAxis.B);
   updateC();
 } // GEN-LAST:event_jButton7ActionPerformed
Example #4
0
 /** Updates the coordinates displayed on the GUI */
 public void updateC() {
   if (!canEdit) {
     jTextField6.setText("" + model.CornOriCoord(cube.c));
     jTextField5.setText("" + model.EdgeOriCoord(cube.e));
     jTextField4.setText("" + model.UDSliceCoord(cube));
     int flipUD = flip.FlipUDSliceCoord(cube);
     jTextField3.setText("" + (int) (flipUD / 16) + " " + (int) (flipUD % 16));
     jTextField2.setText(
         ""
             + prune.Phase1PruningTable[(int) (flipUD / 16)][
                 table.CornOriSym[model.CornOriCoord(cube.c)][flipUD % 16]]);
     jTextField11.setText("" + model.CornPermCoord(cube.c));
     jTextField10.setText("" + model.EdgePermCoord(cube.e));
     jTextField9.setText("" + model.UDSliceSortedCoord(cube));
     if (model.CornOriCoord(cube.c) == 0
         && model.EdgeOriCoord(cube.e) == 0
         && (int) (flipUD / 16) == 0) { // phase2
       jTextField12.setText("" + model.Phase2EdgePermCoord(cube));
       int CornPerm = perm.CornPermCoord(cube);
       jTextField8.setText("" + (int) (perm.CornPermCoord(cube) / 16) + " " + CornPerm % 16);
       jTextField7.setText(
           ""
               + prune.Phase2PruningTable[(int) (CornPerm / 16)][
                   table.P2EdgePermSym[model.Phase2EdgePermCoord(cube)][CornPerm % 16]]);
     }
     updateView();
   }
 }
Example #5
0
  public void updateView() {
    CubieCube cc = cube;
    int corner = cc.c.a[Corner.URF.ordinal()].c.ordinal();
    int ori = cc.c.a[Corner.URF.ordinal()].o;
    if (ori % 3 == 2) {
      ori -= 1;
    } else if (ori % 3 == 1) {
      ori += 1;
    }
    if (ori >= 3) {
      up[2][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori % 3]));
      right[0][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
      front[2][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
    } else {
      up[2][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori]));
      right[0][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
      front[2][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
    }

    corner = cc.c.a[Corner.UFL.ordinal()].c.ordinal();
    ori = cc.c.a[Corner.UFL.ordinal()].o;
    if (ori % 3 == 2) {
      ori -= 1;
    } else if (ori % 3 == 1) {
      ori += 1;
    }
    if (ori >= 3) {
      up[0][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori % 3]));
      front[0][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
      left[2][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
    } else {
      up[0][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori]));
      front[0][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
      left[2][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
    }

    corner = cc.c.a[Corner.ULB.ordinal()].c.ordinal();
    ori = cc.c.a[Corner.ULB.ordinal()].o;
    if (ori % 3 == 2) {
      ori -= 1;
    } else if (ori % 3 == 1) {
      ori += 1;
    }
    if (ori >= 3) {
      up[0][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori % 3]));
      left[0][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
      back[0][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
    } else {
      up[0][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori]));
      left[0][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
      back[0][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
    }

    corner = cc.c.a[Corner.UBR.ordinal()].c.ordinal();
    ori = cc.c.a[Corner.UBR.ordinal()].o;
    if (ori % 3 == 2) {
      ori -= 1;
    } else if (ori % 3 == 1) {
      ori += 1;
    }
    if (ori >= 3) {
      up[2][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori % 3]));
      back[2][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
      right[2][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
    } else {
      up[2][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori]));
      back[2][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
      right[2][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
    }

    corner = cc.c.a[Corner.DFR.ordinal()].c.ordinal();
    ori = cc.c.a[Corner.DFR.ordinal()].o;
    if (ori % 3 == 2) {
      ori -= 1;
    } else if (ori % 3 == 1) {
      ori += 1;
    }
    if (ori >= 3) {
      down[2][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori % 3]));
      front[2][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
      right[0][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
    } else {
      down[2][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori]));
      front[2][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
      right[0][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
    }

    corner = cc.c.a[Corner.DLF.ordinal()].c.ordinal();
    ori = cc.c.a[Corner.DLF.ordinal()].o;
    if (ori % 3 == 2) {
      ori -= 1;
    } else if (ori % 3 == 1) {
      ori += 1;
    }
    if (ori >= 3) {
      down[0][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori % 3]));
      left[2][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
      front[0][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
    } else {
      down[0][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori % 3]));
      left[2][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
      front[0][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
    }

    corner = cc.c.a[Corner.DBL.ordinal()].c.ordinal();
    ori = cc.c.a[Corner.DBL.ordinal()].o;
    if (ori % 3 == 2) {
      ori -= 1;
    } else if (ori % 3 == 1) {
      ori += 1;
    }
    if (ori >= 3) {
      down[0][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori % 3]));
      back[0][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
      left[0][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
    } else {
      down[0][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori]));
      back[0][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
      left[0][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
    }

    corner = cc.c.a[Corner.DRB.ordinal()].c.ordinal();
    ori = cc.c.a[Corner.DRB.ordinal()].o;
    if (ori % 3 == 2) {
      ori -= 1;
    } else if (ori % 3 == 1) {
      ori += 1;
    }
    if (ori >= 3) {
      down[2][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori % 3]));
      right[2][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
      back[2][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
    } else {
      down[2][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][ori]));
      right[2][2].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 1) % 3]));
      back[2][0].setBackground(model.ColorIndexToColor(model.CCI.a[corner][(ori + 2) % 3]));
    }

    int edge = cc.e.a[Edge.UR.ordinal()].e.ordinal();
    ori = cc.e.a[Edge.UR.ordinal()].o;
    up[2][1].setBackground(model.ColorIndexToColor(model.ECI.a[edge][ori]));
    right[1][0].setBackground(model.ColorIndexToColor(model.ECI.a[edge][(ori + 1) % 2]));

    edge = cc.e.a[Edge.UF.ordinal()].e.ordinal();
    ori = cc.e.a[Edge.UF.ordinal()].o;
    up[1][2].setBackground(model.ColorIndexToColor(model.ECI.a[edge][ori]));
    front[1][0].setBackground(model.ColorIndexToColor(model.ECI.a[edge][(ori + 1) % 2]));

    edge = cc.e.a[Edge.UL.ordinal()].e.ordinal();
    ori = cc.e.a[Edge.UL.ordinal()].o;
    up[0][1].setBackground(model.ColorIndexToColor(model.ECI.a[edge][ori]));
    left[1][0].setBackground(model.ColorIndexToColor(model.ECI.a[edge][(ori + 1) % 2]));

    edge = cc.e.a[Edge.UB.ordinal()].e.ordinal();
    ori = cc.e.a[Edge.UB.ordinal()].o;
    up[1][0].setBackground(model.ColorIndexToColor(model.ECI.a[edge][ori]));
    back[1][2].setBackground(model.ColorIndexToColor(model.ECI.a[edge][(ori + 1) % 2]));

    edge = cc.e.a[Edge.DR.ordinal()].e.ordinal();
    ori = cc.e.a[Edge.DR.ordinal()].o;
    down[2][1].setBackground(model.ColorIndexToColor(model.ECI.a[edge][ori]));
    right[1][2].setBackground(model.ColorIndexToColor(model.ECI.a[edge][(ori + 1) % 2]));

    edge = cc.e.a[Edge.DF.ordinal()].e.ordinal();
    ori = cc.e.a[Edge.DF.ordinal()].o;
    down[1][0].setBackground(model.ColorIndexToColor(model.ECI.a[edge][ori]));
    front[1][2].setBackground(model.ColorIndexToColor(model.ECI.a[edge][(ori + 1) % 2]));

    edge = cc.e.a[Edge.DL.ordinal()].e.ordinal();
    ori = cc.e.a[Edge.DL.ordinal()].o;
    down[0][1].setBackground(model.ColorIndexToColor(model.ECI.a[edge][ori]));
    left[1][2].setBackground(model.ColorIndexToColor(model.ECI.a[edge][(ori + 1) % 2]));

    edge = cc.e.a[Edge.DB.ordinal()].e.ordinal();
    ori = cc.e.a[Edge.DB.ordinal()].o;
    down[1][2].setBackground(model.ColorIndexToColor(model.ECI.a[edge][ori]));
    back[1][0].setBackground(model.ColorIndexToColor(model.ECI.a[edge][(ori + 1) % 2]));

    edge = cc.e.a[Edge.FR.ordinal()].e.ordinal();
    ori = cc.e.a[Edge.FR.ordinal()].o;
    front[2][1].setBackground(model.ColorIndexToColor(model.ECI.a[edge][ori]));
    right[0][1].setBackground(model.ColorIndexToColor(model.ECI.a[edge][(ori + 1) % 2]));

    edge = cc.e.a[Edge.FL.ordinal()].e.ordinal();
    ori = cc.e.a[Edge.FL.ordinal()].o;
    front[0][1].setBackground(model.ColorIndexToColor(model.ECI.a[edge][ori]));
    left[2][1].setBackground(model.ColorIndexToColor(model.ECI.a[edge][(ori + 1) % 2]));

    edge = cc.e.a[Edge.BL.ordinal()].e.ordinal();
    ori = cc.e.a[Edge.BL.ordinal()].o;
    back[0][1].setBackground(model.ColorIndexToColor(model.ECI.a[edge][ori]));
    left[0][1].setBackground(model.ColorIndexToColor(model.ECI.a[edge][(ori + 1) % 2]));

    edge = cc.e.a[Edge.BR.ordinal()].e.ordinal();
    ori = cc.e.a[Edge.BR.ordinal()].o;
    back[2][1].setBackground(model.ColorIndexToColor(model.ECI.a[edge][ori]));
    right[2][1].setBackground(model.ColorIndexToColor(model.ECI.a[edge][(ori + 1) % 2]));

    up[1][1].setBackground(Color.ORANGE);
    down[1][1].setBackground(Color.RED);
    left[1][1].setBackground(Color.GREEN);
    right[1][1].setBackground(Color.BLUE);
    back[1][1].setBackground(Color.YELLOW);
    front[1][1].setBackground(Color.WHITE);

    up[1][1].setEnabled(false);
    down[1][1].setEnabled(false);
    left[1][1].setEnabled(false);
    right[1][1].setEnabled(false);
    back[1][1].setEnabled(false);
    front[1][1].setEnabled(false);
  }
Example #6
0
  private void btn_saveActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btn_saveActionPerformed
    CubieCube cc = new CubieCube();
    try {
      cc.c.a[Corner.URF.ordinal()] =
          model.IDCorner(
              up[2][2].getBackground(), right[0][0].getBackground(), front[2][0].getBackground());
      cc.c.a[Corner.UFL.ordinal()] =
          model.IDCorner(
              up[0][2].getBackground(), front[0][0].getBackground(), left[2][0].getBackground());
      cc.c.a[Corner.ULB.ordinal()] =
          model.IDCorner(
              up[0][0].getBackground(), left[0][0].getBackground(), back[0][2].getBackground());
      cc.c.a[Corner.UBR.ordinal()] =
          model.IDCorner(
              up[2][0].getBackground(), back[2][2].getBackground(), right[2][0].getBackground());
      cc.c.a[Corner.DFR.ordinal()] =
          model.IDCorner(
              down[2][0].getBackground(), front[2][2].getBackground(), right[0][2].getBackground());
      cc.c.a[Corner.DLF.ordinal()] =
          model.IDCorner(
              down[0][0].getBackground(), left[2][2].getBackground(), front[0][2].getBackground());
      cc.c.a[Corner.DBL.ordinal()] =
          model.IDCorner(
              down[0][2].getBackground(), back[0][0].getBackground(), left[0][2].getBackground());
      cc.c.a[Corner.DRB.ordinal()] =
          model.IDCorner(
              down[2][2].getBackground(), right[2][2].getBackground(), back[2][0].getBackground());

      cc.e.a[Edge.UR.ordinal()] =
          model.IDEdge(up[2][1].getBackground(), right[1][0].getBackground());
      cc.e.a[Edge.UF.ordinal()] =
          model.IDEdge(up[1][2].getBackground(), front[1][0].getBackground());
      cc.e.a[Edge.UL.ordinal()] =
          model.IDEdge(up[0][1].getBackground(), left[1][0].getBackground());
      cc.e.a[Edge.UB.ordinal()] =
          model.IDEdge(up[1][0].getBackground(), back[1][2].getBackground());
      cc.e.a[Edge.DR.ordinal()] =
          model.IDEdge(down[2][1].getBackground(), right[1][2].getBackground());
      cc.e.a[Edge.DF.ordinal()] =
          model.IDEdge(down[1][0].getBackground(), front[1][2].getBackground());
      cc.e.a[Edge.DL.ordinal()] =
          model.IDEdge(down[0][1].getBackground(), left[1][2].getBackground());
      cc.e.a[Edge.DB.ordinal()] =
          model.IDEdge(down[1][2].getBackground(), back[1][0].getBackground());
      cc.e.a[Edge.FR.ordinal()] =
          model.IDEdge(front[2][1].getBackground(), right[0][1].getBackground());
      cc.e.a[Edge.FL.ordinal()] =
          model.IDEdge(front[0][1].getBackground(), left[2][1].getBackground());
      cc.e.a[Edge.BL.ordinal()] =
          model.IDEdge(back[0][1].getBackground(), left[0][1].getBackground());
      cc.e.a[Edge.BR.ordinal()] =
          model.IDEdge(back[2][1].getBackground(), right[2][1].getBackground());
    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, "Cube is not valid!");
      return;
    }
    if (model.verifyCube(cc)) {
      cube = cc;
      canEdit = false;
      updateC();
      btn_Solve.setEnabled(true);
      btn_input.setEnabled(true);
      btn_save.setEnabled(false);
    } else {
      JOptionPane.showMessageDialog(this, "Cube is not valid!");
    }
  } // GEN-LAST:event_btn_saveActionPerformed
Example #7
0
 private void jButton11ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton11ActionPerformed
   if (jList1.getSelectedIndex() < 0) return;
   cube = model.DoSym(cube, jList1.getSelectedIndices()[0], false);
   updateC();
 } // GEN-LAST:event_jButton11ActionPerformed