private void drawTooltip(FishState fishUnderMouse) { int tooltipHeight = 20, tooltipBottomMargin = 10; bufferGraphics.setColor(Color.WHITE); bufferGraphics.fillRect( 0, buffer.getHeight() - tooltipHeight, buffer.getWidth(), tooltipHeight); bufferGraphics.setColor(Color.BLACK); if (fishUnderMouse != null) { bufferGraphics.drawString( String.format( "Frame %d ID %d, Nut %.2f, Change %.2f, Speed %.2f, Dir %s", state.seqID, fishUnderMouse.fish_id, fishUnderMouse.getNutrients(), Rules.decay(fishUnderMouse), fishUnderMouse.getSpeed(), fishUnderMouse.getRudderVector()), 5, buffer.getHeight() - tooltipBottomMargin); } else { bufferGraphics.drawString( String.format( "Frame %d, Fish %d, Controllers %d, Max fish %d, Max nut %.2f", state.seqID, state.getNumFish(), state.getNumControllers(), state.getMaxFish(), state.getMaxNutrients()), 5, buffer.getHeight() - tooltipBottomMargin); } }