From 63f13b68b15976f33eb8340e45aa833c917f5f4e Mon Sep 17 00:00:00 2001 From: Dan Vasilescu Date: Wed, 11 Dec 2024 14:04:53 -0500 Subject: [PATCH 1/3] Better issues messages, as suggested by Michael. --- .../vcell/mapping/SpeciesContextSpec.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/vcell-core/src/main/java/cbit/vcell/mapping/SpeciesContextSpec.java b/vcell-core/src/main/java/cbit/vcell/mapping/SpeciesContextSpec.java index e8a61b53c0..e560db9136 100644 --- a/vcell-core/src/main/java/cbit/vcell/mapping/SpeciesContextSpec.java +++ b/vcell-core/src/main/java/cbit/vcell/mapping/SpeciesContextSpec.java @@ -1295,8 +1295,8 @@ public void gatherIssues(IssueContext issueContext, List 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; } @@ -1315,8 +1315,8 @@ public void gatherIssues(IssueContext issueContext, List 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; } @@ -1382,8 +1382,8 @@ public void gatherIssues(IssueContext issueContext, List 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; } @@ -1440,15 +1440,15 @@ public void gatherIssues(IssueContext issueContext, List 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; } From cccd315d6778e682ebb898a10e107dca0d31b3dd Mon Sep 17 00:00:00 2001 From: Dan Vasilescu Date: Wed, 11 Dec 2024 14:43:17 -0500 Subject: [PATCH 2/3] Simplified MolecularStructuresTable, colored icons for Links (as suggested by Michael) --- .../gui/MolecularTypeSpecsTableModel.java | 42 ++++++++----------- .../gui/MolecularStructuresPanel.java | 21 +++++++--- .../org/vcell/util/gui/CompositeIcon.java | 32 ++++++++++++++ .../java/org/vcell/util/gui/VCellIcons.java | 3 ++ 4 files changed, 68 insertions(+), 30 deletions(-) create mode 100644 vcell-client/src/main/java/org/vcell/util/gui/CompositeIcon.java diff --git a/vcell-client/src/main/java/cbit/vcell/mapping/gui/MolecularTypeSpecsTableModel.java b/vcell-client/src/main/java/cbit/vcell/mapping/gui/MolecularTypeSpecsTableModel.java index 7abe61a937..69adcf4f2b 100644 --- a/vcell-client/src/main/java/cbit/vcell/mapping/gui/MolecularTypeSpecsTableModel.java +++ b/vcell-client/src/main/java/cbit/vcell/mapping/gui/MolecularTypeSpecsTableModel.java @@ -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 "), @@ -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: @@ -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; @@ -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) { @@ -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: @@ -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: @@ -522,8 +522,6 @@ private void refreshData() { updateColorComboBox(); } - - private void updateColorComboBox() { if(fieldSimulationContext == null) { return; @@ -570,7 +568,6 @@ public Component getListCellRendererComponent(JList list, Object value, setHorizontalTextPosition(SwingConstants.LEFT); if (value instanceof Structure structure) { setText(structure.getName()); - } return this; } @@ -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); } @@ -632,8 +628,6 @@ public void propertyChange(PropertyChangeEvent evt) { refreshColumns(); fireTableStructureChanged(); } - } - } diff --git a/vcell-client/src/main/java/org/vcell/model/springsalad/gui/MolecularStructuresPanel.java b/vcell-client/src/main/java/org/vcell/model/springsalad/gui/MolecularStructuresPanel.java index c1ec7e2cea..8be5c36f4f 100644 --- a/vcell-client/src/main/java/org/vcell/model/springsalad/gui/MolecularStructuresPanel.java +++ b/vcell-client/src/main/java/org/vcell/model/springsalad/gui/MolecularStructuresPanel.java @@ -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; @@ -52,6 +49,7 @@ import java.awt.event.FocusListener; import java.beans.PropertyChangeListener; import java.util.ArrayList; +import java.util.Map; @SuppressWarnings("serial") @@ -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 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; diff --git a/vcell-client/src/main/java/org/vcell/util/gui/CompositeIcon.java b/vcell-client/src/main/java/org/vcell/util/gui/CompositeIcon.java new file mode 100644 index 0000000000..e95a7fe2be --- /dev/null +++ b/vcell-client/src/main/java/org/vcell/util/gui/CompositeIcon.java @@ -0,0 +1,32 @@ +package org.vcell.util.gui; + +import javax.swing.*; +import java.awt.*; + +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) { +// Paint the first icon + icon1.paintIcon(c, g, x, y); + +// Paint the second icon next to the first icon + icon2.paintIcon(c, g, x + icon1.getIconWidth(), y); + } + + @Override public int getIconWidth() { +// The total width is the sum of both icons' widths + return icon1.getIconWidth() + icon2.getIconWidth(); + } + + @Override public int getIconHeight() { +// The height is the maximum of both icons' heights + return Math.max(icon1.getIconHeight(), icon2.getIconHeight()); + } +} \ No newline at end of file diff --git a/vcell-client/src/main/java/org/vcell/util/gui/VCellIcons.java b/vcell-client/src/main/java/org/vcell/util/gui/VCellIcons.java index 288004167b..f249a0fa7d 100644 --- a/vcell-client/src/main/java/org/vcell/util/gui/VCellIcons.java +++ b/vcell-client/src/main/java/org/vcell/util/gui/VCellIcons.java @@ -30,6 +30,9 @@ import javax.swing.UIManager; public abstract class VCellIcons { + + + public static HashMap imagePaths = new HashMap(); private static URL getResourceUrl(String resourcePath){ From e003fcb295ced03b7858d0497703d42213e0aa10 Mon Sep 17 00:00:00 2001 From: Dan Vasilescu Date: Wed, 11 Dec 2024 14:52:02 -0500 Subject: [PATCH 3/3] cosmetic --- .../org/vcell/util/gui/CompositeIcon.java | 28 +++++++++++-------- .../java/org/vcell/util/gui/VCellIcons.java | 2 ++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/vcell-client/src/main/java/org/vcell/util/gui/CompositeIcon.java b/vcell-client/src/main/java/org/vcell/util/gui/CompositeIcon.java index e95a7fe2be..b442733900 100644 --- a/vcell-client/src/main/java/org/vcell/util/gui/CompositeIcon.java +++ b/vcell-client/src/main/java/org/vcell/util/gui/CompositeIcon.java @@ -3,30 +3,34 @@ 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) { -// Paint the first icon - icon1.paintIcon(c, g, x, y); - -// Paint the second icon next to the first icon - icon2.paintIcon(c, g, x + icon1.getIconWidth(), y); + @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() { -// The total width is the sum of both icons' widths - return icon1.getIconWidth() + icon2.getIconWidth(); + @Override + public int getIconWidth() { + return icon1.getIconWidth() + icon2.getIconWidth(); // the total width is the sum of both icons' widths } - @Override public int getIconHeight() { -// The height is the maximum of both icons' heights - return Math.max(icon1.getIconHeight(), icon2.getIconHeight()); + @Override + public int getIconHeight() { + return Math.max(icon1.getIconHeight(), icon2.getIconHeight()); // height is the maximum of both icons' heights } } \ No newline at end of file diff --git a/vcell-client/src/main/java/org/vcell/util/gui/VCellIcons.java b/vcell-client/src/main/java/org/vcell/util/gui/VCellIcons.java index f249a0fa7d..d858a70a18 100644 --- a/vcell-client/src/main/java/org/vcell/util/gui/VCellIcons.java +++ b/vcell-client/src/main/java/org/vcell/util/gui/VCellIcons.java @@ -313,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();