2017-01-03 18:32:45 +01:00
|
|
|
/*
|
|
|
|
|
Copyright 2017 Olga Miller <olga.rgb@gmail.com>
|
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
package om.sstvencoder.TextOverlay;
|
|
|
|
|
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
2017-03-05 14:21:09 +01:00
|
|
|
import java.lang.reflect.Field;
|
2017-03-11 16:11:21 +01:00
|
|
|
import java.lang.reflect.Modifier;
|
2017-01-03 18:32:45 +01:00
|
|
|
|
|
|
|
|
public class Label implements Serializable {
|
2017-03-04 15:47:30 +01:00
|
|
|
public static final float TEXT_SIZE_NORMAL = 2f;
|
2017-03-04 16:02:17 +01:00
|
|
|
public static final float OUTLINE_SIZE_NORMAL = 0.05f;
|
2017-01-03 18:32:45 +01:00
|
|
|
private String mText;
|
2017-03-04 16:02:17 +01:00
|
|
|
private float mTextSize, mOutlineSize;
|
2017-01-03 18:32:45 +01:00
|
|
|
private String mFamilyName;
|
2017-03-04 16:02:17 +01:00
|
|
|
private boolean mBold, mItalic, mOutline;
|
|
|
|
|
private int mForeColor, mBackColor, mOutlineColor;
|
2017-01-03 18:32:45 +01:00
|
|
|
|
|
|
|
|
public Label() {
|
|
|
|
|
mText = "";
|
2017-03-04 15:47:30 +01:00
|
|
|
mTextSize = TEXT_SIZE_NORMAL;
|
2017-01-03 18:32:45 +01:00
|
|
|
mFamilyName = null;
|
|
|
|
|
mBold = true;
|
|
|
|
|
mItalic = false;
|
|
|
|
|
mForeColor = Color.BLACK;
|
|
|
|
|
mBackColor = Color.TRANSPARENT;
|
2017-03-04 16:02:17 +01:00
|
|
|
mOutline = true;
|
|
|
|
|
mOutlineSize = OUTLINE_SIZE_NORMAL;
|
|
|
|
|
mOutlineColor = Color.WHITE;
|
2017-01-03 18:32:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getText() {
|
|
|
|
|
return mText;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setText(String text) {
|
|
|
|
|
if (text != null)
|
|
|
|
|
mText = text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float getTextSize() {
|
|
|
|
|
return mTextSize;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-04 14:48:28 +01:00
|
|
|
public void setTextSize(float size) {
|
|
|
|
|
if (size > 0f)
|
|
|
|
|
mTextSize = size;
|
2017-01-03 18:32:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getFamilyName() {
|
|
|
|
|
return mFamilyName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFamilyName(String familyName) {
|
|
|
|
|
mFamilyName = familyName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean getBold() {
|
|
|
|
|
return mBold;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBold(boolean bold) {
|
|
|
|
|
mBold = bold;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean getItalic() {
|
|
|
|
|
return mItalic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setItalic(boolean italic) {
|
|
|
|
|
mItalic = italic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getForeColor() {
|
|
|
|
|
return mForeColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setForeColor(int color) {
|
|
|
|
|
mForeColor = color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getBackColor() {
|
|
|
|
|
return mBackColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBackColor(int color) {
|
|
|
|
|
mBackColor = color;
|
|
|
|
|
}
|
2017-03-04 14:48:28 +01:00
|
|
|
|
2017-03-04 16:02:17 +01:00
|
|
|
public boolean getOutline() {
|
|
|
|
|
return mOutline;
|
2017-03-04 14:48:28 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-04 16:02:17 +01:00
|
|
|
public void setOutline(boolean outline) {
|
|
|
|
|
mOutline = outline;
|
2017-03-04 14:48:28 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-04 16:02:17 +01:00
|
|
|
public float getOutlineSize() {
|
|
|
|
|
return mOutlineSize;
|
2017-03-04 14:48:28 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-04 16:02:17 +01:00
|
|
|
public void setOutlineSize(float size) {
|
|
|
|
|
mOutlineSize = size;
|
2017-03-04 14:48:28 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-04 16:02:17 +01:00
|
|
|
public int getOutlineColor() {
|
|
|
|
|
return mOutlineColor;
|
2017-03-04 14:48:28 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-04 16:02:17 +01:00
|
|
|
public void setOutlineColor(int color) {
|
|
|
|
|
mOutlineColor = color;
|
2017-03-04 14:48:28 +01:00
|
|
|
}
|
2017-03-05 14:21:09 +01:00
|
|
|
|
|
|
|
|
public Label getClone() {
|
|
|
|
|
Label clone = new Label();
|
|
|
|
|
try {
|
|
|
|
|
for (Field field : getClass().getDeclaredFields()) {
|
2017-03-11 16:11:21 +01:00
|
|
|
if (!Modifier.isFinal(field.getModifiers()))
|
|
|
|
|
field.set(clone, field.get(this));
|
2017-03-05 14:21:09 +01:00
|
|
|
}
|
|
|
|
|
} catch (Exception ignore) {
|
|
|
|
|
}
|
|
|
|
|
return clone;
|
|
|
|
|
}
|
2017-01-03 18:32:45 +01:00
|
|
|
}
|