Search in sources :

Example 11 with VCImageInfo

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

the class ClientDocumentManager method save.

/**
 * Insert the method's description here.
 * Creation date: (2/5/01 4:58:40 PM)
 */
public VCImage save(VCImage vcImage) throws DataAccessException {
    try {
        String vcImageXML = null;
        try {
            vcImageXML = XmlHelper.imageToXML(vcImage);
        } catch (XmlParseException e) {
            e.printStackTrace(System.out);
            throw new DataAccessException(e.getMessage());
        }
        String savedVCImageXML = sessionManager.getUserMetaDbServer().saveVCImage(new BigString(vcImageXML)).toString();
        VCImage savedVCImage = null;
        try {
            savedVCImage = XmlHelper.XMLToImage(savedVCImageXML);
        } catch (XmlParseException e) {
            e.printStackTrace(System.out);
            throw new DataAccessException(e.getMessage());
        }
        savedVCImage.refreshDependencies();
        KeyValue savedKey = savedVCImage.getVersion().getVersionKey();
        if (xmlHash.get(savedKey) == null) {
            xmlHash.put(savedKey, savedVCImageXML);
        }
        try {
            ISize size = new ISize(savedVCImage.getNumX(), savedVCImage.getNumY(), savedVCImage.getNumZ());
            GIFImage browseData = BrowseImage.makeBrowseGIFImage(savedVCImage);
            VCImageInfo savedVCImageInfo = new VCImageInfo(savedVCImage.getVersion(), size, savedVCImage.getExtent(), browseData, VCellSoftwareVersion.fromSystemProperty());
            imgInfoHash.put(savedKey, savedVCImageInfo);
            fireDatabaseInsert(new DatabaseEvent(this, DatabaseEvent.INSERT, null, savedVCImageInfo));
        } catch (Exception e) {
            e.printStackTrace(System.out);
        }
        return savedVCImage;
    } catch (RemoteProxyException e) {
        e.printStackTrace(System.out);
        throw new DataAccessException(VCellErrorMessages.FAIL_SAVE_MESSAGE + "\n\n" + e.getMessage());
    }
}
Also used : GIFImage(cbit.image.GIFImage) KeyValue(org.vcell.util.document.KeyValue) ISize(org.vcell.util.ISize) VCImage(cbit.image.VCImage) BigString(org.vcell.util.BigString) XmlParseException(cbit.vcell.xml.XmlParseException) BigString(org.vcell.util.BigString) DataAccessException(org.vcell.util.DataAccessException) VCImageInfo(cbit.image.VCImageInfo) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) XmlParseException(cbit.vcell.xml.XmlParseException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

Example 12 with VCImageInfo

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

the class VCellBasicCellRenderer method getTreeCellRendererComponent.

/**
 * Insert the method's description here.
 * Creation date: (7/27/2000 6:41:57 PM)
 * @return java.awt.Component
 */
public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    // 
    if (!leaf && expanded) {
        setIcon(fieldFolderOpenIcon);
    } else if (!leaf && !expanded) {
        setIcon(fieldFolderClosedIcon);
    }
    try {
        if (value instanceof BioModelNode) {
            BioModelNode node = (BioModelNode) value;
            boolean bLoaded = false;
            // 
            // Check if node is a SolverResultSetInfo
            // 
            Object userObject = node.getUserObject();
            if (userObject instanceof SimulationInfo) {
                // 
                // Check if node is a SimulationInfo
                // 
                setComponentProperties(component, (SimulationInfo) userObject);
                int maxErrorLevel = getMaxErrorLevel(node);
                if (maxErrorLevel == BioModelNode.ERROR_POSSIBLE) {
                    setIcon(fieldSimulationWarningIcon);
                    component.setToolTipText("Simulation contains possibly invalid results");
                } else if (maxErrorLevel == BioModelNode.ERROR_CONFIRMED) {
                    setIcon(fieldSimulationErrorIcon);
                    component.setToolTipText("Simulation contains invalid results");
                }
            } else if (userObject instanceof String && node.getChildCount() == 0) {
                component.setToolTipText(null);
                component.setText((String) userObject);
            } else if (userObject instanceof BioModelInfo) {
                // 
                // Check if node is a BioModelInfo
                // 
                setComponentProperties(component, (BioModelInfo) userObject);
                bLoaded = isLoaded((BioModelInfo) userObject);
                int maxErrorLevel = getMaxErrorLevel(node);
                if (maxErrorLevel == BioModelNode.ERROR_POSSIBLE) {
                    setIcon(fieldBioModelWarningIcon);
                    component.setToolTipText("BioModel version: Has possibly invalid simulation results");
                } else if (maxErrorLevel == BioModelNode.ERROR_CONFIRMED) {
                    setIcon(fieldBioModelErrorIcon);
                    component.setToolTipText("BioModel version: Has invalid simulation results");
                }
            } else if (userObject instanceof String && node.getChildCount() > 0 && ((BioModelNode) node.getChildAt(0)).getUserObject() instanceof BioModelInfo) {
                // 
                // Check if node is a BioModelName (String), with children (at least one version of biomodel), and if the child is a
                // BioModelInfo node
                // 
                String label = (String) userObject;
                component.setToolTipText("BioModel");
                component.setText(label);
                // 
                // check if child is loaded
                // 
                int maxErrorLevel = BioModelNode.ERROR_NONE;
                for (int i = 0; i < node.getChildCount(); i++) {
                    maxErrorLevel = Math.max(maxErrorLevel, getMaxErrorLevel((BioModelNode) node.getChildAt(i)));
                }
                if (maxErrorLevel == BioModelNode.ERROR_POSSIBLE) {
                    if (!leaf && expanded) {
                        setIcon(fieldFolderOpenWarningIcon);
                    } else if (!leaf && !expanded) {
                        setIcon(fieldFolderClosedWarningIcon);
                    }
                    component.setToolTipText("BioModel: one or more versions may have invalid simulation results");
                } else if (maxErrorLevel == BioModelNode.ERROR_CONFIRMED) {
                    if (!leaf && expanded) {
                        setIcon(fieldFolderOpenErrorIcon);
                    } else if (!leaf && !expanded) {
                        setIcon(fieldFolderClosedErrorIcon);
                    }
                    component.setToolTipText("BioModel: one or more versions have invalid simulation results");
                }
                // 
                for (int i = 0; i < node.getChildCount(); i++) {
                    BioModelInfo bioModelInfo = (BioModelInfo) ((BioModelNode) node.getChildAt(i)).getUserObject();
                    if (isLoaded(bioModelInfo)) {
                        bLoaded = true;
                    }
                }
            } else if (userObject instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof BioModelInfo) {
                // 
                // Check if node is a User, with at least one child which is a string (BioModel name)
                // and if the child's child is a BioModelInfo node
                // 
                String label = ((User) userObject).getName();
                component.setToolTipText("User Name");
                component.setText(label);
                if (isLoaded((User) userObject)) {
                    bLoaded = true;
                }
            } else if (userObject instanceof MathModelInfo) {
                // 
                // Check if node is a MathModelInfo node
                // 
                setComponentProperties(component, (MathModelInfo) userObject);
                bLoaded = isLoaded((MathModelInfo) userObject);
            } else if (userObject instanceof String && node.getChildCount() > 0 && ((BioModelNode) node.getChildAt(0)).getUserObject() instanceof MathModelInfo) {
                // 
                // Check if node is a MathModel name (String), with children (at least one version of mathmodel), and
                // if the child is a MathModelInfo node
                // 
                String label = (String) userObject;
                component.setToolTipText("Mathematical Model");
                component.setText(label);
                // 
                for (int i = 0; i < node.getChildCount(); i++) {
                    MathModelInfo mathModelInfo = (MathModelInfo) ((BioModelNode) node.getChildAt(i)).getUserObject();
                    if (isLoaded(mathModelInfo)) {
                        bLoaded = true;
                    }
                }
            } else if (userObject instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof MathModelInfo) {
                // 
                // Check if node is a User, with at least one child which is a string (Mathmodel name)
                // and if the child's child is a MathModelInfo node
                // 
                String label = ((User) userObject).getName();
                component.setToolTipText("User Name");
                component.setText(label);
                if (isLoaded((User) userObject)) {
                    bLoaded = true;
                }
            } else if (userObject instanceof cbit.vcell.geometry.GeometryInfo) {
                // 
                // Check if node is a GeometryInfo
                // 
                setComponentProperties(component, (GeometryInfo) userObject);
                bLoaded = isLoaded((GeometryInfo) userObject);
            } else if (userObject instanceof String && node.getChildCount() > 0 && ((BioModelNode) node.getChildAt(0)).getUserObject() instanceof GeometryInfo) {
                // 
                // Check if node is a Geometry name (String), with children (at least one version of Geometry), and
                // if the child is a GeometryInfo node
                // 
                String label = (String) userObject;
                component.setToolTipText("Geometry");
                component.setText(label);
                // 
                for (int i = 0; i < node.getChildCount(); i++) {
                    GeometryInfo geometryInfo = (GeometryInfo) ((BioModelNode) node.getChildAt(i)).getUserObject();
                    if (isLoaded(geometryInfo)) {
                        bLoaded = true;
                    }
                }
            } else if (userObject instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof GeometryInfo) {
                // 
                // Check if node is a User, with at least one child which is a string (Geometry name)
                // and if the child's child is a GeometryInfo node
                // 
                String label = ((User) userObject).getName();
                component.setToolTipText("User Name");
                component.setText(label);
                if (isLoaded((User) userObject)) {
                    bLoaded = true;
                }
            } else if (userObject instanceof String && node.getChildCount() > 0) {
                component.setToolTipText(null);
                component.setText((String) userObject);
            // }else if (node.getUserObject() instanceof MathInfo) {
            // setComponentProperties(component,(MathInfo)node.getUserObject());
            } else if (userObject instanceof VCImageInfo) {
                setComponentProperties(component, (VCImageInfo) userObject);
            } else if (userObject instanceof Extent) {
                setComponentProperties(component, (Extent) userObject);
            } else if (userObject instanceof Annotation) {
                setComponentProperties(component, (Annotation) userObject);
            } else if (userObject instanceof MathModel) {
                setComponentProperties(component, (MathModel) userObject);
            } else if (userObject instanceof BioModel) {
                setComponentProperties(component, (BioModel) userObject);
            } else if (userObject instanceof SimulationContext) {
                setComponentProperties(component, (SimulationContext) userObject);
                bLoaded = isLoaded((SimulationContext) userObject);
            } else if (userObject instanceof Simulation) {
                setComponentProperties(component, (Simulation) userObject);
            } else if (userObject instanceof MathDescription) {
                setComponentProperties(component, (MathDescription) userObject);
            } else if (userObject instanceof Geometry) {
                setComponentProperties(component, (Geometry) userObject);
            } else if (userObject instanceof User) {
                setComponentProperties(component, (User) userObject);
            } else {
                setComponentProperties(component, userObject);
            }
            if (selectedFont == null && component.getFont() != null) {
                selectedFont = component.getFont().deriveFont(Font.BOLD);
            }
            if (unselectedFont == null && component.getFont() != null) {
                unselectedFont = component.getFont().deriveFont(Font.PLAIN);
            }
            if (bLoaded) {
                component.setFont(selectedFont);
            } else {
                component.setFont(unselectedFont);
            }
        }
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
    // 
    return component;
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) User(org.vcell.util.document.User) Extent(org.vcell.util.Extent) MathDescription(cbit.vcell.math.MathDescription) BioModelInfo(org.vcell.util.document.BioModelInfo) JLabel(javax.swing.JLabel) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationContext(cbit.vcell.mapping.SimulationContext) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) GeometryInfo(cbit.vcell.geometry.GeometryInfo) VCImageInfo(cbit.image.VCImageInfo) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 13 with VCImageInfo

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

the class ImageDbTreeModel method createOwnerSubTree.

/**
 * Insert the method's description here.
 * Creation date: (11/28/00 1:06:51 PM)
 * @return cbit.vcell.desktop.BioModelNode
 * @param docManager cbit.vcell.clientdb.DocumentManager
 */
private BioModelNode createOwnerSubTree(User owner) throws DataAccessException {
    VCImageInfo[] imageInfos = getDocumentManager().getImageInfos();
    // 
    // for each user
    // 
    BioModelNode rootNode = new BioModelNode(owner, true);
    for (int i = 0; i < imageInfos.length; i++) {
        VCImageInfo imageInfo = imageInfos[i];
        if (imageInfo.getVersion().getOwner().equals(owner)) {
            BioModelNode bioModelNode = new BioModelNode(imageInfo.getVersion().getName(), true);
            rootNode.add(bioModelNode);
            // 
            // get list of images with the same branch
            // 
            Vector<VCImageInfo> imageBranchList = new Vector<VCImageInfo>();
            imageBranchList.addElement(imageInfo);
            for (i = i + 1; i < imageInfos.length; i++) {
                if (imageInfos[i].getVersion().getBranchID().equals(imageInfo.getVersion().getBranchID())) {
                    imageBranchList.add(0, imageInfos[i]);
                } else {
                    i--;
                    break;
                }
            }
            VCImageInfo[] imageInfosInBranch = null;
            if (getLatestOnly()) {
                imageInfosInBranch = new VCImageInfo[1];
                imageInfosInBranch[0] = (VCImageInfo) imageBranchList.elementAt(0);
            } else {
                imageInfosInBranch = new VCImageInfo[imageBranchList.size()];
                imageBranchList.copyInto(imageInfosInBranch);
            }
            for (int versionCount = 0; versionCount < imageInfosInBranch.length; versionCount++) {
                bioModelNode.add(createVersionSubTree(imageInfosInBranch[versionCount]));
            }
        }
    }
    return rootNode;
}
Also used : Vector(java.util.Vector) VCImageInfo(cbit.image.VCImageInfo)

Example 14 with VCImageInfo

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

the class ImageDbTreeModel method databaseDelete.

/**
 * @param event cbit.vcell.clientdb.DatabaseEvent
 */
public void databaseDelete(cbit.vcell.clientdb.DatabaseEvent databaseEvent) {
    if (databaseEvent.getOldVersionInfo() instanceof VCImageInfo) {
        VCImageInfo removedImageInfo = (VCImageInfo) databaseEvent.getOldVersionInfo();
        BioModelNode removedNode = ((BioModelNode) getRoot()).findNodeByUserObject(removedImageInfo);
        if (removedNode.getParent() != null && removedNode.getSiblingCount() == 1) {
            // just this one version
            removedNode = (BioModelNode) removedNode.getParent();
        }
        removeNodeFromParent(removedNode);
    }
}
Also used : VCImageInfo(cbit.image.VCImageInfo)

Example 15 with VCImageInfo

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

the class ImageDbTreeModel method databaseInsert.

/**
 * @param event cbit.vcell.clientdb.DatabaseEvent
 */
public void databaseInsert(cbit.vcell.clientdb.DatabaseEvent databaseEvent) {
    if (databaseEvent.getNewVersionInfo() instanceof VCImageInfo) {
        try {
            VCImageInfo insertedImageInfo = (VCImageInfo) databaseEvent.getNewVersionInfo();
            // 
            // get parent of updated version
            // 
            // model1                           (String)
            // Fri Sept 2, 2001 12:00:00     (VCImageInfo)
            // Fri Sept 1, 2001 10:00:00     (VCImageInfo)
            // 
            // 
            BioModelNode newVersionNode = createVersionSubTree(insertedImageInfo);
            BioModelNode parentNode = ((BioModelNode) getRoot()).findNodeByUserObject(insertedImageInfo.getVersion().getName());
            if (parentNode == null) {
                // 
                // fresh insert
                // Have to create parent node, for all versions of this image,
                // and stick it in the correct order in the tree.
                // 
                parentNode = new BioModelNode(insertedImageInfo.getVersion().getName(), true);
                parentNode.insert(newVersionNode, 0);
                // 
                // find owner node (if it is displayed)
                // 
                User owner = insertedImageInfo.getVersion().getOwner();
                BioModelNode ownerRoot = ((BioModelNode) getRoot()).findNodeByUserObject(owner);
                // 
                if (ownerRoot != null) {
                    // !!!!!!!!!!!!!! new insert on top (index=0) .... should do insertion sort !!!!
                    ownerRoot.insert(parentNode, 0);
                    insertNodeInto(parentNode, ownerRoot, 0);
                }
            } else {
                // 
                // already versions there (just add child in the correct position within parent)
                // 
                // !!!!!!!!!! right now ignore order !!!!!!!!!!
                parentNode.insert(newVersionNode, 0);
                insertNodeInto(newVersionNode, parentNode, 0);
            }
        } catch (DataAccessException e) {
            e.printStackTrace(System.out);
            System.out.println("exception responding to databaseInsert(), refreshing whole tree");
            refreshTree();
        }
    }
}
Also used : User(org.vcell.util.document.User) VCImageInfo(cbit.image.VCImageInfo) DataAccessException(org.vcell.util.DataAccessException)

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