Skip to content

Commit

Permalink
Merge pull request #1399 from virtualcell/dan-ss-reports2
Browse files Browse the repository at this point in the history
Cosmetic changes to molecular structures and links tables
  • Loading branch information
danv61 authored Dec 12, 2024
2 parents 55ef45b + e003fcb commit bc9506d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public enum ColumnType {
COLUMN_SITE("Site"),
// COLUMN_MOLECULE("Molecule"),
COLUMN_STRUCTURE("Location"),
COLUMN_STATE("State"),
// COLUMN_STATE("State"),
COLUMN_X(" X "),
COLUMN_Y(" Y "),
COLUMN_Z(" Z "),
Expand Down Expand Up @@ -94,8 +94,8 @@ public Class<?> getColumnClass(int column) {
// return MolecularType.class;
case COLUMN_STRUCTURE:
return Structure.class;
case COLUMN_STATE:
return ComponentStatePattern.class;
// case COLUMN_STATE:
// return ComponentStatePattern.class;
case COLUMN_X:
case COLUMN_Y:
case COLUMN_Z:
Expand Down Expand Up @@ -140,16 +140,16 @@ public Object getValueAt(int row, int col) {
return null;
}
return sas.getLocation();
case COLUMN_STATE:
ComponentStatePattern csp = mcp.getComponentStatePattern();
if(csp == null) {
return ComponentStatePattern.strNone;
}
if(csp.isAny()) {
return ComponentStatePattern.strAny;
}
String name = csp.getComponentStateDefinition().getName();
return name;
// case COLUMN_STATE:
// ComponentStatePattern csp = mcp.getComponentStatePattern();
// if(csp == null) {
// return ComponentStatePattern.strNone;
// }
// if(csp.isAny()) {
// return ComponentStatePattern.strAny;
// }
// String name = csp.getComponentStateDefinition().getName();
// return name;
case COLUMN_X:
if(sas == null) {
return null;
Expand Down Expand Up @@ -200,8 +200,8 @@ public void setValueAt(Object aValue, int row, int col) {
switch (columnType) {
case COLUMN_SITE:
// case COLUMN_MOLECULE:
case COLUMN_STATE:
return;
// case COLUMN_STATE:
// return;
case COLUMN_STRUCTURE:
if(aValue instanceof Structure structure) {
if(sas == null) {
Expand Down Expand Up @@ -352,8 +352,8 @@ public boolean isCellEditable(int row, int col) {
switch (columnType) {
case COLUMN_SITE:
// case COLUMN_MOLECULE:
case COLUMN_STATE:
return false;
// case COLUMN_STATE:
// return false;
case COLUMN_STRUCTURE:
case COLUMN_X:
case COLUMN_Y:
Expand Down Expand Up @@ -382,7 +382,7 @@ public int compare(MolecularComponentPattern mcp1, MolecularComponentPattern mcp
case COLUMN_SITE:
// case COLUMN_MOLECULE:
case COLUMN_STRUCTURE:
case COLUMN_STATE:
// case COLUMN_STATE:
case COLUMN_X:
case COLUMN_Y:
case COLUMN_Z:
Expand Down Expand Up @@ -522,8 +522,6 @@ private void refreshData() {
updateColorComboBox();
}



private void updateColorComboBox() {
if(fieldSimulationContext == null) {
return;
Expand Down Expand Up @@ -570,7 +568,6 @@ public Component getListCellRendererComponent(JList list, Object value,
setHorizontalTextPosition(SwingConstants.LEFT);
if (value instanceof Structure structure) {
setText(structure.getName());

}
return this;
}
Expand Down Expand Up @@ -621,7 +618,6 @@ public void propertyChange(PropertyChangeEvent evt) {
if (evt.getSource() instanceof SpeciesContext && evt.getPropertyName().equals("name")) {
fireTableRowsUpdated(0,getRowCount()-1);
}

if (evt.getSource() instanceof SpeciesContextSpec) {
fireTableRowsUpdated(0,getRowCount()-1);
}
Expand All @@ -632,8 +628,6 @@ public void propertyChange(PropertyChangeEvent evt) {
refreshColumns();
fireTableStructureChanged();
}

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@
import org.vcell.model.rbm.MolecularTypePattern;
import org.vcell.model.rbm.SpeciesPattern;
import org.vcell.util.Coordinate;
import org.vcell.util.gui.ColorIcon;
import org.vcell.util.gui.DefaultScrollTableCellRenderer;
import org.vcell.util.gui.EditorScrollTable;
import org.vcell.util.gui.*;
import org.vcell.util.gui.ScrollTable.ScrollTableBooleanCellRenderer;
import org.vcell.util.gui.VCellIcons;
import org.vcell.util.gui.sorttable.SortTableModel;
import org.vcell.util.springsalad.Colors;
import org.vcell.util.springsalad.NamedColor;
Expand All @@ -52,6 +49,7 @@
import java.awt.event.FocusListener;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Map;


@SuppressWarnings("serial")
Expand Down Expand Up @@ -598,9 +596,20 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
MolecularComponentPattern firstMcp = mils.getMolecularComponentPatternOne();
MolecularComponentPattern secondtMcp = mils.getMolecularComponentPatternTwo();
setText(firstMcp.getMolecularComponent().getName() + " :: " + secondtMcp.getMolecularComponent().getName());
// Icon icon = new ColorIcon(10,10,namedColor.getColor(), true); // small square icon with subdomain color
SpeciesContextSpec scs = mils.getSpeciesContextSpec();
if(fieldSpeciesContextSpec != scs) {
throw new RuntimeException("SpeciesContextSpec inconsistent.");
}
Map<MolecularComponentPattern, SiteAttributesSpec> siteAttributesMap = getSpeciesContextSpec().getSiteAttributesMap();
SiteAttributesSpec sasFirst = siteAttributesMap.get(firstMcp);
SiteAttributesSpec sasSecond = siteAttributesMap.get(secondtMcp);
NamedColor ncFirst = sasFirst.getColor();
NamedColor ncSecond = sasSecond.getColor();
Icon iconFirst = new ColorIcon(10,10,ncFirst.getColor(), true);
Icon iconSecond = new ColorIcon(10,10,ncSecond.getColor(), true);
Icon compositeIcon = new CompositeIcon(iconFirst, iconSecond);
// setHorizontalTextPosition(SwingConstants.RIGHT);
// setIcon(icon);
setIcon(compositeIcon);
}
}
return this;
Expand Down
36 changes: 36 additions & 0 deletions vcell-client/src/main/java/org/vcell/util/gui/CompositeIcon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.vcell.util.gui;

import javax.swing.*;
import java.awt.*;

// see also VCellIcon
// Usage:
// Icon colorIconFirst = new ColorIcon(10, 10, colorFirst, true);
// Icon colorIconSecond = new ColorIcon(10, 10, colorSecond, true);
// Icon compositeIcon = new CompositeIcon(colorIconFirst, colorIconSecond);
public class CompositeIcon implements Icon
{
private final Icon icon1;
private final Icon icon2;

public CompositeIcon(Icon icon1, Icon icon2) {
this.icon1 = icon1;
this.icon2 = icon2;
}

@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
icon1.paintIcon(c, g, x, y); // paint the first icon
icon2.paintIcon(c, g, x + icon1.getIconWidth(), y); // paint the second icon next to the first icon
}

@Override
public int getIconWidth() {
return icon1.getIconWidth() + icon2.getIconWidth(); // the total width is the sum of both icons' widths
}

@Override
public int getIconHeight() {
return Math.max(icon1.getIconHeight(), icon2.getIconHeight()); // height is the maximum of both icons' heights
}
}
5 changes: 5 additions & 0 deletions vcell-client/src/main/java/org/vcell/util/gui/VCellIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import javax.swing.UIManager;

public abstract class VCellIcons {



public static HashMap<String, URL> imagePaths = new HashMap<String, URL>();

private static URL getResourceUrl(String resourcePath){
Expand Down Expand Up @@ -310,6 +313,8 @@ public static Icon getScaledIcon(Component component, Icon tempIcon){
return new ImageIcon(image);
}

// see also CompositeIcon
// Icon compositeIcon = new CompositeIcon(colorIconFirst, colorIconSecond);
public static Icon addIcon(Icon icon1, Icon icon2){
int separatorWidth = 3;
Image image1 = ((ImageIcon) icon1).getImage();
Expand Down
20 changes: 10 additions & 10 deletions vcell-core/src/main/java/cbit/vcell/mapping/SpeciesContextSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -1295,8 +1295,8 @@ public void gatherIssues(IssueContext issueContext, List<Issue> issueVector){
}
for(MolecularInternalLinkSpec mils : getInternalLinkSet()){
if(mils.getMolecularComponentPatternOne() == mils.getMolecularComponentPatternTwo()){
String msg = "Both sites of the Link are identical.";
String tip = "A site cannot be linked to itself.";
String msg = "Both sites of the Link are identical. A site cannot be linked to itself.";
String tip = msg;
issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, tip, Issue.Severity.WARNING));
return;
}
Expand All @@ -1315,8 +1315,8 @@ public void gatherIssues(IssueContext issueContext, List<Issue> issueVector){
graph.addEdge(one, two);
}
if(!graph.isConnected(GraphContinuity.Algorithm.DFS)) { // let's use DFS!
String msg = "Link chain within the molecule has at least one discontinuity.";
String tip = "One or more links are missing";
String msg = "Link chain within the molecule has at least one discontinuity. One or more links are missing.";
String tip = msg;
issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, tip, Issue.Severity.WARNING));
return;
}
Expand Down Expand Up @@ -1382,8 +1382,8 @@ public void gatherIssues(IssueContext issueContext, List<Issue> issueVector){
} else { // all the other sites of a membrane species must not be on the membrane
SiteAttributesSpec sas = getSiteAttributesMap().get(mcp);
if(sas.getLocation() instanceof Membrane) {
String msg = "All the Sites of a Membrane species, other than the 'Anchor', must NOT be located on a Membrane.";
String tip = "Relocate the site '" + mc.getName() + "' inside a compartment, or rename it to 'Anchor'";
String tip = "All the Sites of a Membrane species, other than the 'Anchor', must NOT be located on a Membrane.";
String msg = "Relocate the site '" + mc.getName() + "' inside a compartment, or rename it to 'Anchor'";
issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, tip, Issue.Severity.WARNING));
return;
}
Expand Down Expand Up @@ -1440,15 +1440,15 @@ public void gatherIssues(IssueContext issueContext, List<Issue> issueVector){
double zCandidate = sasCandidate.getCoordinate().getZ();
if(sasCandidate.getLocation().getName().equals(Structure.SpringStructureEnum.Extracellular.columnName)) {
if(!(zCandidate < zAnchor)) {
String msg = "Sites located in the 'Extracellular' structure must have their z-coordinate smaller that the one of the 'Anchor' site";
String tip = "Relocate the site '" + mc.getName() + "' inside 'Intracellular', or decrease its 'z' coordinate to less than " + zAnchor;
String tip = "Sites located in the 'Extracellular' structure must have their z-coordinate smaller that the one of the 'Anchor' site";
String msg = "Relocate the site '" + mc.getName() + "' inside 'Intracellular', or decrease its 'z' coordinate to less than " + zAnchor;
issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, tip, Issue.Severity.WARNING));
foundSomething = true;
}
} else if(sasCandidate.getLocation().getName().equals(Structure.SpringStructureEnum.Intracellular.columnName)){
if(!(zCandidate > zAnchor)) {
String msg = "Sites located in the 'Intracellular' structure must have their z-coordinate larger that the one of the 'Anchor' site";
String tip = "Relocate the site '" + mc.getName() + "' inside 'Extracellular', or increase its 'z' coordinate to more than " + zAnchor;
String tip = "Sites located in the 'Intracellular' structure must have their z-coordinate larger that the one of the 'Anchor' site";
String msg = "Relocate the site '" + mc.getName() + "' inside 'Extracellular', or increase its 'z' coordinate to more than " + zAnchor;
issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, tip, Issue.Severity.WARNING));
foundSomething = true;
}
Expand Down

0 comments on commit bc9506d

Please sign in to comment.