Android Open Source - java-androidframework Android Image






From Project

Back to project page java-androidframework.

License

The source code is released under:

This project is licensed under the [CC0 1.0 Agreement](http://creativecommons.org/publicdomain/zero/1.0/). To the extent possible under law, Pete Schmitz has waived all copyright and related or neigh...

If you think the Android project java-androidframework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.gamepatriot.androidframework.framework;
//from   w ww.j a v a2s  .com
import android.graphics.Bitmap;

/**
 * An AndroidImage implementation should link a bitmap resource reference to an object that can be used for visual display (By attaching the AndroidImage to an {@link AndroidScreen}).
 * 
 * @author Pete Schmitz, May 8, 2013
 *
 */
public interface AndroidImage {
  
  /**
   * Set information required to properly display and animate an image resource.
   * @param $source      A decoded image resource.
   * @param $sourceX      The source-rectangle position X on the bitmap source.
   * @param $sourceY      The source-rectangle position Y on the bitmap source.
   * @param $frameWidth    The source-rectangle width on the bitmap source.
   * @param $frameHeight    The source-rectangle height on the bitmap source.
   * @param $animation    The {@link AndroidAnimationData} associated with the supplied bitmap source (null simply disables draw-frame animations).
   * @param $allowMatrix    Whether or not this AndroidImage should be allowed to have scaling and rotation applied when requested (More expensive draw calls).
   */
  public void set(Bitmap $source, int $sourceX, int $sourceY, int $frameWidth, int $frameHeight, AndroidAnimationData $animation, boolean $allowMatrix);
  
  /**
   * Set the position of the AndroidImage, modified by its pivot position, to indicate where it will display once it's added to an {@link AndroidScreen}.
   * @param $x  The new X position of the AndroidImage.
   * @param $y  The new Y position of the AndroidImage.
   */
  public void setPosition(float $x, float $y);
  
  /**
   * Set the source's source-rectangle position.
   * @param $x  The new source-rectangle X position.
   * @param $y  The new source-rectangle Y position.
   */
  public void setSource(int $x, int $y);
  
  /**
   * Set the X-scaling of this AndroidImage. Note: Matrix should be allowed in order to properly display the X-scaling.
   * @param $x  The float amount to scale the X-axis by (1.0f == 100%).
   */
  public void setScaleX(float $x);
  
  /**
   * Set the Y-scaling of this AndroidImage. Note: Matrix should be allowed in order to properly display the Y-scaling.
   * @param $y  The float amount to scale the Y-axis by (1.0f == 100%).
   */
  public void setScaleY(float $y);
  
  /**
   * Set both the X and Y axes of this AndroidImage. Note: Matrix should be allowed in order to properly display the scaling.
   * @param $x  The float amount to scale the X-axis by (1.0f == 100%).
   * @param $y  The float amount to scale the Y-axis by (1.0f == 100%).
   */
  public void setScale(float $x, float $y);
  
  /**
   * Set the X and Y axes of this AndroidImage to a new float value. Note: Matrix should be allowed in order to properly display the scaling.
   * @param $amount  The new float amount to scale the X and Y axes by (1.0f == 100%).
   */
  public void setScale(float $amount);
  
  /**
   * Set the X and Y axes of this AndroidImage to a new double value. Note: Matrix should be allowed in order to properly display the scaling.
   * @param $amount  The float amount to scale the X and Y axes by (1.0f == 100%).
   */
  public void setScale(double $amount);
  
  /**
   * Return the parent of this AndroidImage if one exists.
   */
  public AndroidScreen getParent();
  
  /**
   * Remove this AndroidImage from its parent if one exists.
   */
  public void removeFromParent();
  
  /**
   * Return whether or not this AndroidImage is currently parented by an {@link AndroidScreen}.
   */
  public boolean hasParent();
  
  /**
   * Register this AndroidImage as being contained on the provided {@link AndroidScreen}.
   * @param $screen  The AndroidScreen to register as this AndroidImage's parent.
   */
  public void setParent(AndroidScreen $screen);
  
  /**
   * Set the source-rectangle to the next frame of this AndroidImage's animation (if one exists). Note: Resets to frame 1 if frame count exceeds available frames.
   * @return 
   */
  public boolean nextFrame();
  
  /**
   * Set the source-rectangle to the requested frame of this AndroidImage's animaiton (if one exists). Note: Resets to frame 1 if frame count exceeds available frames.
   */
  public void frame(int $frame);
  
  /**
   * Set the pivot point that this image will anchor its display and rotation at.
   * @param $x  The local X position to anchor at.
   * @param $y  The local Y position to anchor at.
   */
  public void setPivot(float $x, float $y);
  
  /**
   * Set the rotation of this image by degrees using the provided float. Note: Matrix should be allowed in order to properly display the rotation.
   * @param $degrees    The amount, in degrees, to set this AndroidImage's rotation to.
   */
  public void setRotationDegrees(float $degrees);
  
  /**
   * Set the rotation of this image by radians using the provided float. Note: Matrix should be allowed in order to properly display the rotation.
   * @param $radians    The amount, in radians, to set this AndroidImage's rotation to.
   */
  public void setRotationRadians(float $radians);
  
  /**
   * Set the alpha this image will be drawn at.
   * @param $amount    The amount to set the alpha to (0.5f == 50% opacity).
   */
  public void setAlpha(float $amount);
  
  /**
   * Set whether or not this AndroidImage should be allowed to use a matrix for rotation and scaling during its draw call. Note: Rotation and scaling have more expensive draw costs.
   * @param $allowMatrix    Whether scaling and rotation should be displayed.
   */
  public void setMatrix(boolean $allowMatrix);
  
}




Java Source Code List

com.gamepatriot.androidframework.framework.AndroidAnimationData.java
com.gamepatriot.androidframework.framework.AndroidAtlas.java
com.gamepatriot.androidframework.framework.AndroidBasicShape.java
com.gamepatriot.androidframework.framework.AndroidGameData.java
com.gamepatriot.androidframework.framework.AndroidImage.java
com.gamepatriot.androidframework.framework.AndroidInputter.java
com.gamepatriot.androidframework.framework.AndroidMain.java
com.gamepatriot.androidframework.framework.AndroidMusicHandler.java
com.gamepatriot.androidframework.framework.AndroidPool.java
com.gamepatriot.androidframework.framework.AndroidRenderer.java
com.gamepatriot.androidframework.framework.AndroidScreen.java
com.gamepatriot.androidframework.framework.AndroidShape.java
com.gamepatriot.androidframework.framework.AndroidSoundHandler.java
com.gamepatriot.framework2d.classes.FPS.java
com.gamepatriot.framework2d.implementation.AnimationData.java
com.gamepatriot.framework2d.implementation.Atlas.java
com.gamepatriot.framework2d.implementation.BasicShape.java
com.gamepatriot.framework2d.implementation.GameData.java
com.gamepatriot.framework2d.implementation.Image.java
com.gamepatriot.framework2d.implementation.Inputter.java
com.gamepatriot.framework2d.implementation.Main.java
com.gamepatriot.framework2d.implementation.MusicHandler.java
com.gamepatriot.framework2d.implementation.Pool.java
com.gamepatriot.framework2d.implementation.Renderer.java
com.gamepatriot.framework2d.implementation.Screen.java
com.gamepatriot.framework2d.implementation.Shape.java
com.gamepatriot.framework2d.implementation.SoundHandler.java
com.gamepatriot.framework2d.screens.Example.java