protected void updateLabel(BufferedImage image, int x, int y, int availableWidth) {
		if (image.getRaster().getNumBands()==1) {
			label.setText(String.format("%d, %d; intensity %d", x, y,
					image.getRaster().getSample(x, y, 0)));
		} else if (image.getRaster().getNumBands()==4) {
			int rgb = image.getRGB(x, y);
			Color c = new Color(rgb, true);
			label.setText(String.format("%d, %d; color %d,%d,%d, alpha %d", x, y,
					c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()));
		} else {
			int rgb = image.getRGB(x, y);
			Color c = new Color(rgb);
			label.setText(String.format("%d, %d; color %d,%d,%d", x, y,
					c.getRed(), c.getGreen(), c.getBlue()));
		}

		if (availableWidth<label.getPreferredSize().width) {
			// not enough space, shorter version is required
			if (image.getRaster().getNumBands()==1) {
				label.setText(String.format("%d, %d; %d", x, y,
						image.getRaster().getSample(x, y, 0)));
			} else if (image.getRaster().getNumBands()==4) {
				int rgb = image.getRGB(x, y);
				Color c = new Color(rgb, true);
				label.setText(String.format("%d, %d; (%d,%d,%d,%d)", x, y,
						c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()));
			} else {
				int rgb = image.getRGB(x, y);
				Color c = new Color(rgb);
				label.setText(String.format("%d, %d; (%d,%d,%d)", x, y,
						c.getRed(), c.getGreen(), c.getBlue()));
			}
		}
	}
protected void updateLabel ( BufferedImage image , int x , int y , int availableWidth ) { if ( image . getRaster ( ) . getNumBands ( ) == 1 ) { label . setText ( String . format ( "%d, %d; intensity %d" , x , y , image . getRaster ( ) . getSample ( x , y , 0 ) ) ) ; } else if ( image . getRaster ( ) . getNumBands ( ) == 4 ) { int rgb = image . getRGB ( x , y ) ; Color c = new Color ( rgb , true ) ; label . setText ( String . format ( "%d, %d; color %d,%d,%d, alpha %d" , x , y , c . getRed ( ) , c . getGreen ( ) , c . getBlue ( ) , c . getAlpha ( ) ) ) ; } else { int rgb = image . getRGB ( x , y ) ; Color c = new Color ( rgb ) ; label . setText ( String . format ( "%d, %d; color %d,%d,%d" , x , y , c . getRed ( ) , c . getGreen ( ) , c . getBlue ( ) ) ) ; } if ( availableWidth < label . getPreferredSize ( ) . width ) { if ( image . getRaster ( ) . getNumBands ( ) == 1 ) { label . setText ( String . format ( "%d, %d; %d" , x , y , image . getRaster ( ) . getSample ( x , y , 0 ) ) ) ; } else if ( image . getRaster ( ) . getNumBands ( ) == 4 ) { int rgb = image . getRGB ( x , y ) ; Color c = new Color ( rgb , true ) ; label . setText ( String . format ( "%d, %d; (%d,%d,%d,%d)" , x , y , c . getRed ( ) , c . getGreen ( ) , c . getBlue ( ) , c . getAlpha ( ) ) ) ; } else { int rgb = image . getRGB ( x , y ) ; Color c = new Color ( rgb ) ; label . setText ( String . format ( "%d, %d; (%d,%d,%d)" , x , y , c . getRed ( ) , c . getGreen ( ) , c . getBlue ( ) ) ) ; } } }
This function updates the contents of the {@link #label}. It is called when the highlighted pixel or the image changes,
and only when the image is not {@code null} and the pixel is within the bounds of the image. If either of these
conditions aren't true, the {@code update} function calls {@link #updateLabelNoData()} instead.
Override it to provide a custom message.
@param image the current image displayed in the viewer
@param x the x coordinate of the pixel that should be displayed
@param y the y coordinate of the pixel that should be displayed
@param availableWidth the maximum label width that can be displayed; you can use this parameter to specify a shorter
message if there is not enough room