Search in sources :

Example 16 with VCImageInfo

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

the class ClientRequestManager method createSelectLoadGeomTask.

private AsynchClientTask createSelectLoadGeomTask(final TopLevelWindowManager requester) {
    AsynchClientTask selectLoadGeomTask = new AsynchClientTask("Select/Load geometry...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            VersionInfo vcVersionInfo = (VersionInfo) hashTable.get(VERSIONINFO_KEY);
            Geometry geom = null;
            if (vcVersionInfo instanceof VCDocumentInfo) {
                geom = getGeometryFromDocumentSelection(requester.getComponent(), (VCDocumentInfo) vcVersionInfo, false);
            } else if (vcVersionInfo instanceof VCImageInfo) {
                VCImage img = getDocumentManager().getImage((VCImageInfo) vcVersionInfo);
                geom = new Geometry("createSelectLoadGeomTask", img);
            } else {
                throw new Exception("Unexpected versioninfo type.");
            }
            // pregenerate sampled image, cpu intensive
            geom.precomputeAll(new GeometryThumbnailImageFactoryAWT());
            hashTable.put(GEOMETRY_KEY, geom);
        }
    };
    return selectLoadGeomTask;
}
Also used : Geometry(cbit.vcell.geometry.Geometry) VersionInfo(org.vcell.util.document.VersionInfo) GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) Hashtable(java.util.Hashtable) VCImage(cbit.image.VCImage) VCImageInfo(cbit.image.VCImageInfo) ProgrammingException(org.vcell.util.ProgrammingException) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) DataFormatException(java.util.zip.DataFormatException) UserCancelException(org.vcell.util.UserCancelException)

Example 17 with VCImageInfo

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

the class DbDriver method getVCInfoContainer.

/**
 * Insert the method's description here.
 * Creation date: (9/24/2003 12:54:32 PM)
 * @return cbit.vcell.modeldb.VCInfoContainer
 */
public static VCInfoContainer getVCInfoContainer(User user, Connection con, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException {
    VCInfoContainer results = null;
    // 
    VCImageInfo[] vcImageInfos = null;
    GeometryInfo[] geometryInfos = null;
    MathModelInfo[] mathModelInfos = null;
    BioModelInfo[] bioModelInfos = null;
    // 
    StringBuffer sql = null;
    String special = null;
    ResultSet rset = null;
    boolean enableSpecial = true;
    boolean enableDistinct = true;
    Statement stmt = con.createStatement();
    try {
        // 
        // BioModelInfos
        // 
        {
            double beginTime = System.currentTimeMillis();
            special = " ORDER BY " + BioModelTable.table.name.getQualifiedColName() + "," + BioModelTable.table.versionBranchID.getQualifiedColName() + "," + BioModelTable.table.versionDate.getQualifiedColName();
            sql = new StringBuffer(BioModelTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), dbSyntax));
            sql.insert(7, Table.SQL_GLOBAL_HINT);
            rset = stmt.executeQuery(sql.toString());
            ArrayList<BioModelInfo> tempInfos = new ArrayList<BioModelInfo>();
            Set<String> distinctV = new HashSet<String>();
            while (rset.next()) {
                BioModelInfo versionInfo = (BioModelInfo) BioModelTable.table.getInfo(rset, con, dbSyntax);
                if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
                    tempInfos.add(versionInfo);
                    distinctV.add(versionInfo.getVersion().getVersionKey().toString());
                }
            }
            rset.close();
            if (tempInfos.size() > 0) {
                bioModelInfos = new BioModelInfo[tempInfos.size()];
                tempInfos.toArray(bioModelInfos);
            }
            if (lg.isInfoEnabled()) {
                lg.info("BioModelInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
            }
        }
        // 
        // MathModelInfos
        // 
        {
            double beginTime = System.currentTimeMillis();
            special = " ORDER BY " + MathModelTable.table.name.getQualifiedColName() + "," + MathModelTable.table.versionBranchID.getQualifiedColName() + "," + MathModelTable.table.versionDate.getQualifiedColName();
            sql = new StringBuffer(MathModelTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), dbSyntax));
            sql.insert(7, Table.SQL_GLOBAL_HINT);
            rset = stmt.executeQuery(sql.toString());
            ArrayList<MathModelInfo> tempInfos = new ArrayList<MathModelInfo>();
            Set<String> distinctV = new HashSet<String>();
            while (rset.next()) {
                MathModelInfo versionInfo = (MathModelInfo) MathModelTable.table.getInfo(rset, con, dbSyntax);
                if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
                    tempInfos.add(versionInfo);
                    distinctV.add(versionInfo.getVersion().getVersionKey().toString());
                }
            }
            rset.close();
            if (tempInfos.size() > 0) {
                mathModelInfos = new MathModelInfo[tempInfos.size()];
                tempInfos.toArray(mathModelInfos);
            }
            if (lg.isInfoEnabled()) {
                lg.info("MathModelInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
            }
        }
        // 
        // VCImageInfos
        // 
        {
            double beginTime = System.currentTimeMillis();
            special = " ORDER BY " + ImageTable.table.name.getQualifiedColName() + "," + ImageTable.table.versionBranchID.getQualifiedColName() + "," + ImageTable.table.versionDate.getQualifiedColName();
            sql = new StringBuffer(ImageTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), true, dbSyntax));
            sql.insert(7, Table.SQL_GLOBAL_HINT);
            rset = stmt.executeQuery(sql.toString());
            ArrayList<VCImageInfo> tempInfos = new ArrayList<VCImageInfo>();
            Set<String> distinctV = new HashSet<String>();
            while (rset.next()) {
                VCImageInfo versionInfo = (VCImageInfo) ImageTable.table.getInfo(rset, con, dbSyntax);
                if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
                    tempInfos.add(versionInfo);
                    distinctV.add(versionInfo.getVersion().getVersionKey().toString());
                }
            }
            rset.close();
            if (tempInfos.size() > 0) {
                vcImageInfos = new VCImageInfo[tempInfos.size()];
                tempInfos.toArray(vcImageInfos);
            }
            if (lg.isInfoEnabled()) {
                lg.info("ImageInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
            }
        }
        // 
        // GeometeryInfos
        // 
        {
            double beginTime = System.currentTimeMillis();
            special = " ORDER BY " + GeometryTable.table.name.getQualifiedColName() + "," + GeometryTable.table.versionBranchID.getQualifiedColName() + "," + GeometryTable.table.versionDate.getQualifiedColName();
            sql = new StringBuffer(GeometryTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), true, dbSyntax));
            sql.insert(7, Table.SQL_GLOBAL_HINT + (enableDistinct ? "DISTINCT " : ""));
            rset = stmt.executeQuery(sql.toString());
            ArrayList<GeometryInfo> tempInfos = new ArrayList<GeometryInfo>();
            Set<String> distinctV = new HashSet<String>();
            while (rset.next()) {
                GeometryInfo versionInfo = (GeometryInfo) GeometryTable.table.getInfo(rset, con);
                if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
                    tempInfos.add(versionInfo);
                    distinctV.add(versionInfo.getVersion().getVersionKey().toString());
                }
            }
            rset.close();
            if (tempInfos.size() > 0) {
                geometryInfos = new GeometryInfo[tempInfos.size()];
                tempInfos.toArray(geometryInfos);
            }
            if (lg.isInfoEnabled()) {
                lg.info("GeometryInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
            }
        }
    } finally {
        if (stmt != null) {
            stmt.close();
        }
    }
    results = new VCInfoContainer(user, vcImageInfos, geometryInfos, mathModelInfos, bioModelInfos);
    return results;
}
Also used : ResultSet(java.sql.ResultSet) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) BioModelInfo(org.vcell.util.document.BioModelInfo) ArrayList(java.util.ArrayList) MathModelInfo(org.vcell.util.document.MathModelInfo) VCInfoContainer(org.vcell.util.document.VCInfoContainer) GeometryInfo(cbit.vcell.geometry.GeometryInfo) ResultSet(java.sql.ResultSet) VCImageInfo(cbit.image.VCImageInfo)

Aggregations

VCImageInfo (cbit.image.VCImageInfo)17 DataAccessException (org.vcell.util.DataAccessException)10 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)6 VCImage (cbit.image.VCImage)4 GeometryInfo (cbit.vcell.geometry.GeometryInfo)4 GIFImage (cbit.image.GIFImage)3 ISize (org.vcell.util.ISize)3 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)3 BioModelInfo (org.vcell.util.document.BioModelInfo)3 MathModelInfo (org.vcell.util.document.MathModelInfo)3 User (org.vcell.util.document.User)3 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)2 Geometry (cbit.vcell.geometry.Geometry)2 MathException (cbit.vcell.math.MathException)2 ExpressionException (cbit.vcell.parser.ExpressionException)2 XmlParseException (cbit.vcell.xml.XmlParseException)2 Hashtable (java.util.Hashtable)2 Vector (java.util.Vector)2 BigString (org.vcell.util.BigString)2 KeyValue (org.vcell.util.document.KeyValue)2