* @param unit The Unit to draw.
     */
    private void displayUnit(Graphics2D g, Unit unit) {
        try {
            // Draw the 'selected unit' image if needed.
            //if ((unit == getActiveUnit()) && cursor) {
            if (displayUnitCursor(unit)) {
                drawCursor(g);
            }

            // Draw the unit.
            // If unit is sentry, draw in grayscale
            boolean fade = (unit.getState() == Unit.UnitState.SENTRY)
                || (unit.getTile() != null
                    && !freeColClient.getMyPlayer().canSee(unit.getTile()));
            Image image = lib.getUnitImageIcon(unit, fade).getImage();
            Point p = getUnitImagePositionInTile(image);
            g.drawImage(image, p.x, p.y, null);

            // Draw an occupation and nation indicator.
            g.drawImage(getOccupationIndicatorImage(g, unit),
                        (int) (STATE_OFFSET_X * lib.getScalingFactor()), 0, null);

            // Draw one small line for each additional unit (like in civ3).
            int unitsOnTile = 0;
            if (unit.getTile() != null) {
                // When a unit is moving from tile to tile, it is removed from the source tile
                // So the unit stack indicator cannot be drawn during the movement
                // see UnitMoveAnimation.animate() for details
                unitsOnTile = unit.getTile().getTotalUnitCount();
            }
            if (unitsOnTile > 1) {
                g.setColor(Color.WHITE);
                int unitLinesY = OTHER_UNITS_OFFSET_Y;
                int x1 = (int) ((STATE_OFFSET_X + OTHER_UNITS_OFFSET_X) * lib.getScalingFactor());
                int x2 = (int) ((STATE_OFFSET_X + OTHER_UNITS_OFFSET_X + OTHER_UNITS_WIDTH) * lib.getScalingFactor());
                for (int i = 0; (i < unitsOnTile) && (i < MAX_OTHER_UNITS); i++) {
                    g.drawLine(x1, unitLinesY, x2, unitLinesY);
                    unitLinesY += 2;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        // FOR DEBUGGING
        net.sf.freecol.server.ai.AIUnit au;
        if (FreeColDebugger.isInDebugMode()
            && !freeColClient.getMyPlayer().owns(unit)
            && freeColClient.getFreeColServer() != null
            && (au = freeColClient.getFreeColServer().getAIMain()
                .getAIUnit(unit)) != null) {
            g.setColor(Color.WHITE);
            String wrap = (unit.getOwner().isAI()) ? "" : "(";
            String text = wrap + ((au.getMission() == null) ? "No mission"
                : Utils.lastPart(au.getMission().getClass().toString(), "."))
                + wrap;
            g.drawString(text, 0, 0);
        }