public class SpotImages extends ChildItem
For performance and disk space reasons the spot images are placed
NxN (N given by the NUM_SPOT_IMAGES
constant) into JPEG
files, which are put in a zip file.
Modifier and Type | Field and Description |
---|---|
static int |
NUM_SPOT_IMAGES
The number of spot images to place side by side in each file.
|
static Item |
TYPE
The type of item represented by this class.
|
Constructor and Description |
---|
SpotImages(SpotImagesData data) |
Modifier and Type | Method and Description |
---|---|
private RenderedImage |
convertTiffImage(RenderedImage image,
byte[] conversionTable)
Convert TIFF image from 16 bits to 8 bits if needed
|
void |
createSpotImages(File spotImagesFile,
int xScale,
int yScale,
int xOffset,
int yOffset,
int spotsize,
float gamma,
float quality,
File redImageFile,
File greenImageFile,
File blueImageFile,
ProgressReporter progress)
Creates spot images with 8 bits per channel, from source images.
|
void |
disconnectSpotImages()
Disconnects the generated spot image file from this item.
|
File |
getBlueImageFile()
Get the file which was used for the blue channel in the
spot images.
|
(package private) SpotImagesData |
getData()
Get the
BasicData object that holds all data for this item. |
float |
getGamma()
Get the gamma correction value.
|
File |
getGreenImageFile()
Get the file which was used for the green channel in the
spot images.
|
(package private) static SpotImages |
getNew(DbControl dc,
RawBioAssay rawBioAssay)
Create a new
Image item. |
float |
getQuality()
Get the quality used for the jpeg compression.
|
RawBioAssay |
getRawBioAssay()
Get the raw bioassay the spot images belongs to.
|
File |
getRedImageFile()
Get the file which was used for the red channel in the
spot images.
|
(package private) SharedData |
getSharedParent()
Get the shareable parent item of this child item.
|
SpotImage |
getSpotImage(RawData data)
Get a spot as a PNG image.
|
List<SpotImage> |
getSpotImages(List<RawData> data)
Get a list of spot PNG images from a list of
RawData . |
File |
getSpotImagesFile()
Get the file which holds the spot images.
|
int |
getSpotsize()
Get the size of the spots in pixels.
|
Item |
getType()
Get the type of item represented by the object.
|
int |
getXOffset()
Get the X-axis offset used to convert data coordinates to image
pixel values:
xPixel = (xData - xOffset) / xScale . |
int |
getXScale()
Get the X-axis scale factor used to convert data coordinates to image
pixel values:
xPixel = (xData - xOffset) / xScale . |
int |
getYOffset()
Get the Y-axis offset used to convert data coordinates to image
pixel values:
yPixel = (yData - yOffset) / yScale . |
int |
getYScale()
Get the Y-axis scale factor used to convert data coordinates to image
pixel values:
yPixel = (yData - yOffset) / yScale . |
private boolean |
insideImage(float x,
float y,
int spotsize,
int width,
int height)
Check if entire spot is inside the soure image.
|
private RenderedOp |
loadTiffImage(File file,
int band)
Loads a TIFF file and returns a
RenderedOp . |
private RenderedOp |
mergeColorImages()
Merge the three color images into a single image.
|
private RenderedOp |
rescaleColors(RenderedOp image,
boolean red,
boolean green,
boolean blue)
Rescale the colors of the images so we use the whole 16-bit color range.
|
private void |
saveImage(ZipOutputStream zipFileStream,
String fileName,
RenderedImage image,
float quality)
Saving an image as jpeg and putting it in a zip file
|
private void |
setBlueImageFile(File blueImageFile) |
private void |
setGamma(float gamma) |
private void |
setGreenImageFile(File greenImageFile) |
private void |
setQuality(float quality) |
(package private) void |
setRawBioAssay(RawBioAssay rawBioAssay)
Set the raw bioassay the spot images belongs to.
|
private void |
setRedImageFile(File redImageFile) |
private void |
setSpotsize(int spotsize) |
private void |
setXOffset(int xOffset) |
private void |
setXScale(int xScale) |
private void |
setYOffset(int yOffset) |
private void |
setYScale(int yScale) |
getPermissionForUse, getPermissionForWriteDeleteAndCreate, getPluginPermissions, initPermissions
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, validate
public static final Item TYPE
Item.SPOTIMAGES
,
getType()
public static final int NUM_SPOT_IMAGES
SpotImages(SpotImagesData data)
static SpotImages getNew(DbControl dc, RawBioAssay rawBioAssay) throws BaseException
Image
item.dc
- The DbControl
which will be used for
permission checking and database accessrawBioAssay
- The RawBioAssay
to create spot images forSpotImages
itemBaseException
- If there is an errorRawBioAssay.getSpotImages()
SpotImagesData getData()
BasicItem
BasicData
object that holds all data for this item.public Item getType()
Identifiable
Item
enumeration.SharedData getSharedParent()
ChildItem
ChildItem.initPermissions(int, int)
method to calculate
the logged in user's permissions for the child item.getSharedParent
in class ChildItem
public RawBioAssay getRawBioAssay() throws PermissionDeniedException, BaseException
RawBioAssay
itemPermissionDeniedException
- If the logged in user doesn't have
Permission.READ
permissionBaseException
- If there is another errorvoid setRawBioAssay(RawBioAssay rawBioAssay) throws PermissionDeniedException, InvalidDataException
InvalidDataException
- If the raw bioassay is nullPermissionDeniedException
public int getXScale()
xPixel = (xData - xOffset) / xScale
. The scale is
always a positive integer.private void setXScale(int xScale) throws InvalidDataException
InvalidDataException
public int getYScale()
yPixel = (yData - yOffset) / yScale
. The scale is
always a positive integer.private void setYScale(int yScale) throws InvalidDataException
InvalidDataException
public int getXOffset()
xPixel = (xData - xOffset) / xScale
. The offset may be
positive or negative.private void setXOffset(int xOffset)
public int getYOffset()
yPixel = (yData - yOffset) / yScale
. The offset may be
positive or negative.private void setYOffset(int yOffset)
public int getSpotsize()
private void setSpotsize(int spotsize) throws InvalidDataException
InvalidDataException
public float getQuality()
private void setQuality(float quality) throws InvalidDataException
InvalidDataException
public float getGamma()
private void setGamma(float gamma) throws InvalidDataException
InvalidDataException
public File getRedImageFile() throws PermissionDeniedException, BaseException
PermissionDeniedException
- If the logged in user doesn't
have read permission for the fileBaseException
- If there is another errorprivate void setRedImageFile(File redImageFile) throws PermissionDeniedException
PermissionDeniedException
public File getGreenImageFile() throws PermissionDeniedException, BaseException
PermissionDeniedException
- If the logged in user doesn't
have read permission for the fileBaseException
- If there is another errorprivate void setGreenImageFile(File greenImageFile) throws PermissionDeniedException
PermissionDeniedException
public File getBlueImageFile() throws PermissionDeniedException, BaseException
PermissionDeniedException
- If the logged in user doesn't
have read permission for the fileBaseException
- If there is another errorprivate void setBlueImageFile(File blueImageFile) throws PermissionDeniedException
PermissionDeniedException
public File getSpotImagesFile() throws PermissionDeniedException, BaseException
PermissionDeniedException
- If the logged in user doesn't
have read permission for the fileBaseException
- If there is another errorpublic void disconnectSpotImages() throws PermissionDeniedException, BaseException
DbControl.deleteItem(BasicItem)
method.PermissionDeniedException
- If the logged in user doesn't have
write permissionBaseException
- If there is an errorpublic void createSpotImages(File spotImagesFile, int xScale, int yScale, int xOffset, int yOffset, int spotsize, float gamma, float quality, File redImageFile, File greenImageFile, File blueImageFile, ProgressReporter progress) throws PermissionDeniedException, InvalidDataException, BaseException
spotImagesFile
- The file which will hold the created zip file with the spot images.
Any existing content will be replacedxScale
- X-axis scale factor from data values to pixel values, must be > 0yScale
- Y-axis scale factor from data values to pixel values, must be > 0xOffset
- X offset in data value, can be any valueyOffset
- Y offset in data value, can be any valuespotsize
- The size of the spot i pixels, must be > 0gamma
- Gamma correction value, must be > 1.0quality
- The JPEG compression qualtity, must be a value between 0.0 and 1.0redImageFile
- The file containing the image to be used for the red channel
or nullgreenImageFile
- The file containing the image to be used for the green channel
or nullblueImageFile
- The file containing the image to be used for the blue channel
or nullprogress
- A ProgressReporter
object if the calling client is
interested in the progress or null if notPermissionDeniedException
- If the logged in user doesn't have write
permission for the raw bioassay or to the specified spot images file or doesn't have
use permission for any of the image filesInvalidDataException
- If the directory or file name is null or all image files are
null, or any of the other values are out of rangeItemAlreadyExistsException
- If a file with the same name already exists in
the directoryBaseException
- If there is another errorpublic SpotImage getSpotImage(RawData data) throws InvalidDataException, ItemNotFoundException, BaseException
SpotImage
.data
- A RawData
object representing the spotSpotImage
as a PNG imageInvalidDataException
- If the data object is nullItemNotFoundException
- If a spot image for the position is not foundBaseException
- If there is another errorpublic List<SpotImage> getSpotImages(List<RawData> data) throws InvalidDataException, ItemNotFoundException, PermissionDeniedException, BaseException
RawData
.
It is returned as a list of SpotImage
objects. The returned list
will be mapped to the incomming list. If a spot image is not found, null will
be put at its position in the list. That will make both list to always have the same size.
It is more efficient having the list sorted by the RawData
's position.data
- A list of RawData
objects representing the spotsSpotImage
objects as PNG imagesInvalidDataException
- If the list of data is nullItemNotFoundException
- If the file with the spot images is not foundPermissionDeniedException
- If the logged in user doesn't have
read permission for the file continaing the spot imagesBaseException
- If there is another errorprivate RenderedOp mergeColorImages() throws BaseException
BaseException
private RenderedOp rescaleColors(RenderedOp image, boolean red, boolean green, boolean blue)
image
- Image to rescalered
- TRUE if the red channel isn't empty and should be included in the calculationgreen
- TRUE if green red channel isn't empty and should be included in the calculationblue
- TRUE if the blue channel isn't empty and should be included in the calculationprivate RenderedOp loadTiffImage(File file, int band) throws BaseException
RenderedOp
.file
- A Base File
object pointing to the image to be loadedband
- The index of the TIFF directory to loadBaseException
private RenderedImage convertTiffImage(RenderedImage image, byte[] conversionTable) throws BaseException
image
- TIFF image to convertconversionTable
- Conversion tableRenderedOp
object of the imageBaseException
- If there is an errorprivate void saveImage(ZipOutputStream zipFileStream, String fileName, RenderedImage image, float quality) throws IOException
zipFileStream
- Destination stream to where the JPEG is saved tofileName
- The filename of the imageimage
- The image to be savedquality
- The quality setting of the JPEG imageIOException
private boolean insideImage(float x, float y, int spotsize, int width, int height)
x
- Spot x coordinatey
- Spot y coordinatespotsize
- Spot width and heightwidth
- Source image widthheight
- Source image height