User 870ab5b546
02-12-2014 20:05:13
The MRectangle API says:
Modifier and Type | Constant Field | Value |
---|---|---|
public static final int | P_CENTER | 4 |
public static final int | P_E | 6 |
public static final int | P_N | 5 |
public static final int | P_NE | 1 |
public static final int | P_NW | 0 |
public static final int | P_S | 7 |
public static final int | P_SE | 2 |
public static final int | P_SW | 3 |
public static final int | P_W | 8 |
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.