Quellcode durchsuchen

adding tracked objects to graphs

dominik.rieder vor 8 Jahren
Ursprung
Commit
3f5b70f257

+ 1 - 1
src/interfaces/GraphListener.java

@@ -6,7 +6,7 @@ import classes.HolonObject;
 
 public interface GraphListener {
 	
-	public void repaintGraph();
+	public void repaintTree();
 	
 	public void addTrackedObject(ArrayList<HolonObject> hlList);
 

+ 2 - 2
src/ui/model/Model.java

@@ -390,7 +390,7 @@ public class Model {
 
 	private void notifyGraphListeners() {
 		for (GraphListener gl : graphListeners) {
-			gl.repaintGraph();
+			gl.repaintTree();
 		}
 
 	}
@@ -707,7 +707,7 @@ public class Model {
 	public void addObjectsToGraphListeners() {
 		for (GraphListener gl : graphListeners) {
 			gl.addTrackedObject(trackingObj);
-			gl.repaintGraph();
+			gl.repaintTree();
 		}
 	}
 

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

@@ -1521,8 +1521,8 @@ public class GUI<E> implements CategoryListener {
 			public void stateChanged(ChangeEvent e) {
 				int i = model.getCurIteration();
 				controller.calculateStateForTimeStep(i);
-
 				unitGraph.repaint();
+				statSplitPane.repaintGraphs();
 			}
 		});
 		splitPane.setRightComponent(splitPane1);

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

@@ -218,7 +218,7 @@ public class StatisticPane extends JPanel implements GraphListener{
     }
 
 	@Override
-	public void repaintGraph() {
+	public void repaintTree() {
 		// TODO Auto-generated method stub
 		statGraph1.repaint();
 	}

+ 29 - 3
src/ui/view/splitPane.java

@@ -24,6 +24,7 @@ import javax.swing.tree.TreeNode;
 import DataSets.GraphDataSet;
 import DataSets.PropertyDataSet;
 import classes.HolonObject;
+import classes.TrackedDataSet;
 import interfaces.GraphListener;
 import ui.controller.Control;
 
@@ -52,6 +53,12 @@ import java.awt.FlowLayout;
 import java.awt.BorderLayout;
 
 public class splitPane extends JSplitPane implements GraphListener {
+	//Property Integers
+	public static  final int CONSUMPTION = 0;
+	public static final int PRODUCTION = 1;
+	public static final int ACTIVATED_ELEMENTS = 2;
+	public static final int ON_OFF = 3;
+	
 	private JTextField graphNrTxtField;
 	private JTextField redField;
 	private JTextField greenField;
@@ -62,6 +69,7 @@ public class splitPane extends JSplitPane implements GraphListener {
 	private DefaultMutableTreeNode wholeHolon;
 	private Hashtable<String, GraphDataSet> objectHashtable;
 	private Hashtable<String, StatisticGraphPanel> graphHashtable;
+	private Hashtable<String, Integer> propValTable;
 	private JPanel colorPanel;
 	private PropertyDataSet currentProperty = new PropertyDataSet();
 	private JComboBox colorComboBox;
@@ -74,6 +82,10 @@ public class splitPane extends JSplitPane implements GraphListener {
 		this.controller = cont;
 		objectHashtable = new Hashtable<String, GraphDataSet>();
 		graphHashtable = new Hashtable<String, StatisticGraphPanel>();
+		propValTable = new Hashtable<String, Integer>();
+		propValTable.put("total Production", PRODUCTION);
+		propValTable.put("total Consumption", CONSUMPTION);
+		propValTable.put("number of activated Elements", ACTIVATED_ELEMENTS);
 		
 		JScrollPane dataPane = new JScrollPane(); 
 		setLeftComponent(dataPane);
@@ -348,8 +360,9 @@ public class splitPane extends JSplitPane implements GraphListener {
 					 return;
 				 }else{
 					 if(selectedNode.getLevel() == 3){
+						 StatisticGraphPanel tmp = null;
 						 if(!graphHashtable.containsKey(graphNrTxtField.getText()) && graphNrTxtField.getText().length() > 0){
-							StatisticGraphPanel tmp = new StatisticGraphPanel(controller.getModel(), controller, graphNrTxtField.getText(), 
+							tmp = new StatisticGraphPanel(controller.getModel(), controller, graphNrTxtField.getText(), 
 									graphHashtable);
 						 	tmp.setPreferredSize(new Dimension(280,150));
 						 	tmp.setMaximumSize(new Dimension(1000,150));
@@ -361,6 +374,13 @@ public class splitPane extends JSplitPane implements GraphListener {
 						 	graphPanel.updateUI();
 						 	graphHashtable.put(graphNrTxtField.getText(), tmp);
 						 }
+						 if(tmp != null){
+							 String object = ((DefaultMutableTreeNode)selectedNode.getParent()).toString();
+							 String property = selectedNode.toString();
+							 GraphDataSet dataSet = objectHashtable.get(object);
+							 TrackedDataSet tds = new TrackedDataSet(dataSet.getObject(), propValTable.get(property), currentProperty.getColor());
+							 tmp.addObjec(tds);
+							 }
 					 }
 				 }
 			}
@@ -538,10 +558,10 @@ public class splitPane extends JSplitPane implements GraphListener {
 		graphPanel.revalidate();
 		graphPanel.updateUI();
 		graphScrollPane.setViewportView(graphPanel);
-		repaintGraph();
+		repaintTree();
 	}
 	@Override
-	public void repaintGraph() {
+	public void repaintTree() {
 		treeModel.reload();
 	}
 	@Override
@@ -600,6 +620,12 @@ public class splitPane extends JSplitPane implements GraphListener {
 		colorPanel.setBackground(Color.WHITE);
 	}
 	
+	public void repaintGraphs(){
+		for(StatisticGraphPanel sg: graphHashtable.values()){
+			sg.repaint();
+		}
+	}
+	
 	private static void addPopup(Component component, final JPopupMenu popup) {
 		component.addMouseListener(new MouseAdapter() {
 			public void mousePressed(MouseEvent e) {