Commit 2043cb46 by Thomas Krex

erster Versuch annotations auch auf thumbails zu markieren

thumbnail erstellung nach dem selben schema wie hauptbild
parent cdb7c8ea
......@@ -232,12 +232,15 @@ public class PlayerActivity extends SherlockActivity implements
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
searchView.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN);
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
search(query);
recording.getIndex().highlightSearchResultsOnThumbnails();
// search(query);
// if (query.isEmpty())
// searchView.clearFocus();
// recording.getIndex().highlightSearchResultsOnThumbnails();
searchView.clearFocus();
return true;
}
......
......@@ -89,11 +89,12 @@ public class GraphicsContext implements MessageConsumer {
@Override
public void handleMessage(android.os.Message inputMessage) {
// Gets the image task from the incoming Message object.
Bitmap bitmap = (Bitmap) inputMessage.obj;
Bitmap bitmap = bitmapContainer.getBimap();
Canvas canvas = new Canvas(bitmap);
if (isWhiteboardEnabled())
paintWhiteboard();
paintAnnotations();
paintWhiteboard(canvas);
paintAnnotations(canvas);
recording.highlightSearchResults(canvas);
imgView.setImageBitmap(bitmap);
......@@ -203,19 +204,18 @@ public class GraphicsContext implements MessageConsumer {
// draw Canvas on current Bitmap
public void updateView() {
if (refreshEnabled) {
android.os.Message message = viewHandler.obtainMessage(0,
bitmapContainer.getBimap());
android.os.Message message = viewHandler.obtainMessage();
message.sendToTarget();
}
}
// set new Bitmap
public void updateView(final Bitmap bitmap) {
if (refreshEnabled) {
android.os.Message message = viewHandler.obtainMessage(0, bitmap);
message.sendToTarget();
}
}
// // set new Bitmap
// public void updateView(final Bitmap bitmap) {
// if (refreshEnabled) {
// android.os.Message message = viewHandler.obtainMessage(0, bitmap);
// message.sendToTarget();
// }
// }
public int decodeColor(byte[] colorField) {
int color = (colorField[1] & 0xFF) << 8 | (colorField[0] & 0xFF);
......@@ -270,7 +270,7 @@ public class GraphicsContext implements MessageConsumer {
x + y * prefs.framebufferWidth, prefs.framebufferWidth, x,
y, w, h);
updateView(bitmapContainer.getBimap());
updateView();
}
}
......@@ -336,7 +336,7 @@ public class GraphicsContext implements MessageConsumer {
}
// display all annotations
synchronized public void paintAnnotations() {
synchronized public void paintAnnotations(Canvas canvas) {
for (int i = 0; i < currentAnnotations.size(); i++) {
currentAnnotations.get(i).paint(canvas);
......@@ -345,39 +345,48 @@ public class GraphicsContext implements MessageConsumer {
}
public Bitmap getScreenshotWithoutAnnotations() {
Bitmap screenshot;
// create new mutable bitmap
Bitmap screenshot = Bitmap.createBitmap(prefs.framebufferWidth,
prefs.framebufferHeight, Config.ARGB_4444);
// show blank page if whiteboard activated
if (isWhiteboardEnabled()) {
int[] whitePixels = new int[(int) (prefs.framebufferWidth * IndexEntry.THUMBNAIL_SCALE_FACTOR)
* (int) (prefs.framebufferWidth * IndexEntry.THUMBNAIL_SCALE_FACTOR)];
for (int i = 0; i < whitePixels.length; i++) {
whitePixels[i] = Color.WHITE;
}
Bitmap whiteboard = Bitmap
.createBitmap(
whitePixels,
(int) (prefs.framebufferWidth * IndexEntry.THUMBNAIL_SCALE_FACTOR),
(int) (prefs.framebufferHeight * IndexEntry.THUMBNAIL_SCALE_FACTOR),
Config.ARGB_4444);
return whiteboard;
} else {
screenshot = Bitmap.createBitmap(pixels, prefs.framebufferWidth,
prefs.framebufferHeight, Config.ARGB_4444);
// Bitmap scaledScreenshot = Bitmap
// .createScaledBitmap(
// screenshot,
// int[] whitePixels = new int[(int) (prefs.framebufferWidth *
// IndexEntry.THUMBNAIL_SCALE_FACTOR)
// * (int) (prefs.framebufferHeight *
// IndexEntry.THUMBNAIL_SCALE_FACTOR)];
// for (int i = 0; i < whitePixels.length; i++) {
// whitePixels[i] = Color.WHITE;
// screenshot.setPixels(whitePixels, 0, stride, x, y, width,
// height);
Canvas canvas = new Canvas(screenshot);
canvas.drawColor(Color.WHITE);
// Bitmap whiteboard = Bitmap
// .createBitmap(
// whitePixels,
// (int) (prefs.framebufferWidth *
// IndexEntry.THUMBNAIL_SCALE_FACTOR),
// (int) (prefs.framebufferHeight *
// IndexEntry.THUMBNAIL_SCALE_FACTOR),
// false);
// screenshot.recycle();
// System.gc();
return screenshot;
}
// Config.ARGB_4444);
// return whiteboard;
} else
screenshot.setPixels(pixels, 0, prefs.framebufferWidth, 0, 0,
prefs.framebufferWidth, prefs.framebufferHeight);
// Bitmap scaledScreenshot = Bitmap
// .createScaledBitmap(
// screenshot,
// (int) (prefs.framebufferWidth *
// IndexEntry.THUMBNAIL_SCALE_FACTOR),
// (int) (prefs.framebufferHeight *
// IndexEntry.THUMBNAIL_SCALE_FACTOR),
// false);
// screenshot.recycle();
// System.gc();
return screenshot;
}
......@@ -404,17 +413,19 @@ public class GraphicsContext implements MessageConsumer {
return new WhiteboardMessage(0, whiteboardPage, prefs);
}
public void paintWhiteboard() {
public void paintWhiteboard(Canvas canvas) {
int[] whitePixel = new int[prefs.framebufferHeight
* prefs.framebufferWidth];
for (int i = 0; i < whitePixel.length; i++) {
whitePixel[i] = Color.WHITE;
}
// int[] whitePixel = new int[prefs.framebufferHeight
// * prefs.framebufferWidth];
// for (int i = 0; i < whitePixel.length; i++) {
// whitePixel[i] = Color.WHITE;
// }
//
// bitmapContainer.getBimap().setPixels(whitePixel, 0,
// prefs.framebufferWidth, 0, 0, prefs.framebufferWidth,
// prefs.framebufferHeight);
bitmapContainer.getBimap().setPixels(whitePixel, 0,
prefs.framebufferWidth, 0, 0, prefs.framebufferWidth,
prefs.framebufferHeight);
canvas.drawColor(Color.WHITE);
Paint p = new Paint(Color.BLACK);
p.setTextSize(20);
......
......@@ -91,7 +91,7 @@ public class Index {
// check if thumbnail is available for each index
public boolean thumbnailsAvailable() {
for (int i = 0; i < index.size(); i++) {
if (index.get(i).getThumbnail() == null)
if (!index.get(i).hasThumbnail())
return false;
}
return true;
......@@ -253,7 +253,7 @@ public class Index {
// add index entry
index.add(new IndexEntry(context, this, title, timestamp,
searchable, null));
searchable));
}
......@@ -336,7 +336,7 @@ public class Index {
static final public int PAINT_ALL_ANNOTATIONS = 0;
static final public int PAINT_NO_ANNOTATIONS = 1;
static final public int PAINT_NO_HIGHLIGHT_ANNOTATIONS = 2;
int annotationsPaintMode = PAINT_NO_HIGHLIGHT_ANNOTATIONS;
int annotationsPaintMode = PAINT_ALL_ANNOTATIONS;
public int getAnnotationsPaintMode() {
return annotationsPaintMode;
......@@ -415,6 +415,7 @@ public class Index {
}
// set collected annotations
Log.d("Index", "Annotations: " + annotations.size());
recording.getIndex().get(i).setAnnotations(annotations);
// clear buffer if index ended with a delete event, which was not
......@@ -717,7 +718,8 @@ public class Index {
public void highlightSearchResultsOnThumbnails() {
for (int i = 0; i < index.size(); i++) {
index.get(i).highlightSearchResultsOnThumbail();
// index.get(i).highlightSearchResultsOnThumbail();
index.get(i).updateThumbail();
}
}
......
......@@ -5,10 +5,11 @@ import java.io.IOException;
import java.util.ArrayList;
import tttclient.messages.Annotation;
import tttclient.messages.HighlightAnnotation;
import tttclient.shapes.ColoredShape;
import tttclient.utils.BitmapContainer;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
......@@ -20,7 +21,7 @@ public class IndexEntry extends ImageButton {
private final int timestamp;
private final Index index;
private int[] pixel;
private Bitmap thumbnail;
private BitmapContainer bitmapContainer;
private String title = "";
private String searchbase_of_page;
private ArrayList<SearchBaseEntry> words;
......@@ -31,13 +32,12 @@ public class IndexEntry extends ImageButton {
private boolean hasThumbnail = false;
public IndexEntry(Context context, final Index index, String title,
int timestamp, String searchableText, Bitmap thumbnail) {
int timestamp, String searchableText) {
super(context);
this.index = index;
this.timestamp = timestamp;
this.title = title;
this.searchbase_of_page = searchableText;
this.thumbnail = thumbnail;
this.setBackgroundColor(Color.WHITE);
......@@ -48,20 +48,7 @@ public class IndexEntry extends ImageButton {
// needed to get correct height
this.setAdjustViewBounds(true);
// ViewTreeObserver vto = this.getViewTreeObserver();
// vto.addOnPreDrawListener(new OnPreDrawListener() {
//
// @Override
// public boolean onPreDraw() {
// getMeasuredWidth();
//
// THUMBNAIL_SCALE_FACTOR = getMeasuredWidth()
// / index.getRecording().getProtocolPreferences().framebufferWidth;
// Log.d("Scale Factor", "" + THUMBNAIL_SCALE_FACTOR);
//
// return true;
// }
// });
this.setOnClickListener(new OnClickListener() {
@Override
......@@ -73,34 +60,37 @@ public class IndexEntry extends ImageButton {
}
public IndexEntry(Context context, Index index) {
this(context, index, "", 0, null, null);
this(context, index, "", 0, null);
}
public IndexEntry(Context context, Index index, int timestamp) {
this(context, index, "", timestamp, null, null);
this(context, index, "", timestamp, null);
}
public int getTimestamp() {
return timestamp;
}
public Bitmap getThumbnail() {
return thumbnail;
}
public void setThumbnail(Bitmap thumbnail) {
// set
// create bitmap container only once
if (!hasThumbnail) {
bitmapContainer = new BitmapContainer(thumbnail);
hasThumbnail = true;
}
public String getTitle() {
return title;
}
// setImageBitmap(thumbnail);
updateThumbail();
// set src of ImageButton
public String getSearchbase_of_page() {
return searchbase_of_page;
}
public void setThumbnail(Bitmap thumbnail) {
this.thumbnail = thumbnail;
// set src of ImageButton
this.setImageBitmap(thumbnail);
hasThumbnail = true;
public void updateThumbail() {
Bitmap bitmap = bitmapContainer.getBimap();
Canvas canvas = new Canvas(bitmap);
paintAnnotations(canvas);
highlightSearchResultsOnThumbail(canvas);
setImageBitmap(bitmap);
}
......@@ -199,12 +189,12 @@ public class IndexEntry extends ImageButton {
}
public void highlightSearchResultsOnThumbail() {
public void highlightSearchResultsOnThumbail(Canvas searchCanvas) {
// TODO
if (!results.isEmpty()) {
// thumbail is inmutable --> create mutable one
Bitmap copy = thumbnail.copy(Config.ARGB_4444, true);
Canvas searchCanvas = new Canvas(copy);
// Bitmap image = bitmapContainer.getBimap();
// Canvas searchCanvas = new Canvas(image);
for (int i = 0; i < results.size(); i++) {
ColoredShape shape = results.get(i);
......@@ -216,37 +206,27 @@ public class IndexEntry extends ImageButton {
else
p.setStyle(Paint.Style.STROKE);
// // scale shape for thumbnails
// RectF scaledRect = new RectF(
// (float) (shape.rectangle.left * THUMBNAIL_SCALE_FACTOR),
// (float) (shape.rectangle.top * THUMBNAIL_SCALE_FACTOR),
// (float) (shape.rectangle.right * THUMBNAIL_SCALE_FACTOR),
// (float) (shape.rectangle.bottom * THUMBNAIL_SCALE_FACTOR));
searchCanvas.drawRect(shape.rectangle, p);
setImageBitmap(copy);
}
} else
setImageBitmap(thumbnail);
}
// // show annoattions (if enabled)
// void paintAnnotations(Canvas canvas, boolean thumbnail) {
// boolean paintHighlightAnnotations = index.getAnnotationsPaintMode() ==
// Index.PAINT_ALL_ANNOTATIONS;
// if (annotations != null)
// if (index.getAnnotationsPaintMode() != Index.PAINT_NO_ANNOTATIONS)
// for (int i = 0; i < annotations.size(); i++) {
// Annotation annotation = annotations.get(i);
// if (paintHighlightAnnotations
// || !(annotation instanceof HighlightAnnotation)) {
// if (thumbnail) {
// annotation.paintToThumbnail(this.thumbnail);
// setThumbnail(this.thumbnail);
// } else
// annotation.paint(canvas);
// }
// }
// }
}
}
// show annoattions (if enabled)
void paintAnnotations(Canvas canvas) {
boolean paintHighlightAnnotations = index.getAnnotationsPaintMode() == Index.PAINT_ALL_ANNOTATIONS;
if (annotations != null)
if (index.getAnnotationsPaintMode() != Index.PAINT_NO_ANNOTATIONS)
for (int i = 0; i < annotations.size(); i++) {
Annotation annotation = annotations.get(i);
if (paintHighlightAnnotations
|| !(annotation instanceof HighlightAnnotation)) {
annotation.paint(canvas);
}
}
}
}
......@@ -97,9 +97,10 @@ public class Recording extends MessageProducerAdapter implements Runnable {
if (!index.isValid())
index.computeIndex();
index.extractAnnotations();
if (!index.thumbnailsAvailable())
index.createScreenshots();
index.extractAnnotations();
initIndexView();
if (audioPlayer != null) {
int desktop_duration = messages.get(messages.size() - 1)
......@@ -527,10 +528,15 @@ public class Recording extends MessageProducerAdapter implements Runnable {
*
* @param time
*/
private int previousTime = 0;
public void setTime(int time, boolean refresh) {
// refresh determine if display is updated or not
// setAdjusting(true);
// while loop is stopped due to performance problems
if (!adjusting)
setAdjusting(true);
time = sync(time);
......@@ -538,6 +544,11 @@ public class Recording extends MessageProducerAdapter implements Runnable {
messages.setTime_full_frame_check(time);
// messages.setTime_full_frame_check_regarding_stripes(time);
if (refresh) {
// TODO timeout justieren
if (Math.abs(time - previousTime) < 10 && time > 5) {
return;
}
previousTime = time;
// focusCurrentIndexEntry(time);
index.setCorrespondingIndex(time);
......@@ -545,7 +556,9 @@ public class Recording extends MessageProducerAdapter implements Runnable {
setAudioPlayerTime(time);
}
// setAdjusting(false);
// while loop is started again
if (adjusting)
setAdjusting(false);
}
......
......@@ -104,6 +104,7 @@ public class FreehandAnnotation extends Annotation {
RectF boundsF = new RectF();
Rect bounds = new Rect();
path.computeBounds(boundsF, true);
boundsF.round(bounds);
return bounds;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment