Pārlūkot izejas kodu

Merge branch 'master' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons

Edgardo Palza 7 gadi atpakaļ
vecāks
revīzija
d05ac03927

BIN
.gradle/3.2.1/taskArtifacts/taskArtifacts.lock


+ 0 - 1
src/DataSets/GraphDataSet.java

@@ -1,6 +1,5 @@
 package DataSets;
 
-import java.awt.Color;
 import java.util.Hashtable;
 
 import classes.AbstractCpsObject;

+ 0 - 2
src/TypeAdapter/AbstractCpsObjectAdapter.java

@@ -12,8 +12,6 @@ import com.google.gson.JsonSerializationContext;
 import com.google.gson.JsonSerializer;
 
 import classes.AbstractCpsObject;
-import classes.HolonSwitch;
-import ui.controller.StoreController;
 
 public class AbstractCpsObjectAdapter
 		implements JsonSerializer<AbstractCpsObject>, JsonDeserializer<AbstractCpsObject> {

+ 26 - 0
src/classes/HolonObject.java

@@ -407,6 +407,32 @@ public class HolonObject extends AbstractCpsObject {
 		}
 		this.totalFlex = tempFlex;
 	}
+	
+	/**
+	 * calculates total flexible Production
+	 */
+	public float getFlexProd(){
+		float tempFlex = 0;
+		for (HolonElement e : getElements()) {
+			if (e.getFlexibility() > 0) {
+				tempFlex += e.getFlexibility();
+			}
+		}
+		return tempFlex;
+	}
+	
+	/**
+	 * calculates total flexible Concumption
+	 */
+	public float getFlexCons(){
+		float tempFlex = 0;
+		for (HolonElement e : getElements()) {
+			if (e.getFlexibility() < 0) {
+				tempFlex += e.getFlexibility();
+			}
+		}
+		return tempFlex;
+	}
 
 	/**
 	 * If the user track any HolonObject the tracking information will be

+ 2 - 3
src/tests/PraktikumHolonsTestGlobalController.java

@@ -1,10 +1,9 @@
 package tests;
 
-import org.junit.Before;
-import org.junit.Test;
 import static org.junit.Assert.assertTrue;
 
-import java.util.ArrayList;
+import org.junit.Before;
+import org.junit.Test;
 
 import ui.controller.GlobalController;
 import ui.model.Model;

+ 0 - 21
src/tests/PraktikumHolonsTestLoadAndStoreController.java

@@ -1,26 +1,6 @@
 package tests;
 
-import java.awt.Point;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedList;
-
-import org.junit.Before;
-import org.junit.Test;
-import classes.Category;
-import classes.CpsEdge;
-
-import classes.AbstractCpsObject;
-
-import classes.HolonElement;
-import classes.HolonObject;
-import classes.HolonSwitch;
 import classes.IdCounter;
-
-import static org.junit.Assert.assertTrue;
-
 import ui.controller.CanvasController;
 import ui.controller.CategoryController;
 import ui.controller.GlobalController;
@@ -29,7 +9,6 @@ import ui.controller.MultiPurposeController;
 import ui.controller.ObjectController;
 import ui.controller.StoreController;
 import ui.model.Model;
-import ui.view.UnitGraph;
 
 /**
  * Tests for LoadAndStoreController.

+ 0 - 5
src/ui/controller/ClipboardController.java

@@ -19,14 +19,10 @@ import java.util.stream.Collectors;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonElement;
-import com.google.gson.JsonIOException;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParseException;
 import com.google.gson.JsonParser;
 import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSyntaxException;
-import com.google.gson.stream.JsonReader;
-import com.google.gson.stream.MalformedJsonException;
 
 import TypeAdapter.AbstractCpsObjectAdapter;
 import TypeAdapter.ColorAdapter;
@@ -45,7 +41,6 @@ import ui.controller.StoreController.GRAPHTYPE;
 import ui.controller.StoreController.NUMTYPE;
 import ui.controller.StoreController.TYPE;
 import ui.model.Model;
-import ui.view.UpperNodeCanvas;
 
 public class ClipboardController {
 

+ 0 - 4
src/ui/controller/ConsoleController.java

@@ -2,11 +2,7 @@ package ui.controller;
 
 import java.awt.Color;
 
-import javax.swing.text.BadLocationException;
-import javax.swing.text.StyleConstants;
-
 import ui.model.Model;
-import ui.view.Console;
 
 /**
  * Controller for the Canvas.

+ 5 - 0
src/ui/controller/Control.java

@@ -22,6 +22,7 @@ import classes.HolonObject;
 import cpsAlgorithm.CpsAlgorithm;
 import interfaces.CategoryListener;
 import ui.model.Model;
+import ui.view.FlexiblePane;
 import ui.view.MyCanvas;
 
 /**
@@ -902,5 +903,9 @@ public class Control {
 	public void setBackgroundImage(String imagePath, int mode, int width, int height) {
 	canvasController.setBackgroundImage(imagePath, mode, width, height);
 	}
+	
+	public void setFlexiblePane(FlexiblePane fp){
+		simulationManager.setFlexiblePane(fp);
+	}
 
 }

+ 0 - 2
src/ui/controller/NodeController.java

@@ -1,7 +1,6 @@
 package ui.controller;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 
 import classes.AbstractCpsObject;
@@ -9,7 +8,6 @@ import classes.CpsEdge;
 import classes.CpsUpperNode;
 import classes.Position;
 import ui.model.Model;
-import ui.view.UpperNodeCanvas;
 
 public class NodeController {
 

+ 9 - 2
src/ui/controller/SimulationManager.java

@@ -3,15 +3,15 @@ package ui.controller;
 import java.util.ArrayList;
 import java.util.HashMap;
 
+import classes.AbstractCpsObject;
 import classes.CpsEdge;
-import classes.CpsNode;
 import classes.CpsUpperNode;
-import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.SubNet;
 import ui.model.Model;
+import ui.view.FlexiblePane;
 import ui.view.MyCanvas;
 
 /**
@@ -28,6 +28,7 @@ public class SimulationManager {
 	private MyCanvas canvas;
 	private int timeStep;
 	private HashMap<Integer, Float> tagTable = new HashMap<Integer, Float>();
+	private FlexiblePane flexPane;
 	/**
 	 * Constructor.
 	 * 
@@ -90,6 +91,7 @@ public class SimulationManager {
 		}
 		canvas.repaint();
 		//printNet();
+		flexPane.recalculate();
 	}
 
 	/**
@@ -591,4 +593,9 @@ public class SimulationManager {
 		}
 	}
 
+	public void setFlexiblePane(FlexiblePane fp) {
+		flexPane = fp;
+		
+	}
+
 }

+ 0 - 3
src/ui/controller/StatsController.java

@@ -3,9 +3,6 @@ package ui.controller;
 import java.util.ArrayList;
 
 import classes.AbstractCpsObject;
-import classes.HolonElement;
-import classes.HolonObject;
-import classes.HolonSwitch;
 import ui.model.Model;
 
 public class StatsController {

+ 1 - 18
src/ui/controller/StoreController.java

@@ -2,9 +2,6 @@ package ui.controller;
 
 import java.awt.Color;
 import java.awt.Point;
-import java.awt.image.BufferedImage;
-import java.awt.image.DataBufferByte;
-import java.awt.image.WritableRaster;
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -12,49 +9,35 @@ import java.io.FileOutputStream;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.LinkedList;
-import java.util.List;
-import java.util.stream.Stream;
-
-import javax.imageio.ImageIO;
 
 import org.apache.commons.compress.archivers.ArchiveException;
 import org.apache.commons.compress.archivers.ArchiveOutputStream;
 import org.apache.commons.compress.archivers.ArchiveStreamFactory;
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
-import org.apache.commons.compress.compressors.CompressorOutputStream;
-import org.apache.commons.compress.compressors.CompressorStreamFactory;
 import org.apache.commons.compress.utils.IOUtils;
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonPrimitive;
-import com.sun.corba.se.spi.ior.Writeable;
 
 import TypeAdapter.AbstractCpsObjectAdapter;
 import TypeAdapter.ColorAdapter;
 import TypeAdapter.PositionAdapter;
-
+import classes.AbstractCpsObject;
 import classes.Category;
 import classes.CpsEdge;
 import classes.CpsUpperNode;
-import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.IdCounter;
 import classes.IdCounterElem;
 import classes.Position;
-import sun.reflect.misc.FieldUtil;
 import ui.model.Model;
 
 /**

+ 0 - 1
src/ui/view/ButtonTabComponent.java

@@ -31,7 +31,6 @@ package ui.view;
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
  
-import javax.swing.*;
 import javax.swing.*;
 import javax.swing.plaf.basic.BasicButtonUI;
 import java.awt.*;

+ 7 - 10
src/ui/view/EditEdgesPopUp.java

@@ -1,29 +1,26 @@
 package ui.view;
 
+import java.awt.BorderLayout;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
 import javax.swing.ButtonGroup;
+import javax.swing.JButton;
 import javax.swing.JDialog;
 import javax.swing.JFrame;
+import javax.swing.JLabel;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JRadioButton;
-import javax.swing.JLabel;
-
-import java.awt.BorderLayout;
-import java.awt.Font;
-
 import javax.swing.JTextField;
-import javax.swing.JButton;
 import javax.swing.border.EmptyBorder;
 
 import classes.AbstractCpsObject;
 import classes.CpsEdge;
 import classes.CpsUpperNode;
-import classes.SubNet;
 import ui.controller.Control;
 
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-
 /**
  * Popup for Editing Edges.
  * 

+ 88 - 0
src/ui/view/FlexibleData.java

@@ -0,0 +1,88 @@
+package ui.view;
+
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import java.awt.Font;
+import java.awt.Dimension;
+import java.awt.Color;
+
+public class FlexibleData extends JPanel {
+	private JLabel name_lbl;
+	private JLabel lblProdVal;
+	private JLabel lblConsVal;
+	private JLabel lblProdConsVal;
+	public FlexibleData(String name, float prod, float cons) {
+		setPreferredSize(new Dimension(614, 100));
+		setMinimumSize(new Dimension(600, 150));
+		setLayout(null);
+		
+		name_lbl = new JLabel();
+		name_lbl.setFont(new Font("Tahoma", Font.PLAIN, 13));
+		name_lbl.setBounds(10, 11, 125, 27);
+		setlblName(name);
+		add(name_lbl);
+		
+		JLabel lblFlProd = new JLabel("Flex. Prod.  :");
+		lblFlProd.setForeground(new Color(0, 128, 0));
+		lblFlProd.setBounds(31, 46, 65, 27);
+		add(lblFlProd);
+		
+		JLabel lblFlexCons = new JLabel("Flex. Cons.  :\r\n");
+		lblFlexCons.setForeground(new Color(255, 0, 0));
+		lblFlexCons.setBounds(181, 46, 65, 27);
+		add(lblFlexCons);
+		
+		JLabel lblProdCons = new JLabel("Prod./Cons. :");
+		lblProdCons.setForeground(new Color(218, 165, 32));
+		lblProdCons.setBounds(327, 46, 65, 27);
+		add(lblProdCons);
+		
+		lblProdVal = new JLabel();
+		setProd(prod);
+		lblProdVal.setBounds(100, 47, 72, 24);
+		add(lblProdVal);
+		
+		lblConsVal = new JLabel();
+		setCons(cons);
+		lblConsVal.setBounds(252, 47, 72, 24);
+		add(lblConsVal);
+		
+		lblProdConsVal = new JLabel();
+		if(cons != 0 && prod != 0){
+		lblProdConsVal.setText(Float.toString((prod/cons)*(-1)));
+		}else if(prod == 0 && cons == 0){
+			lblProdConsVal.setText("not producing or consuming...");
+		}else if(prod == 0){
+			lblProdConsVal.setText("only consuming...");
+		}else if(cons == 0){
+			lblProdConsVal.setText("only producing...");
+		}
+		lblProdConsVal.setBounds(402, 46, 173, 24);
+		add(lblProdConsVal);
+	}
+	
+	public void setProd(float p){
+		lblProdVal.setText(Float.toString(p));
+	}
+	
+	public void setCons(float c){
+		lblConsVal.setText(Float.toString(c));
+	}
+	
+	public void setProdConsVal(float prod, float cons){
+		if(cons != 0 && prod != 0){
+		lblProdConsVal.setText(Float.toString((prod/cons)*(-1)));
+		}else if(prod == 0 && cons == 0){
+			lblProdConsVal.setText("not producing or consuming...");
+		}else if(prod == 0){
+			lblProdConsVal.setText("only consuming...");
+		}else if(cons == 0){
+			lblProdConsVal.setText("only producing...");
+		}
+	}
+	
+	public void setlblName(String name){
+		name_lbl.setText(name);
+	}
+
+}

+ 46 - 2
src/ui/view/FlexiblePane.java

@@ -1,9 +1,53 @@
 package ui.view;
 
 import javax.swing.JPanel;
+import javax.swing.JScrollPane;
 
-public class FlexiblePane extends JPanel {
-	public FlexiblePane() {
+import classes.HolonObject;
+import classes.SubNet;
+import ui.controller.Control;
+
+import java.awt.Color;
+import java.awt.Dimension;
+
+import javax.swing.BoxLayout;
+
+public class FlexiblePane extends JScrollPane {
+	private JPanel flexPanel;
+	private Control controller;
+	
+	public FlexiblePane(Control controller) {
+		this.controller = controller;
+		flexPanel = new JPanel();
+		flexPanel.setLayout(new BoxLayout(flexPanel, BoxLayout.Y_AXIS));
+		setViewportView(flexPanel);
+	}
+	
+	public void recalculate(){
+		flexPanel.removeAll();
+		flexPanel.add(new FlexibleData("Main Grid", 0,0));
+		float gridProd = 0;
+		float gridCons = 0;
+		int counter = 1;
+		for(SubNet sn: controller.getSimManager().getSubNets()){
+			float subProd = 0;
+			float subCons = 0;
+			for(HolonObject hl: sn.getObjects()){
+				subProd += hl.getFlexProd();
+				subCons += hl.getFlexCons();
+				flexPanel.add(new FlexibleData(hl.getName()+" "+hl.getId(),
+						hl.getFlexProd(), hl.getFlexCons()));
+			}
+			gridProd += subProd;
+			gridCons += subCons;
+			flexPanel.add(new FlexibleData("Subnet "+ counter, subProd, subCons));
+			counter++;
+		}
+		if (flexPanel.getComponent(0) instanceof FlexibleData){
+			((FlexibleData)flexPanel.getComponent(0)).setProd(gridProd);
+			((FlexibleData)flexPanel.getComponent(0)).setCons(gridCons);
+			((FlexibleData)flexPanel.getComponent(0)).setProdConsVal(gridProd, gridCons);
+		}
 	}
 
 }

+ 63 - 8
src/ui/view/GUI.java

@@ -5,10 +5,8 @@ import java.awt.Color;
 import java.awt.Component;
 import java.awt.Cursor;
 import java.awt.Dimension;
-import java.awt.Font;
 import java.awt.HeadlessException;
 import java.awt.Image;
-import java.awt.Label;
 import java.awt.Point;
 import java.awt.Toolkit;
 import java.awt.datatransfer.UnsupportedFlavorException;
@@ -26,7 +24,6 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Timer;
 import java.util.TimerTask;
-import java.util.zip.ZipException;
 
 import javax.swing.AbstractAction;
 import javax.swing.ActionMap;
@@ -125,6 +122,8 @@ public class GUI<E> implements CategoryListener {
 	private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
 	private final JTabbedPane tabbedPane2 = new JTabbedPane(JTabbedPane.TOP);
 	private final JButton splitButton = new JButton("Split View");
+	private JSplitPane tempSplit;
+	private boolean initSplit = true;
 
 	private final JPanel panelTapped_SimMenu = new JPanel();
 	private JPopupMenu popmenuEdit = new JPopupMenu();
@@ -302,7 +301,6 @@ public class GUI<E> implements CategoryListener {
 		initialize();
 		updateCategories(model.getCategories());
 		updCon = new UpdateController(model, controller);
-		flexPane = new FlexiblePane();
 	}
 
 	/**
@@ -759,12 +757,15 @@ public class GUI<E> implements CategoryListener {
 
 		// Testing
 		menuBar.add(splitButton);
-		//Split View
+		// Split View
 		splitButton.addActionListener(new ActionListener() {
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				if (panelTapped_SimMenu
 						.getComponent(panelTapped_SimMenu.getComponentCount() - 1) instanceof JSplitPane) {
+					initSplit = true;
+					Component tempC = tabbedPane2.getSelectedComponent();
+					tabbedPane.setComponentAt(tabbedPane2.getSelectedIndex(), tempC);
 					tabbedPane2.removeAll();
 					panelTapped_SimMenu
 							.remove(panelTapped_SimMenu.getComponent(panelTapped_SimMenu.getComponentCount() - 1));
@@ -773,19 +774,71 @@ public class GUI<E> implements CategoryListener {
 					for (int i = 0; i < tabbedPane.getTabCount(); i++) {
 						tabbedPane2.addTab(tabbedPane.getTitleAt(i), null);
 					}
-					JSplitPane tempSplit = new JSplitPane();
+					if (tabbedPane.getSelectedComponent() == statScrollPane) {
+						tabbedPane.setComponentAt(0, null);
+						tabbedPane2.setComponentAt(0, canvasSP);
+						tabbedPane2.setSelectedIndex(0);
+					} else {
+						tabbedPane.setComponentAt(1, null);
+						tabbedPane2.setComponentAt(1, statScrollPane);
+						tabbedPane2.setSelectedIndex(1);
+					}
+					tempSplit = new JSplitPane();
 					tempSplit.setBorder(null);
 					tempSplit.setRightComponent(tabbedPane2);
 					tempSplit.setLeftComponent(tabbedPane);
-					tempSplit.setDividerLocation(tabbedPane.getWidth()/2);
+					tempSplit.setDividerLocation(tabbedPane.getWidth() / 2);
+					tempSplit.setResizeWeight(0.9);
 					panelTapped_SimMenu.remove(tabbedPane);
 					panelTapped_SimMenu.add(tempSplit);
+					initSplit = false;
 				}
 				contentPane.updateUI();
 			}
 
 		});
 
+		tabbedPane.addChangeListener(new ChangeListener() {
+
+			@Override
+			public void stateChanged(ChangeEvent e) {
+				if (tabbedPane.getSelectedComponent() == null) {
+					Component tempC = tabbedPane2.getSelectedComponent();
+					tabbedPane2.setComponentAt(tabbedPane.getSelectedIndex(), null);
+					tabbedPane.setComponentAt(tabbedPane.getSelectedIndex(), tempC);
+					tempC = tabbedPane.getComponentAt((tabbedPane.getSelectedIndex() + 1) % (tabbedPane.getTabCount()));
+					tabbedPane.setComponentAt((tabbedPane.getSelectedIndex() + 1) % (tabbedPane.getTabCount()), null);
+					tabbedPane2.setComponentAt((tabbedPane.getSelectedIndex() + 1) % (tabbedPane.getTabCount()), tempC);
+					tabbedPane2.setSelectedIndex((tabbedPane.getSelectedIndex() + 1) % (tabbedPane.getTabCount()));
+					contentPane.updateUI();
+				}
+			}
+		});
+
+		tabbedPane2.addChangeListener(new ChangeListener() {
+
+			@Override
+			public void stateChanged(ChangeEvent e) {
+				if (tabbedPane2.getSelectedComponent() == null && !initSplit) {
+					Component tempC = tabbedPane.getComponentAt(tabbedPane2.getSelectedIndex());
+					tabbedPane.setComponentAt(tabbedPane2.getSelectedIndex(), null);
+					tabbedPane2.setComponentAt(tabbedPane2.getSelectedIndex(), tempC);
+					for (int i = 0; i < tabbedPane.getTabCount(); i++) {
+						if (tabbedPane2.getComponentAt(i) != null && tabbedPane2.getComponentAt(i) != tempC) {
+							tempC = tabbedPane2.getComponentAt(i);
+							tabbedPane2.setComponentAt(i, null);
+							tabbedPane.setComponentAt(i, tempC);
+							break;
+						}
+					}
+					if (tabbedPane.getSelectedIndex() == tabbedPane2.getSelectedIndex()) {
+						tabbedPane.setSelectedIndex((tabbedPane2.getSelectedIndex() + 1) % tabbedPane.getTabCount());
+					}
+					contentPane.updateUI();
+				}
+			}
+		});
+
 		mnNewMenuOptions.add(mnLanguage);
 		canvas.setBackground(Color.WHITE);
 		canvas.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
@@ -1790,12 +1843,14 @@ public class GUI<E> implements CategoryListener {
 		splitPane1.setDividerLocation(500);
 		splitPaneCanvasConsole.setDividerLocation(550);
 		splitPaneCanvasConsole.setResizeWeight(0.9);
-		
+
 		splitPane.setLeftComponent(scrollPane1);
 		splitPaneCanvasConsole.setLeftComponent(panelTapped_SimMenu);
 		tabbedPane.addTab("View", canvasSP);
 		tabbedPane.addTab("Statistics", statScrollPane);
 		tabbedPane.addTab("Holon", holonCanvas);
+		flexPane = new FlexiblePane(controller);
+		controller.setFlexiblePane(flexPane);
 		tabbedPane.addTab("Flexibility", flexPane);
 
 		splitPaneCanvasConsole.setRightComponent(console);

+ 0 - 5
src/ui/view/HolonCanvas.java

@@ -20,14 +20,9 @@ import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
-import javax.swing.plaf.BorderUIResource.BevelBorderUIResource;
 
 import classes.AbstractCpsObject;
-import classes.Constants;
-import classes.CpsUpperNode;
 import classes.HolonBody;
-import classes.HolonElement;
-import classes.HolonObject;
 import classes.SubNet;
 import classes.Vector2d;
 import ui.controller.Control;

+ 1 - 2
src/ui/view/MyCanvas.java

@@ -555,8 +555,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			// Border Highlighting
 			if (showedInformation[3]) {
 				g2.setColor(cps.getBorderColor());
-				if (!(cps instanceof CpsNode)){
-					//if (g2.getColor() != Color.WHITE) {
+					if (g2.getColor() != Color.WHITE && !(cps instanceof CpsNode)) {
 						g2.fillRect((int) (cps.getPosition().x - controller.getScaleDiv2() - scalediv20 - 3),
 								(int) (cps.getPosition().y - controller.getScaleDiv2() - scalediv20 - 3),
 								(int) (controller.getScale() + ((scalediv20 + 3) * 2)),

+ 4 - 8
src/ui/view/ShowedInformationPopUp.java

@@ -1,19 +1,15 @@
 package ui.view;
 
 import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
 import javax.swing.JDialog;
-import javax.swing.JFrame;
 import javax.swing.JPanel;
 import javax.swing.border.EmptyBorder;
 
-import classes.IdCounter;
-
-import javax.swing.JCheckBox;
-import javax.swing.JButton;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-
 /**
  * This Class represents a Popup to edit the shown Information.
  * 

+ 12 - 17
src/ui/view/SimulationMenu.java

@@ -1,33 +1,28 @@
 package ui.view;
 
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+
 import javax.swing.JButton;
 import javax.swing.JComboBox;
 import javax.swing.JFileChooser;
 import javax.swing.JFrame;
-import javax.swing.JLabel;
 import javax.swing.JMenuBar;
 import javax.swing.JPanel;
-import javax.swing.JRadioButton;
-import javax.swing.JTextField;
-import javax.swing.event.CaretEvent;
-import javax.swing.event.CaretListener;
 import javax.tools.JavaCompiler;
 import javax.tools.ToolProvider;
 
 import ui.controller.Control;
 import ui.model.Model;
-import java.util.HashMap;
-import java.awt.GridBagLayout;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.net.URL;
-import java.net.URLClassLoader;
 
 /**
  * This Class represents the Menu, where you can edit stuff about the

+ 36 - 50
src/ui/view/StatPanel2.java

@@ -1,25 +1,36 @@
 package ui.view;
 
-import javax.swing.JSplitPane;
-import javax.swing.JScrollPane;
-import javax.swing.JPanel;
-
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.Random;
 
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.Alignment;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
 import javax.swing.JLabel;
-import javax.swing.LayoutStyle.ComponentPlacement;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTextField;
+import javax.swing.JTree;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.LineBorder;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 import javax.swing.event.TreeSelectionEvent;
 import javax.swing.event.TreeSelectionListener;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.MutableTreeNode;
-import javax.swing.tree.TreeNode;
 
 import DataSets.GraphDataSet;
 import DataSets.PropertyDataSet;
@@ -31,31 +42,6 @@ import classes.TrackedDataSet;
 import interfaces.GraphListener;
 import ui.controller.Control;
 
-import javax.swing.JTextField;
-import javax.swing.JComboBox;
-import javax.swing.JButton;
-import javax.swing.JTree;
-import java.awt.Color;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-
-import javax.swing.border.CompoundBorder;
-import javax.swing.border.LineBorder;
-import javax.swing.JPopupMenu;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import javax.swing.JMenuItem;
-import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import java.awt.FlowLayout;
-import java.awt.BorderLayout;
-import javax.swing.border.EmptyBorder;
-
 public class StatPanel2 extends JSplitPane implements GraphListener {
 	public static final String MAIN_GRID = "Main Grid";
 	public static final String HOLON = "Holons";
@@ -621,67 +607,67 @@ public class StatPanel2 extends JSplitPane implements GraphListener {
 		editPanel.setLayout(null);
 		
 		JLabel lblObject = new JLabel("Object(s):");
-		lblObject.setBounds(10, 11, 49, 14);
+		lblObject.setBounds(10, 11, 59, 20);
 		editPanel.add(lblObject);
 		
 		showObjectlbl = new JLabel("...");
-		showObjectlbl.setBounds(69, 11, 86, 14);
+		showObjectlbl.setBounds(69, 11, 101, 20);
 		editPanel.add(showObjectlbl);
 		
 		JLabel lblProperty = new JLabel("Property:");
-		lblProperty.setBounds(10, 36, 46, 14);
+		lblProperty.setBounds(10, 36, 59, 20);
 		editPanel.add(lblProperty);
 		
 		showPropertylbl = new JLabel("...");
-		showPropertylbl.setBounds(69, 36, 86, 14);
+		showPropertylbl.setBounds(69, 36, 101, 20);
 		editPanel.add(showPropertylbl);
 		
 		JLabel lblGraph = new JLabel("Graph:");
-		lblGraph.setBounds(10, 61, 33, 14);
+		lblGraph.setBounds(10, 61, 49, 23);
 		editPanel.add(lblGraph);
 		
 		graphNrTxtField.setColumns(10);
-		graphNrTxtField.setBounds(69, 61, 86, 20);
+		graphNrTxtField.setBounds(69, 61, 101, 23);
 		editPanel.add(graphNrTxtField);
 		
 		JLabel lblColor = new JLabel("Color:");
-		lblColor.setBounds(10, 86, 29, 14);
+		lblColor.setBounds(10, 95, 49, 23);
 		editPanel.add(lblColor);
 		
-		colorComboBox.setBounds(69, 83, 86, 20);
+		colorComboBox.setBounds(69, 95, 101, 23);
 		editPanel.add(colorComboBox);
 		
 		JLabel lblR = new JLabel("R");
-		lblR.setBounds(10, 111, 11, 14);
+		lblR.setBounds(10, 139, 11, 14);
 		editPanel.add(lblR);
 		
 		redField.setColumns(10);
-		redField.setBounds(20, 108, 37, 20);
+		redField.setBounds(22, 136, 37, 20);
 		editPanel.add(redField);
 		
 		JLabel lblG = new JLabel("G");
-		lblG.setBounds(58, 111, 11, 14);
+		lblG.setBounds(68, 139, 11, 14);
 		editPanel.add(lblG);
 		
 		greenField.setColumns(10);
-		greenField.setBounds(69, 108, 37, 20);
+		greenField.setBounds(79, 136, 37, 20);
 		editPanel.add(greenField);
 		
 		JLabel lblB = new JLabel("B");
-		lblB.setBounds(108, 111, 10, 14);
+		lblB.setBounds(126, 139, 10, 14);
 		editPanel.add(lblB);
 		
 		blueField.setColumns(10);
-		blueField.setBounds(116, 108, 39, 20);
+		blueField.setBounds(133, 136, 37, 20);
 		editPanel.add(blueField);
 		
 		colorPanel = new JPanel();
 		colorPanel.setBorder(new LineBorder(new Color(0, 0, 0)));
 		colorPanel.setBackground(Color.WHITE);
-		colorPanel.setBounds(10, 136, 49, 36);
+		colorPanel.setBounds(10, 164, 59, 38);
 		editPanel.add(colorPanel);
 
-		btnAdd.setBounds(10, 175, 51, 23);
+		btnAdd.setBounds(10, 213, 59, 23);
 		editPanel.add(btnAdd);
 		splitPane.setDividerLocation(220);
 		

+ 12 - 25
src/ui/view/StatisticGraphPanel.java

@@ -1,32 +1,14 @@
 package ui.view;
 
-import javax.swing.JPanel;
-import javax.swing.JTextPane;
-
-import classes.TrackedDataSet;
-import ui.controller.Control;
-import ui.model.Model;
-
-import javax.swing.JLabel;
-import javax.swing.JButton;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.swing.SwingConstants;
-import javax.swing.Timer;
-import javax.swing.border.Border;
-import javax.swing.text.StyledDocument;
-
 import java.awt.BorderLayout;
 import java.awt.Color;
+import java.awt.Component;
 import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Font;
-import java.awt.LayoutManager;
+import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
 import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.IOException;
@@ -34,12 +16,17 @@ import java.util.Hashtable;
 
 import javax.imageio.ImageIO;
 import javax.swing.BorderFactory;
-import javax.swing.BoxLayout;
-import javax.swing.GroupLayout.Alignment;
-
-import java.awt.GridLayout;
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
-import java.awt.Component;
+
+import classes.TrackedDataSet;
+import ui.controller.Control;
+import ui.model.Model;
 
 public class StatisticGraphPanel extends JPanel {
 

+ 17 - 0
src/ui/view/TimePanel.java

@@ -21,6 +21,10 @@ import javax.swing.event.CaretEvent;
 import javax.swing.event.CaretListener;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
+import javax.swing.plaf.SliderUI;
+import javax.swing.plaf.basic.BasicSliderUI;
+import javax.swing.plaf.metal.MetalSliderUI;
+import javax.swing.plaf.synth.SynthSliderUI;
 
 import ui.controller.Control;
 import ui.model.Model;
@@ -208,6 +212,19 @@ public class TimePanel extends JPanel {
 
 		this.add(timeBtnPanel, BorderLayout.WEST);
 		this.add(timeSlider);
+		
+		// Make the slider jump to mouse position on left click
+		timeSlider.setUI(new SynthSliderUI(timeSlider) {
+		    protected void scrollDueToClickInTrack(int direction) {
+		        int value = timeSlider.getValue(); 
+		        if (timeSlider.getOrientation() == JSlider.HORIZONTAL) {
+		            value = this.valueForXPosition(timeSlider.getMousePosition().x);
+		        } else if (timeSlider.getOrientation() == JSlider.VERTICAL) {
+		            value = ((BasicSliderUI)this).valueForYPosition(timeSlider.getMousePosition().y);
+		        }
+		        timeSlider.setValue(value);
+		    }
+		});
 	}
 
 	/**