|
@@ -0,0 +1,337 @@
|
|
|
|
+/**
|
|
|
|
+ * Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
|
|
|
|
+ * <p>
|
|
|
|
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
|
|
|
|
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
|
|
|
|
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
|
|
|
|
+ * This notice may not be removed from this file.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+package com.compdfkit.tools.annotation.pdfproperties.pdfattr;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import android.content.Context;
|
|
|
|
+import android.os.Parcel;
|
|
|
|
+import android.os.Parcelable;
|
|
|
|
+
|
|
|
|
+import androidx.annotation.ColorInt;
|
|
|
|
+import androidx.annotation.ColorRes;
|
|
|
|
+import androidx.annotation.FloatRange;
|
|
|
|
+import androidx.annotation.IntRange;
|
|
|
|
+import androidx.core.content.ContextCompat;
|
|
|
|
+
|
|
|
|
+import com.compdfkit.core.annotation.CPDFLineAnnotation;
|
|
|
|
+import com.compdfkit.core.annotation.CPDFStampAnnotation;
|
|
|
|
+import com.compdfkit.core.annotation.CPDFTextAttribute;
|
|
|
|
+import com.compdfkit.tools.R;
|
|
|
|
+import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotationType;
|
|
|
|
+
|
|
|
|
+public class CAnnotStyle implements Parcelable {
|
|
|
|
+
|
|
|
|
+ private CAnnotationType type;
|
|
|
|
+
|
|
|
|
+ private int color;
|
|
|
|
+
|
|
|
|
+ private int colorAlpha;
|
|
|
|
+
|
|
|
|
+ private float borderWidth;
|
|
|
|
+
|
|
|
|
+ private int lineColor;
|
|
|
|
+
|
|
|
|
+ private int lineColorAlpha;
|
|
|
|
+
|
|
|
|
+ private int fillColor;
|
|
|
|
+
|
|
|
|
+ private int fillAlpha;
|
|
|
|
+
|
|
|
|
+ private CPDFLineAnnotation.LineType startLineType;
|
|
|
|
+
|
|
|
|
+ private CPDFLineAnnotation.LineType endLineType;
|
|
|
|
+
|
|
|
|
+ private boolean fontBold;
|
|
|
|
+
|
|
|
|
+ private boolean fontItalic;
|
|
|
|
+
|
|
|
|
+ private int textColor;
|
|
|
|
+
|
|
|
|
+ private int textColorAlpha;
|
|
|
|
+
|
|
|
|
+ private int fontSize;
|
|
|
|
+
|
|
|
|
+ private CPDFTextAttribute.FontNameHelper.FontType fontType;
|
|
|
|
+
|
|
|
|
+ private String imagePath;
|
|
|
|
+
|
|
|
|
+ private String textStampContent;
|
|
|
|
+
|
|
|
|
+ private String textStampDate;
|
|
|
|
+
|
|
|
|
+ private CPDFStampAnnotation.TextStampShape textStampShape;
|
|
|
|
+
|
|
|
|
+ private CPDFStampAnnotation.TextStampColor textStampColor;
|
|
|
|
+
|
|
|
|
+ public CAnnotStyle(CAnnotationType type) {
|
|
|
|
+ this.type = type;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected CAnnotStyle(Parcel in) {
|
|
|
|
+ color = in.readInt();
|
|
|
|
+ colorAlpha = in.readInt();
|
|
|
|
+ borderWidth = in.readFloat();
|
|
|
|
+ lineColor = in.readInt();
|
|
|
|
+ lineColorAlpha = in.readInt();
|
|
|
|
+ fillColor = in.readInt();
|
|
|
|
+ fillAlpha = in.readInt();
|
|
|
|
+ fontBold = in.readByte() != 0;
|
|
|
|
+ fontItalic = in.readByte() != 0;
|
|
|
|
+ textColor = in.readInt();
|
|
|
|
+ textColorAlpha = in.readInt();
|
|
|
|
+ fontSize = in.readInt();
|
|
|
|
+ imagePath = in.readString();
|
|
|
|
+ textStampContent = in.readString();
|
|
|
|
+ textStampDate = in.readString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void writeToParcel(Parcel dest, int flags) {
|
|
|
|
+ dest.writeInt(color);
|
|
|
|
+ dest.writeInt(colorAlpha);
|
|
|
|
+ dest.writeFloat(borderWidth);
|
|
|
|
+ dest.writeInt(lineColor);
|
|
|
|
+ dest.writeInt(lineColorAlpha);
|
|
|
|
+ dest.writeInt(fillColor);
|
|
|
|
+ dest.writeInt(fillAlpha);
|
|
|
|
+ dest.writeByte((byte) (fontBold ? 1 : 0));
|
|
|
|
+ dest.writeByte((byte) (fontItalic ? 1 : 0));
|
|
|
|
+ dest.writeInt(textColor);
|
|
|
|
+ dest.writeInt(textColorAlpha);
|
|
|
|
+ dest.writeInt(fontSize);
|
|
|
|
+ dest.writeString(imagePath);
|
|
|
|
+ dest.writeString(textStampContent);
|
|
|
|
+ dest.writeString(textStampDate);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public int describeContents() {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static final Creator<CAnnotStyle> CREATOR = new Creator<CAnnotStyle>() {
|
|
|
|
+ @Override
|
|
|
|
+ public CAnnotStyle createFromParcel(Parcel in) {
|
|
|
|
+ return new CAnnotStyle(in);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CAnnotStyle[] newArray(int size) {
|
|
|
|
+ return new CAnnotStyle[size];
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ public CAnnotationType getType() {
|
|
|
|
+ return type;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setType(CAnnotationType type) {
|
|
|
|
+ this.type = type;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getColor() {
|
|
|
|
+ return color;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setColor(@ColorInt int color) {
|
|
|
|
+ this.color = color;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setColor(Context context, @ColorRes int colorRes) {
|
|
|
|
+ this.color = ContextCompat.getColor(context, colorRes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getColorAlpha() {
|
|
|
|
+ return colorAlpha;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setColorAlpha(@IntRange(from = 0, to = 255) int colorAlpha) {
|
|
|
|
+ this.colorAlpha = colorAlpha;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public float getBorderWidth() {
|
|
|
|
+ return borderWidth;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setBorderWidth(@FloatRange(from = 0.0) float borderWidth) {
|
|
|
|
+ this.borderWidth = borderWidth;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getLineColor() {
|
|
|
|
+ return lineColor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setLineColor(@ColorInt int lineColor) {
|
|
|
|
+ this.lineColor = lineColor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setLineColor(Context context, @ColorRes int colorRes) {
|
|
|
|
+ this.lineColor = ContextCompat.getColor(context, colorRes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getLineColorAlpha() {
|
|
|
|
+ return lineColorAlpha;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setLineColorAlpha(@IntRange(from = 0, to = 255) int lineColorAlpha) {
|
|
|
|
+ this.lineColorAlpha = lineColorAlpha;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getFillColor() {
|
|
|
|
+ return fillColor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setFillColor(@ColorInt int fillColor) {
|
|
|
|
+ this.fillColor = fillColor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setFillColor(Context context, @ColorRes int colorRes) {
|
|
|
|
+ this.fillColor = ContextCompat.getColor(context, colorRes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getFillAlpha() {
|
|
|
|
+ return fillAlpha;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setFillAlpha(@IntRange(from = 0, to = 255) int fillAlpha) {
|
|
|
|
+ this.fillAlpha = fillAlpha;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public CPDFLineAnnotation.LineType getStartLineType() {
|
|
|
|
+ return startLineType;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setStartLineType(CPDFLineAnnotation.LineType startLineType) {
|
|
|
|
+ this.startLineType = startLineType;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public CPDFLineAnnotation.LineType getEndLineType() {
|
|
|
|
+ return endLineType;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setEndLineType(CPDFLineAnnotation.LineType endLineType) {
|
|
|
|
+ this.endLineType = endLineType;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public boolean isFontBold() {
|
|
|
|
+ return fontBold;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setFontBold(boolean fontBold) {
|
|
|
|
+ this.fontBold = fontBold;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public boolean isFontItalic() {
|
|
|
|
+ return fontItalic;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setFontItalic(boolean fontItalic) {
|
|
|
|
+ this.fontItalic = fontItalic;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getTextColor() {
|
|
|
|
+ return textColor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setTextColor(@ColorInt int textColor) {
|
|
|
|
+ this.textColor = textColor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setTextColor(Context context, @ColorRes int colorRes) {
|
|
|
|
+ this.textColor = ContextCompat.getColor(context, colorRes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getTextColorAlpha() {
|
|
|
|
+ return textColorAlpha;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setTextColorAlpha(@IntRange(from = 0, to = 255) int textColorAlpha) {
|
|
|
|
+ this.textColorAlpha = textColorAlpha;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getFontSize() {
|
|
|
|
+ return fontSize;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setFontSize(@IntRange(from = 0) int fontSize) {
|
|
|
|
+ this.fontSize = fontSize;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public CPDFTextAttribute.FontNameHelper.FontType getFontType() {
|
|
|
|
+ return fontType;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setFontType(CPDFTextAttribute.FontNameHelper.FontType fontType) {
|
|
|
|
+ this.fontType = fontType;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getImagePath() {
|
|
|
|
+ return imagePath;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setImagePath(String imagePath) {
|
|
|
|
+ this.imagePath = imagePath;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getTextStampContent() {
|
|
|
|
+ return textStampContent;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setTextStampContent(String textStampContent) {
|
|
|
|
+ this.textStampContent = textStampContent;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getTextStampDate() {
|
|
|
|
+ return textStampDate;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setTextStampDate(String textStampDate) {
|
|
|
|
+ this.textStampDate = textStampDate;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public CPDFStampAnnotation.TextStampShape getTextStampShape() {
|
|
|
|
+ return textStampShape;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setTextStampShape(CPDFStampAnnotation.TextStampShape textStampShape) {
|
|
|
|
+ this.textStampShape = textStampShape;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public CPDFStampAnnotation.TextStampColor getTextStampColor() {
|
|
|
|
+ return textStampColor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setTextStampColor(CPDFStampAnnotation.TextStampColor textStampColor) {
|
|
|
|
+ this.textStampColor = textStampColor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getAnnotTypeTitle(Context context) {
|
|
|
|
+ String title = "";
|
|
|
|
+ switch (type) {
|
|
|
|
+ case HIGHLIGHT:
|
|
|
|
+ title = context.getString(R.string.tools_annot_highlight);
|
|
|
|
+ break;
|
|
|
|
+ case STRIKEOUT:
|
|
|
|
+ title = context.getString(R.string.tools_annot_strikeout);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case UNDERLINE:
|
|
|
|
+ title = context.getString(R.string.tools_annot_underline);
|
|
|
|
+ break;
|
|
|
|
+ case SQUIGGLY:
|
|
|
|
+ title = context.getString(R.string.tools_annot_squiggly);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ title = "Not impt...";
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return title;
|
|
|
|
+ }
|
|
|
|
+}
|