MRectangle point confusion

User 870ab5b546

02-12-2014 20:05:13

The MRectangle API says:


http://www.chemaxon.com/jchem/doc/dev/java/api/resources/titlebar.gif); height: 18px;">chemaxon.struc.graphics.MRectanglehttp://www.chemaxon.com/jchem/doc/dev/java/api/resources/titlebar_end.gif); height: 18px; width: 10px; position: relative; background-position: 100% 0%; background-repeat: no-repeat no-repeat;"> 
Modifier and TypeConstant FieldValue
public static final intP_CENTER4
public static final intP_E6
public static final intP_N5
public static final intP_NE1
public static final intP_NW0
public static final intP_S7
public static final intP_SE2
public static final intP_SW3
public static final intP_W8

Yet this code:


final String[] rectPts = new String[]
{"NW", "NE", "SE", "SW", "CENTER", "N", "E", "S", "W"};
MRectangle rect = null;
for (int objIndex = 0; objIndex < mechDoc.getObjectCount(); objIndex++) {
final MObject mObject = mechDoc.getObject(objIndex);
if (mObject instanceof MRectangle) {
rect = (MRectangle) mObject;
Utils.alwaysPrint(SELF + "rectangle ", rectangleNum++, ":");
for (int ptNum = 0; ptNum < 9; ptNum++) {
Utils.alwaysPrint("\t\tpoint ", ptNum + 1, " (",
rectPts[ptNum], "): ",
rect.getPointRef(ptNum, null).getLocation());
} // for each of 9 points, center, and midpoints of rectangle
} // if is a rectangle or arrow
} // for each object in the MDocument

operating on a rectangle drawn in MarvinSketch, gives this output:


INFO: pointOnLine.jsp: rectangle 1:
point 1 (NW): DPoint3(-3.696000099182129, 2.4639999866485596, 0.0)
point 2 (NE): DPoint3(3.6519999504089355, 2.4639999866485596, 0.0)
point 3 (SE): DPoint3(3.6519999504089355, -1.8919999599456787, 0.0)
point 4 (SW): DPoint3(-3.696000099182129, -1.8919999599456787, 0.0)
point 5 (CENTER): DPoint3(-0.02200007438659668, 2.4639999866485596, 0.0)
point 6 (N): DPoint3(3.6519999504089355, 0.28600001335144043, 0.0)
point 7 (E): DPoint3(-0.02200007438659668, -1.8919999599456787, 0.0)
point 8 (S): DPoint3(-3.696000099182129, 0.28600001335144043, 0.0)
point 9 (W): DPoint3(-0.02200007438659668, 2.4639999866485596, 0.0)

Note that the location of point reference 5 (CENTER) is the same as the location of point reference 9 (W). Perhaps your documentation for MRectangle.getPointRef() and getPoint() should note that only the constant fields for NW, NE, SW, and SE corners should be used as parameters for these methods, and that values 4-7 return the MPoints for points W, N, E, and S of the rectangle, respectively. Though why both values 4 and 8 return the same MPoint is a little beyond me. Unless there is a bug here or a mistake in the documentation. 

ChemAxon d26931946c

04-12-2014 15:59:15

Yes, there are some bugs around here.


Thank you for notifying, we will look into it.


Best regards,


Peter