|
@@ -6,16 +6,19 @@ import java.awt.Font;
|
|
import java.awt.event.ComponentAdapter;
|
|
import java.awt.event.ComponentAdapter;
|
|
import java.awt.event.ComponentEvent;
|
|
import java.awt.event.ComponentEvent;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.LinkedList;
|
|
|
|
|
|
import javax.swing.BoxLayout;
|
|
import javax.swing.BoxLayout;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JScrollPane;
|
|
import javax.swing.JScrollPane;
|
|
|
|
|
|
|
|
+import classes.AbstractCpsObject;
|
|
import classes.HolonObject;
|
|
import classes.HolonObject;
|
|
import classes.SubNet;
|
|
import classes.SubNet;
|
|
|
|
+import interfaces.ObjectListener;
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
|
|
|
|
-public class FlexiblePane extends JScrollPane {
|
|
|
|
|
|
+public class FlexiblePane extends JScrollPane implements ObjectListener {
|
|
private JPanel flexPanel;
|
|
private JPanel flexPanel;
|
|
private Control controller;
|
|
private Control controller;
|
|
|
|
|
|
@@ -33,6 +36,7 @@ public class FlexiblePane extends JScrollPane {
|
|
}
|
|
}
|
|
|
|
|
|
public void recalculate(){
|
|
public void recalculate(){
|
|
|
|
+ LinkedList<Color> netColors = controller.getModel().getSubNetColors();
|
|
flexPanel.removeAll();
|
|
flexPanel.removeAll();
|
|
ArrayList<Float> maxVals = calcMax(controller.getSimManager().getSubNets());
|
|
ArrayList<Float> maxVals = calcMax(controller.getSimManager().getSubNets());
|
|
float gridProd = maxVals.get(0);
|
|
float gridProd = maxVals.get(0);
|
|
@@ -41,14 +45,19 @@ public class FlexiblePane extends JScrollPane {
|
|
maingrid.getColorPanel().setVisible(false);
|
|
maingrid.getColorPanel().setVisible(false);
|
|
maingrid.getNamelbl().setFont(new Font("Tahoma", Font.BOLD, 11));
|
|
maingrid.getNamelbl().setFont(new Font("Tahoma", Font.BOLD, 11));
|
|
flexPanel.add(maingrid);
|
|
flexPanel.add(maingrid);
|
|
- int counter = 1;
|
|
|
|
- for(SubNet sn: controller.getSimManager().getSubNets()){
|
|
|
|
|
|
+ int counter = 0;
|
|
|
|
+ int colorCounter = 0;
|
|
|
|
+ ArrayList<SubNet> subnets = controller.getSimManager().getSubNets();
|
|
|
|
+ for(SubNet sn: subnets){
|
|
|
|
+ if(netColors.size() < subnets.size()){
|
|
|
|
+ netColors.add(new Color((int)(Math.random()*255), (int)(Math.random()*255), (int)(Math.random()*255)));
|
|
|
|
+ }
|
|
JPanel objects = new JPanel();
|
|
JPanel objects = new JPanel();
|
|
objects.setLayout(new BoxLayout(objects, BoxLayout.Y_AXIS));
|
|
objects.setLayout(new BoxLayout(objects, BoxLayout.Y_AXIS));
|
|
int index = flexPanel.getComponentCount();
|
|
int index = flexPanel.getComponentCount();
|
|
float subProd = 0;
|
|
float subProd = 0;
|
|
float subCons = 0;
|
|
float subCons = 0;
|
|
- Color subColor = sn.getObjects().get(0).getBorderColor();
|
|
|
|
|
|
+ Color subColor = netColors.get(colorCounter);
|
|
for(HolonObject hl: sn.getObjects()){
|
|
for(HolonObject hl: sn.getObjects()){
|
|
subProd += hl.getFlexProd();
|
|
subProd += hl.getFlexProd();
|
|
subCons += hl.getFlexCons();
|
|
subCons += hl.getFlexCons();
|
|
@@ -65,6 +74,7 @@ public class FlexiblePane extends JScrollPane {
|
|
wholeSubnet.setListener(this);
|
|
wholeSubnet.setListener(this);
|
|
flexPanel.add(wholeSubnet, index);
|
|
flexPanel.add(wholeSubnet, index);
|
|
counter++;
|
|
counter++;
|
|
|
|
+ colorCounter++;
|
|
}
|
|
}
|
|
flexPanel.revalidate();
|
|
flexPanel.revalidate();
|
|
flexPanel.repaint();
|
|
flexPanel.repaint();
|
|
@@ -96,4 +106,9 @@ public class FlexiblePane extends JScrollPane {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void onChange(ArrayList<AbstractCpsObject> objects) {
|
|
|
|
+ recalculate();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|