Android Open Source - 4est Board






From Project

Back to project page 4est.

License

The source code is released under:

MIT License

If you think the Android project 4est 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.wordsaretoys.rise.utility;
//from w w  w.  jav a 2 s. c om
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PorterDuff;
import android.graphics.SurfaceTexture;
import android.graphics.Typeface;
import android.view.Surface;

import com.wordsaretoys.rise.glwrapper.Texture;

/**
 * billboard helper class, encapsulates surface/texture objects
 */
public class Board {

  public Texture texture;
  public SurfaceTexture surfaceTexture;
  public Surface surface;
  public Canvas canvas;
  
  public Board(int width, int height) {
    texture = new Texture();
    surfaceTexture = new SurfaceTexture(texture.getId());
    surfaceTexture.setDefaultBufferSize(width, height);
    surface = new Surface(surfaceTexture);
    
  }
  
  public Canvas lock() {
    canvas = surface.lockCanvas(null);
    canvas.drawColor(0, PorterDuff.Mode.CLEAR);
    return canvas;
  }
  
  public void unlock() {
    surface.unlockCanvasAndPost(canvas);
    surfaceTexture.updateTexImage();
  }
  
  public void release() {
    texture.release();
    surface.release();
    surfaceTexture.release();
  }
  
  public void draw(int bcolor, String title, float size) {
    lock();
    
    int w = canvas.getWidth();
    int h = canvas.getHeight();

    canvas.drawColor(bcolor);

    Paint brush = new Paint();
    brush.setColor(0xffffffff);
    brush.setStyle(Style.STROKE);
    brush.setStrokeWidth(4f);
    
    canvas.drawRect(2, 2, w - 2, h - 2,  brush);

    brush.setStyle(Style.FILL_AND_STROKE);
    brush.setTextAlign(Paint.Align.CENTER);
    brush.setTypeface(Typeface.SANS_SERIF);
    brush.setTextSize(size);
    
    canvas.drawText(title, w >> 1, h >> 1, brush);
    
    unlock();
  }
  
}




Java Source Code List

com.wordsaretoys.forest.Audio.java
com.wordsaretoys.forest.Debris.java
com.wordsaretoys.forest.Game.java
com.wordsaretoys.forest.GlView.java
com.wordsaretoys.forest.MainActivity.java
com.wordsaretoys.forest.Map.java
com.wordsaretoys.forest.Player.java
com.wordsaretoys.forest.Render.java
com.wordsaretoys.forest.Rotors.java
com.wordsaretoys.forest.Shared.java
com.wordsaretoys.forest.Skybox.java
com.wordsaretoys.rise.geometry.Camera.java
com.wordsaretoys.rise.geometry.Geom.java
com.wordsaretoys.rise.geometry.Mote.java
com.wordsaretoys.rise.geometry.Ortho.java
com.wordsaretoys.rise.geometry.Quaternion.java
com.wordsaretoys.rise.geometry.Vector.java
com.wordsaretoys.rise.glwrapper.Mesh.java
com.wordsaretoys.rise.glwrapper.Shader.java
com.wordsaretoys.rise.glwrapper.Texture.java
com.wordsaretoys.rise.meshutil.HeightMapper.java
com.wordsaretoys.rise.meshutil.IndexBuffer.java
com.wordsaretoys.rise.meshutil.SurfaceMapper.java
com.wordsaretoys.rise.meshutil.VertexBuffer.java
com.wordsaretoys.rise.meshutil.Vindexer.java
com.wordsaretoys.rise.pattern.Bitmap.java
com.wordsaretoys.rise.pattern.F2FSumMap.java
com.wordsaretoys.rise.pattern.I2FCutMap.java
com.wordsaretoys.rise.pattern.I2FMap.java
com.wordsaretoys.rise.pattern.I2IMap.java
com.wordsaretoys.rise.pattern.Pattern.java
com.wordsaretoys.rise.pattern.Ring.java
com.wordsaretoys.rise.utility.Asset.java
com.wordsaretoys.rise.utility.Board.java
com.wordsaretoys.rise.utility.Dbg.java
com.wordsaretoys.rise.utility.Interval.java
com.wordsaretoys.rise.utility.Misc.java
com.wordsaretoys.rise.utility.Needle.java