Examples of RoadMappingBezier


Examples of org.movsim.roadmappings.RoadMappingBezier

                // for control points has been fixed
                // Bezier mapping does not quite give correct control point
                // offsets
                // so only use this if lateral offset is zero (ie not for road
                // edge lines)
                final RoadMappingBezier bezier = (RoadMappingBezier) roadMapping;
                final GeneralPath path = new GeneralPath();
                posTheta = bezier.startPos(lateralOffset);
                path.moveTo(posTheta.x, posTheta.y);
                posTheta = bezier.endPos(lateralOffset);
                final double cx = bezier.controlX(lateralOffset);
                final double cy = bezier.controlY(lateralOffset);
                path.quadTo(cx, cy, posTheta.x, posTheta.y);
                g.draw(path);
                return;
            }
        } else if (roadMappingClass.equals(RoadMappingPolyBezier.class)) {
            if (lateralOffset == 0.0) {
                final RoadMappingPolyBezier polyBezier = (RoadMappingPolyBezier) roadMapping;
                final Iterator<RoadMappingBezier> iterator = polyBezier.iterator();
                if (!iterator.hasNext())
                    return;
                final GeneralPath path = new GeneralPath();
                RoadMappingBezier bezier = iterator.next();
                posTheta = bezier.startPos(lateralOffset);
                final int radius = 10;
                final int radiusC = 6;
                if (drawBezierPoints) {
                    g.fillOval((int) posTheta.x - radius / 2, (int) posTheta.y - radius / 2, radius, radius);
                }
                path.moveTo(posTheta.x, posTheta.y);
                posTheta = bezier.endPos(lateralOffset);
                path.quadTo(bezier.controlX(lateralOffset), bezier.controlY(lateralOffset), posTheta.x, posTheta.y);
                if (drawBezierPoints) {
                    g.fillOval((int) posTheta.x - radius / 2, (int) posTheta.y - radius / 2, radius, radius);
                    g.fillOval((int) bezier.controlX(lateralOffset) - radiusC / 2, (int) bezier.controlY(lateralOffset)
                            - radiusC / 2, radiusC, radiusC);
                }
                while (iterator.hasNext()) {
                    bezier = iterator.next();
                    posTheta = bezier.endPos(lateralOffset);
                    path.quadTo(bezier.controlX(lateralOffset), bezier.controlY(lateralOffset), posTheta.x, posTheta.y);
                    if (drawBezierPoints) {
                        g.fillOval((int) posTheta.x - radius / 2, (int) posTheta.y - radius / 2, radius, radius);
                        g.fillOval((int) bezier.controlX(lateralOffset) - radiusC / 2,
                                (int) bezier.controlY(lateralOffset) - radiusC / 2, radiusC, radiusC);
                    }
                }
                g.draw(path);
                return;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.