@Override public void display( Panel mainContainer, Panel facetContent, Panel headerPanel, Panel logoutPanel, Panel notificationPanel) { mainContainer.clear(); facetContent.clear(); bind(); mainContainer.addStyleName("Border"); mainContainer.add(this.display.getPublishContainer()); }
public void actionPerformed(ActionEvent e) { int mode = -1; if ("MOVE".equals(e.getActionCommand())) { mode = MOVEMODE; p.setMode(mode); } else if ("START".equals(e.getActionCommand())) { mode = STARTMODE; p.setMode(mode); } else if ("END".equals(e.getActionCommand())) { mode = ENDMODE; p.setMode(mode); } else if ("LOAD".equals(e.getActionCommand())) { FileReader f = new FileReader(); f.read(); int j = -2; for (int i = 0; i < 10; i += 2) { p.setItem(f.getPos(i), j); j++; } } else if ("RESET".equals(e.getActionCommand())) { FileReader f = new FileReader(); f.useDefaults(); int j = -2; for (int i = 0; i < 10; i += 2) { p.setItem(f.getPos(i), j); j++; } p.clear(); } else if ("PLAN".equals(e.getActionCommand())) { p.plan(); } }
/** This is called in the unhappy event of there being errors. */ public static void showBuilderErrors( BuilderResult results, Panel buildResults, ClientFactory clientFactory) { buildResults.clear(); BuildPackageErrorsSimpleTable errorsTable = new BuildPackageErrorsSimpleTable(clientFactory); errorsTable.setRowData(results.getLines()); errorsTable.setRowCount(results.getLines().size()); buildResults.add(errorsTable); }
private void doBuild( final Panel buildResults, final String statusOperator, final String statusValue, final boolean enableStatusSelector, final String categoryOperator, final String category, final boolean enableCategorySelector, final String customSelector) { buildResults.clear(); final HorizontalPanel busy = new HorizontalPanel(); busy.add(new Label(constants.ValidatingAndBuildingPackagePleaseWait())); busy.add(new Image(images.redAnime())); buildResults.add(busy); Scheduler scheduler = Scheduler.get(); scheduler.scheduleDeferred( new Command() { public void execute() { RepositoryServiceFactory.getPackageService() .buildPackage( conf.getUuid(), true, buildMode, statusOperator, statusValue, enableStatusSelector, categoryOperator, category, enableCategorySelector, customSelector, new GenericCallback<BuilderResult>() { public void onSuccess(BuilderResult result) { LoadingPopup.close(); if (result == null || !result.hasLines()) { showSuccessfulBuild(buildResults); } else { showBuilderErrors(result, buildResults, clientFactory); } } public void onFailure(Throwable t) { buildResults.clear(); super.onFailure(t); } }); } }); }
/** * This is called to display the success (and a download option). * * @param buildResults */ private void showSuccessfulBuild(Panel buildResults) { buildResults.clear(); VerticalPanel vert = new VerticalPanel(); vert.add( new HTML( AbstractImagePrototype.create(images.greenTick()).getHTML() + "<i>" + constants.PackageBuiltSuccessfully() + " " + conf.getLastModified() + "</i>")); final String hyp = getDownloadLink(this.conf); HTML html = new HTML( "<a href='" + hyp + "' target='_blank'>" + constants.DownloadBinaryPackage() + "</a>"); vert.add(html); buildResults.add(vert); }
@Override public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int delta) throws SlickException { Input in = gameContainer.getInput(); if (in.isKeyPressed(Input.KEY_C)) { clear(); } gameContainer.setMaximumLogicUpdateInterval(updateInterval); if (in.isMousePressed(Input.MOUSE_LEFT_BUTTON)) { float x1 = in.getMouseX() / ratio; float y1 = in.getMouseY() / ratio; if (start == null) { start = new Cell((int) x1, (int) y1, ratio, false); start.start = true; cells[start.gridPosX][start.gridPosY].start = true; cellStack.add(cells[start.gridPosX][start.gridPosY]); } else if (goal == null) { goal = new Cell((int) x1, (int) y1, ratio, false); cells[goal.gridPosX][goal.gridPosY].goal = true; } else { changeCellAtPosition((int) x1, (int) y1); } if (start != null && goal != null) { this.wall = cells[(int) x1][(int) y1].wall; } } if (in.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) { if (start != null && goal != null) { mousePressing = true; float x1 = in.getMouseX() / ratio; float y1 = in.getMouseY() / ratio; cells[(int) x1][(int) y1].wall = this.wall; } } else { mousePressing = false; } if (in.isKeyPressed(Input.KEY_ENTER)) { if (mazeSolved && displayingMaze) { clear(); createGraph(); maze = true; } else if (!maze) { this.search = true; } } if (in.isKeyPressed(Input.KEY_M) && !maze) { createGraph(); maze = true; this.logger.initWriter(); } if (in.isKeyPressed(Input.KEY_S)) { clear(); for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells.length; j++) { Random random = new Random(); if (random.nextInt(3) == 0) { cells[i][j].wall = true; } } } setDefaultStartAndEnd(true); } if (in.isKeyPressed(Input.KEY_ADD)) { if (updateInterval > 1) { updateInterval -= 1; } } if (in.isKeyPressed(Input.KEY_SUBTRACT)) { if (updateInterval < 20) { updateInterval += 1; } } if (in.isKeyPressed(Input.KEY_P)) { if (!gameContainer.isPaused()) { gameContainer.pause(); } else { gameContainer.resume(); } } if (in.isKeyPressed(Input.KEY_D)) { this.diagonal = !this.diagonal; } if (in.isKeyPressed(Input.KEY_ESCAPE)) { stateBasedGame.enterState(1); } if (in.isKeyPressed(Input.KEY_A)) { AnalyzeLog.analyzeBacktracks(AnalyzeLog.FIRST); } if (in.isKeyPressed(Input.KEY_I)) { this.createImage(); } if (this.search) { if (start == null || goal == null) { this.search = false; } else { if (ButtonStates.DFSState) { if (solvingVisited.size() < 1) { solvingVisited.add(cells[start.gridPosX][start.gridPosY]); cells[start.gridPosX][start.gridPosY].solvingVisited = true; currentDFSCell = cells[start.gridPosX][start.gridPosY]; } else { for (int x = 0; x < CELLS; x++) { for (int y = 0; y < CELLS; y++) { cells[x][y].dfsCheckNeighbors(); } } if (currentDFSCell.goal) { this.search = false; this.drawWay = true; this.end = currentDFSCell; getPath(false, null); if (displayingMaze) { mazeSolved = true; } foundSolution = true; } else { if (solvingVisited.size() != (CELLS * CELLS)) { ArrayList<Cell> currentNeighbors = new ArrayList<>(); if (currentDFSCell.dfsNorth != null && !currentDFSCell.dfsNorth.solvingVisited && !currentDFSCell.dfsNorth.wall) { currentNeighbors.add(currentDFSCell.dfsNorth); } else if (currentDFSCell.dfsEast != null && !currentDFSCell.dfsEast.solvingVisited && !currentDFSCell.dfsEast.wall) { currentNeighbors.add(currentDFSCell.dfsEast); } else if (currentDFSCell.dfsSouth != null && !currentDFSCell.dfsSouth.solvingVisited && !currentDFSCell.dfsSouth.wall) { currentNeighbors.add(currentDFSCell.dfsSouth); } else if (currentDFSCell.dfsWest != null && !currentDFSCell.dfsWest.solvingVisited && !currentDFSCell.dfsWest.wall) { currentNeighbors.add(currentDFSCell.dfsWest); } else {; } if (currentNeighbors.size() > 0) { Cell neighbor = currentNeighbors.get(0); neighbor.solvingPrevious = currentDFSCell; neighbor.solvingVisited = true; currentDFSCell = neighbor; } else { dfsBacktracked.add(currentDFSCell); dfsBacktracked.add(currentDFSCell.solvingPrevious); currentDFSCell = currentDFSCell.solvingPrevious; } } } } } else if (ButtonStates.AStarState) { } else if (ButtonStates.BFSState) { if (solvingVisited.size() < 1) { solvingVisited.add(cells[start.gridPosX][start.gridPosY]); cells[start.gridPosX][start.gridPosY].solvingVisited = true; cellStack.add(cells[start.gridPosX][start.gridPosY]); } else { if (!cellStack.isEmpty()) { Cell current = (Cell) cellStack.remove(); Cell child; if (current.goal) { this.end = current; this.drawWay = true; this.search = false; getPath(false, null); if (displayingMaze) { mazeSolved = true; } foundSolution = true; } else { while ((child = getUnvisitedChildCell(current)) != null) { child.solvingVisited = true; child.solvingPrevious = current; solvingVisited.add(child); cellStack.add(child); current.solvingCheckNeighbors(diagonal); getPath(true, child); } } } } } else { try { throw new NoSolvingAlgorithmSelectedException(); } catch (Exception e) { e.printStackTrace(); } } } } if (this.maze) { if (this.logger.used) { this.logger.createNewLogFile(); this.logger.initWriter(); this.logger.used = false; } if (cells.length != 0) { logger.writeInLog("Checking neighbors"); for (int i = 0; i < CELLS; i++) { for (int j = 0; j < CELLS; j++) { cells[i][j].genCheckNeighbors(); } } if (genVisited.size() < 1) { genVisited.add(cells[1][1]); currentGenCell = cells[1][1]; currentGenCell.genVisited = true; logger.writeInLog("Adding Cell X1 and Y1 to visited Cells"); } if (genVisited.size() != totalCells) { ArrayList<Cell> currentNeighbors = new ArrayList<>(); if (currentGenCell.north != null && !currentGenCell.north.genVisited && currentGenCell.north.allWallsIntact) { currentNeighbors.add(currentGenCell.north); logger.writeInLog( "Adding north cell to neighbors at: " + currentGenCell.north.gridPosX + "; " + currentGenCell.north.gridPosY); } if (currentGenCell.east != null && !currentGenCell.east.genVisited && currentGenCell.east.allWallsIntact) { currentNeighbors.add(currentGenCell.east); logger.writeInLog( "Adding east cell to neighbors at: " + currentGenCell.east.gridPosX + "; " + currentGenCell.east.gridPosY); } if (currentGenCell.south != null && !currentGenCell.south.genVisited && currentGenCell.south.allWallsIntact) { currentNeighbors.add(currentGenCell.south); logger.writeInLog( "Adding south cell to neighbors at: " + currentGenCell.south.gridPosX + "; " + currentGenCell.south.gridPosY); } if (currentGenCell.west != null && !currentGenCell.west.genVisited && currentGenCell.west.allWallsIntact) { currentNeighbors.add(currentGenCell.west); logger.writeInLog( "Adding west cell to neighbors at: " + currentGenCell.west.gridPosX + "; " + currentGenCell.west.gridPosY); } if (currentNeighbors.size() > 0) { Random random = new Random(); int randomValue = random.nextInt(currentNeighbors.size()); logger.writeInLog("Generated random number: " + randomValue); Cell neighbor = currentNeighbors.get(randomValue); logger.writeInLog("Picked neighbor: " + neighbor.gridPosX + "; " + neighbor.gridPosY); neighbor.genVisited = true; int wallX = 0; int wallY = 0; // break wall if (neighbor.gridPosX > currentGenCell.gridPosX) { wallX = currentGenCell.gridPosX + 1; } else if (neighbor.gridPosX < currentGenCell.gridPosX) { wallX = currentGenCell.gridPosX - 1; } else { wallX = currentGenCell.gridPosX; } if (neighbor.gridPosY > currentGenCell.gridPosY) { wallY = currentGenCell.gridPosY + 1; } else if (neighbor.gridPosY < currentGenCell.gridPosY) { wallY = currentGenCell.gridPosY - 1; } else { wallY = currentGenCell.gridPosY; } cells[wallX][wallY].wall = false; cells[wallX][wallY].genVisited = true; logger.writeInLog("Breaking wall at: " + wallX + "; " + wallY); genVisited.add(cells[wallX][wallY]); neighbor.genBacktrack = currentGenCell; logger.writeInLog( "Set current cell to backtrack cell at: " + currentGenCell.gridPosX + "; " + currentGenCell.gridPosY); currentGenCell = neighbor; } else { currentGenCell = currentGenCell.genBacktrack; logger.writeInLog( "Backtracking at: " + currentGenCell.genBacktrack.gridPosX + "; " + currentGenCell.genBacktrack.gridPosY); } } else { currentGenCell = null; this.maze = false; setDefaultStartAndEnd(true); displayingMaze = true; if ((this.search = !this.search) == true) { if (this.startSearch == false) { this.search = false; createImage(); } } logger.writeInLog("Done Maze, closing logger."); logger.closeWriter(); if (this.automaticallyGenerateMazes && (generatedMazes < mazesToGenerate)) { generatedMazes += 1; clear(); createGraph(); this.maze = true; } else if (this.logger.stepList.size() != 0) { this.logger.printStepList(); } else {; } } } } char[][] copyOfLevel = new char[CELLS][CELLS]; for (int x = 0; x < cells.length; x++) { for (int y = 0; y < cells.length; y++) { if (cells[x][y].wall) { copyOfLevel[x][y] = 'W'; } else if (!cells[x][y].wall) { copyOfLevel[x][y] = 'D'; } else if (cells[x][y].start) { copyOfLevel[x][y] = 'S'; } else if (cells[x][y].goal) { copyOfLevel[x][y] = 'G'; } else { copyOfLevel[x][y] = 'D'; } } } Level.update(copyOfLevel); }