|
@@ -6,11 +6,14 @@ import javax.swing.JPanel;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Hashtable;
|
|
|
+import java.util.Random;
|
|
|
|
|
|
import javax.swing.GroupLayout;
|
|
|
import javax.swing.GroupLayout.Alignment;
|
|
|
import javax.swing.JLabel;
|
|
|
import javax.swing.LayoutStyle.ComponentPlacement;
|
|
|
+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;
|
|
@@ -18,16 +21,31 @@ import javax.swing.tree.DefaultTreeModel;
|
|
|
import javax.swing.tree.MutableTreeNode;
|
|
|
import javax.swing.tree.TreeNode;
|
|
|
|
|
|
+import DataSets.GraphDataSet;
|
|
|
+import DataSets.PropertyDataSet;
|
|
|
import classes.HolonObject;
|
|
|
-import classes.PropertyDataSet;
|
|
|
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.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.BoxLayout;
|
|
|
+import java.awt.FlowLayout;
|
|
|
|
|
|
public class splitPane extends JSplitPane implements GraphListener {
|
|
|
private JTextField graphNrTxtField;
|
|
@@ -38,16 +56,24 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
private DefaultTreeModel treeModel;
|
|
|
private DefaultMutableTreeNode objectsNode;
|
|
|
private DefaultMutableTreeNode wholeHolon;
|
|
|
- private Hashtable<String, Hashtable<String, PropertyDataSet>> objectHashtable;
|
|
|
+ private Hashtable<String, GraphDataSet> objectHashtable;
|
|
|
+ private JPanel colorPanel;
|
|
|
+ private PropertyDataSet currentProperty = new PropertyDataSet();
|
|
|
+ private JComboBox colorComboBox;
|
|
|
+ private Control controller;
|
|
|
+ private JPanel graphPanel;
|
|
|
|
|
|
JLabel showObjectlbl;
|
|
|
JLabel showPropertylbl;
|
|
|
- public splitPane() {
|
|
|
-
|
|
|
- objectHashtable = new Hashtable<String, Hashtable<String, PropertyDataSet>>();
|
|
|
+ public splitPane(Control cont) {
|
|
|
+ //this.rightComponent
|
|
|
+ this.controller = cont;
|
|
|
+ objectHashtable = new Hashtable<String, GraphDataSet>();
|
|
|
|
|
|
+ JScrollPane dataPane = new JScrollPane();
|
|
|
+ setLeftComponent(dataPane);
|
|
|
JPanel panel = new JPanel();
|
|
|
- setLeftComponent(panel);
|
|
|
+ dataPane.setViewportView(panel);
|
|
|
|
|
|
JScrollPane treeScrollPane = new JScrollPane();
|
|
|
|
|
@@ -61,21 +87,248 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
|
|
|
JLabel lblGraph = new JLabel("Graph:");
|
|
|
|
|
|
+ JLabel lblColor = new JLabel("Color:");
|
|
|
+
|
|
|
+ colorComboBox = new JComboBox();
|
|
|
+ colorComboBox.addItem("");
|
|
|
+ colorComboBox.addItem("Red");
|
|
|
+ colorComboBox.addItem("Blue");
|
|
|
+ colorComboBox.addItem("Green");
|
|
|
+ colorComboBox.addItem("Yellow");
|
|
|
+ colorComboBox.addItem("Orange");
|
|
|
+ colorComboBox.addItem("Cyan");
|
|
|
+ colorComboBox.addItem("Magenta");
|
|
|
+ colorComboBox.addItem("Pink");
|
|
|
+ colorComboBox.addItem("Gray");
|
|
|
+ colorComboBox.addItem("Random");
|
|
|
+ colorComboBox.addItemListener(new ItemListener(){
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void itemStateChanged(ItemEvent e) {
|
|
|
+ String colorName = (String) colorComboBox.getSelectedItem();
|
|
|
+ Color tmpColor = Color.WHITE;
|
|
|
+ switch(colorName){
|
|
|
+ case "" : tmpColor = currentProperty.getColor();
|
|
|
+ break;
|
|
|
+ case "Red": tmpColor = Color.RED;
|
|
|
+ colorChanged(tmpColor);
|
|
|
+ break;
|
|
|
+ case "Blue":tmpColor = Color.BLUE;
|
|
|
+ colorChanged(tmpColor);
|
|
|
+ break;
|
|
|
+ case "Green":tmpColor = Color.GREEN;
|
|
|
+ colorChanged(tmpColor);
|
|
|
+ break;
|
|
|
+ case "Yellow":tmpColor = Color.YELLOW;
|
|
|
+ colorChanged(tmpColor);
|
|
|
+ break;
|
|
|
+ case "Orange":tmpColor = Color.ORANGE;
|
|
|
+ colorChanged(tmpColor);
|
|
|
+ break;
|
|
|
+ case "Cyan":tmpColor = Color.CYAN;
|
|
|
+ colorChanged(tmpColor);
|
|
|
+ break;
|
|
|
+ case "Magenta":tmpColor = Color.MAGENTA;
|
|
|
+ colorChanged(tmpColor);
|
|
|
+ break;
|
|
|
+ case "Pink":tmpColor = Color.PINK;
|
|
|
+ colorChanged(tmpColor);
|
|
|
+ break;
|
|
|
+ case "Gray":tmpColor = Color.GRAY;
|
|
|
+ colorChanged(tmpColor);
|
|
|
+ break;
|
|
|
+ case "Random":Random rdm = new Random();
|
|
|
+ tmpColor = new Color(rdm.nextInt(255),rdm.nextInt(255),rdm.nextInt(255));
|
|
|
+ }
|
|
|
+ redField.setText(Integer.toString(tmpColor.getRed()));
|
|
|
+ greenField.setText(Integer.toString(tmpColor.getGreen()));
|
|
|
+ blueField.setText(Integer.toString(tmpColor.getBlue()));
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ //====================GRAPH NR TEXTFIELD======================//
|
|
|
graphNrTxtField = new JTextField();
|
|
|
graphNrTxtField.setColumns(10);
|
|
|
+ graphNrTxtField.getDocument().addDocumentListener(new DocumentListener(){
|
|
|
+ /*
|
|
|
+ * if textField for Red changes, changes will applied in the DataStructure "currentProperty"
|
|
|
+ * if Value is legit
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void insertUpdate(DocumentEvent e) {
|
|
|
+ if(currentProperty != null){
|
|
|
+ currentProperty.setGraph(graphNrTxtField.getText());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void removeUpdate(DocumentEvent e) {
|
|
|
+ if(currentProperty != null){
|
|
|
+ currentProperty.setGraph(graphNrTxtField.getText());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void changedUpdate(DocumentEvent e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- JLabel lblColor = new JLabel("Color:");
|
|
|
-
|
|
|
- JComboBox colorComboBox = new JComboBox();
|
|
|
+ //====================GRAPH NR TEXTFIELD END==================//
|
|
|
|
|
|
+ //====================RED TEXTFIELD===========================//
|
|
|
redField = new JTextField();
|
|
|
redField.setColumns(10);
|
|
|
+ redField.getDocument().addDocumentListener(new DocumentListener(){
|
|
|
+ /*
|
|
|
+ * if textField for Red changes, changes will applied in the DataStructure "currentProperty"
|
|
|
+ * if Value is legit
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void insertUpdate(DocumentEvent e) {
|
|
|
+ int tmp = -1;
|
|
|
+ try{
|
|
|
+ tmp = Integer.parseInt(redField.getText());
|
|
|
+ }catch(NumberFormatException e1){
|
|
|
+
|
|
|
+ }
|
|
|
+ if(tmp > -1 && tmp <= 255){
|
|
|
+ if(currentProperty != null){
|
|
|
+ Color oldColor = currentProperty.getColor();
|
|
|
+ Color color = new Color(tmp, oldColor.getGreen(), oldColor.getBlue());
|
|
|
+ currentProperty.setColor(color);
|
|
|
+ colorChanged(color);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void removeUpdate(DocumentEvent e) {
|
|
|
+ int tmp = -1;
|
|
|
+ try{
|
|
|
+ tmp = Integer.parseInt(redField.getText());
|
|
|
+ }catch(NumberFormatException e1){
|
|
|
+
|
|
|
+ }
|
|
|
+ if(tmp > -1 && tmp <= 255){
|
|
|
+ if(currentProperty != null){
|
|
|
+ Color oldColor = currentProperty.getColor();
|
|
|
+ Color color = new Color(tmp, oldColor.getGreen(), oldColor.getBlue());
|
|
|
+ currentProperty.setColor(color);
|
|
|
+ colorChanged(color);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void changedUpdate(DocumentEvent e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //======================RED TEXTFIELD END==========================//
|
|
|
|
|
|
+ //======================GREEN TEXTFIELD============================//
|
|
|
greenField = new JTextField();
|
|
|
greenField.setColumns(10);
|
|
|
+ greenField.getDocument().addDocumentListener(new DocumentListener(){
|
|
|
+ /*
|
|
|
+ * if textField for Red changes, changes will applied in the DataStructure "currentProperty"
|
|
|
+ * if Value is legit
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void insertUpdate(DocumentEvent e) {
|
|
|
+ int tmp = -1;
|
|
|
+ try{
|
|
|
+ tmp = Integer.parseInt(greenField.getText());
|
|
|
+ }catch(NumberFormatException e1){
|
|
|
+
|
|
|
+ }
|
|
|
+ if(tmp > -1 && tmp <= 255){
|
|
|
+ if(currentProperty != null){
|
|
|
+ Color oldColor = currentProperty.getColor();
|
|
|
+ Color color = new Color(oldColor.getRed(), tmp, oldColor.getBlue());
|
|
|
+ currentProperty.setColor(color);
|
|
|
+ colorChanged(color);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void removeUpdate(DocumentEvent e) {
|
|
|
+ int tmp = -1;
|
|
|
+ try{
|
|
|
+ tmp = Integer.parseInt(greenField.getText());
|
|
|
+ }catch(NumberFormatException e1){
|
|
|
+
|
|
|
+ }
|
|
|
+ if(tmp > -1 && tmp <= 255){
|
|
|
+ if(currentProperty != null){
|
|
|
+ Color oldColor = currentProperty.getColor();
|
|
|
+ Color color = new Color(oldColor.getRed(), tmp, oldColor.getBlue());
|
|
|
+ currentProperty.setColor(color);
|
|
|
+ colorChanged(color);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void changedUpdate(DocumentEvent e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //======================GREEN TEXTFIELD END========================//
|
|
|
|
|
|
+ //======================BLUE TEXTFIELD=============================//
|
|
|
blueField = new JTextField();
|
|
|
blueField.setColumns(10);
|
|
|
+ blueField.getDocument().addDocumentListener(new DocumentListener(){
|
|
|
+ /*
|
|
|
+ * if textField for Red changes, changes will applied in the DataStructure "currentProperty"
|
|
|
+ * if Value is legit
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void insertUpdate(DocumentEvent e) {
|
|
|
+ int tmp = -1;
|
|
|
+ try{
|
|
|
+ tmp = Integer.parseInt(blueField.getText());
|
|
|
+ }catch(NumberFormatException e1){
|
|
|
+
|
|
|
+ }
|
|
|
+ if(tmp > -1 && tmp <= 255){
|
|
|
+ if(currentProperty != null){
|
|
|
+ Color oldColor = currentProperty.getColor();
|
|
|
+ Color color = new Color(oldColor.getRed(), oldColor.getGreen(), tmp);
|
|
|
+ currentProperty.setColor(color);
|
|
|
+ colorChanged(color);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void removeUpdate(DocumentEvent e) {
|
|
|
+ int tmp = -1;
|
|
|
+ try{
|
|
|
+ tmp = Integer.parseInt(blueField.getText());
|
|
|
+ }catch(NumberFormatException e1){
|
|
|
+
|
|
|
+ }
|
|
|
+ if(tmp > -1 && tmp <= 255){
|
|
|
+ if(currentProperty != null){
|
|
|
+ Color oldColor = currentProperty.getColor();
|
|
|
+ Color color = new Color(oldColor.getRed(), oldColor.getGreen(), tmp);
|
|
|
+ currentProperty.setColor(color);
|
|
|
+ colorChanged(color);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void changedUpdate(DocumentEvent e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //======================BLUE TEXTFIELD END=========================//
|
|
|
|
|
|
JLabel lblR = new JLabel("R:");
|
|
|
|
|
@@ -84,8 +337,16 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
JLabel lblB = new JLabel("B:");
|
|
|
|
|
|
JButton btnAdd = new JButton("Add");
|
|
|
+ btnAdd.addActionListener(new ActionListener() {
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ StatisticGraph tmp = new StatisticGraph(controller.getModel(), controller);
|
|
|
+ graphPanel.add(tmp);
|
|
|
+ graphPanel.revalidate();
|
|
|
+ graphPanel.updateUI();
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- JPanel colorPanel = new JPanel();
|
|
|
+ colorPanel = new JPanel();
|
|
|
colorPanel.setBorder(new LineBorder(new Color(0, 0, 0)));
|
|
|
colorPanel.setBackground(Color.WHITE);
|
|
|
GroupLayout gl_panel = new GroupLayout(panel);
|
|
@@ -93,8 +354,10 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
gl_panel.createParallelGroup(Alignment.LEADING)
|
|
|
.addGroup(gl_panel.createSequentialGroup()
|
|
|
.addContainerGap()
|
|
|
- .addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false)
|
|
|
- .addComponent(treeScrollPane, GroupLayout.PREFERRED_SIZE, 165, GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
|
|
|
+ .addGroup(gl_panel.createSequentialGroup()
|
|
|
+ .addComponent(treeScrollPane, GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
|
|
|
+ .addContainerGap())
|
|
|
.addGroup(gl_panel.createSequentialGroup()
|
|
|
.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
|
|
|
.addComponent(lblGraph)
|
|
@@ -112,6 +375,7 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
.addComponent(showObjectlbl, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
.addComponent(showPropertylbl, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
.addComponent(colorComboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(graphNrTxtField)
|
|
|
.addGroup(gl_panel.createSequentialGroup()
|
|
|
.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
|
|
|
.addComponent(btnAdd)
|
|
@@ -122,16 +386,15 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
.addPreferredGap(ComponentPlacement.RELATED)
|
|
|
.addComponent(lblB)
|
|
|
.addPreferredGap(ComponentPlacement.RELATED)
|
|
|
- .addComponent(blueField, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE))
|
|
|
- .addComponent(graphNrTxtField))))
|
|
|
- .addContainerGap())
|
|
|
+ .addComponent(blueField, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)))
|
|
|
+ .addGap(32))))
|
|
|
);
|
|
|
gl_panel.setVerticalGroup(
|
|
|
gl_panel.createParallelGroup(Alignment.LEADING)
|
|
|
.addGroup(gl_panel.createSequentialGroup()
|
|
|
.addContainerGap()
|
|
|
- .addComponent(treeScrollPane, GroupLayout.PREFERRED_SIZE, 153, GroupLayout.PREFERRED_SIZE)
|
|
|
- .addGap(27)
|
|
|
+ .addComponent(treeScrollPane, GroupLayout.PREFERRED_SIZE, 174, GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
|
|
|
.addComponent(lblObject, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE)
|
|
|
.addComponent(showObjectlbl))
|
|
@@ -157,9 +420,9 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
.addComponent(blueField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
|
|
.addPreferredGap(ComponentPlacement.RELATED)
|
|
|
.addComponent(colorPanel, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
|
|
|
- .addPreferredGap(ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
|
|
|
+ .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
.addComponent(btnAdd)
|
|
|
- .addContainerGap())
|
|
|
+ .addContainerGap(35, Short.MAX_VALUE))
|
|
|
);
|
|
|
|
|
|
objectTree = new JTree();
|
|
@@ -183,40 +446,65 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
|
|
|
treeScrollPane.setViewportView(objectTree);
|
|
|
|
|
|
+ JPopupMenu popupMenu = new JPopupMenu();
|
|
|
+ addPopup(objectTree, popupMenu);
|
|
|
+
|
|
|
+ JMenuItem mntmUntrack = new JMenuItem("Untrack");
|
|
|
+ mntmUntrack.addActionListener(new ActionListener() {
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)objectTree.getLastSelectedPathComponent();
|
|
|
+ if(selectedNode.getLevel() == 2 && !selectedNode.getParent().toString().equals("whole Holon")){
|
|
|
+ String object = selectedNode.toString();
|
|
|
+ controller.removeTrackingObj((HolonObject)objectHashtable.get(object).getObject());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ popupMenu.add(mntmUntrack);
|
|
|
+
|
|
|
objectTree.addTreeSelectionListener(new TreeSelectionListener(){
|
|
|
|
|
|
@Override
|
|
|
public void valueChanged(TreeSelectionEvent e) {
|
|
|
+ resetFields();
|
|
|
showObjectlbl.setText("...");
|
|
|
showPropertylbl.setText("...");
|
|
|
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)objectTree.getLastSelectedPathComponent();
|
|
|
if(selectedNode == null){
|
|
|
return;
|
|
|
}else{
|
|
|
+ if(selectedNode.getLevel() == 0){
|
|
|
+ disableFields();
|
|
|
+ }
|
|
|
if(selectedNode.getLevel() == 1){
|
|
|
+ disableFields();
|
|
|
+ currentProperty = null;
|
|
|
showObjectlbl.setText(selectedNode.toString());
|
|
|
}
|
|
|
if(selectedNode.getLevel() == 2){
|
|
|
if(((DefaultMutableTreeNode)selectedNode.getParent()).toString().equals("whole Holon")){
|
|
|
+ enableFields();
|
|
|
showPropertylbl.setText(selectedNode.toString());
|
|
|
showObjectlbl.setText(selectedNode.getParent().toString());
|
|
|
}else{
|
|
|
+ disableFields();
|
|
|
+ currentProperty = null;
|
|
|
showObjectlbl.setText(selectedNode.toString());
|
|
|
}
|
|
|
}
|
|
|
if(selectedNode.getLevel() == 3){
|
|
|
+ enableFields();
|
|
|
String object = ((DefaultMutableTreeNode)selectedNode.getParent()).toString();
|
|
|
String property = selectedNode.toString();
|
|
|
- int r = objectHashtable.get(object).get(property).getColor().getRed();
|
|
|
- redField.setText(Integer.toString(r));
|
|
|
- int g = objectHashtable.get(object).get(property).getColor().getGreen();
|
|
|
- greenField.setText(Integer.toString(g));
|
|
|
- int b = objectHashtable.get(object).get(property).getColor().getBlue();
|
|
|
- blueField.setText(Integer.toString(b));
|
|
|
+ currentProperty = objectHashtable.get(object).getPropertytTable().get(property);
|
|
|
+ Color color = currentProperty.getColor();
|
|
|
+ redField.setText(Integer.toString(color.getRed()));
|
|
|
+ greenField.setText(Integer.toString(color.getGreen()));
|
|
|
+ blueField.setText(Integer.toString(color.getBlue()));
|
|
|
|
|
|
showObjectlbl.setText(object);
|
|
|
showPropertylbl.setText(property);
|
|
|
- graphNrTxtField.setText(objectHashtable.get(object).get(property).getAssignedGraph());
|
|
|
+ graphNrTxtField.setText(currentProperty.getAssignedGraph());
|
|
|
+ colorPanel.setBackground(color);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -226,6 +514,13 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
|
|
|
JScrollPane graphScrollPane = new JScrollPane();
|
|
|
setRightComponent(graphScrollPane);
|
|
|
+
|
|
|
+ graphPanel = new JPanel();
|
|
|
+ graphScrollPane.setViewportView(graphPanel);
|
|
|
+ graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));
|
|
|
+
|
|
|
+ JPanel panel_1 = new JPanel();
|
|
|
+ graphPanel.add(panel_1);
|
|
|
repaintGraph();
|
|
|
}
|
|
|
@Override
|
|
@@ -234,8 +529,9 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
}
|
|
|
@Override
|
|
|
public void addTrackedObject(ArrayList<HolonObject> hlList) {
|
|
|
+ objectsNode.removeAllChildren();
|
|
|
+ objectHashtable.clear();
|
|
|
if(hlList.size() > 0 && hlList != null){
|
|
|
- objectsNode.removeAllChildren();
|
|
|
for(HolonObject hO : hlList){
|
|
|
Hashtable<String, PropertyDataSet> tmpHash = new Hashtable<String, PropertyDataSet>();
|
|
|
String name = hO.getName() + " " + hO.getID();
|
|
@@ -246,7 +542,8 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
tmpHash.put("total Production", new PropertyDataSet());
|
|
|
tmpHash.put("total Consumption", new PropertyDataSet());
|
|
|
tmpHash.put("number of activated Elements", new PropertyDataSet());
|
|
|
- objectHashtable.put(name, tmpHash);
|
|
|
+ GraphDataSet gS = new GraphDataSet(hO, tmpHash);
|
|
|
+ objectHashtable.put(name, gS);
|
|
|
objectsNode.add(tmp);
|
|
|
}
|
|
|
}else{
|
|
@@ -254,4 +551,53 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public void colorChanged(Color color){
|
|
|
+ colorPanel.setBackground(color);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void resetFields(){
|
|
|
+ colorPanel.setBackground(Color.WHITE);
|
|
|
+ redField.setText("");
|
|
|
+ greenField.setText("");
|
|
|
+ blueField.setText("");
|
|
|
+ //graphNrTxtField.setText("");
|
|
|
+ colorComboBox.setSelectedIndex(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void disableFields(){
|
|
|
+ redField.setEnabled(false);
|
|
|
+ greenField.setEnabled(false);
|
|
|
+ blueField.setEnabled(false);
|
|
|
+ graphNrTxtField.setEnabled(false);
|
|
|
+ colorComboBox.setEnabled(false);
|
|
|
+ colorPanel.setBackground(Color.LIGHT_GRAY);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void enableFields(){
|
|
|
+ redField.setEnabled(true);
|
|
|
+ greenField.setEnabled(true);
|
|
|
+ blueField.setEnabled(true);
|
|
|
+ graphNrTxtField.setEnabled(true);
|
|
|
+ colorComboBox.setEnabled(true);
|
|
|
+ colorPanel.setBackground(Color.WHITE);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void addPopup(Component component, final JPopupMenu popup) {
|
|
|
+ component.addMouseListener(new MouseAdapter() {
|
|
|
+ public void mousePressed(MouseEvent e) {
|
|
|
+ if (e.isPopupTrigger()) {
|
|
|
+ showMenu(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void mouseReleased(MouseEvent e) {
|
|
|
+ if (e.isPopupTrigger()) {
|
|
|
+ showMenu(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void showMenu(MouseEvent e) {
|
|
|
+ popup.show(e.getComponent(), e.getX(), e.getY());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|