/** * @param a the width of the panel * @param b the height of the panel * @param s the slam object to be used */ public EvaulationMapPanel(double a, double b, EvaluationGUI frameUI) { setSize((int) a, (int) b); percentageZoom = 1; // System.out.println(getHeight()); map = frameUI.getSlam2().getMap(); frame = frameUI; main = frame.getSlam2(); mapSize = new Point(getSlam2().getMap().getGrid()[0].length, getSlam2().getMap().getGrid().length); currentCell = new Point(getSlam2().getCurrentIndexX(), getSlam2().getCurrentIndexY()); totalCells = 0; cellsVisited = 0; if (map.getMaxPoint() == null) { map.setMaxPoint(new Point(currentCell.getX() + 1, currentCell.getY() + 1)); } if (map.getMinPoint() == null) { map.setMinPoint(new Point(currentCell.getX() - 1, currentCell.getY() - 1)); } if (map.getMapPoint() == null) { map.setMapPoint( new Point(this.getWidth() / calculateCellSize(), this.getHeight() / calculateCellSize())); } setAutoscrolls(true); mouseListener mouse = new mouseListener(); addMouseWheelListener(mouse); }
public void refreshMaxMin() { xCoordinate = (int) currentCell.getX(); yCoordiante = (int) currentCell.getY(); if (map.getMapPoint().getY() > map.getMaxPoint().getY() - map.getMinPoint().getY() && map.getMapPoint().getX() > map.getMaxPoint().getX() - map.getMinPoint().getX()) { if (yCoordiante - 1 < map.getMinPoint().getY()) { map.getMinPoint().setY(yCoordiante - 1); } if (xCoordinate - 1 < map.getMinPoint().getX()) { map.getMinPoint().setX(xCoordinate - 1); } if (yCoordiante + 1 > map.getMaxPoint().getY()) { map.getMaxPoint().setY(yCoordiante + 1); // System.out.println("doing it"); } if (xCoordinate + 1 > map.getMaxPoint().getX()) { map.getMaxPoint().setX(xCoordinate + 1); } } else { if (map.getMapPoint().getX() < map.getGrid()[0].length) { setPreferredSize( new Dimension((int) (20 * calculateCellSize()) + this.getWidth(), this.getHeight())); this.repaint(); map.getMapPoint().setX(map.getMapPoint().getX() + 20); frame.panelSize.setX(this.getWidth() + (int) (20 * calculateCellSize())); } if (map.getMapPoint().getY() < map.getGrid().length) { frame.panelSize.setY(this.getHeight() + (int) (20 * calculateCellSize())); setPreferredSize( new Dimension(this.getWidth(), this.getHeight() + (int) (20 * calculateCellSize()))); map.getMapPoint().setY(map.getMapPoint().getY() + 10); this.repaint(); } } }