You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BanditAdapter.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package bandit.controller;
  7. import java.util.concurrent.Flow;
  8. import java.util.concurrent.Flow.Subscriber;
  9. import java.util.logging.Logger;
  10. import bandit.model.WuerfelModel;
  11. import bandit.view.WuerfelView;
  12. /**
  13. *
  14. * @author hd
  15. */
  16. public class BanditAdapter implements Subscriber<Integer>
  17. {
  18. private WuerfelView view;
  19. private WuerfelModel model;
  20. private Flow.Subscription subscription;
  21. private static Logger lg = Logger.getLogger("Wuerfelthreads");
  22. public BanditAdapter(WuerfelView view, WuerfelModel model)
  23. {
  24. this.view = view;
  25. this.model = model;
  26. }
  27. public void einschreiben()
  28. {
  29. model.addWertSubscription(this);
  30. }
  31. @Override
  32. public void onSubscribe(Flow.Subscription subscription)
  33. {
  34. this.subscription = subscription;
  35. subscription.request(1);
  36. lg.info("onSubsribe");
  37. }
  38. @Override
  39. public void onNext(Integer item)
  40. {
  41. view.getLbZahl().setText(String.valueOf(item));
  42. subscription.request(1);
  43. lg.info("onNext");
  44. }
  45. @Override
  46. public void onError(Throwable throwable)
  47. {
  48. }
  49. @Override
  50. public void onComplete()
  51. {
  52. }
  53. }