Skip to content

Instantly share code, notes, and snippets.

// some standard includes
#include "colors.inc"
#include "shapes.inc"
// this is the button...
object {
// ...it's a rounded box...
Round_Box(<-1,-1,-1>, <1,1,1>, 0.4, 0)
@tomgibara
tomgibara / SquareGridLayout.java
Created November 27, 2010 01:22
Square grid layout for Android
package com.tomgibara.android.util;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
/**
* A layout that arranges views into a grid of same-sized squares.
try {
FileOutputStream out = new FileOutputStream(file);
try {
bitmap.compress(CompressFormat.PNG, 100, out);
} finally {
try {
out.close();
} catch (IOException e) {
Log.w(DaisyGardenApp.LOG_TAG, "Failed to close file: " + file);
}
package com.tomgibara.daisy.demo.provider;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.format.DateUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import javax.imageio.ImageIO;
//create a factory that creates types within a scope
StuppScope scope = new StuppScope();
StuppType type = StuppType.getInstance(Book.class);
StuppFactory<Book, Long> factory = new StuppFactory(type, scope);
//then use it to create objects
Book book = factory.newInstance(1L);