MarvinSketchForm: Center reaction sketch?

User 1a8d11549a

17-06-2011 08:56:19

Hi Victor,


While we are now approaching a high level of usability of the MarvinSketchForm with the latest modifications, there's a probably final non-cosmetic item to resolve. The issue is, that when opening an existing sketch in the dialog editor, it often doesn't appear centered, as one might expect, but is rendered maybe near an edge, the rest of it being clipped - although there would be plenty of space available to fully display it. The user then has to scroll manually to center it, which rather awkward.


Therefore: Is there a way to center a sketch on the sketch pane? And if yes, would it be an option to include this as a default behaviour in your coming new new version of the MarvinSketchForm?


Stefan


 


 

ChemAxon bd13b5bd77

17-06-2011 09:20:43

Hi Istvan, could you please send us a possible solution if it is available?


If we have an option for that I would expose it in the 5.6 (deadline is today).


 


Thanks,


Viktor

ChemAxon bd13b5bd77

17-06-2011 10:17:25

Stefan,


var molPanel = sketcher.Value.getMolPanel() as chemaxon.marvin.sketch.swing.SketchPanel;
molPanel.centralizeMoleculeDisplay();


Istvan will expose this centralize molecule display option to the sketch pane (interface) in java, so from 5.6 you can directly access it by using


object NativeEditor new interface property in 5.6 .NET version.


 


https://www.chemaxon.com/forum/viewpost35764.html#35764


Viktor

User 1a8d11549a

17-06-2011 11:32:50

Ok, thanks, thats good news. Is there any workaround for now, or will 5.6 be released soon anyway (my understanding is that the above two lines of code are a reference for future use)?


Stefan

ChemAxon bd13b5bd77

17-06-2011 11:36:48

var molPanel = sketcher.Value.getMolPanel() as chemaxon.marvin.sketch.swing.SketchPanel;
molPanel.centralizeMoleculeDisplay();


these lines you can use now.


 


later on:


sketcher = TypecastTo(NativeEditor, MSketchpane) // as nativeEditor is object => to avoid inlcuding JChem by default
sketcher
.centralizeMoleculeDisplay();


will be avialable on the sketcher interface.

User 1a8d11549a

17-06-2011 11:56:18

I was asking because I was unable to get a reference for "chemaxon.marvin.sketch.swing.SketchPanel". I also couldn't find anything on "centralizeMoleculeDisplay" in the JChem_NET API documentation. Is there a specific dll I should reference?

ChemAxon bd13b5bd77

17-06-2011 12:12:32

It should be avialable in 5.5. It was already released in the last month.


 


It is not a documented API right now will be in 5.6,

User 1a8d11549a

17-06-2011 12:25:32

Yes, I am referencing 5.5, and still intellisense doesn't show any of the shown members. However, don't worry - I can wait until 5.6 is released, if it isn't planned in a very distant future.

ChemAxon bd13b5bd77

17-06-2011 12:46:05

Uploaded the project again. It contains the code.

User 1a8d11549a

17-06-2011 14:31:37

Yes, your code works, no problem there. When I try to port it to my project, it doesn't any more - I get the attached error tooltip. I have completely replicated all of your references and imports, but its still the same. I also don't see any chamaxon.marvin.sketch namespace in the object browser, and I am using JChem 5.5.


If you don't have a spontaneous idea what this could be, then I think I have spent plenty of time on this and will wait for the 5.6 release ...

ChemAxon bd13b5bd77

17-06-2011 14:39:16

I think your project points to a different assembly sitting in the GAC side-by-side.


Please check your GAC ...


 


Or you have more than one assembly added bringing the namespace on the board.

User 1a8d11549a

17-06-2011 15:56:11

Please find attached the list of my required references. Maybe you see something I don't see...

ChemAxon bd13b5bd77

20-06-2011 07:54:58

1. Worth checking:

C:\Windows\assembly\GAC_MSIL\ChemAxon.NET\ 
C:\Windows\assembly\GAC_MSIL\JChem\ 
C:\Windows\assembly\GAC_MSIL\Policy.5.5.JChem\ 


should be checked by Total Commander and delete the extra one (which is not shown in the list you sent). 
And the registry policies should also be checked if they point to the correct version of dlls: 



HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion\PublisherPolicy\Default\Policy.5.4.JChemExt__d25ce09139c726a9\1\5.4.1.2099


 


2. Worth checking:



please remove the assemblies from the solution and add them again to your project if does not work,
apply what I sent to you, manually you can edit the project file 
 



<ItemGroup>
    <Reference Include="ChemAxon.NET, Version=5.4.1.1900, Culture=neutral, PublicKeyToken=d25ce09139c726a9, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\..\Program Files\ChemAxon\JChem .NET API 5.4.1.1062\ChemAxon.NET.dll</HintPath>

<Reference Include="JChem, Version=5.4.1.1062, Culture=neutral, PublicKeyToken=d25ce09139c726a9, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\..\Program Files\ChemAxon\JChem .NET API 5.4.1.1062\JChem.dll</HintPath>




 



3. Use reflection (this is the ugliest solution) for calling that method. Because if it is working from my solution it should from yours, the real problem needs to be found out instead.

 var molPanel = sketcher.Value.getMolPanel();
Type panel = molPanel.GetType();
var method = panel.GetMethod("centralizeMoleculeDisplay");
method.Invoke(molPanel, new object[] { });





 



 



 





User 1a8d11549a

20-06-2011 09:07:24

Victor,


I have checked your proposed reflection code, and it works just great! What a difference to what I got before, the editor dialog content now really looks as it should, no more awkward scrolling necessary,what a relief!-  I therefore think I will use your code as a workaround, along with the other reflection bits, until JChem 5.6 appears.


Whenever I find some time I will follow up your suggestions to isolate the root cause of the referencing problem, since that might be interesting too. Since this issue almost drove me crazy during the past few days, I'll give it a little rest now :-). I will let you know whenever I found something.


So I think we can close this thread as solved then for the time being. Thanks again for your help.


Stefan