/** Update the size of the grid in the active tab */ public void updateGridSize() { myGridSpinner = new GridSpinner(myGrid.getSize().width, myGrid.getSize().height); int a = (int) JOptionPane.showConfirmDialog( null, myGridSpinner, "Update Grid Height and Width", JOptionPane.OK_CANCEL_OPTION); if (a == 0) { process( CommandConstants.CHANGE_GRID_SIZE + " " + myGridSpinner.getGridWidth() + ", " + myGridSpinner.getGridHeight()); } }
/** * Paint the contents of the canvas. * * <p>Never called by you directly, instead called by Java runtime when area of screen covered by * this container needs to be displayed (i.e., creation, uncovering, change in status) * * @param pen used to paint shape on the screen */ @Override public void paintComponent(Graphics pen) { pen.setColor(Color.WHITE); pen.fillRect(0, 0, getSize().width, getSize().height); if (myGrid != null) { myGrid.paint((Graphics2D) pen); } }
@Override public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { return myGrid.getScrollableBlockIncrement(visibleRect, orientation, direction); }
@Override public void setRenderable(Renderable<LevelEditing> r) { myGrid = (LEGrid) r; setSize(myGrid.getPixelSize()); repaint(); }
/** * checks if grid is ready for simulation * * @return true if valid */ public boolean isValidForSimulation() { return myGrid.isValidForSimulation(); }