Sunday, September 9, 2007

dragging a bit around

After the A JChemPaint Hack-a-thon a week ago it was time to make something more interesting then dumping the nearest IAtom to STDOUT. So I went on coding to make it possible to move Atoms around.
The new architecture had no way yet make the renderer 'repaint' the window. My first attempt was using the Component from a MouseEvent and after that dragging worked ok for Swing. Egon reminded me that with SWT it is probably not possible that way and unfortunately that was true. So we added a new Interface IViewEventRelay which currently only exist of updateView(). The swing implementation SwingEventRelay is added to the Controller2DHub so Controller2DModules can use updateView() now and the Controller2DHub will know which IViewEventRelay to use.
Because Java2DRenderer calculated the atom boundaries again on a repaint() it showed strange behaviour. If you moved one atom, the other ones would move most likely aswell. Also it was impossible to move atoms 'out of the screen' instead everything would be drawn smaller. So Java2DRenderer is now only calculating new boundaries if the window is new or is resized. If you resize the window it will make sure all atoms/bounds are visible again.
In the video you can see how dragging looks like now. The dragging isn't perfect yet, at some moments when moving an atom 'over' another one it will continu to drag the other atom. video
This also shows that the location of the H symbol isn't always correct and that a charge symbol at some point ends up in 'the air'.
If you want to give the new architecture a test run, look for the TestEditor application.

Wednesday, August 29, 2007

zoomfactor




Scott noticed problems rendering bonds when zooming out with JChemPaint and wondered if this problem currently is being addressed (maybe in the Programmeerzomer)?
So well, here some pictures with zoom set to 0.5, 0.2 and 0.1. As you can see, the bonds are still visible here. I don't know what bonds Scott saw became faint/disappeared so I don't know if my code fixes this issue.

formal charge x,y etc.


So here a picture with formal charges, chemist people will probably noticethat the molecule with such charges doesn't make any sense ;)

The question however here is if the positioning of the '2-', '2+' and '-' is done properly. So comments are welcome!

hydrogen shown


Seems like my last blog was ages ago.. so time for a new one!

The new code now renders the hydrogen stuff correctly at the proper location. At the old jchempaint it was either left or right of the Atom symbol but now it's also possible for the 'H' to be shown above/below the Atom symbol if that looks 'better' on that molecule. You can see this at the picture.
Also no need anymore for screenshots, this picture is created with BufferedImage / ImageIO.write (code in TestRenderer / Java2DRenderer @ http://cdk.svn.sf.net/..../progz/).
Comments are welcome as always..

Tuesday, July 31, 2007

innerbonds including funky colors

So, at breakfast I was thinking about the best way/place to draw the innerbonds. After drawing a simple Benzene-molecule on paper I figured there are a lot of triangles which could be usefull to figure out the right place.
It seems to me that the innerbonds should always inside the triangle with an atom in 2 corners and the center of the ring in the other, giving the green/green/black triangle in the picture. The pink lines are orthogonal to the outerbonds. It seems logical to place the innerbond parallel to the outerbond.
After working this out in the code it seems like the idea works, the picture shows how the current code shows some molecules.



The current code can be found on this page.
The distance between the innerbond and outerbond can be easily changed. I think the distance is fine on the left 2 molecules, and a little too high at the right one. What should the default distance be?

Monday, July 30, 2007

Rings: ellipse or circle?

How do you like your rings to displayed?

The first option with painting aromatic ring is whether to display the aromaticity as double bonding or as a ring.
If you want them to be displayed as a ring, then second question is whether to draw this as a ellipse or as a perfect circle.

In these pictures below you can see the two different options to show aromaticity inside for a Benzene ring.

Is one of them clearly better then the other, is it personal taste or doesn't it matter at all?


Tuesday, July 24, 2007

progz-jchempaint

This new blog is about the project I'm working on for the Dutch summer of code, called 'Programmeerzomer', organised by the Holland Open Software Platform The project I'm working on is called JChemPaint, an editor for 2D molecular structures and part of the The Chemistry Development Kit (CDK). My goal for this project is to rewrite JChemPaint with proper Java2D and SWT support. Egon Willighagen is my mentor for this project.

Why doing this?
-Java2D isn't used efficiently in JChemPaint atm.
-Bioclipse is currently using the SWT_AWT bridge with proprietary code which is not working on virtual machines.

My Goals
-Getting known to CDk, Bioclipse and SWT.
-Checking out current JChemPaint code.
-Find out requirements for code to be replaced.
-Implementing SWT/Java2D in JchedmPaint
-Making chances at other places of the CDK (Renderer2D for example)
-Get new version of JChemPaint working in Bioclipse

Planning
25 June There was a meeting at which the project became clear.
12 July Presentation about the planning and goals
9 August Half-way meeting
20 September Endpresentation at the Holland Open 'Netwerkborrel'