Class PixelImage
java.lang.Object
uk.ac.starlink.ttools.plot2.layer.PixelImage
Aggregates information for painting a colour-mapped image.
Some utility methods are provided for generating suitable colour models.
- Since:
- 4 Sep 2015
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsConstructorDescriptionPixelImage
(Dimension size, int[] pixels, IndexColorModel colorModel) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic IndexColorModel
createColorModel
(Shader shader, boolean zeroTransparent) Returns an indexed colour model whose entries range from one end to the other of a given shader object.static IndexColorModel
createMaskColorModel
(Color color) Returns a 2-colour indexed colour model.Returns the colour model.int[]
Returns the pixel array.getSize()
Returns the dimensions of this image.void
paintPixels
(Graphics g, Point origin) Paints this image to a given graphics context.void
paintScaledPixels
(Graphics g, Point origin, int scale) Paints this image to a given graphics context, with each pixel scaled by an integer factor.
-
Constructor Details
-
PixelImage
Constructor.- Parameters:
size
- dimensions of the imagepixels
- pixel array, fitssize
all values must fall in range of colour modelcolorModel
- indexed colour model
-
-
Method Details
-
getSize
Returns the dimensions of this image.- Returns:
- size
-
getPixels
public int[] getPixels()Returns the pixel array.- Returns:
- pixel array
-
getColorModel
Returns the colour model.- Returns:
- colour model
-
paintPixels
Paints this image to a given graphics context.- Parameters:
g
- graphics contextorigin
- target position for origin of painted image
-
paintScaledPixels
Paints this image to a given graphics context, with each pixel scaled by an integer factor.- Parameters:
g
- graphics contextorigin
- target position for origin of painted imagescale
- scaling factor
-
createColorModel
Returns an indexed colour model whose entries range from one end to the other of a given shader object.- Parameters:
shader
- shader; should be absolutezeroTransparent
- if true, the first entry in the returned colour map is transparent- Returns:
- colour model
-
createMaskColorModel
Returns a 2-colour indexed colour model.- Parameters:
color
- non-blank colour- Returns:
- colour map with two entries:
0=transparent, 1=
color
-