Search in sources :

Example 1 with GifParsingException

use of cbit.image.GifParsingException in project vcell by virtualcell.

the class GeomDbDriver method insertBrowseImageDataSQL.

/**
 * This method was created in VisualAge.
 * @param vcimage cbit.image.VCImage
 * @param userid java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */
private void insertBrowseImageDataSQL(Connection con, KeyValue key, KeyValue imageKey, VCImage image) throws SQLException, DataAccessException, ImageException, GifParsingException {
    String sql;
    sql = "INSERT INTO " + browseImageDataTable.getTableName() + " " + browseImageDataTable.getSQLColumnList() + " VALUES " + browseImageDataTable.getSQLValueList(key, imageKey, dbSyntax);
    // System.out.println(sql);
    byte[] gifEncodedImage = null;
    try {
        if (image != null) {
            if (image.getNumZ() > 1) {
                byte[] sliceBytes = new byte[image.getNumX() * image.getNumY()];
                System.arraycopy(image.getPixels(), 0, sliceBytes, 0, sliceBytes.length);
                gifEncodedImage = BrowseImage.makeBrowseGIFImage(new VCImageUncompressed(null, sliceBytes, new Extent(1, 1, 1), image.getNumX(), image.getNumY(), 1)).getGifEncodedData();
            } else {
                gifEncodedImage = BrowseImage.makeBrowseGIFImage(image).getGifEncodedData();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (gifEncodedImage == null) {
        gifEncodedImage = BrowseImage.makeBrowseGIFImage(new VCImageUncompressed(null, new byte[BrowseImage.BROWSE_XSIZE * BrowseImage.BROWSE_YSIZE], new Extent(1, 1, 1), BrowseImage.BROWSE_XSIZE, BrowseImage.BROWSE_YSIZE, 1)).getGifEncodedData();
    }
    switch(dbSyntax) {
        case ORACLE:
            {
                updateCleanSQL(con, sql);
                updateCleanLOB(con, browseImageDataTable.id.toString(), key, browseImageDataTable.tableName, browseImageDataTable.data, gifEncodedImage, dbSyntax);
                break;
            }
        case POSTGRES:
            {
                updatePreparedCleanSQL(con, sql, gifEncodedImage);
                break;
            }
        default:
            {
                throw new RuntimeException("unexpected DatabaseSyntax " + dbSyntax);
            }
    }
}
Also used : Extent(org.vcell.util.Extent) VCImageUncompressed(cbit.image.VCImageUncompressed) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) PropertyVetoException(java.beans.PropertyVetoException) SQLException(java.sql.SQLException) DependencyException(org.vcell.util.DependencyException) GifParsingException(cbit.image.GifParsingException) RecordChangedException(cbit.sql.RecordChangedException) ImageException(cbit.image.ImageException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException)

Example 2 with GifParsingException

use of cbit.image.GifParsingException in project vcell by virtualcell.

the class ImageTable method getInfo.

/**
 * This method was created in VisualAge.
 * @return VCImage
 * @param rset ResultSet
 * @param log SessionLog
 */
public VersionInfo getInfo(ResultSet rset, Connection con, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException {
    GIFImage gifImage = null;
    try {
        // gifImage = new GIFImage(rset.getBytes(BrowseImageDataTable.table.data.toString()));
        byte[] gifData = (byte[]) DbDriver.getLOB(rset, BrowseImageDataTable.table.data, dbSyntax);
        gifImage = new GIFImage(gifData);
    // 
    } catch (GifParsingException e) {
        throw new DataAccessException("Error Parsing browseImage");
    }
    java.math.BigDecimal groupid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
    Version version = getVersion(rset, DbDriver.getGroupAccessFromGroupID(con, groupid));
    int x = rset.getInt(ImageTable.table.numX.toString());
    int y = rset.getInt(ImageTable.table.numY.toString());
    int z = rset.getInt(ImageTable.table.numZ.toString());
    org.vcell.util.ISize size = new org.vcell.util.ISize(x, y, z);
    double extentX = rset.getBigDecimal(ExtentTable.table.extentX.toString()).doubleValue();
    double extentY = rset.getBigDecimal(ExtentTable.table.extentY.toString()).doubleValue();
    double extentZ = rset.getBigDecimal(ExtentTable.table.extentZ.toString()).doubleValue();
    org.vcell.util.Extent extent = new org.vcell.util.Extent(extentX, extentY, extentZ);
    String softwareVersion = rset.getString(SoftwareVersionTable.table.softwareVersion.toString());
    return new VCImageInfo(version, size, extent, gifImage, VCellSoftwareVersion.fromString(softwareVersion));
}
Also used : GifParsingException(cbit.image.GifParsingException) GIFImage(cbit.image.GIFImage) VCellSoftwareVersion(org.vcell.util.document.VCellSoftwareVersion) Version(org.vcell.util.document.Version) DataAccessException(org.vcell.util.DataAccessException) VCImageInfo(cbit.image.VCImageInfo)

Aggregations

GifParsingException (cbit.image.GifParsingException)2 DataAccessException (org.vcell.util.DataAccessException)2 GIFImage (cbit.image.GIFImage)1 ImageException (cbit.image.ImageException)1 VCImageInfo (cbit.image.VCImageInfo)1 VCImageUncompressed (cbit.image.VCImageUncompressed)1 RecordChangedException (cbit.sql.RecordChangedException)1 ExpressionException (cbit.vcell.parser.ExpressionException)1 PropertyVetoException (java.beans.PropertyVetoException)1 SQLException (java.sql.SQLException)1 DependencyException (org.vcell.util.DependencyException)1 Extent (org.vcell.util.Extent)1 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)1 PermissionException (org.vcell.util.PermissionException)1 VCellSoftwareVersion (org.vcell.util.document.VCellSoftwareVersion)1 Version (org.vcell.util.document.Version)1