瀏覽代碼

console in the gui with sample text

Kevin Trometer 7 年之前
父節點
當前提交
c1eafd64d8
共有 2 個文件被更改,包括 43 次插入6 次删除
  1. 18 5
      src/ui/view/Console.java
  2. 25 1
      src/ui/view/GUI.java

+ 18 - 5
src/ui/view/Console.java

@@ -1,4 +1,5 @@
 package ui.view;
+
 import java.awt.Color;
 
 import javax.swing.JScrollPane;
@@ -37,18 +38,30 @@ public class Console extends JScrollPane {
 		panel.setBackground(Color.WHITE);
 		panel.add(consoleText);
 		setViewportView(panel);
-
 	}
-
-	public void addText(String t, Color c, int p) {
-		StyleConstants.setForeground(style, c);
+	
+	/**
+	 * Getter for selected CpsObject
+	 *
+	 * @param text,
+	 *            String the Text
+	 * @param color,
+	 *            the color of the Text
+	 * @param p,
+	 *            size of the Text
+	 * 
+	 * @return selected CpsObject
+	 */
+	public void addText(String text, Color color, int p, boolean bold) {
+		StyleConstants.setForeground(style, color);
 		StyleConstants.setFontSize(style, p);
+		StyleConstants.setBold(style, bold);
 
 		try {
 			if (consoleText.getText().length() != 0) {
 				doc.insertString(doc.getLength(), "\n", style);
 			}
-			doc.insertString(doc.getLength(), t, style);
+			doc.insertString(doc.getLength(), text, style);
 		} catch (BadLocationException e) {
 		}
 	}

+ 25 - 1
src/ui/view/GUI.java

@@ -96,6 +96,8 @@ public class GUI<E> implements CategoryListener {
 	private final JMenuItem canvasSize = new JMenuItem("View Size");
 	private final JSplitPane splitPane = new JSplitPane();
 	private final JSplitPane splitPane_1 = new JSplitPane();
+	private final JSplitPane splitPane_tree_console = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+
 	private final JScrollPane scrollPane_1 = new JScrollPane();
 	private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
 	private final JScrollPane SimulationPane = new JScrollPane();
@@ -178,6 +180,7 @@ public class GUI<E> implements CategoryListener {
 	private CpsObject tempCps = null;
 	private int yValueElements = 0;
 
+	private Console console = new Console();
 	private MyCanvas canvas;
 	private UnitGraph unitGraph;
 	private final JSplitPane splitPane_3 = new JSplitPane();
@@ -226,6 +229,22 @@ public class GUI<E> implements CategoryListener {
 	 */
 	@SuppressWarnings({ "serial", "unchecked" })
 	private void initialize() {
+		console.addText("Das ist ein blauer Text der größe 12", Color.BLUE, 12, false);
+		console.addText("Das ist ein roter Text der größe 16", Color.RED, 16, false);
+		console.addText("Das ist ein gelber Text der größe 20", Color.YELLOW, 20, true);
+		console.addText("Das ist ein blauer Text der größe 12", Color.BLUE, 12, false);
+		console.addText("Das ist ein roter Text der größe 16", Color.RED, 16, true);
+		console.addText("Das ist ein gelber Text der größe 20", Color.YELLOW, 20, false);
+		console.addText("Das ist ein blauer Text der größe 12", Color.BLUE, 12, true);
+		console.addText("Das ist ein roter Text der größe 16", Color.RED, 16, false);
+		console.addText("Das ist ein gelber Text der größe 20", Color.YELLOW, 20, false);
+		console.addText("Das ist ein blauer Text der größe 12", Color.BLUE, 12, false);
+		console.addText("Das ist ein roter Text der größe 16", Color.RED, 16, true);
+		console.addText("Das ist ein gelber Text der größe 20", Color.YELLOW, 20, true);
+		console.addText("Das ist ein blauer Text der größe 12", Color.BLUE, 12, false);
+		console.addText("Das ist ein roter Text der größe 16", Color.RED, 16, false);
+		console.addText("Das ist ein gelber Text der größe 20", Color.YELLOW, 20, false);
+		
 		simulationSpeedField.setColumns(10);
 		frmCyberPhysical = new JFrame();
 		frmCyberPhysical.setTitle("Cyber Physical Systems Model");
@@ -1425,10 +1444,14 @@ public class GUI<E> implements CategoryListener {
 		splitPane.setRightComponent(splitPane_1);
 		splitPane.setDividerLocation(200);
 		splitPane_1.setDividerLocation(500);
+		splitPane_tree_console.setDividerLocation(500);
 
-		splitPane.setLeftComponent(scrollPane_1);
+		splitPane.setLeftComponent(splitPane_tree_console);
+		splitPane_tree_console.setLeftComponent(scrollPane_1);
+		splitPane_tree_console.setRightComponent(console);
 		splitPane_1.setLeftComponent(tabbedPane);
 		splitPane_1.setRightComponent(split_HolonEl_Pro);
+		
 		split_HolonEl_Pro.setDividerLocation(400);
 		split_HolonEl_Pro.setTopComponent(split_Graph_HolonEl);
 		split_HolonEl_Pro.setBottomComponent(scrollProperties);
@@ -1442,6 +1465,7 @@ public class GUI<E> implements CategoryListener {
 		scrollElements.setBorder(null);
 		splitPane.setBorder(null);
 		splitPane_1.setBorder(null);
+		splitPane_tree_console.setBorder(null);
 		split_HolonEl_Pro.setBorder(null);
 		split_Graph_HolonEl.setBorder(null);
 		SimulationPane.setBorder(null);