use of org.vcell.model.rbm.ComponentStateDefinition in project vcell by virtualcell.
the class MolecularTypeTreeModel method valueForPathChanged.
@Override
public void valueForPathChanged(TreePath path, Object newValue) {
Object obj = path.getLastPathComponent();
if (obj == null || !(obj instanceof BioModelNode)) {
return;
}
BioModelNode selectedNode = (BioModelNode) obj;
Object userObject = selectedNode.getUserObject();
try {
if (newValue instanceof String) {
String inputString = (String) newValue;
if (inputString == null || inputString.length() == 0) {
return;
}
if (userObject instanceof MolecularType) {
String mangled = TokenMangler.fixTokenStrict(inputString);
if (!mangled.equals(inputString)) {
String errMsg = ((Displayable) userObject).getDisplayType() + " '" + inputString + "' not legal identifier, try '" + mangled + "'";
throw new RuntimeException(errMsg);
}
((MolecularType) userObject).setName(inputString);
} else if (userObject instanceof MolecularComponent) {
String mangled = TokenMangler.fixTokenStrict(inputString);
if (!mangled.equals(inputString)) {
String errMsg = ((Displayable) userObject).getDisplayType() + " '" + inputString + "' not legal identifier, try '" + mangled + "'";
throw new RuntimeException(errMsg);
}
((MolecularComponent) userObject).setName(inputString);
} else if (userObject instanceof ComponentStateDefinition) {
if (inputString.matches("[A-Z_a-z0-9]+")) {
((ComponentStateDefinition) userObject).setName(inputString);
}
}
}
} catch (Exception ex) {
DialogUtils.showErrorDialog(ownerTree, ex.getMessage());
}
}
use of org.vcell.model.rbm.ComponentStateDefinition in project vcell by virtualcell.
the class IssueTableModel method getSourceObjectDescription.
private String getSourceObjectDescription(VCDocument vcDocument, Issue issue) {
if (vcDocument instanceof BioModel) {
Object object = issue.getSource();
{
DecoratedIssueSource dis = BeanUtils.downcast(DecoratedIssueSource.class, object);
if (dis != null) {
return dis.getSourcePath();
}
}
String description = "";
if (object instanceof SymbolTableEntry) {
description = ((SymbolTableEntry) object).getName();
} else if (object instanceof ReactionStep) {
description = ((ReactionStep) object).getName();
} else if (object instanceof ReactionRule) {
description = ((ReactionRule) object).getName();
} else if (object instanceof SpeciesPattern) {
// Object parent = issue.getIssueContext().getContextObject();
// if (parent instanceof SpeciesContext){
// description = ((SpeciesContext)parent).getName();
// }
// if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
// SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
// description = thing.getName();
// }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
// ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
// description = thing.getName();
// }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
// RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
// description = thing.getName();
// } else {
System.err.println("Bad issue context for " + ((SpeciesPattern) object).toString());
description = ((SpeciesPattern) object).toString();
// }
} else if (object instanceof MolecularType) {
description = ((MolecularType) object).getName();
} else if (object instanceof MolecularComponent) {
description = ((MolecularComponent) object).getName();
} else if (object instanceof ComponentStateDefinition) {
description = ((ComponentStateDefinition) object).getName();
} else if (object instanceof Structure) {
description = ((Structure) object).getName();
} else if (object instanceof SubDomain) {
description = ((SubDomain) object).getName();
} else if (object instanceof Geometry) {
description = ((Geometry) object).getName();
} else if (object instanceof StructureMapping) {
description = ((StructureMapping) object).getStructure().getName();
} else if (object instanceof OutputFunctionIssueSource) {
description = ((OutputFunctionIssueSource) object).getAnnotatedFunction().getName();
} else if (object instanceof UnmappedGeometryClass) {
description = ((UnmappedGeometryClass) object).getGeometryClass().getName();
} else if (object instanceof MicroscopeMeasurement) {
description = ((MicroscopeMeasurement) object).getName();
} else if (object instanceof SpatialObject) {
description = ((SpatialObject) object).getName();
} else if (object instanceof SpatialProcess) {
description = ((SpatialProcess) object).getName();
} else if (object instanceof GeometryContext) {
description = "Geometry";
} else if (object instanceof ModelOptimizationSpec) {
description = ((ModelOptimizationSpec) object).getParameterEstimationTask().getName();
} else if (object instanceof Simulation) {
description = ((Simulation) object).getName();
} else if (object instanceof SpeciesContextSpec) {
SpeciesContextSpec scs = (SpeciesContextSpec) object;
description = scs.getSpeciesContext().getName();
} else if (object instanceof ReactionCombo) {
ReactionSpec rs = ((ReactionCombo) object).getReactionSpec();
description = rs.getReactionStep().getName();
} else if (object instanceof RbmModelContainer) {
// RbmModelContainer mc = (RbmModelContainer)object;
description = "Rules validator";
} else if (object instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) object;
description = sc.getName();
} else if (object instanceof Model) {
Model m = (Model) object;
description = m.getName();
} else if (object instanceof BioEvent) {
return ((BioEvent) object).getName() + "";
} else if (object instanceof MathDescription) {
return ((MathDescription) object).getName() + "";
} else if (object instanceof AssignmentRule) {
return ((AssignmentRule) object).getDisplayName() + "";
} else if (object instanceof RateRule) {
return ((RateRule) object).getDisplayName() + "";
} else {
System.err.println("unknown object type in IssueTableModel.getSourceObjectDescription(): " + object.getClass());
}
return description;
} else if (vcDocument instanceof MathModel) {
Object object = issue.getSource();
String description = "";
if (object instanceof Variable) {
description = ((Variable) object).getName();
} else if (object instanceof SubDomain) {
description = ((SubDomain) object).getName();
} else if (object instanceof Geometry) {
description = "Geometry";
} else if (object instanceof OutputFunctionIssueSource) {
description = ((OutputFunctionIssueSource) object).getAnnotatedFunction().getName();
} else if (object instanceof MathDescription) {
return "math";
} else if (object instanceof Simulation) {
return "Simulation " + ((Simulation) object).getName() + "";
}
return description;
} else {
System.err.println("unknown document type in IssueTableModel.getSourceObjectDescription()");
return "";
}
}
use of org.vcell.model.rbm.ComponentStateDefinition in project vcell by virtualcell.
the class MolecularTypePropertiesPanel method showPopupMenu.
private void showPopupMenu(MouseEvent e, PointLocationInShapeContext locationContext) {
if (popupFromShapeMenu == null) {
popupFromShapeMenu = new JPopupMenu();
}
if (popupFromShapeMenu.isShowing()) {
return;
}
final Object deepestShape = locationContext.getDeepestShape();
final Object selectedObject;
if (deepestShape == null) {
selectedObject = null;
// when cursor is outside there's nothing to do ???
System.out.println("outside");
return;
} else if (deepestShape instanceof ComponentStateLargeShape) {
System.out.println("inside state");
if (((ComponentStateLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((ComponentStateLargeShape) deepestShape).getComponentStateDefinition();
} else {
// right click only works on highlighted entity, if it's not highlighted we simply return
return;
}
} else if (deepestShape instanceof MolecularComponentLargeShape) {
System.out.println("inside component");
if (((MolecularComponentLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((MolecularComponentLargeShape) deepestShape).getMolecularComponent();
} else {
return;
}
} else if (deepestShape instanceof MolecularTypeLargeShape) {
System.out.println("inside molecule");
if (((MolecularTypeLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((MolecularTypeLargeShape) deepestShape).getMolecularType();
} else {
return;
}
} else if (deepestShape instanceof SpeciesPatternLargeShape) {
// this cannot happen, here just for symmetry
System.out.println("inside species pattern");
if (((SpeciesPatternLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((SpeciesPatternLargeShape) deepestShape).getSpeciesPattern();
} else {
return;
}
} else {
selectedObject = null;
System.out.println("inside something else?");
return;
}
System.out.println(selectedObject);
boolean bDelete = false;
boolean bAdd = false;
popupFromShapeMenu.removeAll();
Point mousePoint = e.getPoint();
if (selectedObject instanceof MolecularType) {
// rename, add
if (selectedObject != molecularType) {
throw new RuntimeException("The selected object from shape different from the current object");
}
JMenuItem renamMenuItem = new JMenuItem("Rename");
popupFromShapeMenu.add(renamMenuItem);
JMenuItem addMenuItem = new JMenuItem("Add " + MolecularComponent.typeName);
// Icon icon = new MolecularTypeSmallShape(1, 4, mt, gc, mt);
// menuItem.setIcon(icon);
popupFromShapeMenu.add(new JSeparator());
popupFromShapeMenu.add(addMenuItem);
addMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularComponent molecularComponent = molecularType.createMolecularComponent();
molecularType.addMolecularComponent(molecularComponent);
bioModel.getModel().getRbmModelContainer().adjustSpeciesContextPatterns(molecularType, molecularComponent);
bioModel.getModel().getRbmModelContainer().adjustObservablesPatterns(molecularType, molecularComponent);
bioModel.getModel().getRbmModelContainer().adjustRulesPatterns(molecularType, molecularComponent);
// editInPlace((LargeShape)deepestShape);
}
});
renamMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
editInPlace((LargeShape) deepestShape);
}
});
} else if (selectedObject instanceof MolecularComponent) {
// move left / right / separator / rename, delete, separator, add
String moveRightMenuText = "Move <b>" + "right" + "</b>";
moveRightMenuText = "<html>" + moveRightMenuText + "</html>";
JMenuItem moveRightMenuItem = new JMenuItem(moveRightMenuText);
Icon icon = VCellIcons.moveRightIcon;
moveRightMenuItem.setIcon(icon);
moveRightMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularComponent from = (MolecularComponent) selectedObject;
List<MolecularComponent> mcList = molecularType.getComponentList();
int fromIndex = mcList.indexOf(from);
if (mcList.size() == fromIndex + 1) {
// already the last element
return;
}
int toIndex = fromIndex + 1;
MolecularComponent to = mcList.remove(toIndex);
mcList.add(fromIndex, to);
molecularTypeTreeModel.populateTree();
molecularType.firePropertyChange("entityChange", null, "bbb");
}
});
popupFromShapeMenu.add(moveRightMenuItem);
String moveLeftMenuText = "Move <b>" + "left" + "</b>";
moveLeftMenuText = "<html>" + moveLeftMenuText + "</html>";
JMenuItem moveLeftMenuItem = new JMenuItem(moveLeftMenuText);
icon = VCellIcons.moveLeftIcon;
moveLeftMenuItem.setIcon(icon);
moveLeftMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularComponent from = (MolecularComponent) selectedObject;
List<MolecularComponent> mcList = molecularType.getComponentList();
int fromIndex = mcList.indexOf(from);
if (fromIndex == 0) {
// already the first element
return;
}
int toIndex = fromIndex - 1;
MolecularComponent to = mcList.remove(toIndex);
mcList.add(fromIndex, to);
molecularTypeTreeModel.populateTree();
molecularType.firePropertyChange("entityChange", null, "bbb");
}
});
popupFromShapeMenu.add(moveLeftMenuItem);
popupFromShapeMenu.add(new JSeparator());
JMenuItem renamMenuItem = new JMenuItem("Rename");
popupFromShapeMenu.add(renamMenuItem);
JMenuItem addMenuItem = new JMenuItem("Add " + ComponentStateDefinition.typeName);
JMenuItem deleteMenuItem = new JMenuItem("Delete ");
popupFromShapeMenu.add(deleteMenuItem);
popupFromShapeMenu.add(new JSeparator());
popupFromShapeMenu.add(addMenuItem);
deleteMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularComponent mc = (MolecularComponent) selectedObject;
// detailed verifications will be done there, to see if they are being used in reactions, species, observables
if (!mc.getComponentStateDefinitions().isEmpty()) {
String[] options = { "OK" };
String errMsg = mc.getDisplayType() + " '<b>" + mc.getDisplayName() + "</b>' cannot be deleted because it contains explicit States.";
errMsg += "<br>Please delete each individual State first.";
errMsg += "<br><br>Detailed usage information will be provided at that time to help you decide.";
errMsg = "<html>" + errMsg + "</html>";
JOptionPane.showOptionDialog(shapePanel, errMsg, "Delete " + mc.getDisplayType(), JOptionPane.NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
return;
}
// we find and display component usage information to help the user decide
Map<String, Pair<Displayable, SpeciesPattern>> usedHere = new LinkedHashMap<String, Pair<Displayable, SpeciesPattern>>();
bioModel.getModel().getRbmModelContainer().findComponentUsage(molecularType, mc, usedHere);
if (!usedHere.isEmpty()) {
String errMsg = mc.dependenciesToHtml(usedHere);
errMsg += "<br><br>Delete anyway?";
errMsg = "<html>" + errMsg + "</html>";
int dialogButton = JOptionPane.YES_NO_OPTION;
int returnCode = JOptionPane.showConfirmDialog(shapePanel, errMsg, "Delete " + mc.getDisplayType(), dialogButton);
if (returnCode == JOptionPane.YES_OPTION) {
// keep this code in sync with MolecularTypeTableModel.setValueAt
if (bioModel.getModel().getRbmModelContainer().delete(molecularType, mc) == true) {
molecularType.removeMolecularComponent(mc);
}
}
} else {
if (bioModel.getModel().getRbmModelContainer().delete(molecularType, mc) == true) {
molecularType.removeMolecularComponent(mc);
}
}
}
});
addMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularComponent mc = (MolecularComponent) selectedObject;
ComponentStateDefinition componentStateDefinition = mc.createComponentStateDefinition();
mc.addComponentStateDefinition(componentStateDefinition);
bioModel.getModel().getRbmModelContainer().adjustObservablesPatterns(molecularType, mc, componentStateDefinition);
bioModel.getModel().getRbmModelContainer().adjustRulesPatterns(molecularType, mc, componentStateDefinition);
bioModel.getModel().getRbmModelContainer().adjustSpeciesPatterns(molecularType, mc, componentStateDefinition);
// editInPlace((LargeShape)deepestShape);
}
});
renamMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
editInPlace((LargeShape) deepestShape);
}
});
} else if (selectedObject instanceof ComponentStateDefinition) {
// rename, delete
JMenuItem renamMenuItem = new JMenuItem("Rename");
popupFromShapeMenu.add(renamMenuItem);
JMenuItem deleteMenuItem = new JMenuItem("Delete");
popupFromShapeMenu.add(deleteMenuItem);
deleteMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ComponentStateDefinition csd = (ComponentStateDefinition) selectedObject;
// must exist, we're deleting one of its states
MolecularComponent mc = locationContext.mcs.getMolecularComponent();
Map<String, Pair<Displayable, SpeciesPattern>> usedHere = new LinkedHashMap<String, Pair<Displayable, SpeciesPattern>>();
bioModel.getModel().getRbmModelContainer().findStateUsage(molecularType, mc, csd, usedHere);
if (!usedHere.isEmpty()) {
String errMsg = csd.dependenciesToHtml(usedHere);
errMsg += "<br><br>Delete anyway?";
errMsg = "<html>" + errMsg + "</html>";
int dialogButton = JOptionPane.YES_NO_OPTION;
int returnCode = JOptionPane.showConfirmDialog(shapePanel, errMsg, "Delete " + ComponentStateDefinition.typeName, dialogButton);
if (returnCode == JOptionPane.YES_OPTION) {
// keep this code in sync with MolecularTypeTableModel.setValueAt
if (bioModel.getModel().getRbmModelContainer().delete(molecularType, mc, csd) == true) {
mc.deleteComponentStateDefinition(csd);
}
}
} else {
if (bioModel.getModel().getRbmModelContainer().delete(molecularType, mc, csd) == true) {
mc.deleteComponentStateDefinition(csd);
}
}
}
});
renamMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
editInPlace((LargeShape) deepestShape);
}
});
}
popupFromShapeMenu.show(e.getComponent(), mousePoint.x, mousePoint.y);
}
use of org.vcell.model.rbm.ComponentStateDefinition in project vcell by virtualcell.
the class RulebasedMathMapping method addSpeciesPatterns.
private HashMap<SpeciesPattern, VolumeParticleSpeciesPattern> addSpeciesPatterns(Domain domain, List<ReactionRule> rrList) throws MathException {
// Particle Molecular Types
//
Model model = getSimulationContext().getModel();
List<RbmObservable> observableList = model.getRbmModelContainer().getObservableList();
List<MolecularType> molecularTypeList = model.getRbmModelContainer().getMolecularTypeList();
for (MolecularType molecularType : molecularTypeList) {
ParticleMolecularType particleMolecularType = new ParticleMolecularType(molecularType.getName());
for (MolecularComponent molecularComponent : molecularType.getComponentList()) {
String pmcName = molecularComponent.getName();
String pmcId = particleMolecularType.getName() + "_" + molecularComponent.getName();
ParticleMolecularComponent particleMolecularComponent = new ParticleMolecularComponent(pmcId, pmcName);
for (ComponentStateDefinition componentState : molecularComponent.getComponentStateDefinitions()) {
ParticleComponentStateDefinition pcsd = particleMolecularComponent.getComponentStateDefinition(componentState.getName());
if (pcsd == null) {
particleMolecularComponent.addComponentStateDefinition(new ParticleComponentStateDefinition(componentState.getName()));
}
}
particleMolecularType.addMolecularComponent(particleMolecularComponent);
}
if (!molecularType.isAnchorAll()) {
List<String> anchorList = new ArrayList<>();
for (Structure struct : molecularType.getAnchors()) {
anchorList.add(struct.getName());
}
particleMolecularType.setAnchorList(anchorList);
}
mathDesc.addParticleMolecularType(particleMolecularType);
}
//
// Assemble list of all Species Patterns (from observables, reaction rules, and seed species).
//
// linked hash set maintains insertion order
LinkedHashMap<SpeciesPattern, Structure> speciesPatternStructureMap = new LinkedHashMap<SpeciesPattern, Structure>();
for (RbmObservable observable : observableList) {
for (SpeciesPattern speciesPattern : observable.getSpeciesPatternList()) {
speciesPatternStructureMap.put(speciesPattern, observable.getStructure());
}
}
for (ReactionRule reactionRule : rrList) {
for (ReactantPattern rp : reactionRule.getReactantPatterns()) {
speciesPatternStructureMap.put(rp.getSpeciesPattern(), rp.getStructure());
}
for (ProductPattern pp : reactionRule.getProductPatterns()) {
speciesPatternStructureMap.put(pp.getSpeciesPattern(), pp.getStructure());
}
}
for (SpeciesContext sc : model.getSpeciesContexts()) {
if (!sc.hasSpeciesPattern()) {
continue;
}
speciesPatternStructureMap.put(sc.getSpeciesPattern(), sc.getStructure());
}
//
// add list of unique speciesPatterns
//
HashMap<String, VolumeParticleSpeciesPattern> speciesPatternVCMLMap = new HashMap<String, VolumeParticleSpeciesPattern>();
HashMap<SpeciesPattern, VolumeParticleSpeciesPattern> speciesPatternMap = new HashMap<SpeciesPattern, VolumeParticleSpeciesPattern>();
String speciesPatternName = "speciesPattern0";
for (SpeciesPattern speciesPattern : speciesPatternStructureMap.keySet()) {
VolumeParticleSpeciesPattern volumeParticleSpeciesPattern = new VolumeParticleSpeciesPattern(speciesPatternName, domain, speciesPatternStructureMap.get(speciesPattern).getName());
for (MolecularTypePattern molecularTypePattern : speciesPattern.getMolecularTypePatterns()) {
ParticleMolecularType particleMolecularType = mathDesc.getParticleMolecularType(molecularTypePattern.getMolecularType().getName());
ParticleMolecularTypePattern particleMolecularTypePattern = new ParticleMolecularTypePattern(particleMolecularType);
String participantMatchLabel = molecularTypePattern.getParticipantMatchLabel();
if (molecularTypePattern.getParticipantMatchLabel() != null) {
particleMolecularTypePattern.setMatchLabel(participantMatchLabel);
}
for (MolecularComponentPattern molecularComponentPattern : molecularTypePattern.getComponentPatternList()) {
MolecularComponent molecularComponent = molecularComponentPattern.getMolecularComponent();
ParticleMolecularComponent particleMolecularComponent = particleMolecularType.getMolecularComponent(molecularComponent.getName());
ParticleMolecularComponentPattern particleMolecularComponentPattern = new ParticleMolecularComponentPattern(particleMolecularComponent);
ComponentStatePattern componentState = molecularComponentPattern.getComponentStatePattern();
if (componentState != null) {
if (componentState.isAny()) {
ParticleComponentStatePattern pcsp = new ParticleComponentStatePattern();
particleMolecularComponentPattern.setComponentStatePattern(pcsp);
} else {
String name = componentState.getComponentStateDefinition().getName();
ParticleComponentStateDefinition pcsd = particleMolecularComponent.getComponentStateDefinition(name);
// ParticleComponentStateDefinition pcsd = new ParticleComponentStateDefinition(componentState.getComponentStateDefinition().getName());
// particleMolecularComponent.addComponentStateDefinition(pcsd);
ParticleComponentStatePattern pcsp = new ParticleComponentStatePattern(pcsd);
particleMolecularComponentPattern.setComponentStatePattern(pcsp);
}
} else {
ParticleComponentStatePattern pcsp = new ParticleComponentStatePattern();
particleMolecularComponentPattern.setComponentStatePattern(pcsp);
}
switch(molecularComponentPattern.getBondType()) {
case Specified:
{
particleMolecularComponentPattern.setBondType(ParticleBondType.Specified);
particleMolecularComponentPattern.setBondId(molecularComponentPattern.getBondId());
break;
}
case Exists:
{
particleMolecularComponentPattern.setBondType(ParticleBondType.Exists);
particleMolecularComponentPattern.setBondId(-1);
break;
}
case None:
{
particleMolecularComponentPattern.setBondType(ParticleBondType.None);
particleMolecularComponentPattern.setBondId(-1);
break;
}
case Possible:
{
particleMolecularComponentPattern.setBondType(ParticleBondType.Possible);
particleMolecularComponentPattern.setBondId(-1);
break;
}
}
particleMolecularTypePattern.addMolecularComponentPattern(particleMolecularComponentPattern);
}
volumeParticleSpeciesPattern.addMolecularTypePattern(particleMolecularTypePattern);
}
String speciesPatternVCML = volumeParticleSpeciesPattern.getVCML("tempName");
VolumeParticleSpeciesPattern uniqueVolumeParticleSpeciesPattern = speciesPatternVCMLMap.get(speciesPatternVCML);
if (uniqueVolumeParticleSpeciesPattern == null) {
speciesPatternVCMLMap.put(speciesPatternVCML, volumeParticleSpeciesPattern);
speciesPatternName = TokenMangler.getNextEnumeratedToken(speciesPatternName);
speciesPatternMap.put(speciesPattern, volumeParticleSpeciesPattern);
} else {
speciesPatternMap.put(speciesPattern, uniqueVolumeParticleSpeciesPattern);
}
}
return speciesPatternMap;
}
use of org.vcell.model.rbm.ComponentStateDefinition in project vcell by virtualcell.
the class MolecularComponentLargeShape method getLongestStateName.
private String getLongestStateName(MolecularComponent mc) {
String longestStateName = "";
if (shapePanel.getZoomFactor() < LargeShapeCanvas.SmallestZoomFactorWithText) {
return "";
}
for (int i = 0; i < mc.getComponentStateDefinitions().size(); i++) {
ComponentStateDefinition csd = mc.getComponentStateDefinitions().get(i);
String stateName = csd.getDisplayName();
stateName = adjustForStateSize(stateName);
longestStateName = stateName.length() > longestStateName.length() ? stateName : longestStateName;
}
return longestStateName;
}
Aggregations