Пример #1
0
  /**
   * Add EventHandler to handlers list & search through the EventHandlers EventTypes, placing it in
   * the correct lists, so Events can be filtered correctly.
   */
  public final void addEventHandler(final EventHandler _handler) {
    if (exists(_handler) == true) {
      Logger.println(_handler.getName() + "already exists within " + name, Logger.Verbosity.MAJOR);
      return;
    }

    handlers.add(_handler);

    final ArrayList<EventType> types = _handler.getWantedEventTypes();
    if (types.isEmpty() == true || types.contains(Event.ALL_EVENT_TYPES) == true) {
      // Due to legacy we must assumme that a types size of 0,
      // represents a developer wishing to recieve all Events.
      // If the types contains ALL_EVENT_TYPES then only add it
      // to the ALL_EVENT_TYPES EventQueue.
      eventQueues.get(Event.ALL_EVENT_TYPES).addEventHandler(_handler);
      return;
    }

    for (final EventType type : types) {
      if (eventQueues.containsKey(type) == false) {
        addEventQueue(type, new EventQueue(type));
      }

      eventQueues.get(type).addEventHandler(_handler);
    }
  }
Пример #2
0
    private MalletTexture.Meta addMeta(final String _path, final MalletTexture.Meta _meta) {
      if (_meta != null) {
        imageMetas.put(_path, _meta);
        return _meta;
      }

      Logger.println("Failed to create Texture Meta: " + _path, Logger.Verbosity.NORMAL);
      return new MalletTexture.Meta(_path, 0, 0);
    }
Пример #3
0
  public final void removeEventFilter(final EventType _type, final EventFilter _filter) {
    assert _type != null || _filter != null;

    if (eventQueues.containsKey(_type) == false) {
      Logger.println(
          "Can't remove EventFilter event queue: " + _type + " does not exist.",
          Logger.Verbosity.MAJOR);
    }

    eventQueues.get(_type).removeEventFilter(_filter);
  }
Пример #4
0
    /**
     * Return the meta information associated with an image defined by _path. If the meta data has
     * yet to be generated, create it and store the meta data in imageMetas. This hashmap is
     * persistant across the runtime of the renderer. If the meta data changes from one call to the
     * next, the meta data stored is NOT updated. FileStream would need to be updated to support
     * file modification timestamps.
     */
    public MalletTexture.Meta getMeta(final String _path) {
      synchronized (imageMetas) {
        MalletTexture.Meta meta = imageMetas.get(_path);
        if (meta != null) {
          return meta;
        }

        final FileStream file = GlobalFileSystem.getFile(_path);
        if (file.exists() == false) {
          Logger.println("No Texture found to create Meta: " + _path, Logger.Verbosity.NORMAL);
          return new MalletTexture.Meta(_path, 0, 0);
        }

        return addMeta(_path, createMeta(_path, file));
      }
    }
Пример #5
0
    public void run() {
      final FileStream file = GlobalFileSystem.getFile(texturePath);
      if (file.exists() == false) {
        Logger.println("Failed to create Texture: " + texturePath, Logger.Verbosity.NORMAL);
        return;
      }

      try {
        final DesktopByteIn in = (DesktopByteIn) file.getByteInStream();
        final InputStream stream = in.getInputStream();
        final BufferedImage image = ImageIO.read(stream);
        in.close();

        synchronized (toBind) {
          // We don't want to bind the BufferedImage now
          // as that will take control of the OpenGL context.
          toBind.add(new Tuple<String, BufferedImage>(texturePath, image));
        }
      } catch (IOException ex) {
        ex.printStackTrace();
      }
    }