-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
joining 2 molfiles #31
Comments
Hi Luc,
the problem is that the bounding rectangle of a molecule depends on the
graphics environment that is used to draw the molecule,
because the font size has a significant influence on the extra size of an
atom that is at the edge of the bounding rect, especially
if implicit hydrogens, query features or custom atom labels are drawn in
addition to the atom label.
For aligning your molecules correctly, you should use a Depictor to
determine the bounding rect and then aling your molecules.
You can use something like the following source to do it. Afterwards you
use addMolecule() to combine all molecules into one.
If you don't want to use a depictor you have to estimate the atom label
sizes your self or simply use enough spacing to allow for large labels.
Thomas
Rectangle2D.Double[] boundingRect = new Rectangle2D.Double[mMolecule.length];
double totalWidth = 0.0;
double totalHeight = 0.0;
for (int i=0; i<mMolecule.length; i++) {
mDepictor[i].validateView(g, null, AbstractDepictor.cModeInflateToMaxAVBL);
boundingRect[i] = mDepictor[i].getBoundingRect();
totalWidth += boundingRect[i].width;
totalHeight = Math.max(totalHeight, boundingRect[i].height);
}
double spacing = 1.5 * AbstractDepictor.cOptAvBondLen;
double rawX = 0.5 * spacing;
for (int i=0; i<mMolecule.length; i++) {
double dx = rawX - boundingRect[i].x;
double dy = 0.5 * (totalHeight - boundingRect[i].height) -
boundingRect[i].y;
mDepictor[i].applyTransformation(new DepictorTransformation(1.0, dx, dy));
rawX += spacing + boundingRect[i].width;
}
…On Thu, Nov 8, 2018 at 3:33 PM Luc Patiny ***@***.***> wrote:
I have a small problem that I don’t know how to solve. I have 2 molfiles
that I would like to join and create a new molfile that looks goodl.
The problem is to put them next to each other and align them vertically.
I could first generate 2 Moleculeand use the addMolecule method. I could
also use the translateCoords but I don't know how to get the boundary of
a molecule, meaning the box that includes all the atom.
Or is there a better way to solve my problem ?
Thanks !
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#31>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJpSBiOr6cQeEeyx58C83owhiTc9Jo9pks5utECzgaJpZM4YUyhe>
.
--
The information of this email and in any file transmitted with it is
strictly confidential and may be legally privileged.
It is intended solely
for the addressee. If you are not the intended recipient, any copying,
distribution or any other use of this email is prohibited and may be
unlawful. In such case, you should please notify the sender immediately and
destroy this email.
The content of this email is not legally binding unless
confirmed by letter.
Any views expressed in this message are those of the
individual sender, except where the message states otherwise and the sender
is authorized to state them to be the views of the sender's company.
|
Perfect thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a small problem that I don’t know how to solve. I have 2 molfiles that I would like to join and create a new molfile that looks goodl.
The problem is to put them next to each other and align them vertically.
I could first generate 2
Molecule
and use theaddMolecule
method. I could also use thetranslateCoords
but I don't know how to get theboundary
of a molecule, meaning the box that includes all the atom.Or is there a better way to solve my problem ?
Thanks !
The text was updated successfully, but these errors were encountered: