public Plotter2DAdapter(MetersReferenceFrame metersFrame, PixelsReferenceFrame screenFrame, PixelsReferenceFrame pixelsFrame) { this.metersFrame = metersFrame; this.screenFrame = screenFrame; this.pixelsFrame = pixelsFrame; for (int i = 0; i < pointBin.length; i++) { pointBin[i] = new PlotterPoint2d(metersFrame); vectorBin[i] = new PlotterVector2d(metersFrame); } }
public void drawOval(PlotterReferenceFrame frame, Point2d center, Vector2d radii) { PlotterPoint2d centerFramePoint = pointBin[0]; PlotterVector2d radiiFrameVector = vectorBin[0]; centerFramePoint.setIncludingFrame(frame, center); radiiFrameVector.setIncludingFrame(frame, radii.getX(), radii.getY()); centerFramePoint.changeFrame(screenFrame); radiiFrameVector.changeFrame(screenFrame); radiiFrameVector.set(Math.abs(radiiFrameVector.getX()), Math.abs(radiiFrameVector.getY())); centerFramePoint.sub(radiiFrameVector); drawOval(pixelate(centerFramePoint.getX()), pixelate(centerFramePoint.getY()), pixelate(2.0 * radiiFrameVector.getX()), pixelate(2.0 * radiiFrameVector.getY())); }
public void drawLine(PlotterReferenceFrame frame, Line2d line) { PlotterPoint2d start = pointBin[0]; PlotterVector2d direction = vectorBin[0]; start.setIncludingFrame(frame, line.getPoint()); direction.setIncludingFrame(frame, line.getNormalizedVector()); start.changeFrame(screenFrame); direction.changeFrame(screenFrame); direction.normalize(); PlotterPoint2d farPointPositive = pointBin[1]; PlotterPoint2d farPointNegative = pointBin[2]; PlotterVector2d far = vectorBin[1]; far.setIncludingFrame(direction); far.scale(1e4); farPointPositive.setIncludingFrame(start); farPointNegative.setIncludingFrame(start); farPointPositive.add(far); farPointNegative.sub(far); drawLineSegment(pixelate(farPointNegative.getX()), pixelate(farPointNegative.getY()), pixelate(farPointPositive.getX()), pixelate(farPointPositive.getY())); }
public void changeFrame(PixelsReferenceFrame pixelsReferenceFrame) { if (getReferenceFrame() instanceof MetersReferenceFrame) { changeFrameAndProjectToXYPlane(ReferenceFrame.getWorldFrame()); scale(pixelsReferenceFrame.getConversionToPixels().getX(), pixelsReferenceFrame.getConversionToPixels().getY()); } super.changeFrameAndProjectToXYPlane(pixelsReferenceFrame); } }
public void changeFrame(MetersReferenceFrame metersReferenceFrame) { if (getReferenceFrame() instanceof PixelsReferenceFrame) { changeFrame(ReferenceFrame.getWorldFrame()); scale(metersReferenceFrame.getConversionToMeters().getX(), metersReferenceFrame.getConversionToMeters().getY()); } super.changeFrame(metersReferenceFrame); }
public void drawSquareFilled(PlotterReferenceFrame frame, Point2d center, Vector2d radii) { PlotterPoint2d centerFramePoint = pointBin[0]; PlotterVector2d radiiFrameVector = vectorBin[0]; centerFramePoint.setIncludingFrame(frame, center); radiiFrameVector.setIncludingFrame(frame, radii.getX(), radii.getY()); centerFramePoint.changeFrame(screenFrame); radiiFrameVector.changeFrame(screenFrame); radiiFrameVector.set(Math.abs(radiiFrameVector.getX()), Math.abs(radiiFrameVector.getY())); centerFramePoint.sub(radiiFrameVector); drawRectangleFilled(pixelate(centerFramePoint.getX()), pixelate(centerFramePoint.getY()), pixelate(2.0 * radiiFrameVector.getX()), pixelate(2.0 * radiiFrameVector.getY())); }
public void drawRectangle(PlotterReferenceFrame frame, Point2d center, Vector2d radii) { PlotterPoint2d centerFramePoint = pointBin[0]; PlotterVector2d radiiFrameVector = vectorBin[0]; centerFramePoint.setIncludingFrame(frame, center); radiiFrameVector.setIncludingFrame(frame, radii.getX(), radii.getY()); centerFramePoint.changeFrame(screenFrame); radiiFrameVector.changeFrame(screenFrame); radiiFrameVector.set(Math.abs(radiiFrameVector.getX()), Math.abs(radiiFrameVector.getY())); centerFramePoint.sub(radiiFrameVector); drawRectangle(pixelate(centerFramePoint.getX()), pixelate(centerFramePoint.getY()), pixelate(2.0 * radiiFrameVector.getX()), pixelate(2.0 * radiiFrameVector.getY())); }
public void drawOvalFilled(PlotterReferenceFrame frame, Point2d center, Vector2d radii) { PlotterPoint2d centerFramePoint = pointBin[0]; PlotterVector2d radiiFrameVector = vectorBin[0]; centerFramePoint.setIncludingFrame(frame, center); radiiFrameVector.setIncludingFrame(frame, radii.getX(), radii.getY()); centerFramePoint.changeFrame(screenFrame); radiiFrameVector.changeFrame(screenFrame); radiiFrameVector.set(Math.abs(radiiFrameVector.getX()), Math.abs(radiiFrameVector.getY())); centerFramePoint.sub(radiiFrameVector); drawOvalFilled(pixelate(centerFramePoint.getX()), pixelate(centerFramePoint.getY()), pixelate(2.0 * radiiFrameVector.getX()), pixelate(2.0 * radiiFrameVector.getY())); }
public void drawRectangle(PlotterReferenceFrame frame, double x, double y, double width, double height) { PlotterPoint2d position = pointBin[0]; PlotterVector2d dimensions = vectorBin[0]; position.setIncludingFrame(frame, x, y); dimensions.setIncludingFrame(frame, Math.abs(width), Math.abs(height)); position.changeFrame(screenFrame); dimensions.changeFrame(screenFrame); drawRectangle(pixelate(position.getX()), pixelate(position.getY()), pixelate(dimensions.getX()), pixelate(dimensions.getY())); }
public void drawArc(PlotterReferenceFrame frame, Point2d center, Vector2d radii, double startAngle, double arcAngle) { PlotterPoint2d plotCenter = pointBin[0]; PlotterVector2d plotRadii = vectorBin[0]; plotCenter.setIncludingFrame(frame, center); plotRadii.setIncludingFrame(frame, radii); plotCenter.changeFrame(screenFrame); plotRadii.changeFrame(screenFrame); graphics2d.drawArc(pixelate(plotCenter.getX()), pixelate(plotCenter.getY()), pixelate(2.0 * plotRadii.getX()), pixelate(2.0 * plotRadii.getY()), pixelate(BodeUnitsConverter.convertRadianToDegrees(startAngle)), pixelate(BodeUnitsConverter.convertRadianToDegrees(arcAngle))); }