Skip to content

Commit afd23fe

Browse files
committed
added option to not automatically assign a color to a molecule, when it is added to the scene
1 parent e36e859 commit afd23fe

File tree

9 files changed

+55
-84
lines changed

9 files changed

+55
-84
lines changed

src/main/java/org/openmolecules/fx/tasks/V3DDockingEngine.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
package org.openmolecules.fx.tasks;
22

3-
import java.util.List;
4-
5-
import org.openmolecules.fx.viewer3d.V3DBindingSite;
6-
import org.openmolecules.fx.viewer3d.V3DRotatableGroup;
7-
import org.openmolecules.fx.viewer3d.V3DMolecule;
8-
import org.openmolecules.fx.viewer3d.V3DMoleculeUpdater;
9-
import org.openmolecules.fx.viewer3d.V3DScene;
10-
113
import com.actelion.research.chem.Coordinates;
124
import com.actelion.research.chem.Molecule;
135
import com.actelion.research.chem.StereoMolecule;
146
import com.actelion.research.chem.docking.DockingEngine;
157
import com.actelion.research.chem.docking.DockingEngine.DockingResult;
168
import com.actelion.research.chem.docking.DockingFailedException;
17-
189
import javafx.application.Platform;
10+
import org.openmolecules.fx.viewer3d.*;
11+
12+
import java.util.List;
1913

2014
public class V3DDockingEngine {
2115

@@ -64,7 +58,7 @@ public void reDock() throws DockingFailedException {
6458
Platform.runLater(() -> {
6559
scene3D.addGroup(dockedGroup);
6660
V3DMolecule fxmol = new V3DMolecule(docked);
67-
scene3D.addMolecule(fxmol, dockedGroup);
61+
scene3D.addMolecule(fxmol, dockedGroup, true);
6862
});
6963
System.out.println(result.getScore());
7064
} catch (DockingFailedException e) {
@@ -91,7 +85,7 @@ public void dockLibrary(List<StereoMolecule> library) throws DockingFailedExcept
9185
StereoMolecule docked = result.getPose();
9286
Platform.runLater(() -> {
9387
V3DMolecule fxmol = new V3DMolecule(docked);
94-
scene3D.addMolecule(fxmol, dockedGroup);
88+
scene3D.addMolecule(fxmol, dockedGroup, true);
9589
});
9690
System.out.println(result.getScore());
9791
} catch (DockingFailedException e) {

src/main/java/org/openmolecules/fx/tasks/V3DShapeAlignerFromFile.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
package org.openmolecules.fx.tasks;
22

3-
import org.openmolecules.fx.viewer3d.CarbonAtomColorPalette;
4-
import org.openmolecules.fx.viewer3d.V3DCustomizablePheSA;
5-
import org.openmolecules.fx.viewer3d.V3DMolecule;
6-
import org.openmolecules.fx.viewer3d.V3DMoleculeUpdater;
7-
import org.openmolecules.fx.viewer3d.V3DScene;
8-
9-
import com.actelion.research.calc.Matrix;
103
import com.actelion.research.chem.Coordinates;
114
import com.actelion.research.chem.StereoMolecule;
125
import com.actelion.research.chem.alignment3d.transformation.Rotation;
136
import com.actelion.research.chem.conf.Conformer;
147
import com.actelion.research.chem.phesa.DescriptorHandlerShape;
158
import com.actelion.research.chem.phesa.MolecularVolume;
16-
import com.actelion.research.chem.phesa.PheSAAlignment;
179
import com.actelion.research.chem.phesa.PheSAMolecule;
18-
1910
import javafx.application.Platform;
2011
import javafx.collections.ObservableList;
2112
import javafx.scene.transform.Transform;
13+
import org.openmolecules.fx.viewer3d.*;
2214

2315
import java.util.ArrayList;
2416
import java.util.List;
@@ -103,7 +95,7 @@ private void run() {
10395
refMolUpdater.update();
10496
Platform.runLater(() -> {
10597
for (int i=0; i<fittedFXMols.size(); i++) {
106-
mScene.addMolecule(fittedFXMols.get(i));
98+
mScene.addMolecule(fittedFXMols.get(i), true);
10799
fittedFXMols.get(i).setColor(CarbonAtomColorPalette.getColor(fittedFXMols.get(i).getID()));
108100
fittedFXMols.get(i).fireCoordinatesChange();
109101
V3DMoleculeUpdater fxMolUpdater = new V3DMoleculeUpdater(fittedFXMols.get(i));

src/main/java/org/openmolecules/fx/tasks/V3DShapeAlignment.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
package org.openmolecules.fx.tasks;
22

3-
import org.openmolecules.fx.viewer3d.CarbonAtomColorPalette;
4-
import org.openmolecules.fx.viewer3d.V3DMolecule;
5-
import org.openmolecules.fx.viewer3d.V3DMoleculeUpdater;
6-
import org.openmolecules.fx.viewer3d.V3DScene;
7-
8-
import com.actelion.research.calc.Matrix;
93
import com.actelion.research.chem.Coordinates;
104
import com.actelion.research.chem.StereoMolecule;
115
import com.actelion.research.chem.alignment3d.transformation.Rotation;
126
import com.actelion.research.chem.conf.Conformer;
137
import com.actelion.research.chem.phesa.DescriptorHandlerShape;
148
import com.actelion.research.chem.phesa.MolecularVolume;
15-
import com.actelion.research.chem.phesa.PheSAAlignment;
169
import com.actelion.research.chem.phesa.PheSAMolecule;
17-
1810
import javafx.application.Platform;
1911
import javafx.collections.ObservableList;
2012
import javafx.scene.transform.Transform;
13+
import org.openmolecules.fx.viewer3d.CarbonAtomColorPalette;
14+
import org.openmolecules.fx.viewer3d.V3DMolecule;
15+
import org.openmolecules.fx.viewer3d.V3DMoleculeUpdater;
16+
import org.openmolecules.fx.viewer3d.V3DScene;
2117

2218
import java.util.ArrayList;
2319
import java.util.List;
@@ -96,7 +92,7 @@ private void run() {
9692
Platform.runLater(() -> {
9793

9894
for (int i=0; i<fittedFXMols.size(); i++) {
99-
mScene.addMolecule(fittedFXMols.get(i));
95+
mScene.addMolecule(fittedFXMols.get(i), true);
10096
fittedFXMols.get(i).setColor(CarbonAtomColorPalette.getColor(fittedFXMols.get(i).getID()));
10197
fittedFXMols.get(i).fireCoordinatesChange();
10298
V3DMoleculeUpdater fxMolUpdater = new V3DMoleculeUpdater(fittedFXMols.get(i));

src/main/java/org/openmolecules/fx/viewer3d/CarbonAtomColorPalette.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,25 @@ public static Color getColor(int id) {
3636
}
3737

3838
private void init() {
39-
mColors = Arrays.asList(new Color[] {Color.AQUAMARINE, Color.BLUEVIOLET,
40-
Color.BROWN,Color.BURLYWOOD, Color.CADETBLUE, Color.CHARTREUSE, Color.CHOCOLATE,
41-
Color.CORAL, Color.CORNFLOWERBLUE, Color.CRIMSON, Color.CYAN,
42-
Color.DARKCYAN, Color.DARKGOLDENROD, Color.DARKGRAY, Color.DARKKHAKI, Color.DARKMAGENTA,
43-
Color.DARKORANGE, Color.DARKORCHID, Color.DARKRED, Color.DARKSALMON, Color.DARKSEAGREEN,
44-
Color.DARKSLATEBLUE, Color.DARKTURQUOISE, Color.DARKTURQUOISE,
45-
Color.DARKVIOLET, Color.DEEPPINK, Color.DEEPSKYBLUE, Color.DODGERBLUE,
46-
Color.FIREBRICK, Color.FUCHSIA, Color.GOLD, Color.GOLDENROD, Color.GREENYELLOW,
47-
Color.HOTPINK, Color.LEMONCHIFFON, Color.INDIANRED, Color.INDIGO, Color.KHAKI,
48-
Color.LAVENDER, Color.LAVENDERBLUSH, Color.LAWNGREEN, Color.LEMONCHIFFON, Color.LIGHTBLUE,
49-
Color.LIGHTCORAL, Color.LIGHTCYAN, Color.LIGHTGOLDENRODYELLOW, Color.LIGHTGREEN,
50-
Color.LIGHTPINK, Color.LIGHTSALMON, Color.LIGHTSEAGREEN, Color.LIGHTSKYBLUE,
51-
Color.LIGHTSTEELBLUE, Color.LIGHTYELLOW, Color.LIME, Color.LIMEGREEN, Color.MEDIUMAQUAMARINE,
52-
Color.MAGENTA, Color.MAROON, Color.MEDIUMORCHID, Color.MEDIUMPURPLE, Color.MEDIUMSEAGREEN,
53-
Color.MEDIUMSLATEBLUE, Color.MEDIUMSPRINGGREEN, Color.MEDIUMTURQUOISE, Color.MEDIUMVIOLETRED,
54-
Color.MIDNIGHTBLUE, Color.MINTCREAM, Color.MISTYROSE, Color.MOCCASIN, Color.OLIVE,
55-
Color.OLIVEDRAB, Color.ORANGE, Color.ORANGERED, Color.ORCHID, Color.PALEGOLDENROD, Color.PALEGREEN,
56-
Color.PALETURQUOISE, Color.PALEVIOLETRED, Color.PAPAYAWHIP, Color.PEACHPUFF, Color.PERU, Color.PINK,
57-
Color.PLUM, Color.POWDERBLUE, Color.PURPLE, Color.SPRINGGREEN, Color.STEELBLUE, Color.TAN, Color.TEAL,
58-
Color.THISTLE, Color.TOMATO, Color.TURQUOISE, Color.VIOLET, Color.WHEAT, Color.YELLOW, Color.YELLOWGREEN});
39+
mColors = Arrays.asList(Color.AQUAMARINE, Color.BLUEVIOLET,
40+
Color.BROWN,Color.BURLYWOOD, Color.CADETBLUE, Color.CHARTREUSE, Color.CHOCOLATE,
41+
Color.CORAL, Color.CORNFLOWERBLUE, Color.CRIMSON, Color.CYAN,
42+
Color.DARKCYAN, Color.DARKGOLDENROD, Color.DARKGRAY, Color.DARKKHAKI, Color.DARKMAGENTA,
43+
Color.DARKORANGE, Color.DARKORCHID, Color.DARKRED, Color.DARKSALMON, Color.DARKSEAGREEN,
44+
Color.DARKSLATEBLUE, Color.DARKTURQUOISE, Color.DARKTURQUOISE,
45+
Color.DARKVIOLET, Color.DEEPPINK, Color.DEEPSKYBLUE, Color.DODGERBLUE,
46+
Color.FIREBRICK, Color.FUCHSIA, Color.GOLD, Color.GOLDENROD, Color.GREENYELLOW,
47+
Color.HOTPINK, Color.LEMONCHIFFON, Color.INDIANRED, Color.INDIGO, Color.KHAKI,
48+
Color.LAVENDER, Color.LAVENDERBLUSH, Color.LAWNGREEN, Color.LEMONCHIFFON, Color.LIGHTBLUE,
49+
Color.LIGHTCORAL, Color.LIGHTCYAN, Color.LIGHTGOLDENRODYELLOW, Color.LIGHTGREEN,
50+
Color.LIGHTPINK, Color.LIGHTSALMON, Color.LIGHTSEAGREEN, Color.LIGHTSKYBLUE,
51+
Color.LIGHTSTEELBLUE, Color.LIGHTYELLOW, Color.LIME, Color.LIMEGREEN, Color.MEDIUMAQUAMARINE,
52+
Color.MAGENTA, Color.MAROON, Color.MEDIUMORCHID, Color.MEDIUMPURPLE, Color.MEDIUMSEAGREEN,
53+
Color.MEDIUMSLATEBLUE, Color.MEDIUMSPRINGGREEN, Color.MEDIUMTURQUOISE, Color.MEDIUMVIOLETRED,
54+
Color.MIDNIGHTBLUE, Color.MINTCREAM, Color.MISTYROSE, Color.MOCCASIN, Color.OLIVE,
55+
Color.OLIVEDRAB, Color.ORANGE, Color.ORANGERED, Color.ORCHID, Color.PALEGOLDENROD, Color.PALEGREEN,
56+
Color.PALETURQUOISE, Color.PALEVIOLETRED, Color.PAPAYAWHIP, Color.PEACHPUFF, Color.PERU, Color.PINK,
57+
Color.PLUM, Color.POWDERBLUE, Color.PURPLE, Color.SPRINGGREEN, Color.STEELBLUE, Color.TAN, Color.TEAL,
58+
Color.THISTLE, Color.TOMATO, Color.TURQUOISE, Color.VIOLET, Color.WHEAT, Color.YELLOW, Color.YELLOWGREEN);
5959
}
6060
}

src/main/java/org/openmolecules/fx/viewer3d/V3DScene.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private void initializeDragAndDrop() {
189189
new ConformerGenerator().getOneConformerAsMolecule(mol);
190190

191191
if (mol != null)
192-
addMolecule(new V3DMolecule(mol));
192+
addMolecule(new V3DMolecule(mol), true);
193193

194194
event.consume();
195195
});
@@ -312,7 +312,7 @@ public void paste() {
312312

313313
V3DMolecule fxmol = new V3DMolecule(mol, V3DMolecule.getNextID(), role);
314314
mCopiedMol = null;
315-
addMolecule(fxmol);
315+
addMolecule(fxmol, true);
316316
optimizeView(fxmol);
317317
}
318318

@@ -606,14 +606,14 @@ public void addGroup(V3DRotatableGroup group) {
606606
addGroup(group, mWorld);
607607
}
608608

609-
public void addMolecule(V3DMolecule fxmol) {
610-
addMolecule(fxmol, mWorld);
609+
public void addMolecule(V3DMolecule fxmol, boolean assignIndividualColor) {
610+
addMolecule(fxmol, mWorld, assignIndividualColor);
611611
}
612612

613-
public void addMolecule(V3DMolecule fxmol, V3DRotatableGroup group) {
613+
public void addMolecule(V3DMolecule fxmol, V3DRotatableGroup group, boolean assignIndividualColor) {
614614
fxmol.setOverrideHydrogens(mMayOverrideHydrogens);
615615
Color color = CarbonAtomColorPalette.getColor(mMoleculeColorID++);
616-
if (fxmol.getColor() == null)
616+
if (fxmol.getColor() == null && assignIndividualColor)
617617
fxmol.setColor(color);
618618
group.addGroup(fxmol);
619619
updateDepthCueing();

src/main/java/org/openmolecules/fx/viewer3d/editor/actions/V3DAddAtomAction.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
package org.openmolecules.fx.viewer3d.editor.actions;
22

3+
import com.actelion.research.chem.StereoMolecule;
34
import org.openmolecules.fx.viewer3d.V3DMolecule;
4-
import org.openmolecules.fx.viewer3d.V3DMoleculeBuilder;
55
import org.openmolecules.fx.viewer3d.V3DMoleculeModifier;
66
import org.openmolecules.fx.viewer3d.V3DScene;
77
import org.openmolecules.fx.viewer3d.nodes.NodeDetail;
88

9-
import com.actelion.research.chem.Molecule;
10-
import com.actelion.research.chem.StereoMolecule;
11-
import com.actelion.research.chem.conf.AtomAssembler;
12-
import com.actelion.research.chem.conf.Conformer;
13-
import com.actelion.research.share.gui.editor.geom.IDrawContext;
14-
import com.actelion.research.share.gui.editor.io.IKeyEvent;
15-
import com.actelion.research.share.gui.editor.io.IMouseEvent;
16-
179
public class V3DAddAtomAction implements V3DEditorAction {
1810

1911
private int mAtomicNo;
@@ -40,7 +32,7 @@ public V3DMolecule onMouseUp(V3DScene scene3D) {
4032
V3DMolecule v3dMol = new V3DMolecule(mol, V3DMolecule.getNextID(), V3DMolecule.MoleculeRole.LIGAND, scene3D.mayOverrideHydrogenColor());
4133
// v3dMol.activateEvents();
4234
V3DMoleculeModifier.placeAtom(v3dMol, mAtomicNo);
43-
scene3D.addMolecule(v3dMol);
35+
scene3D.addMolecule(v3dMol, true);
4436
return v3dMol;
4537
}
4638

src/main/java/org/openmolecules/fx/viewer3d/editor/actions/V3DAddFragmentAction.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package org.openmolecules.fx.viewer3d.editor.actions;
22

3+
import com.actelion.research.chem.StereoMolecule;
34
import org.openmolecules.fx.viewer3d.V3DMolecule;
45
import org.openmolecules.fx.viewer3d.V3DMoleculeModifier;
56
import org.openmolecules.fx.viewer3d.V3DScene;
6-
import org.openmolecules.fx.viewer3d.editor.actions.V3DEditorAction;
77
import org.openmolecules.fx.viewer3d.nodes.NodeDetail;
88

9-
import com.actelion.research.chem.StereoMolecule;
10-
119
public class V3DAddFragmentAction implements V3DEditorAction {
1210

1311

@@ -58,7 +56,7 @@ public V3DMolecule onMouseUp(V3DScene scene3D) {
5856
// v3dMol.activateEvents();
5957
V3DMoleculeModifier.placeFragment(v3dMol, mIDCodes);
6058
v3dMol.setInitialCoordinates();
61-
scene3D.addMolecule(v3dMol);
59+
scene3D.addMolecule(v3dMol, true);
6260
return v3dMol;
6361
}
6462

src/main/java/org/openmolecules/fx/viewer3d/io/V3DMoleculeParser.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,10 @@ else if(file.endsWith(".dwar"))
115115
private static void parseFile(V3DScene scene,String file) {
116116
List<V3DRotatableGroup> molGroups = new ArrayList<V3DRotatableGroup>();
117117

118-
if(file.endsWith(".mol") || file.endsWith(".mol2") || file.endsWith(".sdf") || file.endsWith(".dwar")
119-
|| file.endsWith(".mol") ) {
118+
if(file.endsWith(".mol") || file.endsWith(".mol2") || file.endsWith(".sdf") || file.endsWith(".dwar")) {
120119
List<StereoMolecule> mols = parseChemFile(file);
121120

122-
mols.stream().forEach(e -> scene.addMolecule(new V3DMolecule(e, V3DMolecule.getNextID(),V3DMolecule.MoleculeRole.LIGAND,false)));
121+
mols.stream().forEach(e -> scene.addMolecule(new V3DMolecule(e, V3DMolecule.getNextID(),V3DMolecule.MoleculeRole.LIGAND,false), true));
123122
}
124123
else if(file.endsWith(".pdb")) {
125124
try {
@@ -154,7 +153,7 @@ else if (role==V3DMolecule.MoleculeRole.LIGAND)
154153
});
155154
pdbGroup.addGroup(molGroup);
156155
for(V3DMolecule fxmol : groupMols) {
157-
scene.addMolecule(fxmol, molGroup);
156+
scene.addMolecule(fxmol, molGroup, true);
158157
if(isProtein)
159158
Platform.runLater(() -> fxmol.setColor(Color.DARKGRAY));
160159

src/main/java/org/openmolecules/fx/viewerapp/StartOptions.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ private void loadPDBEntry(V3DScene scene) {
436436
V3DMolecule.MoleculeRole.MACROMOLECULE,
437437
true);
438438
vm.getMolecule().setName("Protein");
439-
scene.addMolecule(vm, complex);
439+
scene.addMolecule(vm, complex, true);
440440
}
441441

442442
V3DMolecule v3dligand = null;
@@ -448,7 +448,7 @@ private void loadPDBEntry(V3DScene scene) {
448448
V3DMolecule.MoleculeRole.LIGAND,
449449
true);
450450
v3dligand.getMolecule().setName("Ligand");
451-
scene.addMolecule(v3dligand, complex);
451+
scene.addMolecule(v3dligand, complex, true);
452452
}
453453

454454
List<Molecule3D> solvents = map.get(StructureAssembler.SOLVENT_GROUP);
@@ -460,7 +460,7 @@ private void loadPDBEntry(V3DScene scene) {
460460
V3DMolecule.MoleculeRole.SOLVENT,
461461
true);
462462
mol.setName((mol.getAllAtoms()==1 && mol.getAtomicNo(0)==8 ? "Water " : "Solvent ")+mol.getAtomChainId(0));
463-
scene.addMolecule(vm, complex);
463+
scene.addMolecule(vm, complex, true);
464464
}
465465

466466
if (v3dligand != null && mCropLigand) {
@@ -487,7 +487,7 @@ private void testMolecules(V3DScene scene) {
487487
mol.center();
488488
mol.translate(dx, dy, dz);
489489
V3DMolecule vm = new V3DMolecule(mol, V3DMolecule.getNextID(),V3DMolecule.MoleculeRole.LIGAND);
490-
scene.addMolecule(vm);
490+
scene.addMolecule(vm, true);
491491
}
492492
}
493493

@@ -504,7 +504,7 @@ private void testFragments(V3DScene scene) {
504504
mol.center();
505505
mol.translate(dx, dy, dz);
506506
V3DMolecule vm = new V3DMolecule(mol, V3DMolecule.getNextID(), V3DMolecule.MoleculeRole.LIGAND);
507-
scene.addMolecule(vm);
507+
scene.addMolecule(vm, true);
508508
}
509509
}
510510

@@ -521,7 +521,7 @@ private void testOrganoMetallics(V3DScene scene) {
521521
mol.center();
522522
mol.translate(dx, dy, dz);
523523
V3DMolecule vm = new V3DMolecule(mol, V3DMolecule.getNextID(),V3DMolecule.MoleculeRole.LIGAND);
524-
scene.addMolecule(vm);
524+
scene.addMolecule(vm, true);
525525
}
526526
}
527527

@@ -544,7 +544,7 @@ private void testSurfaces(V3DScene scene) {
544544
vm.setSurface(0, V3DMolecule.SurfaceMode.FILLED, SurfaceMesh.SURFACE_COLOR_ATOMIC_NOS, transparency);
545545

546546
// vm.activateEvents();
547-
scene.addMolecule(vm);
547+
scene.addMolecule(vm, true);
548548
}
549549
}
550550

@@ -606,7 +606,7 @@ private void testConformers(V3DScene scene) {
606606
vm.setConstructionMode(MoleculeArchitect.CONSTRUCTION_MODE_WIRES);
607607
vm.setColor(Color.hsb(hue, 1.0, 0.5));
608608
// vm.activateEvents();
609-
scene.addMolecule(vm);
609+
scene.addMolecule(vm, true);
610610
hue += 37;
611611
count ++;
612612
if (count == 100)
@@ -620,7 +620,7 @@ private void testSimple(V3DScene scene) {
620620
mol = new ConformerGenerator(1467967297811L, false).getOneConformerAsMolecule(mol);
621621
V3DMolecule vm = new V3DMolecule(mol, V3DMolecule.getNextID(),V3DMolecule.MoleculeRole.LIGAND);
622622
vm.setConstructionMode(MoleculeArchitect.CONSTRUCTION_MODE_BALL_AND_STICKS);
623-
scene.addMolecule(vm);
623+
scene.addMolecule(vm, false);
624624
}
625625

626626
private void testProteinFromMMTF(V3DScene scene) {
@@ -648,7 +648,7 @@ private void testProteinFromMMTF(V3DScene scene) {
648648
millis = printDelay(millis);
649649
System.out.print("adding molecule to scene... ");
650650

651-
scene.addMolecule(vm);
651+
scene.addMolecule(vm, true);
652652
millis = printDelay(millis);
653653
}
654654
}

0 commit comments

Comments
 (0)