@Override public void mousePressed(MouseEvent mouseEvent) { buttonPressed = mouseEvent.getButton(); if (buttonPressed == MouseEvent.BUTTON1) { selected.setIncludingFrame(screenFrame, mouseEvent.getX(), mouseEvent.getY()); selectionAreaStart.setIncludingFrame(screenFrame, mouseEvent.getX(), mouseEvent.getY()); } else if (buttonPressed == MouseEvent.BUTTON2) { middleMouseDragStart.setIncludingFrame(screenFrame, mouseEvent.getX(), mouseEvent.getY()); } else if (buttonPressed == MouseEvent.BUTTON3) { rightMouseDragStart.setIncludingFrame(screenFrame, mouseEvent.getX(), mouseEvent.getY()); if (mouseEvent.getClickCount() > 1) { focusPoint.setIncludingFrame(screenFrame, mouseEvent.getX(), mouseEvent.getY()); centerOnFocusPoint(); panel.repaint(); } } }
private void updateFrames() { panel.computeVisibleRect(visibleRectangle); pixelsFrame.update(); screenFrame.update(); metersFrame.update(); upperLeftCorner.setIncludingFrame(screenFrame, 0.0, 0.0); lowerRightCorner.setIncludingFrame(screenFrame, getPlotterWidthPixels(), getPlotterHeightPixels()); origin.setIncludingFrame(metersFrame, 0.0, 0.0); }
middleMouseDragEnd.setIncludingFrame(screenFrame, mouseEvent.getX(), mouseEvent.getY()); focusPoint.setIncludingFrame(screenFrame, getPlotterWidthPixels() / 2.0, getPlotterHeightPixels() / 2.0); rightMouseDragEnd.setIncludingFrame(screenFrame, mouseEvent.getX(), mouseEvent.getY()); panel.repaint(); rightMouseDragStart.setIncludingFrame(screenFrame, mouseEvent.getX(), mouseEvent.getY());
public void drawLineSegment(PlotterReferenceFrame frame, double firstPointX, double firstPointY, double secondPointX, double secondPointY) { PlotterPoint2d firstEndpoint = pointBin[0]; PlotterPoint2d secondEndpoint = pointBin[1]; firstEndpoint.setIncludingFrame(frame, firstPointX, firstPointY); secondEndpoint.setIncludingFrame(frame, secondPointX, secondPointY); firstEndpoint.changeFrame(screenFrame); secondEndpoint.changeFrame(screenFrame); drawLineSegment(pixelate(firstEndpoint.getX()), pixelate(firstEndpoint.getY()), pixelate(secondEndpoint.getX()), pixelate(secondEndpoint.getY())); }
public void drawString(PlotterReferenceFrame frame, String string, Point2d startPoint) { PlotterPoint2d plotStart = pointBin[0]; plotStart.setIncludingFrame(frame, startPoint); plotStart.changeFrame(screenFrame); drawString(string, pixelate(plotStart.getX()), pixelate(plotStart.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 drawLineSegment(PlotterReferenceFrame frame, LineSegment2d lineSegment) { PlotterPoint2d firstEndpoint = pointBin[0]; PlotterPoint2d secondEndpoint = pointBin[1]; firstEndpoint.setIncludingFrame(frame, lineSegment.getFirstEndpoint()); secondEndpoint.setIncludingFrame(frame, lineSegment.getSecondEndpoint()); firstEndpoint.changeFrame(screenFrame); secondEndpoint.changeFrame(screenFrame); drawLineSegment(pixelate(firstEndpoint.getX()), pixelate(firstEndpoint.getY()), pixelate(secondEndpoint.getX()), pixelate(secondEndpoint.getY())); }
private void setupForDrawPolygon(PlotterReferenceFrame frame, ConvexPolygon2d convexPolygon2d) { for (int i = 0; i < convexPolygon2d.getNumberOfVertices(); i++) { pointBin[i].setIncludingFrame(frame, convexPolygon2d.getVertex(i)); pointBin[i].changeFrame(screenFrame); tempPoints[0][i] = pixelate(pointBin[i].getX()); tempPoints[1][i] = pixelate(pointBin[i].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 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 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 drawPoint(PlotterReferenceFrame frame, Point2d point) { PlotterPoint2d plotterPoint = pointBin[0]; plotterPoint.setIncludingFrame(frame, point); plotterPoint.changeFrame(screenFrame); drawLineSegment(pixelate(plotterPoint.getX()), pixelate(plotterPoint.getY()), pixelate(plotterPoint.getX()), pixelate(plotterPoint.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))); }
focusPoint.setIncludingFrame(metersFrame, 0.0, 0.0);
gridLinePencil.setIncludingFrame(pixelsFrame, gridX, 0.0); labelPosition.setIncludingFrame(gridLinePencil); labelPosition.add(1.0, 0.0); graphics2d.drawString(labelString, labelPosition); gridLinePencil.setIncludingFrame(pixelsFrame, 0.0, gridY); labelPosition.setIncludingFrame(gridLinePencil); labelPosition.add(0.0, 1.0); graphics2d.drawString(labelString, labelPosition);