Exemple #1
0
    private Dimension computeSpriteDimension(double value) {
      Dimension spriteDimension = spriteDimensionMap.get(value);
      if (spriteDimension == null) {
        Texture sprite = spriteMap.get(value);
        if (sprite != null) {
          spriteDimension = sprite.getDataProvider().getTextureSize();
          spriteDimensionMap.put(value, spriteDimension);
        }
      }

      return spriteDimension;
    }
Exemple #2
0
    /**
     * Compute and return a translation along the given <code>direction</code>. This translation is
     * the vector between the <code>sprite</code> center and is projection along the given {@see
     * direction} to the sprite edges.
     *
     * @param sprite the given {@link Texture}
     * @param direction the given direction.
     * @return the vector between the sprite center and is projection to the sprite edges.
     */
    private Vector3d projectCenterToEdge(Texture sprite, Vector3d direction) {
      Vector3d usedDirection;
      if ((direction == null) || (direction.isZero())) {
        usedDirection = new Vector3d(1, 0, 0);
      } else {
        usedDirection = direction;
      }

      /* +1 is used to have a space between the tick and its label */
      Dimension textureSize = sprite.getDataProvider().getTextureSize();
      double ratioX = textureSize.width / Math.abs(usedDirection.getX()) + 1;
      double ratioY = textureSize.height / Math.abs(usedDirection.getY()) + 1;
      double ratio = Math.min(ratioY, ratioX) / 2;
      return usedDirection.times(ratio);
    }
Exemple #3
0
      /**
       * Default constructor.
       *
       * @param sprite the {@link Texture}.
       * @param windowPosition the window position.
       */
      public PositionedSprite(Texture sprite, Vector3d windowPosition) {
        // long tic = Calendar.getInstance().getTimeInMillis();
        this.windowPosition = windowPosition;
        this.sprite = sprite;

        Dimension textureSize = sprite.getDataProvider().getTextureSize();
        windowsBounds =
            new Rectangle2D.Double(
                windowPosition.getX(),
                windowPosition.getY(),
                textureSize.width,
                textureSize.height);

        // System.err.println("====[new PositionedSprite] time =
        // "+(Calendar.getInstance().getTimeInMillis() - tic));
      }