Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void mouseDragged(final MouseEvent e) {
- if (this.m_lastPressedButton != MouseEvent.BUTTON1) {
- return;
- }
- double x; // Rectangle start x without chart bounds
- double y; // Rectangle start y without chart bounds
- double x2; // Rectangle end x without chart bounds
- double y2; // Rectangle end y without chart bounds
- double startX;
- double endX;
- double dimX;
- double dimY;
- double startY;
- double endY;
- double chartStartX = this.getXChartStart();
- double chartEndX = this.getXChartEnd();
- // Switched these around because I think the window's top as y starting coordinates
- double chartStartY = this.getYChartEnd();
- double chartEndY = this.getYChartStart();
- // Checking which coordinates will be rectangles starting and ending points
- x = Math.min(this.m_startPoint.getX(), e.getX());
- x2 = Math.max(this.m_startPoint.getX(), e.getX());
- y = Math.min(this.m_startPoint.getY(), e.getY());
- y2 = Math.max(this.m_startPoint.getY(), e.getY());
- // Bounding rectangle to chart area only
- // x-coordinate
- startX = Math.min(chartEndX, x);
- startX = Math.max(chartStartX, startX);
- endX = Math.min(chartEndX, x2);
- endX = Math.max(chartStartX, endX);
- // y-coordinate
- startY = Math.min(chartEndY, y);
- startY = Math.max(chartStartY, startY);
- endY = Math.min(chartEndY, y2);
- endY = Math.max(chartStartY, endY);
- dimX = endX - startX;
- dimY = endY - startY;
- this.m_zoomArea = new Rectangle2D.Double(startX, startY, dimX, dimY);
- this.setRequestedRepaint(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment