|
@@ -28,6 +28,7 @@ import java.awt.Color;
|
|
import java.awt.Component;
|
|
import java.awt.Component;
|
|
import java.awt.Cursor;
|
|
import java.awt.Cursor;
|
|
import java.awt.Dimension;
|
|
import java.awt.Dimension;
|
|
|
|
+import java.awt.Font;
|
|
import java.awt.Image;
|
|
import java.awt.Image;
|
|
import java.awt.Point;
|
|
import java.awt.Point;
|
|
import java.awt.Toolkit;
|
|
import java.awt.Toolkit;
|
|
@@ -151,17 +152,18 @@ public class GUI implements CategoryListener {
|
|
splitPane.setRightComponent(splitPane_1);
|
|
splitPane.setRightComponent(splitPane_1);
|
|
splitPane.setDividerLocation(200);
|
|
splitPane.setDividerLocation(200);
|
|
splitPane_1.setDividerLocation(500);
|
|
splitPane_1.setDividerLocation(500);
|
|
-
|
|
|
|
|
|
+
|
|
canvas.setBackground(Color.WHITE);
|
|
canvas.setBackground(Color.WHITE);
|
|
canvas.setPreferredSize(new Dimension(10000, 10000));
|
|
canvas.setPreferredSize(new Dimension(10000, 10000));
|
|
JScrollPane canvasSP = new JScrollPane(canvas);
|
|
JScrollPane canvasSP = new JScrollPane(canvas);
|
|
- canvasSP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
|
|
|
- canvasSP.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
|
|
|
|
|
|
|
- tabbedPane.addTab("Modeling", null, canvasSP, null);
|
|
|
|
|
|
+ tabbedPane.addTab("Modeling", new ImageIcon(new ImageIcon(this.getClass().getResource("/Images/home.png"))
|
|
|
|
+ .getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH)), canvasSP, "Model a CPS");
|
|
|
|
|
|
-
|
|
|
|
- tabbedPane.addTab("Simulation", null, scrollPane_2, null);
|
|
|
|
|
|
+ tabbedPane.addTab("Simulation",
|
|
|
|
+ new ImageIcon(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()
|
|
|
|
+ .getScaledInstance(30, 30, Image.SCALE_SMOOTH)),
|
|
|
|
+ scrollPane_2, "Simulate the CPS");
|
|
dtrpnHereWillBe.setText("Here will be the Simulation");
|
|
dtrpnHereWillBe.setText("Here will be the Simulation");
|
|
|
|
|
|
scrollPane_2.setViewportView(dtrpnHereWillBe);
|
|
scrollPane_2.setViewportView(dtrpnHereWillBe);
|
|
@@ -202,13 +204,13 @@ public class GUI implements CategoryListener {
|
|
boolean leaf, int row, boolean hasFocus) {
|
|
boolean leaf, int row, boolean hasFocus) {
|
|
JLabel label = new JLabel();
|
|
JLabel label = new JLabel();
|
|
Image imgR = null;
|
|
Image imgR = null;
|
|
-
|
|
|
|
- if(leaf){
|
|
|
|
|
|
+ if (leaf) {
|
|
for (Category cat : model.getCategories()) {
|
|
for (Category cat : model.getCategories()) {
|
|
for (CpsObject cps : cat.getObjects()) {
|
|
for (CpsObject cps : cat.getObjects()) {
|
|
if (value.toString().compareTo(cps.getCompareName()) == 0) {
|
|
if (value.toString().compareTo(cps.getCompareName()) == 0) {
|
|
imgR = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
imgR = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
- .getScaledInstance(GlobalVariables.SCALE, GlobalVariables.SCALE, java.awt.Image.SCALE_SMOOTH);
|
|
|
|
|
|
+ .getScaledInstance(GlobalVariables.SCALE, GlobalVariables.SCALE,
|
|
|
|
+ java.awt.Image.SCALE_SMOOTH);
|
|
if (imgR != null) {
|
|
if (imgR != null) {
|
|
label.setIcon(new ImageIcon(imgR));
|
|
label.setIcon(new ImageIcon(imgR));
|
|
}
|
|
}
|
|
@@ -217,11 +219,18 @@ public class GUI implements CategoryListener {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- if(hasFocus) label.setForeground(new Color(0, 0, 255));
|
|
|
|
tree.setRowHeight(GlobalVariables.SCALE);
|
|
tree.setRowHeight(GlobalVariables.SCALE);
|
|
- if(label.getText().length() == 0) label.setText(value.toString());
|
|
|
|
-
|
|
|
|
|
|
+ if (hasFocus) {
|
|
|
|
+ label.setForeground(new Color(0, 0, 255));
|
|
|
|
+ label.setOpaque(true);
|
|
|
|
+ }
|
|
|
|
+ if (label.getText().length() == 0) {
|
|
|
|
+ label.setText(value.toString());
|
|
|
|
+ if (value.toString().compareTo("Categories") != 0) {
|
|
|
|
+ label.setIcon(new ImageIcon(this.getClass().getResource("/Images/folder.png")));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
return label;
|
|
return label;
|
|
|
|
|
|
}
|
|
}
|
|
@@ -234,11 +243,16 @@ public class GUI implements CategoryListener {
|
|
try {
|
|
try {
|
|
if (dragging) {
|
|
if (dragging) {
|
|
CpsObject h = null;
|
|
CpsObject h = null;
|
|
- System.out.println(tempCps.getClass().toString());
|
|
|
|
- if(tempCps.getClass() == HolonObject.class) {h = new HolonObject(tempCps);}
|
|
|
|
- if(tempCps.getClass() == HolonSwitch.class) {h = new HolonSwitch(tempCps);}
|
|
|
|
- if(tempCps.getClass() == HolonTransformer.class) {h = new HolonTransformer(tempCps);}
|
|
|
|
-
|
|
|
|
|
|
+ if (tempCps.getClass() == HolonObject.class) {
|
|
|
|
+ h = new HolonObject(tempCps);
|
|
|
|
+ }
|
|
|
|
+ if (tempCps.getClass() == HolonSwitch.class) {
|
|
|
|
+ h = new HolonSwitch(tempCps);
|
|
|
|
+ }
|
|
|
|
+ if (tempCps.getClass() == HolonTransformer.class) {
|
|
|
|
+ h = new HolonTransformer(tempCps);
|
|
|
|
+ }
|
|
|
|
+
|
|
h.setPos((int) canvas.getMousePosition().getX(), (int) canvas.getMousePosition().getY());
|
|
h.setPos((int) canvas.getMousePosition().getX(), (int) canvas.getMousePosition().getY());
|
|
controller.addObject(h);
|
|
controller.addObject(h);
|
|
for (int i = 0; i < model.getObjectsOnCanvas().size(); i++) {
|
|
for (int i = 0; i < model.getObjectsOnCanvas().size(); i++) {
|
|
@@ -258,12 +272,13 @@ public class GUI implements CategoryListener {
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
try {
|
|
try {
|
|
actualObjectClicked = tree.getPathForLocation(e.getX(), e.getY()).getLastPathComponent().toString();
|
|
actualObjectClicked = tree.getPathForLocation(e.getX(), e.getY()).getLastPathComponent().toString();
|
|
-
|
|
|
|
|
|
+
|
|
for (Category cat : model.getCategories()) {
|
|
for (Category cat : model.getCategories()) {
|
|
for (CpsObject cps : cat.getObjects()) {
|
|
for (CpsObject cps : cat.getObjects()) {
|
|
if (actualObjectClicked.compareTo(cps.getCompareName()) == 0) {
|
|
if (actualObjectClicked.compareTo(cps.getCompareName()) == 0) {
|
|
img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
- .getScaledInstance(GlobalVariables.SCALE, GlobalVariables.SCALE, java.awt.Image.SCALE_SMOOTH);
|
|
|
|
|
|
+ .getScaledInstance(GlobalVariables.SCALE, GlobalVariables.SCALE,
|
|
|
|
+ java.awt.Image.SCALE_SMOOTH);
|
|
tempCps = cps;
|
|
tempCps = cps;
|
|
dragging = true;
|
|
dragging = true;
|
|
Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(img, new Point(0, 0),
|
|
Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(img, new Point(0, 0),
|
|
@@ -302,7 +317,7 @@ public class GUI implements CategoryListener {
|
|
controller.addNewCategory(catName);
|
|
controller.addNewCategory(catName);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
case "Object":
|
|
case "Object":
|
|
if (selectedNode == null) {
|
|
if (selectedNode == null) {
|
|
JOptionPane.showMessageDialog(new JFrame(),
|
|
JOptionPane.showMessageDialog(new JFrame(),
|