User a8020badc4
14-10-2011 12:12:38
Hello,
I want to add a distance monitor to a MarvinSpace canvas. I've seen it mentioned in the GUI usage guide but I can't see any documentation on how to add these to a basic canvas.
Does anyone have an example of this or could point me to the neccessary documentation?
Thanks,
Sam
ChemAxon efa1591b5a
18-10-2011 14:02:10
Hi Sam,
1 Clikk the distance icon in the toolbar (leftmost button).
2 Then click one atom of you structure, it becomes pink when selected.
3 Then click the second atom, the distance monitor is displayed, connecting the two selected atoms.
4 Optionally, you can drag the distance label away in a better position.
Does this help?
Miklos
User a8020badc4
18-10-2011 14:51:29
Hello Miklos,
Thank you for your reply.
The Marvin Space window I have implemented is very basic (it looks similar in funcationality to this example http://www.chemaxon.com/marvin/examples/applets/space/embed.html)
i.e. I don't even have a toolbar to accompany my window.
Do you know how I can add on to the MSpace window?
Many thanks,
Sam
ChemAxon eb65a25631
19-10-2011 12:21:57
Hi,
I hope this helps:
// Retrieve a component (the first component in the first cell)
GraphicComponent gc1 = graphicScene.getGraphicComponent( 0, 0 );
// Create a distance monitor
Monitor monitor = new DistanceMonitor();
// Associate the monitor with the component
gc1.associate(monitor);
// Select the first, and the third atom of the component
monitor.selectItem(new ComponentElement(gc1,MoleculeComponent.COMPONENT_TYPE_ATOM, 2, 1));
monitor.selectItem(new ComponentElement(gc1, MoleculeComponent.COMPONENT_TYPE_ATOM, 2, 3));
// Add the monitor to the scene
graphicScene.addComponent( monitor );
monitor.select();
// Now, create a label for the monitor
chemaxon.marvin.space.monitor.Label label = new chemaxon.marvin.space.monitor.Label();
label.selectItem(monitor);
label.setRelativeXCoordinate( graphicScene.getCellLeft() );
label.setRelativeYCoordinate( graphicScene.getCellButtom() );
monitor.unSelect();
// Add label to scene too.
graphicScene.addComponent( label );
// Associate the label with the monitor
monitor.associate( label );
// Do the measurement
((DistanceMonitor)monitor).measurement();
Regards,
Andras