示例#1
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