Skip to content

Commit

Permalink
fix: rxn v3 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Jul 25, 2024
1 parent 420361b commit 898d829
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions scripts/openchemlib/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,15 @@ function changeTautomerHelper(code) {
}

function changeTextDrawingObject(code) {
code = replaceChecked(
code,
'import java.util.ArrayList;',
'import java.math.BigDecimal;\nimport java.math.MathContext;\nimport java.util.ArrayList;',
);
return replaceChecked(
code,
String.raw`detail.append(String.format(" size=\"%.4f\"", new Double(mSize)));`,
String.raw`detail.append(" size=\""+mSize+"\"");`,
String.raw`detail.append(" size=\""+new BigDecimal(mSize, new MathContext(4)).toString()+"\"");`,
);
}

Expand Down Expand Up @@ -365,7 +370,7 @@ function removeRXNStringFormat(code) {
return replaceChecked(
code,
'theWriter.write(String.format("M V30 COUNTS %d %d"+NL,rcnt,pcnt));',
'theWriter.write("M V30 COUNTS "+rcnt+" "+pcnt+NL,rcnt,pcnt);',
'theWriter.write("M V30 COUNTS "+rcnt+" "+pcnt+NL);',
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import com.actelion.research.gui.generic.GenericRectangle;

import java.awt.*;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayList;

public class TextDrawingObject extends AbstractDrawingObject {
Expand Down Expand Up @@ -145,7 +147,7 @@ public String getDescriptorDetail() {
detail.append(" x=\""+mPoint[0].x + "\"");
detail.append(" y=\""+mPoint[0].y + "\"");
if (mSize != DEFAULT_SIZE)
detail.append(" size=\""+mSize+"\"");
detail.append(" size=\""+new BigDecimal(mSize, new MathContext(4)).toString()+"\"");
if (mStyle != DEFAULT_STYLE)
detail.append(" style=\""+mStyle+ "\"");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public RXNFileV3Creator(Reaction r, String programName) {
theWriter.write(NL);
int rcnt = rxn.getReactants();
int pcnt = rxn.getProducts();
theWriter.write("M V30 COUNTS "+rcnt+" "+pcnt+NL,rcnt,pcnt);
theWriter.write("M V30 COUNTS "+rcnt+" "+pcnt+NL);

double scalingFactor = getScalingFactor(rxn);

Expand Down

0 comments on commit 898d829

Please sign in to comment.