SSTVEncoder2/app/src/main/java/om/sstvencoder/TextOverlay/Label.java

141 lines
3.3 KiB
Java
Raw Normal View History

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;
import java.lang.reflect.Field;
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;
public static final float OUTLINE_SIZE_NORMAL = 0.05f;
public static final String DEFAULT_FONT = "Default";
2017-01-03 18:32:45 +01:00
private String mText;
private float mTextSize, mOutlineSize;
2017-01-03 18:32:45 +01:00
private String mFamilyName;
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;
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;
}
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;
}
public boolean getOutline() {
return mOutline;
}
public void setOutline(boolean outline) {
mOutline = outline;
}
public float getOutlineSize() {
return mOutlineSize;
}
public void setOutlineSize(float size) {
mOutlineSize = size;
}
public int getOutlineColor() {
return mOutlineColor;
}
public void setOutlineColor(int color) {
mOutlineColor = color;
}
public Label getClone() {
Label clone = new Label();
try {
for (Field field : getClass().getDeclaredFields()) {
if (!Modifier.isFinal(field.getModifiers()))
field.set(clone, field.get(this));
}
} catch (Exception ignore) {
}
return clone;
}
2017-01-03 18:32:45 +01:00
}