Package ch.bfh.ti.kybernetik.gui.slick.components

Examples of ch.bfh.ti.kybernetik.gui.slick.components.RoboterComponent


    gc.setMaximumLogicUpdateInterval(1 / RENDER_UPDATE_RATE);

    Iterator<Roboter> it = simulator.getRoboterList().iterator();
    while (it.hasNext()) {
      Roboter roboter = it.next();
      RoboterComponent rc = new RoboterComponent(roboter, simulator.getRoboterConstructionForRoboter(roboter));
      this.roboterComponents.add(rc);
    }

    Iterator<LightBulb> it2 = simulator.getLightBulbList().iterator();
    while (it2.hasNext()) {
View Full Code Here


        }
      }
    } else if (input.isKeyPressed(Input.KEY_0)) {
      // the user pressed the 0 KEY which changes the RoboterKI
      if (selectedSlickComponent instanceof RoboterComponent) {
        RoboterComponent selectedRoboterComponent = (RoboterComponent) selectedSlickComponent;
        RoboterKI selectedRoboterKI = simulator.getRoboterKIForRoboter(selectedRoboterComponent.getModelObject());
        Wesen[] wesenArray = RobKIFactr.Wesen.values();
        int pos = Arrays.binarySearch(wesenArray, selectedRoboterKI.getWesen());
        if (++pos >= wesenArray.length) {
          pos = 0;
        }
        RoboterKI newRoboterKI = RobKIFactr.getRoboterKI(wesenArray[pos]);
        simulator.changeRoboterKIForRoboter(selectedRoboterComponent.getModelObject(), newRoboterKI);
      }
    }
  }
View Full Code Here

  }

  private void redirectRobotsToPoint(Point2d mouseClickedPointPosition) {
    Iterator<RoboterComponent> it = this.roboterComponents.iterator();
    while (it.hasNext()) {
      RoboterComponent rc = it.next();
      Roboter roboter = rc.getModelObject();
      Vector2d vec = new Vector2d(mouseClickedPointPosition.getX() - roboter.getX(), mouseClickedPointPosition.getY()
          - roboter.getY());
      vec.normalize();
      roboter.setDirection(vec);
    }
View Full Code Here

    g.setAntiAlias(true);

    Iterator<RoboterComponent> it = this.roboterComponents.iterator();
    while (it.hasNext()) {
      RoboterComponent rc = it.next();
      rc.render(gc, g);
    }

    Iterator<LightBulbComponent> it2 = this.lightBulbComponents.iterator();
    while (it2.hasNext()) {
      LightBulbComponent lbc = it2.next();
      lbc.render(gc, g);
    }

    if (renderTracing) {
      Iterator<RoboterMoveListComponent> it3 = this.roboterMoveListComponent.iterator();
      while (it3.hasNext()) {
        RoboterMoveListComponent rtc = it3.next();
        rtc.render(gc, g);
      }
    }

    // Render current mode
    g.setColor(Color.green);
    if (mode != null) {
      g.drawString("Mode: " + mode.getDisplayText(), 300, 0);
    }

    // Draw Simulator Speed
    g.drawString("Simulating Speed: " + simulator.getSimulatorSpeed(), 300, 30);

    // Draw Selected Roboter Info
    SelectableSlickComponent<?> ssc = this.getSelectedSlickComponent();
    if (ssc instanceof RoboterComponent) {
      RoboterComponent rc = (RoboterComponent) ssc;
      if (rc != null) {
        RoboterKI roboterKI = simulator.getRoboterKIForRoboter(rc.getModelObject());
        g.drawString("Roboter KI: " + roboterKI.getRoboterKIName(), 300, 60);
      }
    }

  }
View Full Code Here

      }
    } else if (observerCommand instanceof RoboterModelObserverCommand) {
      RoboterModelObserverCommand rmoc = (RoboterModelObserverCommand) observerCommand;
      if (rmoc.getState() == RoboterModelCommandState.ROBOTER_ADDED) {
        RoboterComponent newRoboterComponent = new RoboterComponent(rmoc.getModel(),
            simulator.getRoboterConstructionForRoboter(rmoc.getModel()));
        this.roboterComponents.add(newRoboterComponent);
      } else if (rmoc.getState() == RoboterModelCommandState.ROBOTER_REMOVED) {
        RoboterComponent rc = findOrAddRoboterComponent(rmoc.getModel());
        this.roboterComponents.remove(rc);
      }
    } else if (observerCommand instanceof LightSensorModelObserverCommand) {
      LightSensorModelObserverCommand lsmoc = (LightSensorModelObserverCommand) observerCommand;
      if (lsmoc.getState() == LightSensorCommandState.SENSOR_INTENSITY_CHANGED) {
        RoboterComponent rc = findOrAddRoboterComponent(lsmoc.getModel());
        rc.hightLightRoboterElement(lsmoc.getPayLoad());
      } else if (lsmoc.getState() == LightSensorCommandState.SENSOR_INTENSITY_REMAINS) {
        RoboterComponent rc = findOrAddRoboterComponent(lsmoc.getModel());
        rc.unHightLightRoboterElement(lsmoc.getPayLoad());
      }
    } else if (observerCommand instanceof RoboterMoveListModelObserverCommand) {
      RoboterMoveListModelObserverCommand rmlmoc = (RoboterMoveListModelObserverCommand) observerCommand;
      if (rmlmoc.getState() == RoboterMoveModelObserverCommandState.ROBOTER_MOVE_ADDED) {
        RoboterMoveListComponent rtc = findOrAddRoboterTraceComponent(rmlmoc.getModel());
View Full Code Here

  }

  private RoboterComponent findOrAddRoboterComponent(Roboter roboter) {
    Iterator<RoboterComponent> it = this.roboterComponents.iterator();
    while (it.hasNext()) {
      RoboterComponent rc = it.next();
      if (rc.getModelObject() == roboter) {
        return rc;
      }
    }
    RoboterComponent rc = new RoboterComponent(roboter, simulator.getRoboterConstructionForRoboter(roboter));
    this.roboterComponents.add(rc);
    return rc;
  }
View Full Code Here

TOP

Related Classes of ch.bfh.ti.kybernetik.gui.slick.components.RoboterComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.