public synchronized byte[] getTileDirect(Integer z, Integer c, Integer t, Integer x, Integer y, Integer w, Integer h, byte[] buffer) throws IOException { checkTileParameters(x, y, w, h); t = getRasterizedT(z, c, t); c = 0; z = 0; return delegate().getTileDirect(z, c, t, x, y, w, h, buffer); }
protected void acquireLock() { try { lockFile = lockFile(); lockRaf = new RandomAccessFile(lockFile, "rw"); fileLock = lockRaf.getChannel().lock(); // THROWS! } catch (OverlappingFileLockException overlap) { closeRaf(); throw new LockTimeout("Already locked! " + lockFile.getAbsolutePath(), 15*1000, 0); } catch (IOException e) { closeRaf(); throw new LockTimeout("IOException while locking " + lockFile.getAbsolutePath(), 15*1000, 0); } }
private BfPixelBuffer delegate() { if (isWrite()) { try { closeWriter(); try { initializeReader(); } catch (FormatException e) { throw new RuntimeException(e); } } catch (IOException e1) { throw new RuntimeException(e1); } } else if (delegate == null) { try { initializeReader(); } catch (IOException e) { throw new RuntimeException(e); } catch (FormatException e) { throw new RuntimeException(e); } } return delegate; }
public synchronized byte[] getColDirect(Integer x, Integer z, Integer c, Integer t, byte[] buffer) throws IOException, DimensionsOutOfBoundsException { t = getRasterizedT(z, c, t); c = 0; z = 0; return delegate().getColDirect(x, z, c, t, buffer); }
public synchronized void setTile(byte[] buffer, Integer z, Integer c, Integer t, Integer x, Integer y, Integer w, Integer h) throws IOException, BufferOverflowException { if (!isWrite()) { throw new ApiUsageException("In read-only mode!"); } try { int planeCount = getSizeZ() * getSizeC() * getSizeT(); int planeNumber = FormatTools.getIndex( "XYZCT", getSizeZ(), getSizeC(), getSizeT(), planeCount, z, c, t); IFD ifd = getIFD(z, c, t, w, h); if (log.isDebugEnabled()) { log.debug(String.format( "Writing tile planeNumber:%d bufferSize:%d ifd:%s " + "x:%d y:%d w:%d h:%d", planeNumber, buffer.length, ifd.toString(), x, y, w, h)); } writer.saveBytes(planeNumber, buffer, ifd, x, y, w, h); } catch (FormatException e) { throw new RuntimeException(e); } }
public synchronized Integer getRowSize() { return delegate().getRowSize(); }
protected void init(String filePath, boolean write) throws IOException, FormatException { if (!write || readerFile.exists()) { if (write) { log.debug("Initialized in a write-context; setting read-only for " + filePath); } if (!readerFile.exists() && !readerFile.canRead()) { throw new IOException("Cannot access " + filePath); } initializeReader(); } else { final File readerDir = readerFile.getParentFile(); writerFile = File.createTempFile("." + readerFile.getName(), ".tmp", readerDir); writerFile.deleteOnExit(); acquireLock(); } }
private void releaseLock() { try { if (fileLock != null) { fileLock.release(); } } catch (IOException e) { throw new RuntimeException(e); } finally { fileLock = null; closeRaf(); if (lockFile != null) { lockFile.delete(); lockFile = null; } } }
remainingLength); createSeries(series, newImageWidth, newImageLength); series++;
public synchronized void close() throws IOException { try { if (delegate != null) { delegate.close(); } } catch (IOException e) { log.error("Failure to close delegate.", e); } delegate = null; if (reader != null) { try { reader.close(); } catch (Exception e) { log.warn("Failed to close reader", e); } finally { reader = null; } } closeWriter(); }
/** * Helper method to properly log any exceptions raised by Bio-Formats. * @param pixels passed to {@link BfPixelBuffer} * @param filePath Non-null. * @return the initialized {@link BfPyramidPixelBuffer} */ protected BfPyramidPixelBuffer createPyramidPixelBuffer(final Pixels pixels, final String filePath, boolean write) { try { if (write) { // #5159. Creating the path if we need to write. createSubpath(filePath); } return new BfPyramidPixelBuffer(pixels, filePath, write); } catch (Exception e) { if (e instanceof LockTimeout) { throw (LockTimeout) e; } String msg = "Error instantiating pixel buffer: " + filePath; log.error(msg, e); throw new ResourceError(msg); } }
pixelsPyramid.close();
lociServiceFactory.getInstance(OMEXMLService.class); metadata = service.createOMEXMLMetadata(); addSeries(tileWidth, tileLength); writer = new OmeroPixelsPyramidWriter(); writer.setMetadataRetrieve(metadata);
public synchronized void checkBounds(Integer x, Integer y, Integer z, Integer c, Integer t) throws DimensionsOutOfBoundsException { t = getRasterizedT(z, c, t); c = 0; z = 0; delegate().checkBounds(x, y, z, c, t); }
public synchronized String getPath() { return delegate().getPath(); }
public synchronized byte[] getPlaneDirect(Integer z, Integer c, Integer t, byte[] buffer) throws IOException, DimensionsOutOfBoundsException { t = getRasterizedT(z, c, t); c = 0; z = 0; return delegate().getPlaneDirect(z, c, t, buffer); }
public synchronized PixelData getTile(Integer z, Integer c, Integer t, Integer x, Integer y, Integer w, Integer h) throws IOException { checkTileParameters(x, y, w, h); t = getRasterizedT(z, c, t); c = 0; z = 0; PixelData data = delegate().getTile(z, c, t, x, y, w, h); data.setOrder(byteOrder); return data; }