use of java.awt.geom.Point2D in project JMRI by JMRI.
the class LayoutTurntable method getRayCoordsOrdered.
public Point2D getRayCoordsOrdered(int i) {
Point2D result = MathUtil.zeroPoint2D();
RayTrack rt = rayList.get(i);
if (rt != null) {
double angle = Math.toRadians(rt.getAngle());
// calculate coordinates
result = new Point2D.Double((center.getX() + ((1.25 * radius) * Math.sin(angle))), (center.getY() - ((1.25 * radius) * Math.cos(angle))));
}
return result;
}
use of java.awt.geom.Point2D in project JMRI by JMRI.
the class LevelXing method scaleCoords.
public void scaleCoords(float xFactor, float yFactor) {
Point2D pt = new Point2D.Double(Math.round(center.getX() * xFactor), Math.round(center.getY() * yFactor));
center = pt;
pt = new Point2D.Double(Math.round(dispA.getX() * xFactor), Math.round(dispA.getY() * yFactor));
dispA = pt;
pt = new Point2D.Double(Math.round(dispB.getX() * xFactor), Math.round(dispB.getY() * yFactor));
dispB = pt;
}
use of java.awt.geom.Point2D in project JMRI by JMRI.
the class LayoutTurntable method scaleCoords.
public void scaleCoords(float xFactor, float yFactor) {
Point2D pt = new Point2D.Double(Math.round(center.getX() * xFactor), Math.round(center.getY() * yFactor));
center = pt;
}
use of java.awt.geom.Point2D in project JMRI by JMRI.
the class LayoutTurntable method drawEditControls.
public void drawEditControls(Graphics2D g2) {
Point2D pt = getCoordsCenter();
g2.setColor(defaultTrackColor);
g2.draw(layoutEditor.trackControlPointRectAt(pt));
for (int j = 0; j < getNumberRays(); j++) {
pt = getRayCoordsOrdered(j);
if (getRayConnectOrdered(j) == null) {
g2.setColor(Color.red);
} else {
g2.setColor(Color.green);
}
g2.draw(layoutEditor.trackControlPointRectAt(pt));
}
}
use of java.awt.geom.Point2D in project JMRI by JMRI.
the class LayoutTurnout method getCoordsForConnectionType.
/**
* return the coordinates for a specified connection type
* @param connectionType the connection type
* @return the coordinates for the specified connection type
*/
public Point2D getCoordsForConnectionType(int connectionType) {
Point2D result = center;
double circleRadius = controlPointSize * layoutEditor.getTurnoutCircleSize();
switch(connectionType) {
case TURNOUT_CENTER:
break;
case TURNOUT_A:
result = getCoordsA();
break;
case TURNOUT_B:
result = getCoordsB();
break;
case TURNOUT_C:
result = getCoordsC();
break;
case TURNOUT_D:
result = getCoordsD();
break;
default:
//I18IN
log.error("Invalid connection type " + connectionType);
}
return result;
}
Aggregations