Browse Source

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

Edgardo Palza 7 years ago
parent
commit
adb5876a3c

+ 5 - 1
.classpath

@@ -6,7 +6,11 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
 	<classpathentry kind="lib" path="jars/CpsAlgorithm.jar"/>
-	<classpathentry kind="lib" path="jars/gson-2.8.0.jar"/>
+	<classpathentry kind="lib" path="jars/gson-2.8.0.jar">
+		<attributes>
+			<attribute name="javadoc_location" value="jar:platform:/resource/praktikum-holons/jars/gson-2.8.0-javadoc.jar!/"/>
+		</attributes>
+	</classpathentry>
 	<classpathentry kind="lib" path="jars/commons-compress-1.13/commons-compress-1.13.jar" sourcepath="jars/commons-compress-1.13/commons-compress-1.13-sources.jar">
 		<attributes>
 			<attribute name="javadoc_location" value="jar:platform:/resource/praktikum-holons/jars/commons-compress-1.13/commons-compress-1.13-javadoc.jar!/"/>

BIN
jars/gson-2.8.0-javadoc.jar


+ 15 - 4
src/ui/controller/ClipboardController.java

@@ -149,9 +149,8 @@ public class ClipboardController {
 				&& !content.isDataFlavorSupported(DataFlavor.allHtmlFlavor)) {
 
 			String str = (String) content.getTransferData(DataFlavor.stringFlavor);
-			
-			
-			if (parser.parse(str).isJsonObject()) 
+
+			if (parser.parse(str).isJsonObject())
 				json = (JsonObject) parser.parse(str);
 			else
 				throw new JsonParseException("Unknown Clipboard Information");
@@ -475,7 +474,19 @@ public class ClipboardController {
 
 	private void updatePosition(AbstractCpsObject temp) {
 		// TODO Auto-generated method stub
-		temp.setPosition(new Position(temp.getPosition().x - point.x, temp.getPosition().y - point.y));
+		int x = temp.getPosition().x - point.x;
+		int y = temp.getPosition().y - point.y;
+		if(x < 0)
+			x = 0;
+		if(x > model.getCanvasX())
+			x = model.getCanvasX();
+		if(y < 0)
+			y = 0;
+		if(y > model.getCanvasX())
+			y = model.getCanvasY();
+		
+		temp.setPosition(new Position(x, y));
+		
 	}
 
 }

+ 14 - 11
src/ui/controller/StoreController.java

@@ -132,7 +132,7 @@ public class StoreController {
 		writer.flush();
 		writer.close();
 
-		addFilesToSave(holonFile, stream);
+		addFileToSave(holonFile, stream, false);
 
 		stream.finish();
 		output.close();
@@ -258,17 +258,19 @@ public class StoreController {
 
 	/**
 	 * Save wanted Data
+	 * 
 	 * @param stream
 	 * @throws IOException
 	 */
 	private void storeData(ArchiveOutputStream stream) throws IOException {
 		// TODO Auto-generated method stub
-		
+
 		File images = new File(System.getProperty("user.home") + "/HolonGUI/Images");
 		File background = new File(System.getProperty("user.home") + "/HolonGUI/BackgroundImages");
+		System.out.println(images.getCanonicalPath());
 		addFilesToSave(images, stream);
 		addFilesToSave(background, stream);
-	
+
 	}
 
 	/**
@@ -397,15 +399,15 @@ public class StoreController {
 	private void addFilesToSave(File src, ArchiveOutputStream stream) throws IOException {
 		if (!src.exists())
 			return;
-		
-		if (!src.isDirectory()) {
-			addFileToSave(src, stream, false);
-			return;
-		}
+
 		ArrayList<File> files = new ArrayList<>();
 		files.addAll(Arrays.asList(src.listFiles()));
+
 		for (File file : files) {
-			addFileToSave(file, stream, true);
+			if (file.isDirectory())
+				addFilesToSave(file, stream);
+			else
+				addFileToSave(file, stream, true);
 		}
 
 	}
@@ -419,8 +421,9 @@ public class StoreController {
 	 * @throws IOException
 	 */
 	private void addFileToSave(File src, ArchiveOutputStream stream, boolean dir) throws IOException {
-		String entryName = (dir == true ? src.getParentFile().getName() + File.separator + src.getName()
-				: src.getName());
+		String entryName = (dir == true ? src.getCanonicalPath() : src.getName());
+		entryName = entryName.replace(System.getProperty("user.home") + "/HolonGUI/", "");
+		
 		ZipArchiveEntry entry = new ZipArchiveEntry(entryName);
 		stream.putArchiveEntry(entry);
 		BufferedInputStream input = new BufferedInputStream(new FileInputStream(src));

+ 1 - 6
src/ui/model/Model.java

@@ -1,7 +1,6 @@
 package ui.model;
 
 import java.awt.Color;
-import java.awt.RenderingHints;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -9,14 +8,11 @@ import java.util.List;
 
 import javax.swing.JTable;
 
-import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;
-
+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 interfaces.CategoryListener;
 import interfaces.GraphListener;
@@ -24,7 +20,6 @@ import interfaces.ObjectListener;
 import ui.view.Console;
 import ui.view.DefaulTable;
 import ui.view.PropertyTable;
-import ui.view.DefaulTable;
 
 /**
  * The Class Model is the class where everything is saved. All changes made to

+ 1 - 1
src/ui/view/BackgroundPopUp.java

@@ -202,7 +202,7 @@ public class BackgroundPopUp extends JDialog {
 
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				// Bild ausgewählt?
+				// picture selected?
 				if (!path.isEmpty()) {
 					if (rdbtnImagePixel.isSelected()) {
 						mode = 0;

+ 35 - 2
src/ui/view/GUI.java

@@ -123,6 +123,9 @@ public class GUI<E> implements CategoryListener {
 	private final JScrollPane scrollPane1 = new JScrollPane();
 	// private final JScrollPane holonSP = new JScrollPane();
 	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 final JPanel panelTapped_SimMenu = new JPanel();
 	private JPopupMenu popmenuEdit = new JPopupMenu();
 	private JMenuItem editItem = new JMenuItem("Edit Object");
@@ -754,6 +757,35 @@ public class GUI<E> implements CategoryListener {
 
 		mnHelp.add(aboutUs);
 
+		// Testing
+		menuBar.add(splitButton);
+		//Split View
+		splitButton.addActionListener(new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				if (panelTapped_SimMenu
+						.getComponent(panelTapped_SimMenu.getComponentCount() - 1) instanceof JSplitPane) {
+					tabbedPane2.removeAll();
+					panelTapped_SimMenu
+							.remove(panelTapped_SimMenu.getComponent(panelTapped_SimMenu.getComponentCount() - 1));
+					panelTapped_SimMenu.add(tabbedPane);
+				} else {
+					for (int i = 0; i < tabbedPane.getTabCount(); i++) {
+						tabbedPane2.addTab(tabbedPane.getTitleAt(i), null);
+					}
+					JSplitPane tempSplit = new JSplitPane();
+					tempSplit.setBorder(null);
+					tempSplit.setRightComponent(tabbedPane2);
+					tempSplit.setLeftComponent(tabbedPane);
+					tempSplit.setDividerLocation(tabbedPane.getWidth()/2);
+					panelTapped_SimMenu.remove(tabbedPane);
+					panelTapped_SimMenu.add(tempSplit);
+				}
+				contentPane.updateUI();
+			}
+
+		});
+
 		mnNewMenuOptions.add(mnLanguage);
 		canvas.setBackground(Color.WHITE);
 		canvas.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
@@ -1757,8 +1789,9 @@ public class GUI<E> implements CategoryListener {
 		splitPane.setRightComponent(splitPane1);
 		splitPane.setDividerLocation(200);
 		splitPane1.setDividerLocation(500);
-		splitPaneCanvasConsole.setDividerLocation(500);
-
+		splitPaneCanvasConsole.setDividerLocation(550);
+		splitPaneCanvasConsole.setResizeWeight(0.9);
+		
 		splitPane.setLeftComponent(scrollPane1);
 		splitPaneCanvasConsole.setLeftComponent(panelTapped_SimMenu);
 		tabbedPane.addTab("View", canvasSP);

+ 8 - 7
src/ui/view/MyCanvas.java

@@ -555,12 +555,13 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			// Border Highlighting
 			if (showedInformation[3]) {
 				g2.setColor(cps.getBorderColor());
-				if (g2.getColor() != Color.WHITE) {
-					g2.fillRect((int) (cps.getPosition().x - controller.getScaleDiv2() - scalediv20 - 3),
-							(int) (cps.getPosition().y - controller.getScaleDiv2() - scalediv20 - 3),
-							(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
-							(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
-				}
+				if (!(cps instanceof CpsNode)){
+					//if (g2.getColor() != Color.WHITE) {
+						g2.fillRect((int) (cps.getPosition().x - controller.getScaleDiv2() - scalediv20 - 3),
+								(int) (cps.getPosition().y - controller.getScaleDiv2() - scalediv20 - 3),
+								(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
+								(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
+					}
 			}
 			// node image
 			if (cps instanceof CpsNode && (cps == tempCps || model.getSelectedCpsObject() == cps
@@ -744,7 +745,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	public void mouseReleased(MouseEvent e) {
 		x = e.getX();
 		y = e.getY();
-		
+
 		dragging = false;
 
 		if (drawEdge) {

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

@@ -104,6 +104,13 @@ public class TimePanel extends JPanel {
 				controller.resetSimulation();
 			}
 		});
+		
+		timeSlider.addMouseMotionListener(new MouseAdapter() {
+			@Override
+			public void mouseDragged(MouseEvent e) {
+				controller.resetSimulation();
+			}
+		});
 
 		// Panel
 		timeBtnPanel.setBorder(null);

+ 7 - 6
src/ui/view/UnitGraph.java

@@ -156,13 +156,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 
 			/*
 			 * // Actual Iteration Point Visualization g2.setColor(Color.RED);
-			 * if (arrayOfValue != null) { for (int i = 0; i <
-			 * arrayOfValue.length; i++) { g2.fillOval((int) (i * width /
+			 * if (arrayOfFloats != null) { for (int i = 0; i <
+			 * arrayOfFloats.length; i++) { g2.fillOval((int) (i * width /
 			 * (model.getIterations() - 1) * scaleX - recSize.getX() / 2), (int)
-			 * (convertToCanvasY((int) arrayOfValue[i]) * scaleY -
+			 * (convertToCanvasY((int) arrayOfFloats[i]) * scaleY -
 			 * recSize.getY() / 2), (int) recSize.getX(), (int) recSize.getY());
 			 * } }
 			 */
+
 		} else if (isSwitch) {
 			if (arrayOfBooleans != null) {
 				// array fillen
@@ -517,8 +518,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	public void reset() {
 		pointList.removeAll(pointList);
 		if (isSwitch) {
-			pointList.addFirst(new Point(-4, (int)(height/6)));
-			pointList.addLast(new Point((int) (width)+4, (int) (height / 6)));
+			pointList.addFirst(new Point(-4, (int) (height / 6)));
+			pointList.addLast(new Point((int) (width) + 4, (int) (height / 6)));
 		} else {
 			pointList.addFirst(new Point(0, 0));
 			pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
@@ -583,7 +584,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		// First time clicked on the Element
 		if (pointList.isEmpty()) {
 			pointList.addFirst(new Point(-4, (int) (height / 6)));
-			pointList.addLast(new Point((int) (width)+4, (int) (height / 6)));
+			pointList.addLast(new Point((int) (width) + 4, (int) (height / 6)));
 		}
 		repaint();
 	}