|
@@ -1,8 +1,11 @@
|
|
|
package ui.view;
|
|
|
|
|
|
+import java.awt.BasicStroke;
|
|
|
import java.awt.Color;
|
|
|
+import java.awt.Container;
|
|
|
import java.awt.Font;
|
|
|
import java.awt.Graphics;
|
|
|
+import java.awt.Graphics2D;
|
|
|
import java.awt.Image;
|
|
|
import java.awt.Paint;
|
|
|
import java.awt.Rectangle;
|
|
@@ -11,11 +14,13 @@ import java.awt.event.ActionListener;
|
|
|
import java.awt.event.MouseEvent;
|
|
|
import java.awt.event.MouseListener;
|
|
|
import java.awt.event.MouseMotionListener;
|
|
|
+import java.awt.geom.Line2D;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.LinkedList;
|
|
|
|
|
|
import javax.swing.AbstractButton;
|
|
|
import javax.swing.ImageIcon;
|
|
|
+import javax.swing.JComponent;
|
|
|
import javax.swing.JLabel;
|
|
|
import javax.swing.JMenuItem;
|
|
|
import javax.swing.JPanel;
|
|
@@ -36,6 +41,7 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
|
//edge Object Start Point
|
|
|
private Model model;
|
|
|
private final Control controller;
|
|
|
+ Graphics2D g2; //For Painting
|
|
|
private int cx;
|
|
|
private int cy;
|
|
|
|
|
@@ -78,21 +84,25 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
|
*/
|
|
|
public void paintComponent(Graphics g) {
|
|
|
super.paintComponent(g);
|
|
|
+ g2 = (Graphics2D) g;
|
|
|
|
|
|
//Selection
|
|
|
if(selectRect != null){
|
|
|
- g.setColor(new Color(100, 255, 100));
|
|
|
- g.fillRect((int)selectRect.getX(), (int)selectRect.getY(), (int)selectRect.getWidth(), (int)selectRect.getHeight());
|
|
|
+ g2.setColor(new Color(100, 255, 100));
|
|
|
+ g2.fillRect((int)selectRect.getX(), (int)selectRect.getY(), (int)selectRect.getWidth(), (int)selectRect.getHeight());
|
|
|
}
|
|
|
|
|
|
- //Edges
|
|
|
+
|
|
|
+
|
|
|
+ //drawEdge
|
|
|
+ g2.setStroke(new BasicStroke(GlobalVariables.SCALE/10));
|
|
|
g.setColor(Color.BLACK);
|
|
|
if(drawEdge)g.drawLine(tempCps.getPos().x+GlobalVariables.SCALE_DIVIDED2, tempCps.getPos().y+GlobalVariables.SCALE_DIVIDED2, x, y);
|
|
|
|
|
|
//Objects
|
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
|
img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
|
|
|
- g.drawImage(img, cps.getPos().x, cps.getPos().y, GlobalVariables.SCALE, GlobalVariables.SCALE, null);
|
|
|
+ g2.drawImage(img, cps.getPos().x, cps.getPos().y, GlobalVariables.SCALE, GlobalVariables.SCALE, null);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -150,6 +160,7 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
|
tempCps.setPos(e.getX() - GlobalVariables.SCALE_DIVIDED2, e.getY() - GlobalVariables.SCALE_DIVIDED2);
|
|
|
tempCps = null;
|
|
|
}
|
|
|
+
|
|
|
// Rechtsklick Liste
|
|
|
if (e.getButton() == e.BUTTON3) {
|
|
|
if (e.getButton() == e.BUTTON3 && tempCps != null) {
|