Цифровая подпись с PoinF на странице mupdfJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Цифровая подпись с PoinF на странице mupdf

Сообщение Anonymous »

У меня есть подпись, которая хорошо перетаскивается, но у меня проблема с функцией масштабирования и поворота, растровое изображение может работать хорошо, но я работаю с точкой F. Проблема в точке F, потому что mupdf принимает точку F
Я хочу просто метод поворота и метод увеличения и уменьшения масштаба, как это сделать. У меня нет решений в стеке или других вещей
Это изображение
также ограничивающая рамка не вращается. Я выполнил некоторые функции, но не работает
а теперь посмотрите мой код, если вам понадобится какой-либо другой код, я вам предоставлю

Код: Выделить всё

public void setPage(final int page, final PointF size) {
if (this.mDrawEntire != null) {
this.mDrawEntire.cancelAndWait();
this.mDrawEntire = null;
}
this.mIsBlank = false;
if (this.mSearchView != null) {
this.mSearchView.invalidate();
}
this.mPageNumber = page;
if (this.mEntire == null) {
(this.mEntire = (ImageView) new OpaqueImageView(this.mContext)).setScaleType(ImageView.ScaleType.MATRIX);
this.addView((View) this.mEntire);
}
this.mSourceScale = Math.min(this.mParentSize.x / size.x, this.mParentSize.y / size.y);
this.mSize = new Point((int) (size.x * this.mSourceScale), (int) (size.y * this.mSourceScale));
this.pageWidth = (int) (size.x * this.mSourceScale);
this.pageHeight = (int) (size.y * this.mSourceScale);
this.mEntire.setImageBitmap((Bitmap) null);
this.mEntire.invalidate();
(this.mGetLinkInfo = new AsyncTask() {
protected LinkInfo[] doInBackground(final Void...  v) {
return PageView.this.getLinkInfo();
}

protected void onPostExecute(final LinkInfo[] v) {
PageView.this.mLinks = v;
if (PageView.this.mSearchView != null) {
PageView.this.mSearchView.invalidate();
}
}
}).execute(new Void[0]);
(this.mDrawEntire = new CancellableAsyncTask(this.getDrawPageTask(this.mEntireBm, this.mSize.x, this.mSize.y, 0, 0, this.mSize.x, this.mSize.y)) {
@Override
public void onPreExecute() {
PageView.this.setBackgroundColor(-1);
PageView.this.mEntire.setImageBitmap((Bitmap) null);
PageView.this.mEntire.invalidate();
if (PageView.this.mBusyIndicator == null) {
PageView.this.mBusyIndicator = new ProgressBar(PageView.this.mContext);
PageView.this.mBusyIndicator.setIndeterminate(true);
PageView.this.addView((View) PageView.this.mBusyIndicator);
PageView.this.mBusyIndicator.setVisibility(View.INVISIBLE);
PageView.this.mHandler.postDelayed((Runnable) new Runnable() {
@Override
public void run() {
if (PageView.this.mBusyIndicator != null) {
PageView.this.mBusyIndicator.setVisibility(VISIBLE);
}
}
}, 200L);
}
}

@Override
public void onPostExecute(final Void result) {
PageView.this.removeView((View) PageView.this.mBusyIndicator);
PageView.this.mBusyIndicator = null;
PageView.this.mEntire.setImageBitmap(PageView.this.mEntireBm);
PageView.this.mEntire.invalidate();
PageView.this.setBackgroundColor(0);
}
}).execute(new Void[0]);
if (this.mSearchView == null) {
Log.d("PLOL", "setPage: Checking " + mSearchView);
this.addView(this.mSearchView = new View(this.mContext) {
protected void onDraw(final Canvas canvas) {
super.onDraw(canvas);
final float scale = PageView.this.mSourceScale * this.getWidth() / PageView.this.mSize.x;
PageView.this.current_scale = scale;
final Paint paint = new Paint();
if (!PageView.this.mIsBlank && PageView.this.mSearchBoxes != null) {
paint.setColor(SharedPreferencesUtil.getSearchTextColor());
for (final RectF rect : PageView.this.mSearchBoxes) {
canvas.drawRect(rect.left * scale, rect.top * scale, rect.right * scale, rect.bottom * scale, paint);
}
}
if (!PageView.this.mIsBlank && PageView.this.mLinks != null && PageView.this.mHighlightLinks) {
paint.setColor(PageView.this.LINK_COLOR);
for (final LinkInfo link : PageView.this.mLinks) {
canvas.drawRect(link.rect.left * scale, link.rect.top * scale, link.rect.right * scale, link.rect.bottom * scale, paint);
}
}
if (PageView.this.mSelectBox != null &&  PageView.this.mText != null) {
int color = getInkColor();
paint.setColor(Color.argb(123, Color.red(color), Color.green(color), Color.blue(color)));
PageView.this.processSelectedText(new TextProcessor() {
RectF rect;

@Override
public void onStartLine() {
this.rect = new RectF();
}

@Override
public void onWord(final TextWord word) {
this.rect.union((RectF) word);
}

@Override
public void onEndLine() {
if (!this.rect.isEmpty()) {
canvas.drawRect(this.rect.left * scale, (this.rect.top + HIGHLIGHT_RECT_OFFSET) * scale, this.rect.right * scale, (this.rect.bottom - HIGHLIGHT_RECT_OFFSET) * scale, paint);
}
}
});
}
if (PageView.this.mItemSelectBox != null) {
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(4.0f);
paint.setColor(-9868951);
canvas.drawRect(PageView.this.mItemSelectBox.left * scale, PageView.this.mItemSelectBox.top * scale, PageView.this.mItemSelectBox.right * scale, PageView.this.mItemSelectBox.bottom * scale, paint);
}
if (PageView.this.mDrawing != null) {
final Path path = new Path();
paint.setAntiAlias(true);
paint.setDither(true);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStyle(Paint.Style.FILL);
paint.setStrokeWidth(PageView.this.INK_THICKNESS * scale);
paint.setColor(PageView.this.INK_COLOR);
for (final ArrayList
 arc : PageView.this.mDrawing) {
if (arc.size() >= 2) {
final Iterator iit = arc.iterator();
PointF p = iit.next();
float mX = p.x * scale;
float mY = p.y * scale;
path.moveTo(mX, mY);
while (iit.hasNext()) {
p = iit.next();
final float x = p.x * scale;
final float y = p.y * scale;
path.quadTo(mX, mY, (x + mX) / 2.0f, (y + mY) / 2.0f);
mX = x;
mY = y;
}
path.lineTo(mX, mY);
} else {
final PointF p = arc.get(0);
canvas.drawCircle(p.x * scale, p.y * scale, PageView.this.INK_THICKNESS * scale / 2.0f, paint);
}
}
paint.setStyle(Paint.Style.STROKE);
canvas.drawPath(path, paint);
}

if (signaturePoints != null && !signaturePoints.isEmpty()) {
Log.d("PLOL", "onDraw: 6 " + mSearchView);
final Path path = new Path();
paint.setAntiAlias(true);
paint.setDither(true);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStyle(Paint.Style.FILL);
paint.setStrokeWidth(PageView.this.INK_THICKNESS);
paint.setColor(PageView.this.INK_COLOR);
for (final ArrayList arc : PageView.this.signaturePoints) {
Log.d("LOGO", "onDraw: " + arc);
if (arc.size() >= 2) {
final Iterator  iit = arc.iterator();
PointF p = iit.next();
float mX = p.x * scale;
float mY = p.y * scale;
path.moveTo(mX, mY);
while (iit.hasNext()) {
p = iit.next();
final float x = p.x * scale;
final float y = p.y * scale;
path.quadTo(mX, mY, (x + mX) / 2.0f, (y + mY) / 2.0f);
mX = x;
mY = y;
}
path.lineTo(mX, mY);
} else {
final PointF p = arc.get(0);
canvas.drawCircle(p.x * scale, p.y * scale, PageView.this.INK_THICKNESS * scale / 2.0f, paint);
}
}
paint.setStyle(Paint.Style.STROKE);
canvas.drawPath(path, paint);
boundingBox = calculateBoundingBox(signaturePoints);
if (boundingBox != null) {
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(2.0f);
paint.setColor(Color.RED);
canvas.drawRect(boundingBox.left * scale, boundingBox.top * scale, boundingBox.right * scale, boundingBox.bottom * scale, paint);
canvas.drawBitmap(deleteIcon, boundingBox.left * scale - deleteIcon.getWidth() +20, boundingBox.top * scale - deleteIcon.getHeight()+20, null);
canvas.drawBitmap(zoomIcon, boundingBox.right * scale - 20, boundingBox.bottom * scale -20 , null);
}
//                        CommTools.addsignature = false;
}
}
});
}
this.requestLayout();
}
и это связано с каким-то действием вверх, вниз и т. д.

Код: Выделить всё

 public void actionmethod(MotionEvent event) {
if (event.getPointerCount() >= 2) {
calculateMidPoint(event);
oldDistance = calculateDistance(event.getX(0), event.getY(0), event.getX(1), event.getY(1));
}
}

public void actiondown(MotionEvent event) {
if (event.getPointerCount() == 1) {
midPointToStartPoint(event);
lastLength = diagonalLength(event);
oldDistance = calculateDistance(getWidth() / 2F, getHeight() / 2F, event.getX(), event.getY());
Log.d("LMAO", "actiondown: 1");
if (isDeleteIconTouched(event.getX(), event.getY()))
deleteSignature();
isZoomingIn = isZoomIconTouched(event.getX(), event.getY());
if(isTouchingSignature(event.getX(), event.getY())){
isDraggingSignature = true;
lastX = event.getX();
lastY = event.getY();
}
}
}
public void acttionmove(MotionEvent event) {
if (isZoomingIn && event.getPointerCount() == 1) {
zoomSignature(event);

} else if (isDraggingSignature && event.getPointerCount() == 1) {
float dx = event.getX() - lastX;
float dy = event.getY() - lastY;
translateSignature(dx, dy);
lastX = event.getX();
lastY = event.getY();
}
}

public void actionup(MotionEvent event) {
isDraggingSignature = false;
isZoomingIn = false;
}
private boolean isDeleteIconTouched(float x, float y) {
float top = this.getTop();
if (top = scaledLeft && x = scaledTop &&  y  right) right = point.x;
if (point.y > bottom) bottom = point.y;
}
}

return new RectF(left, top, right, bottom);
}

public static Bitmap getBitmapFromDrawable(Drawable drawable) {
if (drawable == null) {
return null;
}
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable) drawable).getBitmap();
}
Bitmap bitmap;
if (drawable.getIntrinsicWidth()  {
float newX = midX + (point.x - midX) * zoomFactor;
float newY = midY + (point.y - midY) * zoomFactor;
point.set(newX, newY);  // Update point coordinates
});
}

if (mSearchView != null) {
mSearchView.invalidate();
}
}
}
private float rotationToStartPoint(MotionEvent event) {

float[] arrayOfFloat = new float[9];
matrix.getValues(arrayOfFloat);
float x = 0.0f * arrayOfFloat[0] + 0.0f * arrayOfFloat[1] + arrayOfFloat[2];
float y = 0.0f * arrayOfFloat[3] + 0.0f * arrayOfFloat[4] + arrayOfFloat[5];
double arc = Math.atan2(event.getY(0) - y, event.getX(0) - x);
return (float) Math.toDegrees(arc);
}

private void midPointToStartPoint(MotionEvent event) {
float[] arrayOfFloat = new float[9];
matrix.getValues(arrayOfFloat);
float f1 = 0.0f * arrayOfFloat[0] + 0.0f * arrayOfFloat[1] + arrayOfFloat[2];
float f2 = 0.0f * arrayOfFloat[3] + 0.0f * arrayOfFloat[4] + arrayOfFloat[5];
float f3 = f1 + event.getX(0);
float f4 = f2 + event.getY(0);
mid.set(f3 / 2, f4 / 2);
}
private float diagonalLength(MotionEvent event) {
float dx = event.getX() - mid.x;
float dy = event.getY() - mid.y;
return (float) Math.hypot(dx, dy);
}
protected float calculateDistance(float x1, float y1, float x2, float y2) {
float dx = x1 - x2;
float dy = y1 - y2;
return (float) Math.sqrt(dx * dx + dy * dy);
}

protected void calculateMidPoint(@Nullable MotionEvent event) {
if (event == null || event.getPointerCount() < 2) {
midPoints.set(0, 0);
return;
}
float x = (event.getX(0) + event.getX(1)) / 2;
float y = (event.getY(0) + event.getY(1)) / 2;
midPoints.set(x, y);
}
private void rotateSignature(MotionEvent event) {
if (signaturePoints != null && event.getPointerCount() == 1) {
float midX = boundingBox.centerX();
float midY = boundingBox.centerY();

float dx = event.getX() - midX;
float dy = event.getY() - midY;
float distance = (float) Math.hypot(dx, dy);
float rotationAngle = (dx > 0 ? 1 : -1) * distance / 50; // Adjust rotation speed

// Update the cumulative rotation angle
lastRotationAngle += rotationAngle;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
signaturePoints.stream()
.flatMap(Collection::stream)
.forEach(point -> {
float x = point.x - midX;
float y = point.y - midY;
float newX = (float) (x * Math.cos(Math.toRadians(lastRotationAngle)) - y * Math.sin(Math.toRadians(lastRotationAngle))) + midX;
float newY = (float) (x * Math.sin(Math.toRadians(lastRotationAngle)) + y * Math.cos(Math.toRadians(lastRotationAngle))) + midY;
point.set(newX, newY);
});
}

// Rotate the bounding box points
float[] boundingBoxPoints = {
boundingBox.left, boundingBox.top,
boundingBox.right, boundingBox.top,
boundingBox.right, boundingBox.bottom,
boundingBox.left, boundingBox.bottom
};

for (int i = 0; i < boundingBoxPoints.length; i += 2) {
float x = boundingBoxPoints[i] - midX;
float y = boundingBoxPoints[i + 1] - midY;
boundingBoxPoints[i] = (float) (x * Math.cos(Math.toRadians(lastRotationAngle)) - y * Math.sin(Math.toRadians(lastRotationAngle))) + midX;
boundingBoxPoints[i + 1] = (float) (x * Math.sin(Math.toRadians(lastRotationAngle)) + y * Math.cos(Math.toRadians(lastRotationAngle))) + midY;
}

boundingBox.set(
boundingBoxPoints[0], boundingBoxPoints[1],
boundingBoxPoints[4], boundingBoxPoints[5]
);

if (mSearchView != null) {
mSearchView.invalidate();
}
}
}
Надеюсь, вы поможете, я могу предоставить вам свой репозиторий, если хотите


Подробнее здесь: https://stackoverflow.com/questions/787 ... mupdf-page
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Цифровая подпись с PoinF на странице mupdf
    Anonymous » » в форуме Android
    0 Ответы
    9 Просмотры
    Последнее сообщение Anonymous
  • Цифровая подпись eBay для Restful API/подпись базы подписи с заданным закрытым ключом на C#
    Anonymous » » в форуме C#
    0 Ответы
    47 Просмотры
    Последнее сообщение Anonymous
  • Itextpdf Знак «Цифровая подпись…»
    Anonymous » » в форуме JAVA
    0 Ответы
    21 Просмотры
    Последнее сообщение Anonymous
  • Цифровая подпись Itext7 не видна
    Anonymous » » в форуме C#
    0 Ответы
    25 Просмотры
    Последнее сообщение Anonymous
  • Цифровая подпись дайджеста PDF в подписанный хэш pkcs7 с помощью AWS CloudHSM
    Anonymous » » в форуме JAVA
    0 Ответы
    25 Просмотры
    Последнее сообщение Anonymous

Вернуться в «JAVA»