if (null != this.hScrollbar) { this.hScrollbar.setVisibleAmount(size.width); this.hScrollbar.setBlockIncrement(size.width); this.hScrollbar.setUnitIncrement((int) (scale * HEX_W / 2.0)); this.hScrollbar.setMaximum(boardSize.width);
if (null != hScrollbar) { hScrollbar.setVisibleAmount(size.width); hScrollbar.setBlockIncrement(size.width); hScrollbar.setUnitIncrement((int) (scale * HEX_W / 2.0)); hScrollbar.setMaximum(boardSize.width);
    public synchronized void update(Graphics g) {        // Limit our size to the viewport of the scroll pane.        final Dimension size = getSize();        //         final long startTime = System.currentTimeMillis(); // commentme        // Make sure our scrollbars have the right sizes.        // N.B. A buggy Sun implementation makes me to do this here instead         // of updateBoardSize() (which is where *I* think it belongs).        if (null != this.vScrollbar) {            this.vScrollbar.setVisibleAmount(size.height);            this.vScrollbar.setBlockIncrement(size.height);            this.vScrollbar.setUnitIncrement((int) (scale * HEX_H / 2.0));            this.vScrollbar.setMaximum(boardSize.height);        }        if (null != this.hScrollbar) {            this.hScrollbar.setVisibleAmount(size.width);            this.hScrollbar.setBlockIncrement(size.width);            this.hScrollbar.setUnitIncrement((int) (scale * HEX_W / 2.0));            this.hScrollbar.setMaximum(boardSize.width);        }        // update view, offset        view.setLocation(scroll);        view.setSize(getOptimalView(size));        offset.setLocation(getOptimalOffset(size));        if (!this.isTileImagesLoaded()) {            g.drawString(Messages.getString("BoardView1.loadingImages"), 20, 50); //$NON-NLS-1$            if (!tileManager.isStarted()) {                System.out.println("boardview1: loading images for board"); //$NON-NLS-1$                tileManager.loadNeededImages(game);            }            return;        }        // make sure back buffer is valid        if (backGraph == null || !view.getSize().equals(backSize)) {            // make new back buffer            backSize = view.getSize();            backImage = createImage(backSize.width, backSize.height);            backGraph = backImage.getGraphics();        }                // make sure board rectangle contains our current view rectangle        if (boardImage == null || !boardRect.union(view).equals(boardRect)) {            updateBoardImage();        }        // draw onto the back buffer:        // draw the board        backGraph.drawImage(boardImage, 0, 0, this);        // draw wrecks        if (GUIPreferences.getInstance().getShowWrecks()) {            drawSprites(wreckSprites);        }        // Minefield signs all over the place!        drawMinefields();                // Artillery targets        drawArtilleryHexes();        // draw highlight border        drawSprite(highlightSprite);        // draw cursors        drawSprite(cursorSprite);        drawSprite(selectedSprite);        drawSprite(firstLOSSprite);        drawSprite(secondLOSSprite);        // draw deployment indicators        if (m_plDeployer != null) {            drawDeployment();        }        // draw C3 links        drawSprites(C3Sprites);        // draw onscreen entities        drawSprites(entitySprites);        // draw moving onscreen entities        drawSprites(movingEntitySprites);        // draw ghost onscreen entities        drawSprites(ghostEntitySprites);        // draw onscreen attacks        drawSprites(attackSprites);        // draw movement, if valid        drawSprites(pathSprites);        // added by kenn        // draw the ruler line        if (rulerStart != null) {            Point start = getCentreHexLocation(rulerStart);            if (rulerEnd != null) {                Point end = getCentreHexLocation(rulerEnd);                backGraph.setColor(Color.yellow);                backGraph.drawLine(start.x - boardRect.x, start.y - boardRect.y, end.x - boardRect.x, end.y - boardRect.y);                backGraph.setColor(rulerEndColor);                backGraph.fillRect(end.x - boardRect.x - 1, end.y - boardRect.y - 1, 2, 2);            }            backGraph.setColor(rulerStartColor);            backGraph.fillRect(start.x - boardRect.x - 1, start.y - boardRect.y - 1, 2, 2);        }        // end kenn        // draw all the "displayables"        for (int i = 0; i < displayables.size(); i++) {            Displayable disp = (Displayable) displayables.elementAt(i);            disp.draw(backGraph, backSize);        }        // draw the back buffer onto the screen        // first clear the entire view if the map has been zoomed        if (scale < 1.00f) {            Image tmpImage = createImage(size.width, size.height);            Graphics tmpGraphics = tmpImage.getGraphics();            tmpGraphics.drawImage(backImage, offset.x, offset.y, this);            g.drawImage(tmpImage, 0, 0, this);            hasZoomed = false;        } else {            g.drawImage(backImage, offset.x, offset.y, this);        }        //g.drawString(""+scale, 10, 10);        //         final long finishTime = System.currentTimeMillis();//commentme        //         System.out.println("BoardView1: updated screen in " + (finishTime - startTime) + " ms."); //commentme    }