Ergh English fail…

On 2 Dec 2013, at 12:13, John May <> wrote:

Hi Gilleain,

Thanks for the info. So the scale does indeed account for different model coordinates… but that seems to be taken in to account by the transform. I think it should be possible to leave the scale out of the generator/draw visitor but still account for different coordinate systems. 

      transform.translate(drawCenter.x, drawCenter.y);
            transform.scale(1,-1); // Converts between CDK Y-up & Java2D Y-down coordinate-systems  // I wondered why my text was upside down to begin with!
            transform.scale(scale, scale);   // considers model different coordinate systems (i.e. normalise to 1.5 Angstroms).
            transform.scale(zoom, zoom);

I’m thinking from your comments the BoundsElement is the simplest and safest solution.

Yes text is a problem. Better bounds calculations help (TextLayout instead of FontMetrics) but as you say one solution is two pass rendering. An alternative is putting the bond and atom generation in the same generator :-). This loses modularity but it eliminates the need for cross-talk and is expandable if three passes are needed (minimise label congestion). 

Instead of using fonts I’m drawing the glyphs as shapes - this removes system dependance and allows the convex hull to be used for good bond ‘back off’ (see Alex Clark's paper):

Here’s how scaling looks for atom labels in png/svg: