Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void mousePressed(MouseEvent e)
- {
- if (e.getButton() == MouseEvent.BUTTON1)
- {
- System.out.println("mousePressed() added line to index = " + index);
- undoClearArray.clear();
- clearBtn.setText("Clear");
- x1 = e.getX();
- y1 = e.getY();
- x2 = x1;
- y2 = y1;
- if (optionNum == 0)
- s = new Line(x1, y1, x2, y2, c, stroke);
- else if (optionNum == 1)
- s = new Rect(x1, y1, x2, y2, c, stroke);
- else if (optionNum == 2)
- s = new SolidRect(x1, y1, x2, y2, c, stroke);
- else if (optionNum == 3)
- s = new Circle(x1, y1, x2, y2, c, stroke);
- else if (optionNum == 4)
- s = new SolidCircle(x1, y1, x2, y2, c, stroke);
- else if (optionNum == 5)
- {
- if (text == null || text == "") text = "@";
- s = new Text(x1, y1, (int)(stroke * 6.4), text, c);
- }
- drawPanel.shape.add(s);
- drawPanel.repaint();
- }
- }
- @Override
- public void mouseDragged(MouseEvent e)
- {
- x2 = e.getX();
- y2 = e.getY();
- if (optionNum == 0)
- {
- ((Line) s).setX2(x2);
- ((Line) s).setY2(y2);
- }
- else if (optionNum == 1)
- {
- ((Rect) s).setX2(x2);
- ((Rect) s).setY2(y2);
- }
- else if (optionNum == 2)
- {
- ((SolidRect) s).setX2(x2);
- ((SolidRect) s).setY2(y2);
- }
- else if (optionNum == 3)
- {
- ((Circle) s).setX2(x2);
- ((Circle) s).setY2(y2);
- }
- else if (optionNum == 4)
- {
- ((SolidCircle) s).setX2(x2);
- ((SolidCircle) s).setY2(y2);
- }
- else if (optionNum == 5)
- {
- ((Text) s).setX1(x2);
- ((Text) s).setY1(y2);
- }
- drawPanel.repaint();
- }
- @Override
- public void mouseReleased(MouseEvent e)
- {
- if (e.getButton() == MouseEvent.BUTTON1)
- {
- drawPanel.repaint();
- cleanLineArray();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement