Search in sources :

Example 66 with Point2D

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;
}
Also used : Point2D(java.awt.geom.Point2D)

Example 67 with Point2D

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;
}
Also used : Point2D(java.awt.geom.Point2D)

Example 68 with Point2D

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;
}
Also used : Point2D(java.awt.geom.Point2D)

Example 69 with Point2D

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));
    }
}
Also used : Point2D(java.awt.geom.Point2D)

Example 70 with Point2D

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;
}
Also used : Point2D(java.awt.geom.Point2D)

Aggregations

Point2D (java.awt.geom.Point2D)193 Color (java.awt.Color)22 Rectangle2D (java.awt.geom.Rectangle2D)20 RadialGradientPaint (java.awt.RadialGradientPaint)19 Graphics2D (java.awt.Graphics2D)18 Point (java.awt.Point)18 Paint (java.awt.Paint)17 Line2D (java.awt.geom.Line2D)12 AffineTransform (java.awt.geom.AffineTransform)11 Rectangle (java.awt.Rectangle)9 BasicStroke (java.awt.BasicStroke)8 Stroke (java.awt.Stroke)8 Ellipse2D (java.awt.geom.Ellipse2D)8 BufferedImage (java.awt.image.BufferedImage)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 Element (org.jdom2.Element)6 GradientPaint (java.awt.GradientPaint)5 Arc2D (java.awt.geom.Arc2D)5 GeneralPath (java.awt.geom.GeneralPath)5