private void draw() throws IOException { // NOPMD
		assert x == 0;
		final double myPercent = Math.max(Math.min(percentValue, 100d), 0d);
		final int fullBlockCount = (int) Math.floor(myPercent / (UNIT_SIZE * PARTIAL_BLOCKS));
		final int partialBlockIndex = (int) Math
				.floor((myPercent - fullBlockCount * UNIT_SIZE * PARTIAL_BLOCKS) / UNIT_SIZE);

		addImage(getBarImage(fullBlockCount > 0 || partialBlockIndex > 0 ? "a" : "a0"));

		final BufferedImage fullBody = getBarImage(String.valueOf(PARTIAL_BLOCKS));
		for (int i = 0; i < fullBlockCount; i++) {
			addImage(fullBody);
		}

		if (partialBlockIndex > 0) {
			final BufferedImage partialBody = getBarImage(String.valueOf(partialBlockIndex));
			addImage(partialBody);
		}

		final int emptyBlocks = FULL_BLOCKS - fullBlockCount - (partialBlockIndex > 0 ? 1 : 0);
		final BufferedImage emptyBody = getBarImage(String.valueOf(0));
		for (int i = 0; i < emptyBlocks; i++) {
			addImage(emptyBody);
		}

		addImage(getBarImage(fullBlockCount == FULL_BLOCKS ? "b" : "b0"));

		if (alertOnHighUsage) {
			x += 8;
			graphics.drawImage(getImage("alert.png"), x, 0, null);
		}
	}
private void draw ( ) throws IOException { assert x == 0 ; final double myPercent = Math . max ( Math . min ( percentValue , 100d ) , 0d ) ; final int fullBlockCount = ( int ) Math . floor ( myPercent / ( UNIT_SIZE * PARTIAL_BLOCKS ) ) ; final int partialBlockIndex = ( int ) Math . floor ( ( myPercent - fullBlockCount * UNIT_SIZE * PARTIAL_BLOCKS ) / UNIT_SIZE ) ; addImage ( getBarImage ( fullBlockCount > 0 || partialBlockIndex > 0 ? "a" : "a0" ) ) ; final BufferedImage fullBody = getBarImage ( String . valueOf ( PARTIAL_BLOCKS ) ) ; for ( int i = 0 ; i < fullBlockCount ; i ++ ) { addImage ( fullBody ) ; } if ( partialBlockIndex > 0 ) { final BufferedImage partialBody = getBarImage ( String . valueOf ( partialBlockIndex ) ) ; addImage ( partialBody ) ; } final int emptyBlocks = FULL_BLOCKS - fullBlockCount - ( partialBlockIndex > 0 ? 1 : 0 ) ; final BufferedImage emptyBody = getBarImage ( String . valueOf ( 0 ) ) ; for ( int i = 0 ; i < emptyBlocks ; i ++ ) { addImage ( emptyBody ) ; } addImage ( getBarImage ( fullBlockCount == FULL_BLOCKS ? "b" : "b0" ) ) ; if ( alertOnHighUsage ) { x += 8 ; graphics . drawImage ( getImage ( "alert.png" ) , x , 0 , null ) ; } }
méthode inspirée de VisualScoreTag dans LambdaProbe/JStripe (Licence GPL)