Search in sources :

Example 31 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class ChooseFile method run.

/**
 * Insert the method's description here.
 * Creation date: (5/31/2004 6:04:14 PM)
 * @param hashTable java.util.Hashtable
 * @param clientWorker cbit.vcell.desktop.controls.ClientWorker
 */
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
    VCDocument documentToExport = fetch(hashTable, DocumentToExport.EXPORT_DOCUMENT, VCDocument.class, true);
    File exportFile = null;
    if (documentToExport instanceof BioModel) {
        exportFile = showBioModelXMLFileChooser(hashTable);
    } else if (documentToExport instanceof MathModel) {
        exportFile = showMathModelXMLFileChooser(hashTable);
    } else if (documentToExport instanceof Geometry) {
        exportFile = showGeometryModelXMLFileChooser(hashTable);
    } else {
        throw new Exception("Unsupported document type for XML export: " + documentToExport.getClass());
    }
    // check to see if we've changed extension from what user entered
    if (extensionUserProvided != null && !extensionUserProvided.isEmpty()) {
        String fp = exportFile.getAbsolutePath();
        String currentExt = FilenameUtils.getExtension(fp);
        if (!extensionUserProvided.equals(currentExt)) {
            hashTable.put(RENAME_KEY, fp);
        }
    }
    hashTable.put(EXPORT_FILE, exportFile);
}
Also used : Geometry(cbit.vcell.geometry.Geometry) MathModel(cbit.vcell.mathmodel.MathModel) VCDocument(org.vcell.util.document.VCDocument) BioModel(cbit.vcell.biomodel.BioModel) File(java.io.File) UserCancelException(org.vcell.util.UserCancelException)

Example 32 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class ExportDocument method run.

/**
 * Insert the method's description here.
 * Creation date: (5/31/2004 6:04:14 PM)
 * @param hashTable java.util.Hashtable
 * @param clientWorker cbit.vcell.desktop.controls.ClientWorker
 */
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
    VCDocument documentToExport = (VCDocument) hashTable.get("documentToExport");
    File exportFile = fetch(hashTable, EXPORT_FILE, File.class, true);
    ExtensionFilter fileFilter = fetch(hashTable, FILE_FILTER, ExtensionFilter.class, true);
    DocumentManager documentManager = fetch(hashTable, DocumentManager.IDENT, DocumentManager.class, true);
    String resultString = null;
    FileCloseHelper closeThis = null;
    try {
        if (documentToExport instanceof BioModel) {
            if (!(fileFilter instanceof SelectorExtensionFilter)) {
                throw new Exception("Expecting fileFilter type " + SelectorExtensionFilter.class.getName() + " but got " + fileFilter.getClass().getName());
            }
            BioModel bioModel = (BioModel) documentToExport;
            SimulationContext chosenSimContext = fetch(hashTable, SIM_CONTEXT, SimulationContext.class, false);
            ((SelectorExtensionFilter) fileFilter).writeBioModel(documentManager, bioModel, exportFile, chosenSimContext);
        /*		DELETE this after finishing validation testing
			
			// check format requested
			if (fileFilter.getDescription().equals(FileFilters.FILE_FILTER_MATLABV6.getDescription())){
				// matlab from application; get application
		
				SimulationContext chosenSimContext = fetch(hashTable,SIM_CONTEXT,SimulationContext.class, true);
				// regenerate a fresh MathDescription
				MathMapping mathMapping = chosenSimContext.createNewMathMapping();
				MathDescription mathDesc = mathMapping.getMathDescription();
				if(mathDesc != null && !mathDesc.isSpatial() && !mathDesc.isNonSpatialStoch()){
					// do export
					resultString = exportMatlab(exportFile, fileFilter, mathDesc);
				}else{
					throw new Exception("Matlab export failed: NOT an non-spatial deterministic application!");
				}
			} else if (fileFilter.equals(FileFilters.FILE_FILTER_PDF)) {   
				FileOutputStream fos = null;
				try {
					fos = new FileOutputStream(exportFile);
					documentManager.generatePDF(bioModel, fos);				
				} finally {
					if(fos != null) {
						fos.close();					
					}
				}
				return; 									//will take care of writing to the file as well.
			}
			//Export a simulation to Smoldyn input file, if there are parameter scans
			//in simulation, we'll export multiple Smoldyn input files.
			else if (fileFilter.equals(FileFilters.FILE_FILTER_SMOLDYN_INPUT)) 
			{ 
				Simulation selectedSim = (Simulation)hashTable.get("selectedSimulation");
				if (selectedSim != null) {
					int scanCount = selectedSim.getScanCount();
					if(scanCount > 1) // has parameter scan
					{
						String baseExportFileName = exportFile.getPath().substring(0, exportFile.getPath().indexOf("."));
						for(int i=0; i<scanCount; i++)
						{
							SimulationTask simTask = new SimulationTask(new SimulationJob(selectedSim, i, null),0);
							// Need to export each parameter scan into a separate file
							String newExportFileName = baseExportFileName + "_" + i + SMOLDYN_INPUT_FILE_EXTENSION;
							exportFile = new File(newExportFileName);
							
							PrintWriter pw = new PrintWriter(exportFile);
							SmoldynFileWriter smf = new SmoldynFileWriter(pw, true, null, simTask, false);
							smf.write();
							pw.close();	
						}
					}
					else if(scanCount == 1)// regular simulation, no parameter scan
					{
						SimulationTask simTask = new SimulationTask(new SimulationJob(selectedSim, 0, null),0);
						// export the simulation to the selected file
						PrintWriter pw = new PrintWriter(exportFile);
						SmoldynFileWriter smf = new SmoldynFileWriter(pw, true, null, simTask, false);
						smf.write();
						pw.close();
					}
					else
					{
						throw new Exception("Simulation scan count is smaller than 1.");
					}
				}
				return;
													
			} else {
				// convert it if other format
				if (!fileFilter.equals(FileFilters.FILE_FILTER_VCML)) {
					// SBML or CellML; get application name
					if ((fileFilter.equals(FileFilters.FILE_FILTER_SBML_12)) || (fileFilter.equals(FileFilters.FILE_FILTER_SBML_21)) || 
						(fileFilter.equals(FileFilters.FILE_FILTER_SBML_22)) || (fileFilter.equals(FileFilters.FILE_FILTER_SBML_23)) || 
						(fileFilter.equals(FileFilters.FILE_FILTER_SBML_24)) || (fileFilter.equals(FileFilters.FILE_FILTER_SBML_31_CORE)) || 
						(fileFilter.equals(FileFilters.FILE_FILTER_SBML_31_SPATIAL)) ) {
						SimulationContext selectedSimContext = (SimulationContext)hashTable.get("selectedSimContext");
						Simulation selectedSim = (Simulation)hashTable.get("selectedSimulation");
						int sbmlLevel = 0;
						int sbmlVersion = 0;
						int sbmlPkgVersion = 0;
						boolean bIsSpatial = false;
						if ((fileFilter.equals(FileFilters.FILE_FILTER_SBML_12))) {
							sbmlLevel = 1;
							sbmlVersion = 2;
						} else if (fileFilter.equals(FileFilters.FILE_FILTER_SBML_21)) {
							sbmlLevel = 2;
							sbmlVersion = 1;
						} else if (fileFilter.equals(FileFilters.FILE_FILTER_SBML_22)) {
							sbmlLevel = 2;
							sbmlVersion = 2;
						} else if (fileFilter.equals(FileFilters.FILE_FILTER_SBML_23)) {
							sbmlLevel = 2;
							sbmlVersion = 3;
						} else if (fileFilter.equals(FileFilters.FILE_FILTER_SBML_24)) {
							sbmlLevel = 2;
							sbmlVersion = 4;
						} else if (fileFilter.equals(FileFilters.FILE_FILTER_SBML_31_CORE)) {
							sbmlLevel = 3;
							sbmlVersion = 1;
						} else if (fileFilter.equals(FileFilters.FILE_FILTER_SBML_31_SPATIAL)) {
							sbmlLevel = 3;
							sbmlVersion = 1;
							sbmlPkgVersion = 1;
							bIsSpatial = true;
						}
						if (selectedSim == null) {
							resultString = XmlHelper.exportSBML(bioModel, sbmlLevel, sbmlVersion, sbmlPkgVersion, bIsSpatial, selectedSimContext, null);
							XmlUtil.writeXMLStringToFile(resultString, exportFile.getAbsolutePath(), true);
							return;
						} else {
							for (int sc = 0; sc < selectedSim.getScanCount(); sc++) {
								SimulationJob simJob = new SimulationJob(selectedSim, sc, null);
								resultString = XmlHelper.exportSBML(bioModel, sbmlLevel, sbmlVersion, sbmlPkgVersion, bIsSpatial, selectedSimContext, simJob);
								// Need to export each parameter scan into a separate file 
								String newExportFileName = exportFile.getPath().substring(0, exportFile.getPath().indexOf(".xml")) + "_" + sc + ".xml";
								exportFile.renameTo(new File(newExportFileName));
								XmlUtil.writeXMLStringToFile(resultString, exportFile.getAbsolutePath(), true);
							}
							return;
						}
					} else if (fileFilter.equals(FileFilters.FILE_FILTER_BNGL)) {
						RbmModelContainer rbmModelContainer = bioModel.getModel().getRbmModelContainer();
						StringWriter bnglStringWriter = new StringWriter();
						PrintWriter pw = new PrintWriter(bnglStringWriter);
						RbmNetworkGenerator.writeBngl(bioModel, pw);
						resultString = bnglStringWriter.toString();
						pw.close();
						
					} else if (fileFilter.equals(FileFilters.FILE_FILTER_NFSIM)) {
						// TODO: get the first thing we find for now, in the future we'll need to modify ChooseFile 
						//       to only offer the applications / simulations with bngl content
						SimulationContext simContexts[] = bioModel.getSimulationContexts();
						SimulationContext aSimulationContext = simContexts[0];
						Simulation selectedSim = aSimulationContext.getSimulations(0);
						//Simulation selectedSim = (Simulation)hashTable.get("selectedSimulation");
						SimulationTask simTask = new SimulationTask(new SimulationJob(selectedSim, 0, null),0);
						long randomSeed = 0;	// a fixed seed will allow us to run reproducible simulations
						//long randomSeed = System.currentTimeMillis();
						NFsimSimulationOptions nfsimSimulationOptions = new NFsimSimulationOptions();
						// we get the data we need from the math description
						Element root = NFsimXMLWriter.writeNFsimXML(simTask, randomSeed, nfsimSimulationOptions);
						Document doc = new Document();
						doc.setRootElement(root);
						XMLOutputter xmlOut = new XMLOutputter();
						resultString = xmlOut.outputString(doc);
	
					} else if (fileFilter.equals(FileFilters.FILE_FILTER_CELLML)) {
						Integer chosenSimContextIndex = (Integer)hashTable.get("chosenSimContextIndex");
						String applicationName = bioModel.getSimulationContext(chosenSimContextIndex.intValue()).getName();
						resultString = XmlHelper.exportCellML(bioModel, applicationName);
						// cellml still uses default character encoding for now ... maybe UTF-8 in the future
					} else if (fileFilter.equals(FileFilters.FILE_FILTER_SEDML)) {
						// export the entire biomodel to a SEDML file (for now, only non-spatial,non-stochastic applns)
						int sedmlLevel = 1;
						int sedmlVersion = 1;
						String sPath = FileUtils.getFullPathNoEndSeparator(exportFile.getAbsolutePath());
						String sFile = FileUtils.getBaseName(exportFile.getAbsolutePath());
						String sExt = FileUtils.getExtension(exportFile.getAbsolutePath());
						
						SEDMLExporter sedmlExporter = null;
						if (bioModel instanceof BioModel) {
							sedmlExporter = new SEDMLExporter(bioModel, sedmlLevel, sedmlVersion);
							resultString = sedmlExporter.getSEDMLFile(sPath);
						} else {
							throw new RuntimeException("unsupported Document Type " + bioModel.getClass().getName() + " for SedML export");
						}
						if(sExt.equals("sedx")) {
							sedmlExporter.createManifest(sPath, sFile);
							String sedmlFileName = sPath + FileUtils.WINDOWS_SEPARATOR + sFile + ".sedml";
							XmlUtil.writeXMLStringToFile(resultString, sedmlFileName, true);
							sedmlExporter.addSedmlFileToList(sFile + ".sedml");
							sedmlExporter.addSedmlFileToList("manifest.xml");
							sedmlExporter.createZipArchive(sPath, sFile);
							return;
						} else {
							XmlUtil.writeXMLStringToFile(resultString, exportFile.getAbsolutePath(), true);
						}
					}
				} else {
					// if format is VCML, get it from biomodel.
					bioModel.getVCMetaData().cleanupMetadata();
					resultString = XmlHelper.bioModelToXML(bioModel);
					XmlUtil.writeXMLStringToFile(resultString, exportFile.getAbsolutePath(), true);
					return;
				}
			}*/
        } else if (documentToExport instanceof MathModel) {
            MathModel mathModel = (MathModel) documentToExport;
            // check format requested
            if (fileFilter.equals(FileFilters.FILE_FILTER_MATLABV6)) {
                // check if it's ODE
                if (mathModel.getMathDescription() != null && (!mathModel.getMathDescription().isSpatial() && !mathModel.getMathDescription().isNonSpatialStoch())) {
                    MathDescription mathDesc = mathModel.getMathDescription();
                    resultString = exportMatlab(exportFile, fileFilter, mathDesc);
                } else {
                    throw new Exception("Matlab export failed: NOT an non-spatial deterministic model.");
                }
            } else if (fileFilter.equals(FileFilters.FILE_FILTER_PDF)) {
                FileOutputStream fos = new FileOutputStream(exportFile);
                documentManager.generatePDF(mathModel, fos);
                fos.close();
                // will take care of writing to the file as well.
                return;
            } else if (fileFilter.equals(FileFilters.FILE_FILTER_VCML)) {
                resultString = XmlHelper.mathModelToXML(mathModel);
            } else if (fileFilter.equals(FileFilters.FILE_FILTER_CELLML)) {
                resultString = XmlHelper.exportCellML(mathModel, null);
            } else if (fileFilter.equals(FileFilters.FILE_FILTER_SBML_23)) {
                resultString = XmlHelper.exportSBML(mathModel, 2, 3, 0, false, null, null);
            } else if (fileFilter.equals(FileFilters.FILE_FILTER_SBML_24)) {
                resultString = XmlHelper.exportSBML(mathModel, 2, 4, 0, false, null, null);
            } else // in simulation, we'll export multiple Smoldyn input files.
            if (fileFilter.equals(FileFilters.FILE_FILTER_SMOLDYN_INPUT)) {
                Simulation selectedSim = (Simulation) hashTable.get("selectedSimulation");
                if (selectedSim != null) {
                    int scanCount = selectedSim.getScanCount();
                    // -----
                    String baseExportFileName = (scanCount == 1 ? null : exportFile.getPath().substring(0, exportFile.getPath().indexOf(".")));
                    for (int i = 0; i < scanCount; i++) {
                        SimulationTask simTask = new SimulationTask(new SimulationJob(selectedSim, i, null), 0);
                        // Need to export each parameter scan into a separate file
                        File localExportFile = (scanCount == 1 ? exportFile : new File(baseExportFileName + "_" + i + SMOLDYN_INPUT_FILE_EXTENSION));
                        FileCloseHelper localCloseThis = new FileCloseHelper(localExportFile);
                        try {
                            SmoldynFileWriter smf = new SmoldynFileWriter(localCloseThis.getPrintWriter(), true, null, simTask, false);
                            smf.write();
                        } finally {
                            if (localCloseThis != null) {
                                localCloseThis.close();
                            }
                        }
                    }
                }
                return;
            }
        } else if (documentToExport instanceof Geometry) {
            Geometry geom = (Geometry) documentToExport;
            if (fileFilter.equals(FileFilters.FILE_FILTER_PDF)) {
                documentManager.generatePDF(geom, (closeThis = new FileCloseHelper(exportFile)).getFileOutputStream());
            } else if (fileFilter.equals(FileFilters.FILE_FILTER_VCML)) {
                resultString = XmlHelper.geometryToXML(geom);
            } else if (fileFilter.equals(FileFilters.FILE_FILTER_AVS)) {
                cbit.vcell.export.AVS_UCD_Exporter.writeUCDGeometryOnly(geom.getGeometrySurfaceDescription(), (closeThis = new FileCloseHelper(exportFile)).getFileWriter());
            } else if (fileFilter.equals(FileFilters.FILE_FILTER_STL)) {
                // make sure filename end with .stl
                File stlFile = exportFile;
                if (!exportFile.getName().toLowerCase().endsWith(".stl")) {
                    stlFile = new File(exportFile.getParentFile(), exportFile.getName() + ".stl");
                }
                cbit.vcell.geometry.surface.StlExporter.writeBinaryStl(geom.getGeometrySurfaceDescription(), (closeThis = new FileCloseHelper(stlFile)).getRandomAccessFile("rw"));
            } else if (fileFilter.equals(FileFilters.FILE_FILTER_PLY)) {
                writeStanfordPolygon(geom.getGeometrySurfaceDescription(), (closeThis = new FileCloseHelper(exportFile)).getFileWriter());
            }
        }
        if (resultString != null) {
            (closeThis = new FileCloseHelper(exportFile)).getFileWriter().write(resultString);
        }
    } finally {
        if (closeThis != null) {
            closeThis.close();
        }
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) SimulationTask(cbit.vcell.messaging.server.SimulationTask) VCDocument(org.vcell.util.document.VCDocument) SmoldynFileWriter(org.vcell.solver.smoldyn.SmoldynFileWriter) MathDescription(cbit.vcell.math.MathDescription) DocumentManager(cbit.vcell.clientdb.DocumentManager) SelectorExtensionFilter(org.vcell.util.gui.exporter.SelectorExtensionFilter) SimulationContext(cbit.vcell.mapping.SimulationContext) IOException(java.io.IOException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) ExtensionFilter(org.vcell.util.gui.exporter.ExtensionFilter) SelectorExtensionFilter(org.vcell.util.gui.exporter.SelectorExtensionFilter) BioModel(cbit.vcell.biomodel.BioModel) FileOutputStream(java.io.FileOutputStream) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) SimulationJob(cbit.vcell.solver.SimulationJob)

Example 33 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class FieldDataGUIPanel method getJButtonCreateGeom.

/**
 * This method initializes jButtonCopyInfo
 *
 * @return javax.swing.JButton
 */
private JButton getJButtonCreateGeom() {
    if (jButtonCreateGeom == null) {
        jButtonCreateGeom = new JButton();
        jButtonCreateGeom.setEnabled(false);
        jButtonCreateGeom.setText("Create Geom");
        jButtonCreateGeom.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                try {
                    RequestManager clientRequestManager = fieldDataWindowManager.getLocalRequestManager();
                    javax.swing.tree.TreePath selPath = getJTree1().getSelectionPath();
                    javax.swing.tree.DefaultMutableTreeNode lastPathComponent = (javax.swing.tree.DefaultMutableTreeNode) selPath.getLastPathComponent();
                    if (lastPathComponent.getUserObject() instanceof FieldDataVarList) {
                        DataIdentifier dataIdentifier = ((FieldDataVarList) lastPathComponent.getUserObject()).dataIdentifier;
                        TreePath ppPath = selPath.getParentPath().getParentPath();
                        javax.swing.tree.DefaultMutableTreeNode ppLastPathComp = (javax.swing.tree.DefaultMutableTreeNode) ppPath.getLastPathComponent();
                        if (ppLastPathComp.getUserObject() instanceof FieldDataMainList) {
                            ExternalDataIdentifier extDataID = ((FieldDataMainList) ppLastPathComp.getUserObject()).externalDataIdentifier;
                            final OpenModelInfoHolder openModelInfoHolder = FieldDataWindowManager.selectOpenModelsFromDesktop(FieldDataGUIPanel.this, fieldDataWindowManager.getRequestManager(), false, "Select BioModel or MathModel to receive new geometry", false);
                            if (openModelInfoHolder == null) {
                                DialogUtils.showErrorDialog(FieldDataGUIPanel.this, "Before proceeding, please open a Biomodel application or Mathmodel you wish to apply a new Field Data Geometry to");
                                return;
                            }
                            AsynchClientTask applyGeomTask = new AsynchClientTask("apply geometry", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

                                @Override
                                public void run(Hashtable<String, Object> hashTable) throws Exception {
                                    Geometry newGeom = (Geometry) hashTable.get("doc");
                                    final String OK_OPTION = "Ok";
                                    if (openModelInfoHolder instanceof FDSimMathModelInfo) {
                                        Version version = ((FDSimMathModelInfo) openModelInfoHolder).getMathModelVersion();
                                        String modelName = (version == null ? "NoName" : version.getName());
                                        if (newGeom.getName() == null) {
                                            newGeom.setName(modelName + "_" + BeanUtils.generateDateTimeString());
                                        }
                                        String message = "Confirm Setting new FieldData derived geometry on MathModel '" + modelName + "'";
                                        if (DialogUtils.showWarningDialog(FieldDataGUIPanel.this, message, new String[] { OK_OPTION, "Cancel" }, OK_OPTION).equals(OK_OPTION)) {
                                            ((FDSimMathModelInfo) openModelInfoHolder).getMathDescription().setGeometry(newGeom);
                                        }
                                    } else if (openModelInfoHolder instanceof FDSimBioModelInfo) {
                                        Version version = ((FDSimBioModelInfo) openModelInfoHolder).getBioModelVersion();
                                        String modelName = (version == null ? "NoName" : version.getName());
                                        String simContextName = ((FDSimBioModelInfo) openModelInfoHolder).getSimulationContext().getName();
                                        if (newGeom.getName() == null) {
                                            newGeom.setName(modelName + "_" + simContextName + "_" + BeanUtils.generateDateTimeString());
                                        }
                                        String message = "Confirm Setting new FieldData derived geometry on BioModel '" + modelName + "' , Application '" + simContextName + "'";
                                        if (DialogUtils.showWarningDialog(FieldDataGUIPanel.this, message, new String[] { OK_OPTION, "Cancel" }, OK_OPTION).equals(OK_OPTION)) {
                                            ((FDSimBioModelInfo) openModelInfoHolder).getSimulationContext().setGeometry(newGeom);
                                        }
                                    }
                                }
                            };
                            VCDocument.GeomFromFieldDataCreationInfo geomFromFieldDataCreationInfo = new VCDocument.GeomFromFieldDataCreationInfo(extDataID, dataIdentifier.getName());
                            AsynchClientTask[] createGeomTask = clientRequestManager.createNewGeometryTasks(fieldDataWindowManager, geomFromFieldDataCreationInfo, new AsynchClientTask[] { applyGeomTask }, "Apply Geometry");
                            Hashtable<String, Object> hash = new Hashtable<String, Object>();
                            hash.put(ClientRequestManager.GUI_PARENT, fieldDataWindowManager.getComponent());
                            ClientTaskDispatcher.dispatch(FieldDataGUIPanel.this, hash, createGeomTask, false, false, null, true);
                        }
                    }
                } catch (UserCancelException e1) {
                // ignore
                } catch (Exception e1) {
                    e1.printStackTrace();
                    DialogUtils.showErrorDialog(FieldDataGUIPanel.this, e1.getMessage());
                }
            // jButtonFDCopyRef_ActionPerformed(e);
            // fieldDataWindowManager.newDocument(VCDocument.GEOMETRY_DOC, option);
            // copyMethod(COPY_CRNL);
            // //				javax.swing.tree.TreePath selPath = getJTree1().getSelectionPath();
            // //				if(selPath != null){
            // //					javax.swing.tree.DefaultMutableTreeNode lastPathComponent = (javax.swing.tree.DefaultMutableTreeNode)selPath.getLastPathComponent();
            // //					copyMethod(lastPathComponent, copyMode);
            // //				}
            // //					String copyString = "";
            // //					javax.swing.tree.DefaultMutableTreeNode lastPathComponent = (javax.swing.tree.DefaultMutableTreeNode)selPath.getLastPathComponent();
            // //					if(lastPathComponent.equals(getJTree1().getModel().getRoot())){
            // //						int childCount = lastPathComponent.getChildCount();
            // //						for(int i=0;i<childCount;i+= 1){
            // //							if(i != 0){
            // //								copyString+="\n";
            // //							}
            // //							copyString+=
            // //								((FieldDataMainList)((DefaultMutableTreeNode)lastPathComponent.getChildAt(i)).getUserObject()).externalDataIdentifier.getName();
            // //						}
            // //					}else if(lastPathComponent.getUserObject() instanceof FieldDataOriginList){
            // //						Origin origin = ((FieldDataOriginList)lastPathComponent.getUserObject()).origin;
            // //						copyString = origin.getX()+","+origin.getY()+","+origin.getZ();
            // //					}else if(lastPathComponent.getUserObject() instanceof FieldDataExtentList){
            // //						Extent extent = ((FieldDataExtentList)lastPathComponent.getUserObject()).extent;
            // //						copyString = extent.getX()+","+extent.getY()+","+extent.getZ();
            // //					}else if(lastPathComponent.getUserObject() instanceof FieldDataISizeList){
            // //						ISize isize = ((FieldDataISizeList)lastPathComponent.getUserObject()).isize;
            // //						copyString = isize.getX()+","+isize.getY()+","+isize.getZ();
            // //					}else if(lastPathComponent.getUserObject() instanceof FieldDataTimeList){
            // //						double[] times = ((FieldDataTimeList)lastPathComponent.getUserObject()).times;
            // //						for(int i=0;i<times.length;i+= 1){
            // //							if(i != 0){
            // //								copyString+="\n";
            // //							}
            // //							copyString+= times[i]+"";
            // //						}
            // //					}else if(lastPathComponent.getUserObject() instanceof FieldDataMainList){
            // //						ExternalDataIdentifier extDataID =
            // //							((FieldDataMainList)lastPathComponent.getUserObject()).externalDataIdentifier;
            // //						copyString = extDataID.getName();
            // //					}else if(lastPathComponent.getUserObject() instanceof FieldDataVarList){
            // //						DataIdentifier dataIdentifier =
            // //							((FieldDataVarList)lastPathComponent.getUserObject()).dataIdentifier;
            // //						copyString = dataIdentifier.getName();
            // //					}else if(lastPathComponent.getUserObject() instanceof FieldDataVarMainList){
            // //						int childCount = lastPathComponent.getChildCount();
            // //						for(int i=0;i<childCount;i+= 1){
            // //							if(i != 0){
            // //								copyString+="\n";
            // //							}
            // //							copyString+=
            // //								((FieldDataVarList)((DefaultMutableTreeNode)lastPathComponent.getChildAt(i)).getUserObject()).dataIdentifier.getName();
            // //						}
            // //					}
            // //					if(copyString.length() > 0 ){
            // //						VCellTransferable.sendToClipboard(copyString);
            // //					}
            // //				}
            }
        });
    }
    return jButtonCreateGeom;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) ActionListener(java.awt.event.ActionListener) DataIdentifier(cbit.vcell.simdata.DataIdentifier) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JButton(javax.swing.JButton) UserCancelException(org.vcell.util.UserCancelException) RequestManager(cbit.vcell.client.RequestManager) ClientRequestManager(cbit.vcell.client.ClientRequestManager) Version(org.vcell.util.document.Version) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) VCDocument(org.vcell.util.document.VCDocument) Hashtable(java.util.Hashtable) FDSimMathModelInfo(cbit.vcell.client.TopLevelWindowManager.FDSimMathModelInfo) OpenModelInfoHolder(cbit.vcell.client.TopLevelWindowManager.OpenModelInfoHolder) ActionEvent(java.awt.event.ActionEvent) DataFormatException(java.util.zip.DataFormatException) UserCancelException(org.vcell.util.UserCancelException) Geometry(cbit.vcell.geometry.Geometry) TreePath(javax.swing.tree.TreePath) FDSimBioModelInfo(cbit.vcell.client.TopLevelWindowManager.FDSimBioModelInfo)

Example 34 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class CurveRendererGeometry method setGeometry.

/**
 * Sets the geometry property (cbit.vcell.geometry.Geometry) value.
 * @param geometry The new value for the property.
 * @see #getGeometry
 */
public void setGeometry(Geometry geometry) {
    if (geometry != null && geometry.getDimension() == 0) {
        geometry = null;
    }
    if (geometry == null) {
        setWorldDelta(null);
        setWorldOrigin(null);
    }
    Geometry oldValue = fieldGeometry;
    if (oldValue != null) {
        oldValue.getGeometrySpec().getFilamentGroup().removePropertyChangeListener(this);
    }
    fieldGeometry = geometry;
    firePropertyChange(GEOMETRY_PROPERTY, oldValue, fieldGeometry);
    // 
    if (geometry != null) {
        fieldGeometry.getGeometrySpec().getFilamentGroup().addPropertyChangeListener(FilamentGroup.FILAMENT_GROUP_PROPERTY, this);
        firePropertyChange(CURVES_VALID, null, new Boolean(true));
    } else {
        firePropertyChange(CURVES_VALID, null, new Boolean(false));
    }
    // 
    updateCurves();
}
Also used : Geometry(cbit.vcell.geometry.Geometry)

Example 35 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class GeometryFilamentCurvePanel method setGeometry1.

/**
 * Set the Geometry1 to a new value.
 * @param newValue cbit.vcell.geometry.Geometry
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void setGeometry1(cbit.vcell.geometry.Geometry newValue) {
    if (ivjGeometry1 != newValue) {
        try {
            cbit.vcell.geometry.Geometry oldValue = getGeometry1();
            ivjGeometry1 = newValue;
            connPtoP2SetSource();
            firePropertyChange("geometry", oldValue, newValue);
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    ;
// user code begin {3}
// user code end
}
Also used : Geometry(cbit.vcell.geometry.Geometry)

Aggregations

Geometry (cbit.vcell.geometry.Geometry)121 MathDescription (cbit.vcell.math.MathDescription)32 SimulationContext (cbit.vcell.mapping.SimulationContext)31 Simulation (cbit.vcell.solver.Simulation)29 PropertyVetoException (java.beans.PropertyVetoException)24 BioModel (cbit.vcell.biomodel.BioModel)23 DataAccessException (org.vcell.util.DataAccessException)23 VCImage (cbit.image.VCImage)22 SubVolume (cbit.vcell.geometry.SubVolume)21 MathModel (cbit.vcell.mathmodel.MathModel)21 Expression (cbit.vcell.parser.Expression)19 ISize (org.vcell.util.ISize)19 Hashtable (java.util.Hashtable)18 GeometryThumbnailImageFactoryAWT (cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT)17 UserCancelException (org.vcell.util.UserCancelException)17 KeyValue (org.vcell.util.document.KeyValue)17 ImageException (cbit.image.ImageException)16 Extent (org.vcell.util.Extent)16 SurfaceClass (cbit.vcell.geometry.SurfaceClass)15 ExpressionException (cbit.vcell.parser.ExpressionException)15