Commit 3a48ce9d authored by Thomas Krex's avatar Thomas Krex
Browse files

empty view in feedactivity hinzugefügt

parent 2043cb46
......@@ -29,7 +29,6 @@ import java.io.IOException;
import tttclient.core.Constants;
import tttclient.shapes.StrokedPath;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint.Cap;
import android.graphics.Paint.Join;
......@@ -119,19 +118,6 @@ public class FreehandAnnotation extends Annotation {
}
@Override
public void paintToThumbnail(Bitmap thumbnail) {
// graphics.setColor(annotationColors[color]);
// Stroke stroke = graphics.getStroke();
// // painting to thumbnails
// graphics.setStroke(new BasicStroke(6f, BasicStroke.CAP_ROUND,
// BasicStroke.JOIN_ROUND));
// graphics.draw(path);
// graphics.setStroke(stroke);
}
// TODO
@Override
public boolean contains(int x, int y) {
......
......@@ -35,6 +35,7 @@ import java.util.Random;
import tttclient.core.Constants;
import tttclient.core.GraphicsContext;
import android.graphics.Rect;
import android.util.Log;
public class HextileMessage extends FramebufferUpdateMessage {
// reading from stream is easier then reading from byte array
......@@ -71,9 +72,7 @@ public class HextileMessage extends FramebufferUpdateMessage {
this(timestamp, x, y, width, height, handleAndBufferHextileRect(
graphicsContext, is, x, y, width, height, false));
// Log.d("HextileMessageConstructor", "new update message at " + x +
// " , "
// + y);
}
@Override
......@@ -136,13 +135,7 @@ public class HextileMessage extends FramebufferUpdateMessage {
updateFlag);
}
}
// // mark rectangle
// graphicsContext.memGraphics.setColor(Color.CYAN);
// graphicsContext.memGraphics.drawRect(x, y, w, h);
// Finished, now let's show it.
// graphicsContext.refresh(x, y, w, h);
}
// Handle one tile in the Hextile-encoded data.
......@@ -242,66 +235,33 @@ public class HextileMessage extends FramebufferUpdateMessage {
DataInputStream is, DataOutputStream os, int x, int y, int w, int h)
throws IOException {
switch (graphicsContext.getPrefs().bytesPerPixel) {
// case 1:
// for (int dy = y; dy < y + h; dy++) {
// is.readFully(graphicsContext.pixels8, dy
// * graphicsContext.prefs.framebufferWidth + x, w);
//
// // buffering
// if (os != null)
// os.write(graphicsContext.pixels8, dy
// * graphicsContext.prefs.framebufferWidth + x, w);
// }
// break;
// TODO Android: support more bytes per pixel
switch (graphicsContext.getPrefs().bytesPerPixel) {
case 2:
byte[] buf = new byte[w * 2];
byte[] buf = new byte[2];
// Paint p = new Paint();
int color;
for (int dy = y; dy < y + h; dy++) {
is.readFully(buf);
// buffering
if (os != null)
os.write(buf);
int offset = dy * graphicsContext.getPrefs().framebufferWidth
+ x;
if (graphicsContext.getPrefs().bigEndian)
for (int i = 0; i < w; i++)
graphicsContext.getPixels()[offset + i] = (buf[i * 2] & 0xFF) << 8
| (buf[i * 2 + 1] & 0xFF);
else
for (int i = 0; i < w; i++)
graphicsContext.getPixels()[offset + i] = (buf[i * 2 + 1] & 0xFF) << 8
| (buf[i * 2] & 0xFF);
for (int i = x; i < x + w; i++) {
// TODO make buffer containing the whole rect, not only 2
// bytes... Android
is.readFully(buf);
// buffering
if (os != null)
os.write(buf);
color = graphicsContext.decodeColor(buf);
graphicsContext.getPixels()[dy
* graphicsContext.getPrefs().framebufferWidth + i] = color;
}
}
break;
default:
buf = new byte[w * 4];
for (int dy = y; dy < y + h; dy++) {
is.readFully(buf);
// buffering
if (os != null)
os.write(buf);
int offset = dy * graphicsContext.getPrefs().framebufferWidth
+ x;
if (graphicsContext.getPrefs().bigEndian)
for (int i = 0; i < w; i++)
graphicsContext.getPixels()[offset + i] = (buf[i * 4 + 1] & 0xFF) << 16
| (buf[i * 4 + 2] & 0xFF) << 8
| (buf[i * 4 + 3] & 0xFF);
else
for (int i = 0; i < w; i++)
graphicsContext.getPixels()[offset + i] = (buf[i * 4 + 2] & 0xFF) << 16
| (buf[i * 4 + 1] & 0xFF) << 8
| (buf[i * 4] & 0xFF);
}
}
}
// paint sub-reactangle
......@@ -309,6 +269,8 @@ public class HextileMessage extends FramebufferUpdateMessage {
int w, int h, byte[] colorField, boolean updateFlag) {
int color = graphicsContext.decodeColor(colorField);
if (updateFlag)
Log.d("Hextile Message", "update flag ");
GraphicsContext
.fillRect(graphicsContext.getPixels(), new Rect(x, y, x + w, y
......@@ -317,8 +279,8 @@ public class HextileMessage extends FramebufferUpdateMessage {
}
// static Color getGrayscale(Color color) {
// int argb = color.a;
// static int getGrayscale(int color) {
// int argb = Color.s;
// int a = argb >> 24 & 0xff;
// int r = argb >> 16 & 0xff;
// int g = argb >> 8 & 0xff;
......
......@@ -29,7 +29,6 @@ import java.io.IOException;
import tttclient.core.Constants;
import tttclient.core.IndexEntry;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
......@@ -97,12 +96,11 @@ public class HighlightAnnotation extends SimpleAnnotation {
}
@Override
public void paintToThumbnail(Bitmap bitmap) {
public void paintToThumbnail(Canvas canvas) {
int highlightColor = annotationColors[color];
// create canvas to draw on Bitmap thumbnail
Canvas canvas = new Canvas(bitmap);
// highlight area
Paint highlightPaint = new Paint();
......@@ -125,6 +123,7 @@ public class HighlightAnnotation extends SimpleAnnotation {
Color.green(highlightColor), Color.blue(highlightColor));
Paint borderPaint = new Paint();
borderPaint.setStrokeWidth(3);
borderPaint.setStyle(Paint.Style.STROKE);
borderPaint.setColor(borderColor);
canvas.drawRect(getBounds(), borderPaint);
......
......@@ -28,7 +28,6 @@ import java.io.DataInputStream;
import java.io.IOException;
import tttclient.core.Constants;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
......@@ -96,10 +95,4 @@ public class LineAnnotation extends SimpleAnnotation {
return 0;
}
@Override
public void paintToThumbnail(Bitmap bitmap) {
// TODO Auto-generated method stub
}
}
......@@ -29,7 +29,6 @@ import java.io.IOException;
import tttclient.core.Constants;
import tttclient.shapes.StrokedRect;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint.Cap;
import android.graphics.Paint.Join;
......@@ -39,6 +38,7 @@ import android.graphics.Rect;
public class RectangleAnnotation extends SimpleAnnotation {
private StrokedRect rect;
private StrokedRect thumbRect;
public RectangleAnnotation(int timestamp, int color, int startx,
int starty, int endx, int endy) {
......@@ -101,28 +101,21 @@ public class RectangleAnnotation extends SimpleAnnotation {
// create shape
rect = new StrokedRect(new Rect(x, y, x + width, y + height), 2.5f,
Cap.ROUND, Join.ROUND);
thumbRect = new StrokedRect(new Rect(x, y, x + width, y + height), 6f,
Cap.ROUND, Join.ROUND);
// shape = new BasicStroke(2.5f, BasicStroke.CAP_ROUND,
// BasicStroke.JOIN_ROUND).createStrokedShape(new Rectangle(x, y,
// width, height));
// thumbshape = new BasicStroke(6f, BasicStroke.CAP_ROUND,
// BasicStroke.JOIN_ROUND).createStrokedShape(new Rectangle(x, y,
// width, height));
}
@Override
public void paintToThumbnail(Bitmap thumbail) {
// TODO: fix color - don't use table for new protocol
// graphics.setColor(annotationColors[color]);
// graphics.fill(thumbshape);
public void paintToThumbnail(Canvas canvas) {
thumbRect.setColor(annotationColors[color]);
thumbRect.setStyle(Style.STROKE);
thumbRect.paint(canvas);
}
@Override
public void paint(Canvas canvas) {
// TODO: fix color - don't use table for new protocol
// graphics.setColor(annotationColors[color]);
// graphics.fill(shape);
// TODO rot als Test
rect.setColor(annotationColors[color]);
rect.setStyle(Style.STROKE);
rect.paint(canvas);
......
......@@ -3,6 +3,7 @@ package tttclient.models;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
public class FeedDbManager {
......@@ -46,17 +47,18 @@ public class FeedDbManager {
}
// gets the all the entries with the same name
Cursor c = db.rawQuery("SELECT id FROM feeds WHERE 'name' = ?",
new String[] { f.name });
Cursor c = db.rawQuery("SELECT id FROM feeds WHERE 'feedUrl' = ?",
new String[] { f.url });
// checks if already a entry with the same name exists and update it if
// so
if (c.moveToNext()) {
db.execSQL("UPDATE feeds SET 'name' =?, 'feedUrl' =? WHERE id=?",
new String[] { f.name, f.url, c.getString(0) });
}
db.execSQL("INSERT INTO feeds ( name , feedUrl) VALUES (?, ?)",
new String[] { f.name, f.url });
Log.d("SQL", "Entry with same URL found");
} else
db.execSQL("INSERT INTO feeds ( name , feedUrl) VALUES (?, ?)",
new String[] { f.name, f.url });
c.close();
......
package tttclient.utils;
import android.annotation.SuppressLint;
import android.graphics.Bitmap;
@SuppressLint("NewApi")
public class BitmapContainer {
private final Bitmap image;
private final int width, height;
......@@ -23,11 +25,15 @@ public class BitmapContainer {
pixels[x + y * width] = color;
}
public Bitmap getBimap() {
public Bitmap getBitmap() {
image.setPixels(pixels, 0, width, 0, 0, width, height);
return image;
}
public Bitmap getCurBitmap() {
return image;
}
public int getWidth() {
return image.getWidth();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment