This commit is contained in:
Mariusz Pacek committed 2012-12-09 21:21:41 +01:00
commit e92f9bd078
5 files changed
+55 -9

No files matched your search

+13 -4
View File
@@ -1,5 +1,8 @@
package canteen;
import gui.AnimPanel;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
@@ -17,6 +20,8 @@ import desmoj.core.simulator.TimeSpan;
public class Canteen extends Model implements PropertyChangeListener{
static int clientLeftOnInitCount = 0;
private AnimPanel animPanel;
private int cashierCount;
private int cookCount;
@@ -58,17 +63,21 @@ public class Canteen extends Model implements PropertyChangeListener{
private DishesStorage storage;
private LinkedList<Cook> cooks;
private boolean automaticMode = true;
protected PropertyChangeSupport change = new PropertyChangeSupport(this);
public Canteen(Model model, String name, boolean showInRaport,
boolean showInTrace) {
super(model, name, showInRaport, showInRaport);
change.addPropertyChangeListener(animPanel);
change.addPropertyChangeListener("cookCount", animPanel);
change.addPropertyChangeListener("tableTwoCount", animPanel);
// TODO Auto-generated constructor stub
}
public void setParam() {
public void setAnimPanel(AnimPanel anim)
{
animPanel = anim;
}
public void addPropertyChangeListener(PropertyChangeListener listener) {
this.change.addPropertyChangeListener(listener);
+1 -1
View File
@@ -123,7 +123,7 @@ public class Client extends SimProcess {
LinkedList<String> lDr = avaliableDishes.get("drink");// drink
selectedMenu.add(lDr.get(rand.nextInt(lDr.size())));
}
public LinkedList<String> getMenu() {
+1
View File
@@ -13,6 +13,7 @@ public class DishesStorage extends Dishes {
private Canteen model;
public DishesStorage(double averagePrice, int initValue,Canteen model) {
super(averagePrice);
this.model = model;
storage = new HashMap<String, Integer>();
this.startDishValue = initValue;
+18 -1
View File
@@ -1,11 +1,14 @@
package gui;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JLabel;
import javax.swing.JPanel;
import canteen.Canteen;
public class AnimPanel extends JPanel
public class AnimPanel extends JPanel implements PropertyChangeListener
{
private static final long serialVersionUID = 1L;
@@ -29,6 +32,7 @@ public class AnimPanel extends JPanel
{
frame = _frame;
model = frame.getCanteen();
frame.getCanteen().setAnimPanel(this);
setLayout(null);
idleCook = new JLabel("Wolni kucharze ");
@@ -83,4 +87,17 @@ public class AnimPanel extends JPanel
}
@Override
public void propertyChange(PropertyChangeEvent event)
{
System.out.println("EVENT");
if (event.getPropertyName().equals("cookCount"))
System.out.println("COOK COUNT" + event.getNewValue());
if (event.getPropertyName().equals("clientQueue"))
System.out.println("CLIENT QUEUE" + event.getNewValue());
if (event.getPropertyName().equals("Storage kompot"))
System.out.println("KUMPOT" + event.getNewValue());
}
}
+22 -3
View File
@@ -13,6 +13,7 @@ import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import canteen.Canteen;
import desmoj.core.dist.ContDistNormal;
public class StartPanel extends JPanel
{
@@ -112,6 +113,7 @@ public class StartPanel extends JPanel
add(table4Box);
add(Box.createRigidArea(rigidOutBox));
//minimalny czas pojawiania sie nowego klienta badz grupy
Box minTimeClientBox = Box.createHorizontalBox();
JLabel minTimeClientLabel = new JLabel("Minimalny czas pojawiania sie nowych klientow");
@@ -124,7 +126,10 @@ public class StartPanel extends JPanel
add(minTimeClientBox);
add(Box.createRigidArea(rigidOutBox));
//minimalny czas pojawiania sie nowego klienta badz grupy
//maksymalny czas pojawiania sie nowego klienta badz grupy
Box maxTimeClientBox = Box.createHorizontalBox();
JLabel maxTimeClientLabel = new JLabel("Maksymalny czas pojawiania sie nowych klientow");
maxTimeClientBox.add(maxTimeClientLabel);
@@ -136,6 +141,7 @@ public class StartPanel extends JPanel
add(maxTimeClientBox);
add(Box.createRigidArea(rigidOutBox));
//czestosc pojawiania sie grupy
Box groupFreqBox = Box.createHorizontalBox();
JLabel groupFreqLabel = new JLabel("Czestosc pojawiania sie grupy (w %)");
@@ -228,7 +234,7 @@ public class StartPanel extends JPanel
minValueIngredientSpinner = new JSpinner(spinnerModel);
minValueIngredientSpinner.setMaximumSize(spinnerSize);
minValueIngredientBox.add(Box.createRigidArea(rigidInBox));
minValueIngredientBox.add(minTimeClientSpinner);
minValueIngredientBox.add(minValueIngredientSpinner);
add(minValueIngredientBox);
add(Box.createRigidArea(new Dimension(0, 50)));
@@ -245,7 +251,20 @@ public class StartPanel extends JPanel
frame.getContentPane().removeAll();
frame.add(frame.getAnimPanel());
frame.revalidate();
frame.getCanteen().setParam();
//frame.set
System.out.println("Kasjerek " + (int)cookSpinner.getValue());
frame.getCanteen().setCashierCount((int)cashierSpinner.getValue());
frame.getCanteen().setCookCount((int)cookSpinner.getValue());
frame.getCanteen().setTableTwoCount((int)table2Spinner.getValue());
frame.getCanteen().setTableFourthCount((int)table4Spinner.getValue());
frame.getCanteen().setMinMealCount((int)minValueIngredientSpinner.getValue());
//frame.getCanteen().setClientArrivialTime(Double.parseDouble(Integer.toString((int)minTimeClientSpinner.getValue())), Double.parseDouble(Integer.toString((int)maxTimeClientSpinner.getValue())));
frame.getCanteen().start();
}
}