this.image = createImage(new FilteredImageSource(tempImage.getSource(), new KeyAlphaFilter(TRANSPARENT)));
if (zoomIndex == BASE_ZOOM_INDEX ){ image = createImage(new FilteredImageSource(tempImage.getSource(), new KeyAlphaFilter(TRANSPARENT))); } else { image = getScaledImage(createImage(new FilteredImageSource(tempImage.getSource(), new KeyAlphaFilter(TRANSPARENT)))); } graph.dispose(); tempImage.flush();
        public void prepare() {            // create image for buffer            Image tempImage = createImage(bounds.width, bounds.height);            Graphics graph = tempImage.getGraphics();            // fill with key color            graph.setColor(new Color(TRANSPARENT));            graph.fillRect(0, 0, bounds.width, bounds.height);            // setup some variables            final Point stepPos = getHexLocation(step.getPosition());            stepPos.translate(-bounds.x, -bounds.y);            final Polygon facingPoly = facingPolys[step.getFacing()];            final Polygon movePoly = movementPolys[step.getFacing()];            Point offsetCostPos;            Polygon myPoly;            Color col;            // set color            switch (step.getMovementType()) {                case IEntityMovementType.MOVE_RUN:                case IEntityMovementType.MOVE_VTOL_RUN:                    if (step.isUsingMASC()) {                        col = GUIPreferences.getInstance().getColor("AdvancedMoveMASCColor");                    } else {                        col = GUIPreferences.getInstance().getColor("AdvancedMoveRunColor");                    }                    break;                case IEntityMovementType.MOVE_JUMP:                    col = GUIPreferences.getInstance().getColor("AdvancedMoveJumpColor");                    break;                case IEntityMovementType.MOVE_ILLEGAL:                    col = GUIPreferences.getInstance().getColor("AdvancedMoveIllegalColor");                    break;                default :                    if (step.getType() == MovePath.STEP_BACKWARDS) {                        col = GUIPreferences.getInstance().getColor("AdvancedMoveBackColor");                    } else {                        col = GUIPreferences.getInstance().getColor("AdvancedMoveDefaultColor");                    }                    break;            }            // draw arrows and cost for the step            switch (step.getType()) {                case MovePath.STEP_FORWARDS:                case MovePath.STEP_SWIM:                case MovePath.STEP_BACKWARDS:                case MovePath.STEP_CHARGE:                case MovePath.STEP_DFA:                case MovePath.STEP_LATERAL_LEFT:                case MovePath.STEP_LATERAL_RIGHT:                case MovePath.STEP_LATERAL_LEFT_BACKWARDS:                case MovePath.STEP_LATERAL_RIGHT_BACKWARDS:                    // draw arrows showing them entering the next                    myPoly = new Polygon(movePoly.xpoints, movePoly.ypoints,                            movePoly.npoints);                    graph.setColor(Color.darkGray);                    myPoly.translate(stepPos.x + 1, stepPos.y + 1);                    graph.drawPolygon(myPoly);                    graph.setColor(col);                    myPoly.translate(-1, -1);                    graph.drawPolygon(myPoly);                    // draw movement cost                    drawMovementCost(step, stepPos, graph, col, true);                    break;                case MovePath.STEP_GO_PRONE:                case MovePath.STEP_HULL_DOWN:                case MovePath.STEP_DOWN:                case MovePath.STEP_DIG_IN:                case MovePath.STEP_FORTIFY:                    // draw arrow indicating dropping prone                    // also doubles as the descent indication                    Polygon downPoly = movementPolys[7];                    myPoly = new Polygon(downPoly.xpoints, downPoly.ypoints, downPoly.npoints);                    graph.setColor(Color.darkGray);                    myPoly.translate(stepPos.x, stepPos.y);                    graph.drawPolygon(myPoly);                    graph.setColor(col);                    myPoly.translate(-1, -1);                    graph.drawPolygon(myPoly);                    offsetCostPos = new Point(stepPos.x + 1, stepPos.y + 15);                    drawMovementCost(step, offsetCostPos, graph, col, false);                    break;                case MovePath.STEP_GET_UP:                case MovePath.STEP_UP:                    // draw arrow indicating standing up                    // also doubles as the climb indication                    Polygon upPoly = movementPolys[6];                    myPoly = new Polygon(upPoly.xpoints, upPoly.ypoints, upPoly.npoints);                    graph.setColor(Color.darkGray);                    myPoly.translate(stepPos.x, stepPos.y);                    graph.drawPolygon(myPoly);                    graph.setColor(col);                    myPoly.translate(-1, -1);                    graph.drawPolygon(myPoly);                    offsetCostPos = new Point(stepPos.x, stepPos.y + 15);                    drawMovementCost(step, offsetCostPos, graph, col, false);                    break;                case MovePath.STEP_CLIMB_MODE_ON:                    // draw climb mode indicator                    String climb = Messages.getString("BoardView1.Climb"); //$NON-NLS-1$                    if (step.isPastDanger()) {                        climb = "(" + climb + ")"; //$NON-NLS-1$ //$NON-NLS-2$                    }                    graph.setFont(new Font("SansSerif", Font.PLAIN, 12)); //$NON-NLS-1$                    int climbX = stepPos.x + 42 - (graph.getFontMetrics(graph.getFont()).stringWidth(climb) / 2);                    graph.setColor(Color.darkGray);                    graph.drawString(climb, climbX, stepPos.y + 39);                    graph.setColor(col);                    graph.drawString(climb, climbX - 1, stepPos.y + 38);                    break;                case MovePath.STEP_CLIMB_MODE_OFF:                    // cancel climb mode indicator                    String climboff = Messages.getString("BoardView1.ClimbOff"); //$NON-NLS-1$                    if (step.isPastDanger()) {                        climboff = "(" + climboff + ")"; //$NON-NLS-1$ //$NON-NLS-2$                    }                    graph.setFont(new Font("SansSerif", Font.PLAIN, 12)); //$NON-NLS-1$                    int climboffX = stepPos.x + 42 - (graph.getFontMetrics(graph.getFont()).stringWidth(climboff) / 2);                    graph.setColor(Color.darkGray);                    graph.drawString(climboff, climboffX, stepPos.y + 39);                    graph.setColor(col);                    graph.drawString(climboff, climboffX - 1, stepPos.y + 38);                    break;                case MovePath.STEP_TURN_LEFT:                case MovePath.STEP_TURN_RIGHT:                    // draw arrows showing the facing                    myPoly = new Polygon(facingPoly.xpoints, facingPoly.ypoints,                            facingPoly.npoints);                    graph.setColor(Color.darkGray);                    myPoly.translate(stepPos.x + 1, stepPos.y + 1);                    graph.drawPolygon(myPoly);                    graph.setColor(col);                    myPoly.translate(-1, -1);                    graph.drawPolygon(myPoly);                    break;                case MovePath.STEP_LOAD:                    // Announce load.                    String load = Messages.getString("BoardView1.Load"); //$NON-NLS-1$                    if (step.isPastDanger()) {                        load = "(" + load + ")"; //$NON-NLS-1$ //$NON-NLS-2$                    }                    graph.setFont(new Font("SansSerif", Font.PLAIN, 12)); //$NON-NLS-1$                    int loadX = stepPos.x + 42 - (graph.getFontMetrics(graph.getFont()).stringWidth(load) / 2);                    graph.setColor(Color.darkGray);                    graph.drawString(load, loadX, stepPos.y + 39);                    graph.setColor(col);                    graph.drawString(load, loadX - 1, stepPos.y + 38);                    break;                case MovePath.STEP_UNLOAD:                    // Announce unload.                    String unload = Messages.getString("BoardView1.Unload"); //$NON-NLS-1$                    if (step.isPastDanger()) {                        unload = "(" + unload + ")"; //$NON-NLS-1$ //$NON-NLS-2$                    }                    graph.setFont(new Font("SansSerif", Font.PLAIN, 12)); //$NON-NLS-1$                    int unloadX = stepPos.x + 42 - (graph.getFontMetrics(graph.getFont()).stringWidth(unload) / 2);                    int unloadY = stepPos.y + 38 + graph.getFontMetrics(graph.getFont()).getHeight();                    graph.setColor(Color.darkGray);                    graph.drawString(unload, unloadX, unloadY + 1);                    graph.setColor(col);                    graph.drawString(unload, unloadX - 1, unloadY);                    break;                default :                    break;            }            // create final image            this.image = createImage(new FilteredImageSource(tempImage.getSource(),                    new KeyAlphaFilter(TRANSPARENT)));        }