|
@@ -53,12 +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;
|
|
|
+ // 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;
|
|
@@ -78,6 +78,7 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
|
|
|
JLabel showObjectlbl;
|
|
|
JLabel showPropertylbl;
|
|
|
+
|
|
|
public splitPane(Control cont) {
|
|
|
this.controller = cont;
|
|
|
objectHashtable = new Hashtable<String, GraphDataSet>();
|
|
@@ -86,25 +87,25 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
propValTable.put("total Production", PRODUCTION);
|
|
|
propValTable.put("total Consumption", CONSUMPTION);
|
|
|
propValTable.put("number of activated Elements", ACTIVATED_ELEMENTS);
|
|
|
-
|
|
|
- JScrollPane dataPane = new JScrollPane();
|
|
|
+
|
|
|
+ JScrollPane dataPane = new JScrollPane();
|
|
|
setLeftComponent(dataPane);
|
|
|
JPanel panel = new JPanel();
|
|
|
dataPane.setViewportView(panel);
|
|
|
-
|
|
|
+
|
|
|
JScrollPane treeScrollPane = new JScrollPane();
|
|
|
JLabel lblObject = new JLabel("Object(s):");
|
|
|
-
|
|
|
+
|
|
|
showObjectlbl = new JLabel("...");
|
|
|
-
|
|
|
+
|
|
|
JLabel lblProperty = new JLabel("Property:");
|
|
|
-
|
|
|
+
|
|
|
showPropertylbl = new JLabel("...");
|
|
|
-
|
|
|
+
|
|
|
JLabel lblGraph = new JLabel("Graph:");
|
|
|
-
|
|
|
+
|
|
|
JLabel lblColor = new JLabel("Color:");
|
|
|
-
|
|
|
+
|
|
|
colorComboBox = new JComboBox();
|
|
|
colorComboBox.addItem("");
|
|
|
colorComboBox.addItem("Red");
|
|
@@ -117,118 +118,129 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
colorComboBox.addItem("Pink");
|
|
|
colorComboBox.addItem("Gray");
|
|
|
colorComboBox.addItem("Random");
|
|
|
- colorComboBox.addItemListener(new ItemListener(){
|
|
|
+ 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));
|
|
|
+ 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======================//
|
|
|
+
|
|
|
+ // ====================GRAPH NR TEXTFIELD======================//
|
|
|
graphNrTxtField = new JTextField();
|
|
|
graphNrTxtField.setColumns(10);
|
|
|
- graphNrTxtField.getDocument().addDocumentListener(new DocumentListener(){
|
|
|
+ graphNrTxtField.getDocument().addDocumentListener(new DocumentListener() {
|
|
|
/*
|
|
|
- * if textField for Red changes, changes will applied in the DataStructure "currentProperty"
|
|
|
- * if Value is legit
|
|
|
+ * 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){
|
|
|
+ if (currentProperty != null) {
|
|
|
currentProperty.setGraph(graphNrTxtField.getText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void removeUpdate(DocumentEvent e) {
|
|
|
- if(currentProperty != null){
|
|
|
+ if (currentProperty != null) {
|
|
|
currentProperty.setGraph(graphNrTxtField.getText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void changedUpdate(DocumentEvent e) {
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- //====================GRAPH NR TEXTFIELD END==================//
|
|
|
-
|
|
|
- //====================RED TEXTFIELD===========================//
|
|
|
+
|
|
|
+ // ====================GRAPH NR TEXTFIELD END==================//
|
|
|
+
|
|
|
+ // ====================RED TEXTFIELD===========================//
|
|
|
redField = new JTextField();
|
|
|
redField.setColumns(10);
|
|
|
- redField.getDocument().addDocumentListener(new DocumentListener(){
|
|
|
+ redField.getDocument().addDocumentListener(new DocumentListener() {
|
|
|
/*
|
|
|
- * if textField for Red changes, changes will applied in the DataStructure "currentProperty"
|
|
|
- * if Value is legit
|
|
|
+ * 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{
|
|
|
+ try {
|
|
|
tmp = Integer.parseInt(redField.getText());
|
|
|
- }catch(NumberFormatException e1){
|
|
|
-
|
|
|
+ } catch (NumberFormatException e1) {
|
|
|
+
|
|
|
}
|
|
|
- if(tmp > -1 && tmp <= 255){
|
|
|
- if(currentProperty != null){
|
|
|
+ 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{
|
|
|
+ try {
|
|
|
tmp = Integer.parseInt(redField.getText());
|
|
|
- }catch(NumberFormatException e1){
|
|
|
-
|
|
|
+ } catch (NumberFormatException e1) {
|
|
|
+
|
|
|
}
|
|
|
- if(tmp > -1 && tmp <= 255){
|
|
|
- if(currentProperty != null){
|
|
|
+ if (tmp > -1 && tmp <= 255) {
|
|
|
+ if (currentProperty != null) {
|
|
|
Color oldColor = currentProperty.getColor();
|
|
|
Color color = new Color(tmp, oldColor.getGreen(), oldColor.getBlue());
|
|
|
currentProperty.setColor(color);
|
|
@@ -239,47 +251,47 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
|
|
|
@Override
|
|
|
public void changedUpdate(DocumentEvent e) {
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
- //======================RED TEXTFIELD END==========================//
|
|
|
-
|
|
|
- //======================GREEN TEXTFIELD============================//
|
|
|
+ // ======================RED TEXTFIELD END==========================//
|
|
|
+
|
|
|
+ // ======================GREEN TEXTFIELD============================//
|
|
|
greenField = new JTextField();
|
|
|
greenField.setColumns(10);
|
|
|
- greenField.getDocument().addDocumentListener(new DocumentListener(){
|
|
|
+ greenField.getDocument().addDocumentListener(new DocumentListener() {
|
|
|
/*
|
|
|
- * if textField for Red changes, changes will applied in the DataStructure "currentProperty"
|
|
|
- * if Value is legit
|
|
|
+ * 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{
|
|
|
+ try {
|
|
|
tmp = Integer.parseInt(greenField.getText());
|
|
|
- }catch(NumberFormatException e1){
|
|
|
-
|
|
|
+ } catch (NumberFormatException e1) {
|
|
|
+
|
|
|
}
|
|
|
- if(tmp > -1 && tmp <= 255){
|
|
|
- if(currentProperty != null){
|
|
|
+ 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{
|
|
|
+ try {
|
|
|
tmp = Integer.parseInt(greenField.getText());
|
|
|
- }catch(NumberFormatException e1){
|
|
|
-
|
|
|
+ } catch (NumberFormatException e1) {
|
|
|
+
|
|
|
}
|
|
|
- if(tmp > -1 && tmp <= 255){
|
|
|
- if(currentProperty != null){
|
|
|
+ if (tmp > -1 && tmp <= 255) {
|
|
|
+ if (currentProperty != null) {
|
|
|
Color oldColor = currentProperty.getColor();
|
|
|
Color color = new Color(oldColor.getRed(), tmp, oldColor.getBlue());
|
|
|
currentProperty.setColor(color);
|
|
@@ -290,47 +302,47 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
|
|
|
@Override
|
|
|
public void changedUpdate(DocumentEvent e) {
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
- //======================GREEN TEXTFIELD END========================//
|
|
|
-
|
|
|
- //======================BLUE TEXTFIELD=============================//
|
|
|
+ // ======================GREEN TEXTFIELD END========================//
|
|
|
+
|
|
|
+ // ======================BLUE TEXTFIELD=============================//
|
|
|
blueField = new JTextField();
|
|
|
blueField.setColumns(10);
|
|
|
- blueField.getDocument().addDocumentListener(new DocumentListener(){
|
|
|
+ blueField.getDocument().addDocumentListener(new DocumentListener() {
|
|
|
/*
|
|
|
- * if textField for Red changes, changes will applied in the DataStructure "currentProperty"
|
|
|
- * if Value is legit
|
|
|
+ * 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{
|
|
|
+ try {
|
|
|
tmp = Integer.parseInt(blueField.getText());
|
|
|
- }catch(NumberFormatException e1){
|
|
|
-
|
|
|
+ } catch (NumberFormatException e1) {
|
|
|
+
|
|
|
}
|
|
|
- if(tmp > -1 && tmp <= 255){
|
|
|
- if(currentProperty != null){
|
|
|
+ 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{
|
|
|
+ try {
|
|
|
tmp = Integer.parseInt(blueField.getText());
|
|
|
- }catch(NumberFormatException e1){
|
|
|
-
|
|
|
+ } catch (NumberFormatException e1) {
|
|
|
+
|
|
|
}
|
|
|
- if(tmp > -1 && tmp <= 255){
|
|
|
- if(currentProperty != null){
|
|
|
+ if (tmp > -1 && tmp <= 255) {
|
|
|
+ if (currentProperty != null) {
|
|
|
Color oldColor = currentProperty.getColor();
|
|
|
Color color = new Color(oldColor.getRed(), oldColor.getGreen(), tmp);
|
|
|
currentProperty.setColor(color);
|
|
@@ -341,130 +353,131 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
|
|
|
@Override
|
|
|
public void changedUpdate(DocumentEvent e) {
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
- //======================BLUE TEXTFIELD END=========================//
|
|
|
-
|
|
|
+ // ======================BLUE TEXTFIELD END=========================//
|
|
|
+
|
|
|
JLabel lblR = new JLabel("R:");
|
|
|
-
|
|
|
+
|
|
|
JLabel lblG = new JLabel("G:");
|
|
|
-
|
|
|
+
|
|
|
JLabel lblB = new JLabel("B:");
|
|
|
-
|
|
|
+
|
|
|
JButton btnAdd = new JButton("Add");
|
|
|
btnAdd.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)objectTree.getLastSelectedPathComponent();
|
|
|
- if(selectedNode == null){
|
|
|
- return;
|
|
|
- }else{
|
|
|
- if(selectedNode.getLevel() == 3){
|
|
|
- StatisticGraphPanel tmp = null;
|
|
|
- if(graphNrTxtField.getText().length() > 0){
|
|
|
- if(!graphHashtable.containsKey(graphNrTxtField.getText()) && graphNrTxtField.getText().length() > 0){
|
|
|
- tmp = new StatisticGraphPanel(controller.getModel(), controller, graphNrTxtField.getText(),
|
|
|
- graphHashtable);
|
|
|
- tmp.setPreferredSize(new Dimension(280,150));
|
|
|
- tmp.setMaximumSize(new Dimension(1000,150));
|
|
|
- tmp.setMinimumSize(new Dimension(100,45));
|
|
|
- tmp.setBorder(new LineBorder(new Color(0, 0, 0), 1));
|
|
|
- graphPanel.add(tmp);
|
|
|
- graphPanel.add(Box.createRigidArea(new Dimension(50,50)));
|
|
|
- graphPanel.revalidate();
|
|
|
- graphPanel.updateUI();
|
|
|
- graphHashtable.put(graphNrTxtField.getText(), tmp);
|
|
|
- }
|
|
|
- String object = ((DefaultMutableTreeNode)selectedNode.getParent()).toString();
|
|
|
+ DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) objectTree
|
|
|
+ .getLastSelectedPathComponent();
|
|
|
+ if (selectedNode == null) {
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ if (selectedNode.getLevel() == 3) {
|
|
|
+ StatisticGraphPanel tmp = null;
|
|
|
+ if (graphNrTxtField.getText().length() > 0) {
|
|
|
+ if (!graphHashtable.containsKey(graphNrTxtField.getText())
|
|
|
+ && graphNrTxtField.getText().length() > 0) {
|
|
|
+ tmp = new StatisticGraphPanel(controller.getModel(), controller,
|
|
|
+ graphNrTxtField.getText(), graphHashtable);
|
|
|
+ //tmp.setPreferredSize(new Dimension(280, 150));
|
|
|
+ //tmp.setMaximumSize(new Dimension(1000, 1000));
|
|
|
+ // tmp.setMinimumSize(new Dimension(100, 45));
|
|
|
+ tmp.setBorder(new LineBorder(new Color(0, 0, 0), 1));
|
|
|
+ graphPanel.add(tmp);
|
|
|
+ graphPanel.add(Box.createRigidArea(new Dimension(50, 50)));
|
|
|
+ graphPanel.revalidate();
|
|
|
+ graphPanel.updateUI();
|
|
|
+ graphHashtable.put(graphNrTxtField.getText(), tmp);
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ TrackedDataSet tds = new TrackedDataSet(dataSet.getObject(), propValTable.get(property),
|
|
|
+ currentProperty.getColor());
|
|
|
graphHashtable.get(graphNrTxtField.getText()).addObjec(tds);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
colorPanel = new JPanel();
|
|
|
colorPanel.setBorder(new LineBorder(new Color(0, 0, 0)));
|
|
|
colorPanel.setBackground(Color.WHITE);
|
|
|
GroupLayout gl_panel = new GroupLayout(panel);
|
|
|
- gl_panel.setHorizontalGroup(
|
|
|
- gl_panel.createParallelGroup(Alignment.LEADING)
|
|
|
- .addGroup(gl_panel.createSequentialGroup()
|
|
|
- .addContainerGap()
|
|
|
- .addGroup(gl_panel.createParallelGroup(Alignment.TRAILING, false)
|
|
|
- .addComponent(treeScrollPane, Alignment.LEADING)
|
|
|
- .addGroup(Alignment.LEADING, gl_panel.createSequentialGroup()
|
|
|
- .addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
|
|
|
- .addComponent(lblGraph)
|
|
|
- .addComponent(lblObject)
|
|
|
- .addComponent(lblProperty)
|
|
|
- .addComponent(lblColor)
|
|
|
- .addGroup(gl_panel.createSequentialGroup()
|
|
|
- .addComponent(lblR)
|
|
|
- .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
- .addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false)
|
|
|
- .addComponent(colorPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
- .addComponent(redField, GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE))))
|
|
|
- .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
- .addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false)
|
|
|
- .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)
|
|
|
- .addGroup(gl_panel.createSequentialGroup()
|
|
|
- .addComponent(lblG)
|
|
|
- .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
- .addComponent(greenField, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)))
|
|
|
- .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
- .addComponent(lblB)
|
|
|
- .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
- .addComponent(blueField, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)))))
|
|
|
- .addGap(32))
|
|
|
- );
|
|
|
+ gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING)
|
|
|
+ .addGroup(gl_panel.createSequentialGroup().addContainerGap().addGroup(gl_panel
|
|
|
+ .createParallelGroup(Alignment.TRAILING, false).addComponent(treeScrollPane,
|
|
|
+ Alignment.LEADING)
|
|
|
+ .addGroup(Alignment.LEADING,
|
|
|
+ gl_panel.createSequentialGroup()
|
|
|
+ .addGroup(gl_panel.createParallelGroup(Alignment.LEADING).addComponent(lblGraph)
|
|
|
+ .addComponent(lblObject).addComponent(lblProperty)
|
|
|
+ .addComponent(lblColor)
|
|
|
+ .addGroup(gl_panel.createSequentialGroup().addComponent(lblR)
|
|
|
+ .addPreferredGap(ComponentPlacement.RELATED).addGroup(gl_panel
|
|
|
+ .createParallelGroup(Alignment.LEADING, false)
|
|
|
+ .addComponent(colorPanel, GroupLayout.DEFAULT_SIZE,
|
|
|
+ GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(redField, GroupLayout.DEFAULT_SIZE, 37,
|
|
|
+ Short.MAX_VALUE))))
|
|
|
+ .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
+ .addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false)
|
|
|
+ .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)
|
|
|
+ .addGroup(gl_panel.createSequentialGroup().addComponent(lblG)
|
|
|
+ .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
+ .addComponent(greenField, GroupLayout.PREFERRED_SIZE,
|
|
|
+ 37, GroupLayout.PREFERRED_SIZE)))
|
|
|
+ .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblB)
|
|
|
+ .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
+ .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, 174, GroupLayout.PREFERRED_SIZE)
|
|
|
- .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
- .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
|
|
|
- .addComponent(lblObject, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE)
|
|
|
- .addComponent(showObjectlbl))
|
|
|
- .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
- .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
|
|
|
- .addComponent(lblProperty)
|
|
|
- .addComponent(showPropertylbl))
|
|
|
- .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
- .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
|
|
|
- .addComponent(lblGraph)
|
|
|
- .addComponent(graphNrTxtField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
|
|
- .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
- .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
|
|
|
- .addComponent(lblColor)
|
|
|
- .addComponent(colorComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
|
|
- .addGap(18)
|
|
|
- .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
|
|
|
- .addComponent(lblR)
|
|
|
- .addComponent(redField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
|
- .addComponent(lblG)
|
|
|
- .addComponent(greenField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
|
- .addComponent(lblB)
|
|
|
- .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)
|
|
|
- .addComponent(btnAdd)
|
|
|
- .addContainerGap(35, Short.MAX_VALUE))
|
|
|
- );
|
|
|
-
|
|
|
+ gl_panel.createParallelGroup(Alignment.LEADING)
|
|
|
+ .addGroup(gl_panel.createSequentialGroup().addContainerGap()
|
|
|
+ .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))
|
|
|
+ .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
+ .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE).addComponent(lblProperty)
|
|
|
+ .addComponent(showPropertylbl))
|
|
|
+ .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
+ .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE).addComponent(lblGraph)
|
|
|
+ .addComponent(graphNrTxtField, GroupLayout.PREFERRED_SIZE,
|
|
|
+ GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addPreferredGap(ComponentPlacement.RELATED)
|
|
|
+ .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE).addComponent(lblColor)
|
|
|
+ .addComponent(colorComboBox, GroupLayout.PREFERRED_SIZE,
|
|
|
+ GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addGap(18)
|
|
|
+ .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE).addComponent(lblR)
|
|
|
+ .addComponent(redField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
|
|
|
+ GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addComponent(lblG)
|
|
|
+ .addComponent(greenField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
|
|
|
+ GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addComponent(lblB).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).addComponent(btnAdd)
|
|
|
+ .addContainerGap(35, Short.MAX_VALUE)));
|
|
|
+
|
|
|
objectTree = new JTree();
|
|
|
- treeModel = (DefaultTreeModel)objectTree.getModel();
|
|
|
+ treeModel = (DefaultTreeModel) objectTree.getModel();
|
|
|
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Statistics");
|
|
|
wholeHolon = new DefaultMutableTreeNode("whole Holon");
|
|
|
wholeHolon.add(new DefaultMutableTreeNode("total Production"));
|
|
@@ -475,84 +488,86 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
|
|
|
objectsNode = new DefaultMutableTreeNode("Objects");
|
|
|
DefaultMutableTreeNode defaultNode = new DefaultMutableTreeNode("empty");
|
|
|
-
|
|
|
+
|
|
|
objectsNode.add(defaultNode);
|
|
|
treeModel.setRoot(root);
|
|
|
root.add(wholeHolon);
|
|
|
root.add(objectsNode);
|
|
|
objectTree.setModel(treeModel);
|
|
|
-
|
|
|
+
|
|
|
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());
|
|
|
- }
|
|
|
+ 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(){
|
|
|
+
|
|
|
+ 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();
|
|
|
- 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(currentProperty.getAssignedGraph());
|
|
|
- colorPanel.setBackground(color);
|
|
|
- }
|
|
|
- }
|
|
|
+ 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();
|
|
|
+ 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(currentProperty.getAssignedGraph());
|
|
|
+ colorPanel.setBackground(color);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
});
|
|
|
panel.setLayout(gl_panel);
|
|
|
-
|
|
|
+
|
|
|
JScrollPane graphScrollPane = new JScrollPane();
|
|
|
setRightComponent(graphScrollPane);
|
|
|
-
|
|
|
+
|
|
|
graphPanel = new JPanel();
|
|
|
graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));
|
|
|
graphPanel.revalidate();
|
|
@@ -560,16 +575,18 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
graphScrollPane.setViewportView(graphPanel);
|
|
|
repaintTree();
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public void repaintTree() {
|
|
|
treeModel.reload();
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public void addTrackedObject(ArrayList<HolonObject> hlList) {
|
|
|
objectsNode.removeAllChildren();
|
|
|
objectHashtable.clear();
|
|
|
- if(hlList.size() > 0 && hlList != null){
|
|
|
- for(HolonObject hO : hlList){
|
|
|
+ if (hlList.size() > 0 && hlList != null) {
|
|
|
+ for (HolonObject hO : hlList) {
|
|
|
Hashtable<String, PropertyDataSet> tmpHash = new Hashtable<String, PropertyDataSet>();
|
|
|
String name = hO.getName() + " " + hO.getID();
|
|
|
DefaultMutableTreeNode tmp = new DefaultMutableTreeNode(name);
|
|
@@ -583,26 +600,26 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
objectHashtable.put(name, gS);
|
|
|
objectsNode.add(tmp);
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
objectsNode.add(new DefaultMutableTreeNode("empty"));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
- public void colorChanged(Color color){
|
|
|
+
|
|
|
+ public void colorChanged(Color color) {
|
|
|
colorPanel.setBackground(color);
|
|
|
}
|
|
|
-
|
|
|
- public void resetFields(){
|
|
|
+
|
|
|
+ public void resetFields() {
|
|
|
colorPanel.setBackground(Color.WHITE);
|
|
|
redField.setText("");
|
|
|
greenField.setText("");
|
|
|
blueField.setText("");
|
|
|
- //graphNrTxtField.setText("");
|
|
|
+ // graphNrTxtField.setText("");
|
|
|
colorComboBox.setSelectedIndex(0);
|
|
|
}
|
|
|
-
|
|
|
- public void disableFields(){
|
|
|
+
|
|
|
+ public void disableFields() {
|
|
|
redField.setEnabled(false);
|
|
|
greenField.setEnabled(false);
|
|
|
blueField.setEnabled(false);
|
|
@@ -610,8 +627,8 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
colorComboBox.setEnabled(false);
|
|
|
colorPanel.setBackground(Color.LIGHT_GRAY);
|
|
|
}
|
|
|
-
|
|
|
- public void enableFields(){
|
|
|
+
|
|
|
+ public void enableFields() {
|
|
|
redField.setEnabled(true);
|
|
|
greenField.setEnabled(true);
|
|
|
blueField.setEnabled(true);
|
|
@@ -619,13 +636,13 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
colorComboBox.setEnabled(true);
|
|
|
colorPanel.setBackground(Color.WHITE);
|
|
|
}
|
|
|
-
|
|
|
- public void repaintGraphs(){
|
|
|
- for(StatisticGraphPanel sg: graphHashtable.values()){
|
|
|
+
|
|
|
+ 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) {
|
|
@@ -633,11 +650,13 @@ public class splitPane extends JSplitPane implements GraphListener {
|
|
|
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());
|
|
|
}
|