-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/tenprint' into develop
- Loading branch information
Showing
15 changed files
with
2,027 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
simplified-app/src/main/java/org/nypl/simplified/app/testing/CoverGeneration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.nypl.simplified.app.testing; | ||
|
||
import org.nypl.simplified.app.R; | ||
import org.nypl.simplified.tenprint.TenPrintGenerator; | ||
import org.nypl.simplified.tenprint.TenPrintGeneratorType; | ||
import org.nypl.simplified.tenprint.TenPrintInput; | ||
import org.nypl.simplified.tenprint.TenPrintInputBuilderType; | ||
|
||
import android.app.Activity; | ||
import android.graphics.Bitmap; | ||
import android.os.Bundle; | ||
import android.view.ViewGroup; | ||
import android.widget.FrameLayout; | ||
import android.widget.ImageView; | ||
|
||
import com.io7m.jnull.NullCheck; | ||
import com.io7m.jnull.Nullable; | ||
|
||
public final class CoverGeneration extends Activity | ||
{ | ||
@Override protected void onCreate( | ||
final @Nullable Bundle state) | ||
{ | ||
super.onCreate(state); | ||
|
||
final TenPrintGeneratorType g = TenPrintGenerator.newGenerator(); | ||
|
||
final TenPrintInputBuilderType b = TenPrintInput.newBuilder(); | ||
b.setAuthor("G. Mercer Adam, A Ethelwyn Wetherby"); | ||
b.setTitle("An Algonquin Maiden: A Romance ..."); | ||
b.setBaseBrightness(0.9f); | ||
b.setBaseSaturation(0.9f); | ||
b.setCoverHeight(120); | ||
b.setGridScale(1.0f); | ||
b.setShapeThickness(15); | ||
b.setDebuggingArtwork(false); | ||
|
||
final TenPrintInput i = b.build(); | ||
final Bitmap image = g.generate(i); | ||
this.setContentView(R.layout.test_cover_gen); | ||
|
||
final ViewGroup container = | ||
NullCheck.notNull((ViewGroup) this | ||
.findViewById(R.id.test_cover_container)); | ||
|
||
final ImageView v = new ImageView(this); | ||
v.setLayoutParams(new FrameLayout.LayoutParams(image.getWidth(), image | ||
.getHeight())); | ||
v.setImageBitmap(image); | ||
container.addView(v); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
simplified-app/src/main/java/org/nypl/simplified/app/testing/DrawTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.nypl.simplified.app.testing; | ||
|
||
import org.nypl.simplified.app.R; | ||
|
||
import android.app.Activity; | ||
import android.graphics.Bitmap; | ||
import android.graphics.Bitmap.Config; | ||
import android.graphics.Canvas; | ||
import android.graphics.Color; | ||
import android.graphics.Paint; | ||
import android.graphics.RectF; | ||
import android.os.Bundle; | ||
import android.view.ViewGroup; | ||
import android.widget.FrameLayout; | ||
import android.widget.ImageView; | ||
|
||
import com.io7m.jnull.NullCheck; | ||
import com.io7m.jnull.Nullable; | ||
|
||
public final class DrawTest extends Activity | ||
{ | ||
private static void drawEllipse( | ||
final Canvas c, | ||
final int x, | ||
final int y, | ||
final int w, | ||
final int h, | ||
final Paint p) | ||
{ | ||
final float left = x; | ||
final float top = y; | ||
final float right = x + w; | ||
final float bottom = y + h; | ||
final RectF oval = new RectF(left, top, right, bottom); | ||
c.drawOval(oval, p); | ||
} | ||
|
||
private static void drawRing( | ||
final Canvas c, | ||
final int x, | ||
final int y, | ||
final int w, | ||
final int h, | ||
final int thick, | ||
final Paint p, | ||
final Paint q) | ||
{ | ||
{ | ||
final float left = x; | ||
final float top = y; | ||
final float right = x + w; | ||
final float bottom = y + h; | ||
final RectF oval = new RectF(left, top, right, bottom); | ||
c.drawOval(oval, p); | ||
} | ||
|
||
{ | ||
final float left = x + thick; | ||
final float top = y + thick; | ||
final float right = x + (w - thick); | ||
final float bottom = y + (h - thick); | ||
final RectF oval = new RectF(left, top, right, bottom); | ||
c.drawOval(oval, q); | ||
} | ||
} | ||
|
||
@Override protected void onCreate( | ||
final @Nullable Bundle state) | ||
{ | ||
super.onCreate(state); | ||
|
||
this.setContentView(R.layout.test_cover_gen); | ||
|
||
final ViewGroup container = | ||
NullCheck.notNull((ViewGroup) this | ||
.findViewById(R.id.test_cover_container)); | ||
|
||
final Bitmap image = Bitmap.createBitmap(300, 450, Config.RGB_565); | ||
final Canvas canvas = new Canvas(image); | ||
|
||
final Paint p = new Paint(); | ||
p.setColor(Color.RED); | ||
final Paint q = new Paint(); | ||
p.setColor(Color.BLUE); | ||
DrawTest.drawRing(canvas, 10, 10, 200, 200, 20, p, q); | ||
|
||
final ImageView v = new ImageView(this); | ||
v.setLayoutParams(new FrameLayout.LayoutParams(image.getWidth(), image | ||
.getHeight())); | ||
v.setImageBitmap(image); | ||
container.addView(v); | ||
} | ||
} |
Oops, something went wrong.