Skip to content

Commit

Permalink
Merge pull request #1401 from virtualcell/dan-ss-num-trials
Browse files Browse the repository at this point in the history
Improvements to springsalad specific properties panel and shape representation
  • Loading branch information
danv61 authored Dec 16, 2024
2 parents 67ddfba + f196316 commit 248a984
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ protected Comparator<MolecularInternalLinkSpec> getComparator(int col, boolean a
* to, or greater than the second.<p>
*/
public int compare(MolecularInternalLinkSpec mils1, MolecularInternalLinkSpec mils2) {

ColumnType columnType = columns.get(col);
switch (columnType) {
case COLUMN_LINK:
Expand Down Expand Up @@ -260,6 +259,24 @@ protected List<MolecularInternalLinkSpec> computeData() {
} else {
return null;
}

Collections.sort(allParameterList, new Comparator<MolecularInternalLinkSpec>() {
@Override
public int compare(MolecularInternalLinkSpec mils1, MolecularInternalLinkSpec mils2) {
SpeciesContextSpec scs = mils1.getSpeciesContextSpec();
if(fieldSpeciesContextSpec != scs) {
throw new RuntimeException("SpeciesContextSpec inconsistent.");
}
MolecularComponentPattern mcp1 = mils1.getLink().one;
MolecularComponentPattern mcp2 = mils2.getLink().one;
Map<MolecularComponentPattern, SiteAttributesSpec> siteAttributesMap = getSpeciesContextSpec().getSiteAttributesMap();
SiteAttributesSpec sas1 = siteAttributesMap.get(mcp1);
SiteAttributesSpec sas2 = siteAttributesMap.get(mcp2);
Double z1 = sas1.getCoordinate().getZ();
Double z2 = sas2.getCoordinate().getZ();
return z1.compareTo(z2);
}
});
return allParameterList;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import cbit.vcell.graph.gui.LargeShapePanel;
import cbit.vcell.graph.gui.SsldLargeShapePanel;
import cbit.vcell.graph.gui.ZoomShapeIcon;
import cbit.vcell.mapping.MolecularInternalLinkSpec;
import cbit.vcell.mapping.SiteAttributesSpec;
import cbit.vcell.mapping.SpeciesContextSpec;
import cbit.vcell.model.GroupingCriteria;
import cbit.vcell.model.Model;
Expand All @@ -22,11 +24,16 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.geom.Ellipse2D;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import static cbit.vcell.mapping.SpeciesContextSpec.PROPERTY_NAME_LINK_SELECTED_IN_SHAPE;
import static cbit.vcell.mapping.SpeciesContextSpec.PROPERTY_NAME_SITE_SELECTED_IN_SHAPE;

public class MolecularStructuresPropertiesPanel extends DocumentEditorSubPanel {

private BioModel bioModel = null;
Expand All @@ -37,6 +44,8 @@ public class MolecularStructuresPropertiesPanel extends DocumentEditorSubPanel {
private LargeShapePanel shapePanel = null;
private SpeciesContextSpecLargeShape scsls; // the real thing

private MolecularComponentPattern mcpSelected = null;
private MolecularInternalLinkSpec milsSelected = null;

private JButton zoomLargerButton = null;
private JButton zoomSmallerButton = null;
Expand Down Expand Up @@ -67,6 +76,22 @@ public void propertyChange(PropertyChangeEvent evt) {
updateShape();
} else if(evt.getSource() instanceof SpeciesContextSpec && evt.getPropertyName().equals(SpeciesContextSpec.PROPERTY_NAME_LINK_LENGTH)) {
updateShape();
} else if(evt.getSource() instanceof SpeciesContextSpec && evt.getPropertyName().equals(SpeciesContextSpec.PROPERTY_NAME_SITE_SELECTED_IN_TABLE)) {
Object o = evt.getNewValue();
if(o instanceof MolecularComponentPattern mcp) {
mcpSelected = mcp;
} else {
mcpSelected = null;
}
updateShape();
} else if(evt.getSource() instanceof SpeciesContextSpec && evt.getPropertyName().equals(SpeciesContextSpec.PROPERTY_NAME_LINK_SELECTED_IN_TABLE)) {
Object o = evt.getNewValue();
if(o instanceof MolecularInternalLinkSpec mils) {
milsSelected = mils;
} else {
milsSelected = null;
}
updateShape();
}
}
}
Expand Down Expand Up @@ -95,7 +120,8 @@ public void paintComponent(Graphics g) {
if (speciesContextSpec == null || speciesContextSpec.getSpeciesContext() == null) {
return;
}
scsls = new SpeciesContextSpecLargeShape(speciesContextSpec, shapePanel, speciesContextSpec, issueManager);
scsls = new SpeciesContextSpecLargeShape(speciesContextSpec, shapePanel, speciesContextSpec,
mcpSelected, milsSelected, issueManager);
scsls.paintSelf(g);
}
@Override
Expand Down Expand Up @@ -140,11 +166,39 @@ public boolean isViewSingleRow() {
}
};
shapePanel.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
// this will fire if the mouse moves over the panel, we may need it for drag and drop
super.mouseMoved(e);
// Point overWhat = e.getPoint();
// Object overObject = scsls.contains(overWhat);
// if(overObject != null) {
// System.out.println("MouseMotionAdapter: over something");
// }
}
});
shapePanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
if(speciesContextSpec == null) {
throw new RuntimeException("speciesContextSpec is null");
}
Point overWhat = e.getPoint();
// PointLocationInShapeContext locationContext = new PointLocationInShapeContext(overWhat);
// spls.contains(locationContext);
// shapePanel.setToolTipText("View-Only panel");
Object overObject = scsls.contains(overWhat); // check if we clicked inside a site oval or link line
if(overObject instanceof MolecularInternalLinkSpec mils) {
milsSelected = mils;
// redraw the whole shape to highlight the selected site oval
updateShape();
// we tell the table in the upper panel to update the selected row
speciesContextSpec.firePropertyChange(PROPERTY_NAME_LINK_SELECTED_IN_SHAPE, null, milsSelected);
} else if(overObject instanceof SiteAttributesSpec sas) {
mcpSelected = sas.getMolecularComponentPattern();
// redraw the whole shape to highlight the selected link line
updateShape();
// we tell the table in the upper panel to update the selected row
speciesContextSpec.firePropertyChange(PROPERTY_NAME_SITE_SELECTED_IN_SHAPE, null, mcpSelected);
}
}
});
shapePanel.setPreferredSize(new Dimension(2000, 800));
Expand Down Expand Up @@ -213,7 +267,8 @@ private void updateShape() {
if(speciesContextSpec == null || speciesContextSpec.getSpeciesContext() == null) {
return;
}
scsls = new SpeciesContextSpecLargeShape(speciesContextSpec, shapePanel, speciesContextSpec, issueManager);
scsls = new SpeciesContextSpecLargeShape(speciesContextSpec, shapePanel, speciesContextSpec,
mcpSelected, milsSelected, issueManager);

// shapePanel.setPreferredSize(scsls.getMaxSize());

Expand All @@ -232,6 +287,9 @@ public void setSpeciesContextSpec(SpeciesContextSpec scSpec) {
scSpec.addPropertyChangeListener(eventHandler);
}
// getSpeciesContextSpecParameterTableModel().setSpeciesContextSpec(scSpec);

mcpSelected = null;
milsSelected = null;
updateInterface();
}
public void setBioModel(BioModel newValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand Down Expand Up @@ -136,6 +137,36 @@ public void focusLost(FocusEvent e) {
public void propertyChange(java.beans.PropertyChangeEvent e) {
if(e.getSource() instanceof Model && e.getPropertyName().equals(RbmModelContainer.PROPERTY_NAME_MOLECULAR_TYPE_LIST)) {
updateInterface();
} else if(e.getSource() instanceof SpeciesContextSpec && e.getPropertyName().equals(SpeciesContextSpec.PROPERTY_NAME_SITE_SELECTED_IN_SHAPE)) {
// notified that the user clicked in a site oval shape or link line shape
// we need to update the selected row in the corresponding table
for(int row=0 ; row < molecularTypeSpecsTableModel.getRowCount(); row++) {
MolecularComponentPattern mcp = molecularTypeSpecsTableModel.getValueAt(row);
if(e.getNewValue() instanceof MolecularComponentPattern mcpSelected) {
if(mcpSelected == mcp) {
// select the table row
getMolecularTypeSpecsTable().setRowSelectionInterval(row, row);
// bring the row into view if it's not visible
Rectangle rect = getMolecularTypeSpecsTable().getCellRect(row, 0, true);
getMolecularTypeSpecsTable().scrollRectToVisible(rect);
break;
}
}
}
} else if(e.getSource() instanceof SpeciesContextSpec && e.getPropertyName().equals(SpeciesContextSpec.PROPERTY_NAME_LINK_SELECTED_IN_SHAPE)) {
for(int row=0 ; row < linkSpecsTableModel.getRowCount(); row++) {
MolecularInternalLinkSpec mils = linkSpecsTableModel.getValueAt(row);
if(e.getNewValue() instanceof MolecularInternalLinkSpec milsSelected) {
if(milsSelected == mils) {
// select the table row
getLinkSpecsTable().setRowSelectionInterval(row, row);
// bring the row into view if it's not visible
Rectangle rect = getLinkSpecsTable().getCellRect(row, 0, true);
getLinkSpecsTable().scrollRectToVisible(rect);
break;
}
}
}
}
// if (e.getSource() == selectionManager) {
// System.out.println(e.getPropertyName());
Expand Down Expand Up @@ -739,12 +770,16 @@ public SpeciesContextSpec getSpeciesContextSpec() {
}
void setMolecularComponentPattern(MolecularComponentPattern mcp) {
fieldMolecularComponentPattern = mcp;
//TODO: stuff
if(fieldSpeciesContextSpec != null) { // mcp may be null
fieldSpeciesContextSpec.firePropertyChange(SpeciesContextSpec.PROPERTY_NAME_SITE_SELECTED_IN_TABLE, null, mcp);
}
updateInterface();
}
void setMolecularInternalLinkSpec(MolecularInternalLinkSpec mils) {
fieldMolecularInternalLinkSpec = mils;
//TODO: stuff
if(fieldSpeciesContextSpec != null) { // mils may be null
fieldSpeciesContextSpec.firePropertyChange(SpeciesContextSpec.PROPERTY_NAME_LINK_SELECTED_IN_TABLE, null, mils);
}
updateInterface();
}

Expand Down
Loading

0 comments on commit 248a984

Please sign in to comment.