Package engine

Examples of engine.Scheme


    case UndoAction.EDIT_NEW_SCHEME: {
      action = new UndoAction(type,null,null,null,currentSchemeIndex,currentMoveIndex,currentMoveIndex);
      break;
    }
    default: {
      action = new UndoAction(type,null,null,new Scheme(currentScheme),currentSchemeIndex,currentMoveIndex,currentMoveIndex);
      break;
    }
    }
    undoActions.addLast(action);
    redoActions.clear();
View Full Code Here


    case UndoAction.EDIT_REMOVE_SCHEME: {
      redoActions.addLast(new UndoAction(action.type,null,null,null,action.schemeIndex,action.prevMoveIndex,action.nextMoveIndex));
      break;
    }
    default: {
      redoActions.addLast(new UndoAction(action.type,null,null,new Scheme(currentSchemeSet.get(action.schemeIndex)),action.schemeIndex,action.prevMoveIndex,action.nextMoveIndex));
      break;
    }
    }
    updateUndo();
    // Perform undo action
View Full Code Here

    case UndoAction.EDIT_REMOVE_SCHEME: {
      undoActions.addLast(new UndoAction(action.type,null,null,null,action.schemeIndex,action.prevMoveIndex,action.nextMoveIndex));
      break;
    }
    case UndoAction.EDIT_NEW_SCHEME: {
      undoActions.addLast(new UndoAction(action.type,null,null,new Scheme(currentSchemeSet.get(action.schemeIndex-1)),action.schemeIndex,action.prevMoveIndex,action.nextMoveIndex));
      break;
    }
    default: {
      undoActions.addLast(new UndoAction(action.type,null,null,new Scheme(currentSchemeSet.get(action.schemeIndex)),action.schemeIndex,action.prevMoveIndex,action.nextMoveIndex));
      break;
    }
    }
    updateUndo();
    // Perform redo action
View Full Code Here

  private void setDialog(JDialog dialog) {
    boolean enabled = (dialog == null);
    currentDialog = dialog;
    if (dialog != null) {
      if (dialog instanceof SchemeDialog) {
        setScheme(new Scheme(currentSchemeSet.get(currentSchemeIndex)),false);
        ((SchemeDialog)dialog).setScheme(currentSchemeSet.get(currentSchemeIndex));
      } else {
        setSchemeSet(new SchemeSet(currentSchemeSet),currentMoveIndexes);
        ((SchemeSetDialog)dialog).setSchemeSet(currentSchemeSet);
      }
View Full Code Here

       
    if (ev.getSource() == miEditNewScheme) {
      viewBoard.pause();
      currentSchemeIndex++;
      beginUndoAction(UndoAction.EDIT_NEW_SCHEME);
      addScheme(currentSchemeIndex,new Scheme(new Board(DEFAULT_BOARD_WIDTH,DEFAULT_BOARD_HEIGHT)),currentMoveIndex);
      setSchemeIndex(currentSchemeIndex,true);
      endUndoAction();
    } else

    if (ev.getSource() == miEditDuplicateScheme) {
      viewBoard.pause();
      currentSchemeIndex++;
      beginUndoAction(UndoAction.EDIT_DUPLICATE_SCHEME);   
      addScheme(currentSchemeIndex,new Scheme(currentSchemeSet.get(currentSchemeIndex-1)),currentMoveIndex);
      setSchemeIndex(currentSchemeIndex,true);
      endUndoAction();
    } else

    if (ev.getSource() == miEditRemoveScheme) {
      if (currentSchemeSet.size() > 1) {
        viewBoard.pause();
        beginUndoAction(UndoAction.EDIT_REMOVE_SCHEME);   
        removeScheme(currentSchemeIndex);
        if (currentSchemeIndex >= currentSchemeSet.size())
          currentSchemeIndex = currentSchemeSet.size()-1;
        setSchemeIndex(currentSchemeIndex,true);
        endUndoAction();
      }
    } else
     
    if (ev.getSource() == miEditMoveSchemeForward) {
      if (currentSchemeIndex < currentSchemeSet.size()-1) {
        viewBoard.pause();
        beginUndoAction(UndoAction.EDIT_MOVE_SCHEME_FORWARD);   
        swapSchemes(currentSchemeIndex,currentSchemeIndex+1);
        currentSchemeIndex++;
        updateSchemeIndex();
        endUndoAction();
        viewBoard.resume();
      }
    } else

    if (ev.getSource() == miEditMoveSchemeBackward) {
      if (currentSchemeIndex > 0) {
        viewBoard.pause();
        beginUndoAction(UndoAction.EDIT_MOVE_SCHEME_BACKWARD);   
        swapSchemes(currentSchemeIndex,currentSchemeIndex-1);
        currentSchemeIndex--;
        updateSchemeIndex();
        endUndoAction();
        viewBoard.resume();
      }
    } else

    if (ev.getSource() == miEditRemoveAllSchemesMoves) {
      viewBoard.pause();
      beginUndoAction(UndoAction.EDIT_REMOVE_ALL_SCHEMES_MOVES);
      for (int i=0;i<currentSchemeSet.size();i++) {
        currentSchemeSet.get(i).moves.clear();
        currentMoveIndexes.set(i,0);       
      }
      endUndoAction();
      updateSchemeSet();
      setMoveIndex(0,false);
      viewBoard.resume();
    } else
       
    if (ev.getSource() == miEditAppendSet) {
      viewBoard.pause();
      if (dialogFileChooser.showDialog(this,"Dołącz układy...") == JFileChooser.APPROVE_OPTION) {
        try {
        SchemeSet appendingSet = new SchemeSet(new FileInputStream(dialogFileChooser.getSelectedFile()));
        currentSchemeIndex++;
        beginUndoAction(UndoAction.EDIT_APPEND_SET);
        currentSchemeSet.addAll(currentSchemeIndex,appendingSet);
        for (int i=0;i<appendingSet.size();i++)
          currentMoveIndexes.add(currentSchemeIndex+i,0);
        setSchemeSet(currentSchemeSet,currentMoveIndexes,currentSchemeIndex);
        endUndoAction();
        } catch (IOException e) {}
      }
      viewBoard.resume();
    } else
   
    if (ev.getSource() == miEditSchemeSetProperties) {
      setDialog(dialogSchemeSetProperties);
    } else
   
    // ***************************************************************
    // Scheme menu
   
    if (ev.getSource() == miSchemeProperties) {
      setDialog(dialogSchemeProperties);
    } else
     
    if (ev.getSource() == miSchemeOptimizeMoves) {
      viewBoard.pause();
      beginUndoAction(UndoAction.SCHEME_OPTIMIZE_MOVES);
      currentScheme.optimizeMoves();
      setMoveIndex(0,false);
      endUndoAction();
    } else
     
    if (ev.getSource() == miSchemeRemoveBeginMoves) {
      viewBoard.pause();
      beginUndoAction(UndoAction.SCHEME_REMOVE_BEGIN_MOVES);
      currentScheme.movesTrimStart(currentMoveIndex);
      replaceScheme(currentSchemeIndex,currentScheme);
      setMoveIndex(0,false);
      endUndoAction();
    } else
   
    if (ev.getSource() == miSchemeRemoveEndMoves) {
      beginUndoAction(UndoAction.SCHEME_REMOVE_END_MOVES);
      currentScheme.movesTrimEnd(currentScheme.moves.size() - currentMoveIndex);
      updateMoveIndex();
      endUndoAction();
    } else
     
    if (ev.getSource() == miSchemeRemoveAllMoves) {
      beginUndoAction(UndoAction.SCHEME_REMOVE_ALL_MOVES);
      currentScheme.movesTrimStart(currentMoveIndex);
      currentScheme.movesTrimEnd(currentScheme.moves.size());
      replaceScheme(currentSchemeIndex,currentScheme);
      setMoveIndex(0,false);
      endUndoAction();
    } else
     
    if (ev.getSource() == miSchemeAppendMoves) {
      if (currentSchemeIndex < currentSchemeSet.size()-1) {
        viewBoard.pause();
        beginUndoAction(UndoAction.SCHEME_APPEND_MOVES);
        currentSchemeSet.get(currentSchemeIndex).appendMoves(currentSchemeSet.get(currentSchemeIndex+1));
        updateMoveIndex();
        endUndoAction();
        viewBoard.resume();
      }
    } else

    // ***************************************************************
    // Board menu
   
    if (ev.getSource() == miBoardResize) {
      setDialog(dialogSchemeResize);
    } else
              
    if (ev.getSource() == miBoardMakeConnected) {
      viewBoard.pause();
      beginUndoAction(UndoAction.BOARD_MAKE_CONNECTED);
      BoardManager.makeConnected(currentScheme.start);
      currentScheme.start.doFramesToStability();
      currentScheme.removeIncorrectMoves();
      replaceScheme(currentSchemeIndex,currentScheme);
      currentMoveIndexes.set(currentSchemeIndex,0);
      setSchemeIndex(currentSchemeIndex,false);
      endUndoAction();
    } else
   
    if (ev.getSource() == miBoardRemoveElements) {
      beginUndoAction(UndoAction.BOARD_REMOVE_ELEMENTS);
      BoardManager.removeElements(currentScheme.start);
      currentScheme.moves.clear();
      setSchemeIndex(currentSchemeIndex,false);
      endUndoAction();
    } else
         
    if (ev.getSource() == miBoardConvertConcrete) {
      beginUndoAction(UndoAction.BOARD_CONVERT_CONCRETE);
      BoardManager.convertConcrete(currentScheme.start);
      setSchemeIndex(currentSchemeIndex,false);
      endUndoAction();
    } else
           
    if (ev.getSource() == miBoardRemoveBlocks) {
      beginUndoAction(UndoAction.BOARD_REMOVE_BLOCKS);
      BoardManager.removeBlocks(currentScheme.start);
      currentScheme.moves.clear();
      setSchemeIndex(currentSchemeIndex,false);
      endUndoAction();
    } else
          
    if (ev.getSource() == miBoardRemoveSurroundedSolids) {
      viewBoard.pause();
      beginUndoAction(UndoAction.BOARD_REMOVE_SURROUNDED_SOLIDS);
      BoardManager.removeSurroundedSolids(currentScheme.start);
      replaceScheme(currentSchemeIndex,currentScheme);
      setSchemeIndex(currentSchemeIndex,false);
      endUndoAction();
    } else
     
    // ***************************************************************
    // Generator menu
   
    if (ev.getSource() == miGeneratorOutline) {
      setDialog(dialogSchemeGenerateOutline);
    } else
   
    if (ev.getSource() == miGeneratorEquivalent) {
      viewBoard.pause();
      beginUndoAction(UndoAction.GENERATE_EQUIVALENT);
      Scheme mixedScheme = MixGenerator.generateEquivalent(1.0d,currentScheme);
      mixedScheme.appendMoves(currentScheme);
      replaceScheme(currentSchemeIndex,mixedScheme);
      currentMoveIndexes.set(currentSchemeIndex,0);
      setSchemeIndex(currentSchemeIndex,false);
      endUndoAction();
    } else
    
    if (ev.getSource() == miGeneratorPrevious) {
      viewBoard.pause();
      beginUndoAction(UndoAction.GENERATE_PREVIOUS);
      Scheme mixedScheme = MixGenerator.generatePrevious(1.0d,currentScheme);
      mixedScheme.appendMoves(currentScheme);
      replaceScheme(currentSchemeIndex,mixedScheme);
      currentMoveIndexes.set(currentSchemeIndex,0);
      setSchemeIndex(currentSchemeIndex,false);
      endUndoAction();
    } else
View Full Code Here

TOP

Related Classes of engine.Scheme

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.