Skip to content

Commit

Permalink
WIP: link length editor
Browse files Browse the repository at this point in the history
  • Loading branch information
danv61 committed Nov 21, 2024
1 parent 03ba3ce commit 08be444
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import cbit.vcell.model.Structure;
import cbit.vcell.parser.Expression;
import org.vcell.model.rbm.*;
import org.vcell.util.Coordinate;
import org.vcell.util.gui.GuiUtils;
import org.vcell.util.gui.ScrollTable;
import org.vcell.util.springsalad.NamedColor;

import javax.swing.*;
import java.beans.PropertyChangeEvent;
import java.util.*;

Expand Down Expand Up @@ -86,13 +88,40 @@ public Object getValueAt(int row, int col) {
@Override
public void setValueAt(Object aValue, int row, int col) {
MolecularInternalLinkSpec mils = getValueAt(row);
if(mils == null) {
return;
}
ColumnType columnType = columns.get(col);
switch (columnType) {
case COLUMN_LINK:
SpeciesContextSpec scs = getSpeciesContextSpec();

MolecularComponentPattern mcpOne = mils.getMolecularComponentPatternOne();
MolecularComponentPattern mcpTwo = mils. getMolecularComponentPatternTwo();
SiteAttributesSpec sasOne = mils. getSite1();
SiteAttributesSpec sasTwo = mils. getSite2();

switch (columnType) {
case COLUMN_LINK: // not editable
return;
case COLUMN_LENGTH:

if (aValue instanceof String newExpressionString) {
double res = 0.0;
try {
res = Double.parseDouble(newExpressionString);
} catch(NumberFormatException ex) {
JOptionPane.showMessageDialog(null, "Number expected", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
// the link is a derived value, we don't store it - we just show it in the table
// instead, we adjust the x, y, z of the molecules involved
double[] unitVector = mils.unitVector();
double newX = sasOne.getX() + res*unitVector[0];
double newY = sasOne.getY() + res*unitVector[1];
double newZ = sasOne.getZ() + res*unitVector[2];
Coordinate coord = new Coordinate (newX, newY, newZ);
sasTwo.setCoordinate(coord);
refreshData();
scs.firePropertyChange(SpeciesContextSpec.PROPERTY_NAME_LINK_LENGTH, null, mils);
}
return;
default:
return;
Expand All @@ -103,8 +132,9 @@ public boolean isCellEditable(int row, int col) {
ColumnType columnType = columns.get(col);
switch (columnType) {
case COLUMN_LINK:
case COLUMN_LENGTH:
return false;
case COLUMN_LENGTH:
return true;
default:
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public void actionPerformed(java.awt.event.ActionEvent e) {
public void propertyChange(PropertyChangeEvent evt) {
if(evt.getSource() instanceof SpeciesContextSpec && evt.getPropertyName().equals(SpeciesContextSpec.PROPERTY_NAME_SITE_ATTRIBUTE)) {
updateShape();
} else if(evt.getSource() instanceof SpeciesContextSpec && evt.getPropertyName().equals(SpeciesContextSpec.PROPERTY_NAME_LINK_LENGTH)) {
updateShape();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public class SpeciesContextSpec implements Matchable, ScopedSymbolTable, Seriali
public static final String PARAMETER_NAME_PROXY_PARAMETERS = "proxyParameters";
private static final String PROPERTY_NAME_WELL_MIXED = "wellMixed";
private static final String PROPERTY_NAME_FORCECONTINUOUS = "forceContinuous";
public static final String PROPERTY_NAME_SITE_ATTRIBUTE = "SiteAttributes";
public static final String PROPERTY_NAME_SITE_ATTRIBUTE = "SiteAttributes"; // springsalad
public static final String PROPERTY_NAME_LINK_LENGTH = "LinkLength"; // springsalad
private static final int INITIAL_YZ_SITE_OFFSET = 4;

public static final boolean TrackClusters = true; // SpringSaLaD specific
Expand Down

0 comments on commit 08be444

Please sign in to comment.