Commit 0c3fb0ba by Lee Jaebin

メモの座標変換を元のソースに修正

parent 927e55be
......@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Point;
import android.graphics.PointF;
import android.view.DragEvent;
import android.view.GestureDetector;
......@@ -636,9 +637,9 @@ public class ZoomRelativeLayout extends RelativeLayout {
for (int i = 0; i < listMemo.size(); i++) {
// アイコン追加
ContentMemoDto dto = listMemo.get(i);
PointF point = convertToAuthoringPoint(dto.axisX, dto.axisY);
dto.viewX = (int) point.x;
dto.viewY = (int) point.y;
Point point = convertToMemoViewPoint(dto.axisX, dto.axisY);
dto.viewX = point.x;
dto.viewY = point.y;
MemoManager.addMemoIcon(this, dto);
}
}
......@@ -701,12 +702,45 @@ public class ZoomRelativeLayout extends RelativeLayout {
}
}
public Point convertToMemoViewPoint(float x, float y) {
Logger.d(TAG, "convertToViewPoint:x=%s, y=%s", x, y);
// オーサリング基準座標から変換PDF基準座標に変換
float scale = Math.min(getDefaultPDFWidth() / (float)mAuthoringPageSize.width, getDefaultPDFHeight() / (float)mAuthoringPageSize.height);
float pdfX = x * scale;
float pdfY = y * scale;
Logger.d(TAG, "convertToMemoViewPoint:scale=%s scaledWidth=%s, scaledHeight=%s pdfX=%s, pdfY=%s", scale, getDefaultPDFWidth(), getDefaultPDFHeight(), pdfX, pdfY);
// PDF座標からタッチ座標に変換
float viewX = pdfX + margin.left;
float viewY = pdfY + margin.top;
Logger.d(TAG, "convertToMemoViewPoint:marginX=%s, marginY=%s, mPdfScale=%s viewX=%s, viewY=%s", margin.left, margin.top, mPdfScale, viewX, viewY);
Point point = new Point((int)viewX, (int)viewY);
return point;
}
public Point convertToMemoAuthoringPoint(float x, float y) {
Logger.d(TAG, "convertToMemoAuthoringPoint:x=%s, y=%s", x, y);
// タッチ座標からPDF座標に変換
mPdfScale = Math.min(getWidth() / (float)mPdfSize.width, getHeight() / (float)mPdfSize.height);
float marginX = getMarginX(mPdfScale);
float marginY = getMarginY(mPdfScale);
float pdfX = x - marginX;
float pdfY = y - marginY;
Logger.d(TAG, "convertToMemoAuthoringPoint:marginX=%s, marginY=%s, mPdfScale=%s pdfX=%s, pdfY=%s", margin.left, margin.top, mPdfScale, pdfX, pdfY);
// 変換PDF基準座標からオーサリング基準座標に変換
float scale = Math.min((float)mAuthoringPageSize.width / getDefaultPDFWidth(), (float)mAuthoringPageSize.height / getDefaultPDFHeight());
Point point = new Point((int)(pdfX * scale), (int)(pdfY * scale));
Logger.d(TAG, "convertToAuthoringPoint:scale=%s scaledWidth=%s, scaledHeight=%s authX=%s, auyhY=%s", scale, getDefaultPDFWidth(), getDefaultPDFHeight(), (pdfX * scale), (pdfY * scale));
return point;
}
public boolean isLeftSideOfPdf(int x) {
return x < mAuthoringPageSize.width / 2;
}
private void showMemoMenu(final float x, final float y) {
final PointF convertedPoint = convertToAuthoringPoint(x, y);
final Point convertedPoint = convertToMemoAuthoringPoint(x, y);
if (contentMemoDao.getCopiedMemo() != null) {
// メモのコピーまたは切り取り中
final ABVPopupListWindow memoPopupWindow = createSimplePopupWindow();
......@@ -721,8 +755,8 @@ public class ZoomRelativeLayout extends RelativeLayout {
if (position == 0) {
// 新規
ContentMemoDto dto = new ContentMemoDto();
dto.axisX = (int) convertedPoint.x;
dto.axisY = (int) convertedPoint.y;
dto.axisX = convertedPoint.x;
dto.axisY = convertedPoint.y;
dto.viewX = (int)x;
dto.viewY = (int)y;
dto.contentId = mContentDto.contentId;
......
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 to comment