use of cbit.vcell.xml.gui.MiriamTreeModel.LinkNode in project vcell by virtualcell.
the class AnnotationsPanel method getJTreeMIRIAM.
private JTree getJTreeMIRIAM() {
if (jTreeMIRIAM == null) {
try {
DefaultTreeSelectionModel ivjLocalSelectionModel;
ivjLocalSelectionModel = new DefaultTreeSelectionModel();
ivjLocalSelectionModel.setSelectionMode(1);
jTreeMIRIAM = new JTree();
jTreeMIRIAM.setName("JTree1");
jTreeMIRIAM.setToolTipText("");
jTreeMIRIAM.setBounds(0, 0, 357, 405);
jTreeMIRIAM.setMinimumSize(new java.awt.Dimension(100, 72));
jTreeMIRIAM.setSelectionModel(ivjLocalSelectionModel);
jTreeMIRIAM.setRowHeight(0);
jTreeMIRIAM.setRootVisible(false);
// Add cellRenderer
DefaultTreeCellRenderer dtcr = new BioModelCellRenderer(null) {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
// default for LinkNode is in BioModelCellRenderer.java
JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
// TODO: here
component.setIcon(null);
return component;
}
};
jTreeMIRIAM.setCellRenderer(dtcr);
MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
// TreePath closestMousePath =jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
// showPopup(e, closestMousePath);
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
// TreePath closestMousePath =jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
// showPopup(e,closestMousePath);
}
public void mousePressed(MouseEvent e) {
TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
jTreeMIRIAM.setSelectionPath(closestMousePath);
// showPopup(e,closestMousePath);
if (e.getClickCount() == 2) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTreeMIRIAM.getLastSelectedPathComponent();
if (node instanceof LinkNode) {
showBrowseToLink((LinkNode) node);
}
}
}
};
jTreeMIRIAM.addMouseListener(mouseListener);
} catch (java.lang.Throwable ivjExc) {
ivjExc.printStackTrace(System.out);
}
}
return jTreeMIRIAM;
}
use of cbit.vcell.xml.gui.MiriamTreeModel.LinkNode in project vcell by virtualcell.
the class MIRIAMAnnotationEditor method getJTreeMIRIAM.
private JTree getJTreeMIRIAM() {
if (jTreeMIRIAM == null) {
try {
DefaultTreeSelectionModel ivjLocalSelectionModel;
ivjLocalSelectionModel = new DefaultTreeSelectionModel();
ivjLocalSelectionModel.setSelectionMode(1);
jTreeMIRIAM = new JTree();
jTreeMIRIAM.setName("JTree1");
jTreeMIRIAM.setToolTipText("");
jTreeMIRIAM.setBounds(0, 0, 357, 405);
jTreeMIRIAM.setMinimumSize(new java.awt.Dimension(100, 72));
jTreeMIRIAM.setSelectionModel(ivjLocalSelectionModel);
jTreeMIRIAM.setRowHeight(0);
// Add cellRenderer
DefaultTreeCellRenderer dtcr = new BioModelCellRenderer(null) {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
// System.out.println(MIRIAMAnnotationEditor.this.getClass().getName()+".getJTreeMiriam():BioModelCellRenderer "+value.getClass()+" "+
// (value instanceof cbit.vcell.desktop.BioModelNode?
// ((cbit.vcell.desktop.BioModelNode)value).getUserObject().getClass():""));
JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (value instanceof BioModelNode && ((BioModelNode) value).getUserObject() instanceof Annotation) {
component.setToolTipText("(Double-click to edit notes)");
Annotation annotation = (Annotation) ((BioModelNode) value).getUserObject();
if (annotation.toString() == null || annotation.toString().length() == 0) {
component.setText("(Double-click to edit notes)");
}
}
return component;
}
};
jTreeMIRIAM.setCellRenderer(dtcr);
MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
super.mouseClicked(e);
TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
showPopup(e, closestMousePath);
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
super.mouseReleased(e);
TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
showPopup(e, closestMousePath);
}
public void mousePressed(MouseEvent e) {
TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
jTreeMIRIAM.setSelectionPath(closestMousePath);
showPopup(e, closestMousePath);
if (e.getClickCount() == 2) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTreeMIRIAM.getLastSelectedPathComponent();
if (node instanceof LinkNode) {
showBrowseToLink((LinkNode) node);
} else if (isNodeFreeHandTextEditable(node)) {
showEditFreehandText(node);
}
}
}
};
jTreeMIRIAM.addMouseListener(mouseListener);
} catch (java.lang.Throwable ivjExc) {
ivjExc.printStackTrace(System.out);
}
}
return jTreeMIRIAM;
}
use of cbit.vcell.xml.gui.MiriamTreeModel.LinkNode in project vcell by virtualcell.
the class BioModelEditorTreeCellRenderer method getTreeCellRendererComponent.
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (regularFont == null) {
regularFont = getFont();
boldFont = regularFont.deriveFont(Font.BOLD);
}
Font font = regularFont;
Icon icon = null;
String labelText = null;
String toolTipPrefix = "";
String toolTipSuffix = "";
if (value instanceof LinkNode) {
LinkNode ln = (LinkNode) value;
String link = ln.getLink();
String text = ln.getText();
String qualifier = ln.getMiriamQualifier().getDescription();
if (link != null) {
String colorString = (sel) ? "white" : "blue";
toolTipPrefix = "double-click to open link " + link;
labelText = "<html>" + qualifier + " <font color=\"" + colorString + "\"><a href=" + link + ">" + text + "</a></font></html>";
} else {
String colorString = (sel) ? "white" : "black";
labelText = "<html>" + qualifier + " <font color=\"" + colorString + "\">" + text + "</font></html>";
}
} else if (value instanceof BioModelNode) {
BioModelNode node = (BioModelNode) value;
Object userObj = node.getUserObject();
if (userObj instanceof BioModel) {
font = boldFont;
icon = VCellIcons.documentIcon;
labelText = ((BioModel) userObj).getName();
toolTipPrefix = "BioModel: ";
} else if (userObj instanceof SimulationContext) {
// --- root: application name
font = boldFont;
// icon = VCellIcons.applicationIcon;
SimulationContext simContext = (SimulationContext) userObj;
if (simContext.isRuleBased()) {
if (simContext.getGeometry().getDimension() == 0) {
icon = VCellIcons.appRbmNonspIcon;
toolTipSuffix = "Rule Based / Non spatial";
}
} else if (simContext.isStoch()) {
if (simContext.getGeometry().getDimension() == 0) {
icon = VCellIcons.appStoNonspIcon;
toolTipSuffix = "Stochastic / Non spatial";
} else {
icon = VCellIcons.appStoSpatialIcon;
toolTipSuffix = "Stochastic / Spatial";
}
} else {
// deterministic
if (simContext.getGeometry().getDimension() == 0) {
icon = VCellIcons.appDetNonspIcon;
toolTipSuffix = "Deterministic / Non spatial";
} else {
icon = VCellIcons.appDetSpatialIcon;
toolTipSuffix = "Deterministic / Spatial";
}
}
labelText = /*"Application: " + */
((SimulationContext) userObj).getName();
toolTipPrefix = "Application: ";
} else if (userObj instanceof DocumentEditorTreeFolderNode) {
// --- 1st level folders
DocumentEditorTreeFolderNode folder = (DocumentEditorTreeFolderNode) userObj;
labelText = folder.getName();
if (folder.isBold()) {
font = boldFont;
}
DocumentEditorTreeFolderClass folderClass = folder.getFolderClass();
switch(folderClass) {
// break;
case REACTIONS_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
int numReactions = bioModel.getModel().getNumReactions();
if (bioModel.getModel().getRbmModelContainer() != null) {
numReactions += bioModel.getModel().getRbmModelContainer().getReactionRuleList().size();
}
labelText = folder.getName() + " (" + numReactions + ")";
}
break;
case STRUCTURES_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + bioModel.getModel().getNumStructures() + ")";
}
break;
case SPECIES_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + bioModel.getModel().getNumSpeciesContexts() + ")";
}
break;
case MOLECULAR_TYPES_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
RbmModelContainer rbmModelContainer = bioModel.getModel().getRbmModelContainer();
if (rbmModelContainer == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + rbmModelContainer.getMolecularTypeList().size() + ")";
}
}
break;
case OBSERVABLES_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
RbmModelContainer rbmModelContainer = bioModel.getModel().getRbmModelContainer();
if (rbmModelContainer == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + rbmModelContainer.getObservableList().size() + ")";
}
}
break;
case APPLICATIONS_NODE:
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + bioModel.getNumSimulationContexts() + ")";
}
break;
case REACTION_DIAGRAM_NODE:
icon = VCellIcons.diagramIcon;
break;
// break;
case GEOMETRY_NODE:
icon = VCellIcons.geometryIcon;
break;
case SPECIFICATIONS_NODE:
icon = VCellIcons.settingsIcon;
break;
case PROTOCOLS_NODE:
icon = VCellIcons.protocolsIcon;
TreeNode tn = node.getParent();
if (tn instanceof BioModelNode) {
BioModelNode applicationNode = (BioModelNode) tn;
Object uo = applicationNode.getUserObject();
if (uo instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) uo;
int numProtocols = 0;
// }
if (sc.getRateRules() != null) {
numProtocols += sc.getRateRules().length;
}
if (sc.getAssignmentRules() != null) {
numProtocols += sc.getAssignmentRules().length;
}
if (numProtocols > 0) {
labelText += " (rules: " + numProtocols + ")";
}
}
}
break;
case SIMULATIONS_NODE:
icon = VCellIcons.simulationIcon;
break;
case PARAMETER_ESTIMATION_NODE:
icon = VCellIcons.fittingIcon;
break;
case PATHWAY_DIAGRAM_NODE:
icon = VCellIcons.diagramIcon;
break;
case PATHWAY_OBJECTS_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + bioModel.getPathwayModel().getBiopaxObjects().size() + ")";
}
break;
case BIOPAX_SUMMARY_NODE:
icon = VCellIcons.textNotesIcon;
break;
case BIOPAX_TREE_NODE:
icon = VCellIcons.tableIcon;
break;
}
}
}
setIcon(icon);
setFont(font);
setText(labelText);
if (toolTipSuffix.length() == 0) {
toolTipSuffix = labelText;
}
setToolTipText(toolTipPrefix + toolTipSuffix);
return this;
}
use of cbit.vcell.xml.gui.MiriamTreeModel.LinkNode in project vcell by virtualcell.
the class BioModelPropertiesPanel method updateInterface.
/**
* Comment
*/
private void updateInterface() {
if (bioModel == null || bioModelWindowManager == null) {
return;
}
nameLabel.setText("<html><b>" + bioModel.getName() + "</b></html>");
Version version = bioModel.getVersion();
if (version != null) {
ownerLabel.setText(version.getOwner().getName());
String text = "biomodel-" + version.getVersionKey().toString();
idLabel.setText(text);
lastModifiedLabel.setText(version.getDate().toString());
try {
// permissions
BioModelInfo bioModelInfo = bioModelWindowManager.getRequestManager().getDocumentManager().getBioModelInfo(version.getVersionKey());
String permissions = bioModelInfo.getVersion().getGroupAccess().getDescription();
if (bioModelInfo.getPublicationInfos() != null && bioModelInfo.getPublicationInfos().length > 0) {
if (bioModelInfo.getVersion().getFlag().compareEqual(org.vcell.util.document.VersionFlag.Published)) {
// must be Public
permissions = "Published";
} else {
permissions = "Curated";
}
} else if (bioModelInfo.getVersion().getFlag().compareEqual(org.vcell.util.document.VersionFlag.Archived)) {
permissions += "Archived";
}
permissionLabel.setText(permissions);
} catch (DataAccessException e) {
e.printStackTrace();
}
changePermissionButton.setEnabled(true);
}
// not in use anymore and unmaintained
webLinksPanel.removeAll();
webLinksPanel.setLayout(new GridLayout(0, 1));
Set<MiriamRefGroup> resources = new HashSet<MiriamRefGroup>();
Set<MiriamRefGroup> isDescribedByAnnotation = bioModel.getVCMetaData().getMiriamManager().getMiriamRefGroups(bioModel, MIRIAMQualifier.MODEL_isDescribedBy);
Set<MiriamRefGroup> isAnnotation = bioModel.getVCMetaData().getMiriamManager().getMiriamRefGroups(bioModel, MIRIAMQualifier.MODEL_is);
resources.addAll(isDescribedByAnnotation);
resources.addAll(isAnnotation);
for (MiriamRefGroup refGroup : resources) {
for (MiriamResource miriamResources : refGroup.getMiriamRefs()) {
LinkNode linkNode = new MiriamTreeModel.LinkNode(MIRIAMQualifier.MODEL_isDescribedBy, miriamResources);
final String link = linkNode.getLink();
String labelText = miriamResources.getDataType() == null ? "" : miriamResources.getDataType().getDataTypeName();
String toolTip = null;
if (link != null) {
toolTip = "double-click to open link " + link;
labelText = "<html><b>" + labelText + "</b> " + "<font color=blue><a href=" + link + ">" + link + "</a></font></html>";
}
JLabel label = new JLabel(labelText);
label.addMouseListener(new MouseListener() {
public void mouseReleased(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
DialogUtils.browserLauncher(BioModelPropertiesPanel.this, link, "failed to open " + link);
}
}
});
label.setToolTipText(toolTip);
webLinksPanel.add(label);
}
}
applicationsPanel.updateInterface();
}
use of cbit.vcell.xml.gui.MiriamTreeModel.LinkNode in project vcell by virtualcell.
the class AnnotationsPanel method removeIdentifier.
private void removeIdentifier() {
Object treeNode = jTreeMIRIAM.getLastSelectedPathComponent();
if (treeNode instanceof LinkNode) {
LinkNode linkNode = (LinkNode) treeNode;
MiriamResource resourceToDelete = linkNode.getMiriamResource();
Identifiable entity = getIdentifiable(selectedObject);
// Map<MiriamRefGroup, MIRIAMQualifier> refGroupsToRemove = vcMetaData.getMiriamManager().getAllMiriamRefGroups(entity);
MiriamManager mm = vcMetaData.getMiriamManager();
Map<MiriamRefGroup, MIRIAMQualifier> refGroupsToRemove = mm.getMiriamTreeMap().get(entity);
boolean found = false;
for (MiriamRefGroup refGroup : refGroupsToRemove.keySet()) {
MIRIAMQualifier qualifier = refGroupsToRemove.get(refGroup);
for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
if (!isEqual(miriamResource, resourceToDelete)) {
continue;
}
try {
// remove the ref group for this resource
mm.remove2(entity, qualifier, refGroup);
System.out.println(vcMetaData.printRdfStatements());
found = true;
break;
} catch (URNParseFailureException e) {
e.printStackTrace(System.out);
}
}
if (found == true) {
updateInterface();
if (selectedObject instanceof ReactionStep) {
((ReactionStep) selectedObject).firePropertyChange("addIdentifier", true, false);
}
break;
}
}
}
}
Aggregations