From: gilleain t. <gil...@gm...> - 2009-06-25 20:06:02
|
Hi, As one of the developers of it, I'm glad you like the new architecture. We don't really have a place to put custom generators at the moment, but the changes you made could be incorporated into the reaction generator, I suppose. There's a balance between having a few large flexible generators, and many smaller specific generators. The changes to the placement of the '+' seem reasonable to me - since Stefan wrote that class, I will ask what he thinks. As for the problem of scaling and text, that is a tricky one. Text size is only known at the point of actually drawing, so it doesn't get included in the bounding box. One solution is to set the border - although that is not as precise. The possibility of a two-pass rendering has been raised before, and I was .. less than enthusiastic. I think "absolutely not" was what I said. However, the problem of text size is not going to go away, so perhaps it could be considered. What could be done is to run through all the generated TextElements in the visitor, and compute the on-screen size, given the current font. The bounds would then be re-calculated, and perhaps any other adjustments made, and only then would things be drawn. This would be slower, but more exact. gilleain On Thu, Jun 25, 2009 at 6:44 PM, <ekk...@no...> wrote: > > Hello, > > I switched for my rendering of structures and reactions to the > jchempaint-primary branch and I really like the new visitor based design. > This gave me the opportunity to write a new generator for reactions which > places the exact mass underneath each of the reactants/products > ("MolWeightGenerator", I am happy to send this in if anybody has some use > for it) and a slightly modified ReactionPlusGenerator. > > Here I have a suggstion and a question. > > In the ReactionPlusGenerator I changed the x position in the makePlus method > > from > double x = (a.getCenterX() + b.getCenterX()) / 2; > > to > double x = a.getMaxX() + (b.getMinX() - a.getMaxX()) / 2; > > This places the plus more nicely between molecules of largely different > size. > > With the MolWeightGenerator I have an issue with the correct scaling of the > diagram: depending on the aspect ratio of the reaction and the AWT image the > extra text might be clipped off. > > For the placement of the extra text I first calculate the "total bounds" > (copied from the ReactionBoxGenerator) and an offset: > > double d = model.getBondLength() / model.getScale(); > Rectangle2D totalBounds = Renderer.calculateBounds(reaction); > > Then the text is placed for each molecule like > > diagram.add(new TextElement((molBounds.getMinX() > +molBounds.getMaxX())/2, > totalBounds.getMaxY() + d, > "EM = "+String.valueOf(mass), > model.getForeColor())); > > So all the masses are below the "totalBounds box". > > Now comes the scaling issue: if the reaction has a lower value of > width/height than the image into which it will be rendered the reaction is > scaled (at least I think so) such that the height of the totalBounds box is > equal to the height of the image. In effect the text below the totalBounds > box is clipped off. > > As far as I can see in the paintReaction method of the Renderer any > generated elements have no effect on the scaling of the diagram to fit the > graphic area. Is that right ? Perhaps one could do a second scaling after > the decoration from all the generators? > > Hope this all makes sense. > > Thanks, > Ekkehard > > > > > > _________________________ > > CONFIDENTIALITY NOTICE > > The information contained in this e-mail message is intended only for the > exclusive use of the individual or entity named above and may contain > information that is privileged, confidential or exempt from disclosure under > applicable law. If the reader of this message is not the intended recipient, > or the employee or agent responsible for delivery of the message to the > intended recipient, you are hereby notified that any dissemination, > distribution or copying of this communication is strictly prohibited. If you > have received this communication in error, please notify the sender > immediately by e-mail and delete the material from any computer. Thank you. > > ------------------------------------------------------------------------------ > > _______________________________________________ > Cdk-devel mailing list > Cdk...@li... > https://lists.sourceforge.net/lists/listinfo/cdk-devel > > |