Draws a color bar with the LUT, with a black rectangle around. 'x' is the coordinate of the field for the lowest LUT color. Note that 'width' is the width of the area for the LUT colors; thus no colors will be omitted with a 256-entry LUT if width=256. The left line of the rectangle is at x, the
(Graphics g, int x, int y, int width, int height)
| 86 | * will be omitted with a 256-entry LUT if width=256. |
| 87 | * The left line of the rectangle is at x, the right one at x+width+1. */ |
| 88 | public void drawColorBar(Graphics g, int x, int y, int width, int height) { |
| 89 | double scale = width/(double)mapSize; |
| 90 | ColorProcessor cp = new ColorProcessor(width, height); |
| 91 | for (int i = 0; i<mapSize; i++) { |
| 92 | cp.setColor(new Color(rLUT[i]&0xff,gLUT[i]&0xff,bLUT[i]&0xff)); |
| 93 | int xloc0 = (int)Math.round(i*scale); |
| 94 | int xloc1 = (int)Math.round((i+1)*scale); |
| 95 | cp.fillRect(xloc0, 0, xloc1-xloc0, height); |
| 96 | } |
| 97 | g.drawImage(cp.createImage(), x+1, y, null); |
| 98 | g.setColor(Color.black); |
| 99 | g.drawRect(x, y, width+1, height); |
| 100 | } |
| 101 | |
| 102 | public void drawUnscaledColorBar(ImageProcessor ip, int x, int y, int width, int height) { |
| 103 | ImageProcessor bar = null; |