Procházet zdrojové kódy

Facilities bug fixed

Gilian Joosen před 10 roky
rodič
revize
23b076400c
1 změnil soubory, kde provedl 31 přidání a 16 odebrání
  1. 31 16
      src/gui/simulator/Sidebar.java

+ 31 - 16
src/gui/simulator/Sidebar.java

@@ -72,24 +72,24 @@ public class Sidebar implements Serializable  {
 	 */
 	public void loadDrawableObjects(){
 		//stages
-		drawableStages.put("Stage1",new SimulatorStage(0, 0, 0.26, 1, terrain));
+		drawableStages.put("Stage1", new SimulatorStage(0, 0, 0.26, 1, terrain));
 		drawableStages.put("Stage2",new SimulatorStage(0, 0, 0.26, 1, terrain));
 		drawableStages.put("Stage3",new SimulatorStage(0, 0, 0.26, 1, terrain));
-		drawableStages.put("Stage4",new SimulatorStage(0, 0, 0.26, 1, terrain));
-		drawableStages.put("Stage5",new SimulatorStage(0, 0, 0.26, 1, terrain));
-		drawableStages.put("Stage6",new SimulatorStage(0, 0, 0.26, 1, terrain));
-		drawableStages.put("Stage7",new SimulatorStage(0, 0, 0.26, 1, terrain));
-		drawableStages.put("Stage8",new SimulatorStage(0, 0, 0.26, 1, terrain));
-		drawableStages.put("Stage9",new SimulatorStage(0, 0, 0.26, 1, terrain));
-		drawableStages.put("Stage10",new SimulatorStage(0, 0, 0.26, 1, terrain));
-		drawableStages.put("Stage11",new SimulatorStage(0, 0, 0.26, 1, terrain));
+		drawableStages.put("Stage4", new SimulatorStage(0, 0, 0.26, 1, terrain));
+		drawableStages.put("Stage5", new SimulatorStage(0, 0, 0.26, 1, terrain));
+		drawableStages.put("Stage6", new SimulatorStage(0, 0, 0.26, 1, terrain));
+		drawableStages.put("Stage7", new SimulatorStage(0, 0, 0.26, 1, terrain));
+		drawableStages.put("Stage8", new SimulatorStage(0, 0, 0.26, 1, terrain));
+		drawableStages.put("Stage9", new SimulatorStage(0, 0, 0.26, 1, terrain));
+		drawableStages.put("Stage10", new SimulatorStage(0, 0, 0.26, 1, terrain));
+		drawableStages.put("Stage11", new SimulatorStage(0, 0, 0.26, 1, terrain));
 		
 		//facilities
-		drawableFacilities.put("Toilet",new RestRoom(0, 0, 0.8, 1, this.terrain));
-		drawableFacilities.put("Ingang",new AccessPoint(terrain, 0, 0, 0.26, 1));
-		drawableFacilities.put("Uitgang",new ExitPoint(terrain, 0, 0, 0.26, 1));
-		drawableFacilities.put("Snackbar",new SnackBar(0, 0, 0.2, 1, this.terrain));
-		drawableFacilities.put("Wegwijzer",new WayPoint(0, 0, 0.8,1, this.terrain));
+		drawableFacilities.put("Toilet", new RestRoom(0, 0, 0.8, 1, this.terrain));
+		drawableFacilities.put("Ingang", new AccessPoint(terrain, 0, 0, 0.26, 1));
+		drawableFacilities.put("Uitgang", new ExitPoint(terrain, 0, 0, 0.26, 1));
+		drawableFacilities.put("Snackbar", new SnackBar(0, 0, 0.2, 1, this.terrain));
+		drawableFacilities.put("Wegwijzer", new WayPoint(0, 0, 0.8, 1, this.terrain));
 		
 		//paths
 		drawablePaths.put("Ground-stone", Images.ImageType.PathGroundStone);
@@ -229,8 +229,23 @@ public class Sidebar implements Serializable  {
 							Constructor<?> constructor = object.getValue().getClass().getConstructor(int.class, int.class, double.class, double.class, Terrain.class, boolean.class);
 							dragObject = (DrawEngine) constructor.newInstance(new Object[] { (int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10, terrain, true});
 							terrain.setDragObject(dragObject);					
-	    				} catch (NoSuchMethodException | SecurityException |  IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException e1) {
-							e1.printStackTrace();
+	    				} catch (NoSuchMethodException e1) {
+							try{
+								Constructor<?> constructor = object.getValue().getClass().getConstructor(int.class, int.class, double.class, double.class, Terrain.class);
+								dragObject = (DrawEngine) constructor.newInstance(new Object[] { (int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10, terrain});
+								terrain.setDragObject(dragObject);
+							}catch (NoSuchMethodException ex){
+								ex.printStackTrace();
+							} catch (InvocationTargetException e2) {
+								e2.printStackTrace();
+							} catch (InstantiationException e2) {
+								e2.printStackTrace();
+							} catch (IllegalAccessException e2) {
+								e2.printStackTrace();
+							}
+
+						} catch (SecurityException |  IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException ex){
+							ex.printStackTrace();
 						}
 	    			}
 	    		}