private void nova_senha(HttpServletRequest request, HttpServletResponse response) throws XolerDAOException, IOException { String email = request.getParameter("email"); SendGrid sendgrid = new SendGrid("*****@*****.**", "3teptep3!"); SendGrid.Email sendgrid_email = new Email(); sendgrid_email.addTo(email); sendgrid_email.setFrom("*****@*****.**"); sendgrid_email.setSubject("Nova Senha"); DAOUsuario user = new DAOUsuario(true); int hash = email.hashCode(); String novasenha = Integer.toString(Math.abs(hash)); System.out.println("novasenha"); System.out.println(novasenha); user.nova_senha(email, novasenha); sendgrid_email.setText("Sua nova senha no Drogaria.me é: " + novasenha); try { SendGrid.Response response_sendgrid = sendgrid.send(sendgrid_email); System.out.println(response_sendgrid.getMessage()); } catch (SendGridException e) { System.err.println(e); } response.sendRedirect("index.jsp"); }
public static FibonacciHeap<NodeInfoHelper> initialStartSet( long startNode, long endNode, HashMap<Long, FibonacciHeapNode<NodeInfoHelper>> nodeHelperCache) { FibonacciHeap<NodeInfoHelper> openSet = new FibonacciHeap<NodeInfoHelper>(); NodeInfo start = OSMData.nodeHashMap.get(startNode); NodeInfoHelper initial; FibonacciHeapNode<NodeInfoHelper> fInitial; // initial start end set if (start.isIntersect()) { // initial initial = new NodeInfoHelper(startNode); initial.setCost(0); initial.setHeuristic(estimateHeuristic(startNode, endNode)); fInitial = new FibonacciHeapNode<NodeInfoHelper>(initial); openSet.insert(fInitial, initial.getTotalCost()); // push the start node nodeHelperCache.put(initial.getNodeId(), fInitial); // add cache } else { EdgeInfo edge = start.getOnEdgeList().getFirst(); double speed = edge.getTravelSpeed(); int travelTime = 1; // second int distance; if (!edge.isOneway()) { // distance from start to middle distance = edge.getStartDistance(startNode); travelTime = (int) Math.round(distance / speed * OSMParam.MILLI_PER_SECOND); initial = new NodeInfoHelper(edge.getStartNode()); initial.setCost(travelTime); initial.setHeuristic(estimateHeuristic(edge.getStartNode(), endNode)); fInitial = new FibonacciHeapNode<NodeInfoHelper>(initial); openSet.insert(fInitial, initial.getTotalCost()); // push the start node nodeHelperCache.put(initial.getNodeId(), fInitial); // add cache } distance = edge.getEndDistance(startNode); travelTime = (int) Math.round(distance / speed * OSMParam.MILLI_PER_SECOND); initial = new NodeInfoHelper(edge.getEndNode()); initial.setCost(travelTime); initial.setHeuristic(estimateHeuristic(edge.getEndNode(), endNode)); fInitial = new FibonacciHeapNode<NodeInfoHelper>(initial); openSet.insert(fInitial, initial.getTotalCost()); // push the start node nodeHelperCache.put(initial.getNodeId(), fInitial); // add cache } return openSet; }
public MircString lanCountdown() { LocalDateTime lan = LocalDateTime.of(2016, 4, 29, 18, 0, 0); LocalDateTime now = LocalDateTime.now(); Long seconds = now.until(lan, ChronoUnit.SECONDS); int totalSeconds = (60 * 60 * 24 * 365 * 1000); BigDecimal bigSeconds = new BigDecimal(totalSeconds); BigDecimal secondsLeft = new BigDecimal(seconds); BigDecimal millennia = secondsLeft.divide(bigSeconds, 50, RoundingMode.HALF_UP); String inputString = "There are " + seconds.toString() + " seconds to LAN - you'd better be prepared for it, mofos. Or, if you're Ragnar, there are " + millennia + " millennia left."; if (seconds < 0) { seconds = Math.abs(seconds); inputString = "LAN has been running for " + seconds.toString() + " seconds! Kick ass!"; } MircString mircString = MircString.of(inputString.toString()); return mircString; }
public NodeInfoHelper getEndNodeHelper(long endNode) { // TODO: not time dependent now, need to modify NodeInfo end = OSMData.nodeHashMap.get(endNode); NodeInfoHelper endNodeHelper = new NodeInfoHelper(endNode); if (getNodeId() == end.getNodeId()) { // no need to do in edge routing return this; } else { EdgeInfo edge = end.getOnEdgeList().getFirst(); int distance; // from start to middle if (getNodeId() == edge.getStartNode()) { distance = edge.getStartDistance(endNode); } else { // from end to middle distance = edge.getEndDistance(endNode); } double speed = edge.getTravelSpeed(); int travelTime = 1; // second travelTime = (int) Math.round(distance / speed); endNodeHelper.setCost(getCost() + travelTime); endNodeHelper.setParentId(getNodeId()); } return endNodeHelper; }
@FXML private void ratingButtonClicked(ActionEvent event) throws SQLException { configureButtons(); ratingButton.setGraphic(ratingSelectedIMV); // clear old content contentPane.getChildren().clear(); // set up titleLabel.setText("Rating and Feedback"); // rating box HBox ratingBox = new HBox(); ratingBox.setAlignment(Pos.CENTER); ratingBox.setSpacing(20); ratingBox.setPadding(new Insets(10, 0, 10, 0)); // Rating label Label ratingTitle = new Label("Average Rating: "); ratingTitle.setFont(new Font("System", 24)); // 5 stars String yellowStarURL = "Graphics/StarYellow.png"; String blankStarURL = "Graphics/StarBlank.png"; ImageView starBlank1 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); ImageView starBlank2 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); ImageView starBlank3 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); ImageView starBlank4 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); ImageView starBlank5 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); Button star1 = new Button(); star1.setGraphic(starBlank1); star1.setStyle("-fx-background-color: transparent"); Button star2 = new Button(); star2.setGraphic(starBlank2); star2.setStyle("-fx-background-color: transparent"); Button star3 = new Button(); star3.setGraphic(starBlank3); star3.setStyle("-fx-background-color: transparent"); Button star4 = new Button(); star4.setGraphic(starBlank4); star4.setStyle("-fx-background-color: transparent"); Button star5 = new Button(); star5.setGraphic(starBlank5); star5.setStyle("-fx-background-color: transparent"); // get average rating double avgRating = 0; try { avgRating = operation.getAverageRating(); } catch (SQLException e) { e.printStackTrace(); ratingTitle.setText("Error! Can't get average rating"); } Button[] buttonlist = new Button[5]; buttonlist[0] = star1; buttonlist[1] = star2; buttonlist[2] = star3; buttonlist[3] = star4; buttonlist[4] = star5; for (int i = 0; i < Math.floor(avgRating); i++) { ImageView image = new ImageView(new Image(getClass().getResourceAsStream(yellowStarURL))); buttonlist[i].setGraphic(image); } // feedback box VBox feedBackBox = new VBox(); feedBackBox.setAlignment(Pos.CENTER); feedBackBox.setSpacing(20); // Feedback title Label feedBackLabel = new Label("Feedback:"); feedBackLabel.setFont(new Font("System", 24)); // get feedback string String feedback = ""; ArrayList<Rating> list = operation.getRatingsAndFeedbacks(); for (Rating r : list) { feedback += r.getFeedback() + "\n\n"; } Text feedbackText = new Text(feedback); feedbackText.setFont(new Font("System", 14)); ScrollPane scrollPane = new ScrollPane(); scrollPane.setContent(feedbackText); // Add children nodes to appropriate boxes ratingBox.getChildren().addAll(ratingTitle, star1, star2, star3, star4, star5); feedBackBox.getChildren().addAll(feedBackLabel, scrollPane); // main box VBox mainBox = new VBox(); mainBox.setSpacing(40); mainBox.getChildren().addAll(ratingBox, feedBackBox); contentPane.getChildren().add(mainBox); }
public boolean checkIfPathIsClear(Point startPosition, Point endPosition) { boolean isPathClear = true; Point difference = new Point(); difference.setLocation( Math.abs(endPosition.getX() - startPosition.getX()), Math.abs(endPosition.getY() - startPosition.getY())); if (difference.getX() > 0 && difference.getY() == 0) { int largerPlace = (int) (startPosition.getX() > endPosition.getX() ? startPosition.getX() : endPosition.getX()); for (int j = (int) (largerPlace - (difference.getX() - 1)); j < largerPlace; j++) { if (b.containsKey(new Point(j, (int) startPosition.getY()))) { isPathClear = false; } } } else if ((int) difference.getY() > 0 && (int) difference.getX() == 0) { int largerPlace = 0; if (startPosition.getY() > endPosition.getY()) { largerPlace = (int) startPosition.getY(); } else { largerPlace = (int) endPosition.getY(); } for (int i = largerPlace - ((int) difference.getY() - 1); i < largerPlace; i++) { if (b.containsKey(new Point((int) startPosition.getX(), i))) { isPathClear = false; } } } else if (difference.getX() == difference.getY()) { int leftPoint = (int) (startPosition.getX() < endPosition.getX() ? startPosition.getY() : endPosition.getY()); int rightPoint = (int) (startPosition.getX() > endPosition.getX() ? startPosition.getY() : endPosition.getY()); int largerPlace = (int) (startPosition.getX() > endPosition.getX() ? startPosition.getX() : endPosition.getX()); int slope = leftPoint - rightPoint; int y = slope > 0 ? leftPoint - 1 : leftPoint + 1; for (int j = (int) (largerPlace - (difference.getX() - 1)); j < largerPlace; j++) { if (b.containsKey(new Point(j, y))) { isPathClear = false; } y = slope > 0 ? y - 1 : y + 1; } } return isPathClear; }