1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 18:29:23 +02:00

removed obsolete code

This commit is contained in:
Nikolay Pultsin 2014-06-06 07:41:52 +01:00
parent dcc0ec8f09
commit 4fb33dc945
5 changed files with 10 additions and 335 deletions

View file

@ -255,32 +255,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
final Screen moreStylesScreen = textScreen.createPreferenceScreen("more");
byte styles[] = {
FBTextKind.REGULAR,
//FBTextKind.XHTML_TAG_P,
//FBTextKind.TITLE,
//FBTextKind.SECTION_TITLE,
//FBTextKind.SUBTITLE,
//FBTextKind.H1,
//FBTextKind.H2,
//FBTextKind.H3,
//FBTextKind.H4,
//FBTextKind.H5,
//FBTextKind.H6,
FBTextKind.ANNOTATION,
FBTextKind.EPIGRAPH,
FBTextKind.AUTHOR,
FBTextKind.POEM_TITLE,
//FBTextKind.STANZA,
FBTextKind.VERSE,
//FBTextKind.CITE,
};
for (int i = 0; i < styles.length; ++i) {
final ZLTextStyleDecoration decoration = collection.getDecoration(styles[i]);
if (decoration == null) {
continue;
}
/*
final Screen formatScreen = moreStylesScreen.createPreferenceScreen(decoration.Name);
formatScreen.addPreference(new FontPreference(
this, textScreen.Resource, "font",
@ -349,7 +324,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
this, textScreen.Resource, "lineSpacing",
spacePercentOption, spacingValues, spacingKeys
));
}
*/
for (ZLTextNGStyleDescription description : collection.getDescriptionList()) {
final Screen ngScreen = moreStylesScreen.createPreferenceScreen(description.Name);

View file

@ -157,10 +157,6 @@ abstract class ZLTextViewBase extends ZLView {
getTextStyleCollection().getDescription(control.Kind);
if (description != null) {
setTextStyle(new ZLTextNGStyle(myTextStyle, description, hyperlink));
} else {
final ZLTextStyleDecoration decoration =
getTextStyleCollection().getDecoration(control.Kind);
setTextStyle(new ZLTextSimpleDecoratedStyle(myTextStyle, decoration, hyperlink));
}
} else {
setTextStyle(myTextStyle.Parent);

View file

@ -1,162 +0,0 @@
/*
* Copyright (C) 2007-2014 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
package org.geometerplus.zlibrary.text.view.style;
import java.util.List;
import java.util.ArrayList;
import org.geometerplus.zlibrary.core.fonts.FontEntry;
import org.geometerplus.zlibrary.text.model.ZLTextAlignmentType;
import org.geometerplus.zlibrary.text.model.ZLTextMetrics;
import org.geometerplus.zlibrary.text.view.ZLTextHyperlink;
import org.geometerplus.zlibrary.text.view.ZLTextStyle;
public class ZLTextSimpleDecoratedStyle extends ZLTextDecoratedStyle {
protected final ZLTextStyleDecoration myDecoration;
public ZLTextSimpleDecoratedStyle(ZLTextStyle parent, ZLTextStyleDecoration decoration, ZLTextHyperlink hyperlink) {
super(parent, hyperlink);
myDecoration = decoration;
}
@Override
protected List<FontEntry> getFontEntriesInternal() {
final List<FontEntry> parentEntries = Parent.getFontEntries();
final String decoratedValue = myDecoration.FontFamilyOption.getValue();
if ("".equals(decoratedValue)) {
return parentEntries;
}
final FontEntry e = FontEntry.systemEntry(decoratedValue);
if (e.equals(parentEntries.get(parentEntries.size() - 1))) {
return parentEntries;
}
final List<FontEntry> entries = new ArrayList<FontEntry>(parentEntries.size() + 1);
entries.add(e);
entries.addAll(parentEntries);
return entries;
}
@Override
protected int getFontSizeInternal(ZLTextMetrics metrics) {
return Parent.getFontSize(metrics) + myDecoration.FontSizeDeltaOption.getValue();
}
@Override
protected int getVerticalAlignInternal(ZLTextMetrics metrics, int fontSize) {
return Parent.getVerticalAlign(metrics) + myDecoration.VerticalAlignOption.getValue();
}
@Override
protected boolean isBoldInternal() {
switch (myDecoration.BoldOption.getValue()) {
case B3_TRUE:
return true;
case B3_FALSE:
return false;
default:
return Parent.isBold();
}
}
@Override
protected boolean isItalicInternal() {
switch (myDecoration.ItalicOption.getValue()) {
case B3_TRUE:
return true;
case B3_FALSE:
return false;
default:
return Parent.isItalic();
}
}
@Override
protected boolean isUnderlineInternal() {
switch (myDecoration.UnderlineOption.getValue()) {
case B3_TRUE:
return true;
case B3_FALSE:
return false;
default:
return Parent.isUnderline();
}
}
@Override
protected boolean isStrikeThroughInternal() {
switch (myDecoration.StrikeThroughOption.getValue()) {
case B3_TRUE:
return true;
case B3_FALSE:
return false;
default:
return Parent.isStrikeThrough();
}
}
@Override
public boolean allowHyphenations() {
switch (myDecoration.AllowHyphenationsOption.getValue()) {
case B3_FALSE:
return false;
case B3_TRUE:
return true;
default:
return Parent.allowHyphenations();
}
}
@Override
public int getLeftIndentInternal(ZLTextMetrics metrics, int fontSize) {
return Parent.getLeftIndent(metrics) + myDecoration.LeftIndentOption.getValue();
}
@Override
public int getRightIndentInternal(ZLTextMetrics metrics, int fontSize) {
return Parent.getRightIndent(metrics) + myDecoration.RightIndentOption.getValue();
}
@Override
public int getFirstLineIndentInternal(ZLTextMetrics metrics, int fontSize) {
return getAlignment() == ZLTextAlignmentType.ALIGN_CENTER ? 0 : Parent.getFirstLineIndent(metrics) + myDecoration.FirstLineIndentDeltaOption.getValue();
}
@Override
public int getLineSpacePercent() {
int value = myDecoration.LineSpacePercentOption.getValue();
return (value != -1) ? value : Parent.getLineSpacePercent();
}
@Override
protected int getSpaceBeforeInternal(ZLTextMetrics metrics, int fontSize) {
return myDecoration.SpaceBeforeOption.getValue();
}
@Override
protected int getSpaceAfterInternal(ZLTextMetrics metrics, int fontSize) {
return myDecoration.SpaceAfterOption.getValue();
}
@Override
public byte getAlignment() {
byte value = (byte)myDecoration.AlignmentOption.getValue();
return (value == ZLTextAlignmentType.ALIGN_UNDEFINED) ? Parent.getAlignment() : value;
}
}

View file

@ -33,7 +33,6 @@ public class ZLTextStyleCollection {
private ZLTextBaseStyle myBaseStyle;
private final List<ZLTextNGStyleDescription> myDescriptionList;
private final ZLTextNGStyleDescription[] myDescriptionMap = new ZLTextNGStyleDescription[256];
private final ZLTextStyleDecoration[] myDecorationMap = new ZLTextStyleDecoration[256];
public ZLTextStyleCollection(String screen) {
Screen = screen;
@ -64,10 +63,6 @@ public class ZLTextStyleCollection {
return myDescriptionMap[kind & 0xFF];
}
public ZLTextStyleDecoration getDecoration(byte kind) {
return myDecorationMap[kind & 0xFF];
}
private class TextStyleReader extends ZLXMLReaderAdapter {
private final int myDpi = ZLibrary.Instance().getDisplayDPI();
@ -77,78 +72,22 @@ public class ZLTextStyleCollection {
}
private int intValue(ZLStringMap attributes, String name, int defaultValue) {
int i = defaultValue;
String value = attributes.getValue(name);
final String value = attributes.getValue(name);
if (value != null) {
if (value.startsWith("dpi*")) {
try {
final float coe = Float.parseFloat(value.substring(4));
i = (int)(coe * myDpi + .5f);
} catch (NumberFormatException e) {
}
} else {
try {
i = Integer.parseInt(value);
return Integer.parseInt(value);
} catch (NumberFormatException e) {
}
}
}
return i;
}
private boolean booleanValue(ZLStringMap attributes, String name) {
return "true".equals(attributes.getValue(name));
}
private ZLBoolean3 b3Value(ZLStringMap attributes, String name) {
return ZLBoolean3.getByName(attributes.getValue(name));
return defaultValue;
}
@Override
public boolean startElementHandler(String tag, ZLStringMap attributes) {
final String BASE = "base";
final String STYLE = "style";
if (BASE.equals(tag)) {
if (Screen.equals(attributes.getValue("screen"))) {
if ("base".equals(tag) && Screen.equals(attributes.getValue("screen"))) {
myDefaultFontSize = intValue(attributes, "fontSize", 0);
myBaseStyle = new ZLTextBaseStyle(Screen, attributes.getValue("family"), myDefaultFontSize);
}
} else if (STYLE.equals(tag)) {
String idString = attributes.getValue("id");
String name = attributes.getValue("name");
if (idString != null && name != null) {
byte id = Byte.parseByte(idString);
final int fontSizeDelta = intValue(attributes, "fontSizeDelta", 0);
final ZLBoolean3 bold = b3Value(attributes, "bold");
final ZLBoolean3 italic = b3Value(attributes, "italic");
final ZLBoolean3 allowHyphenations = b3Value(attributes, "allowHyphenations");
int spaceBefore = intValue(attributes, "spaceBefore", 0);
int spaceAfter = intValue(attributes, "spaceAfter", 0);
int leftIndent = intValue(attributes, "leftIndent", 0);
int rightIndent = intValue(attributes, "rightIndent", 0);
int firstLineIndentDelta = intValue(attributes, "firstLineIndentDelta", 0);
byte alignment = ZLTextAlignmentType.ALIGN_UNDEFINED;
String alignmentString = attributes.getValue("alignment");
if (alignmentString != null) {
if (alignmentString.equals("left")) {
alignment = ZLTextAlignmentType.ALIGN_LEFT;
} else if (alignmentString.equals("right")) {
alignment = ZLTextAlignmentType.ALIGN_RIGHT;
} else if (alignmentString.equals("center")) {
alignment = ZLTextAlignmentType.ALIGN_CENTER;
} else if (alignmentString.equals("justify")) {
alignment = ZLTextAlignmentType.ALIGN_JUSTIFY;
}
}
final int lineSpacePercent = intValue(attributes, "lineSpacingPercent", -1);
myDecorationMap[id & 0xFF] = new ZLTextStyleDecoration(name, null, fontSizeDelta, bold, italic, ZLBoolean3.B3_UNDEFINED, ZLBoolean3.B3_UNDEFINED, spaceBefore, spaceAfter, leftIndent, rightIndent, firstLineIndentDelta, 0, alignment, lineSpacePercent, allowHyphenations);
}
}
return false;
}
}

View file

@ -1,73 +0,0 @@
/*
* Copyright (C) 2007-2014 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
package org.geometerplus.zlibrary.text.view.style;
import org.geometerplus.zlibrary.core.util.ZLBoolean3;
import org.geometerplus.zlibrary.core.options.*;
import org.geometerplus.zlibrary.text.view.ZLTextStyle;
import org.geometerplus.zlibrary.text.view.ZLTextHyperlink;
public class ZLTextStyleDecoration {
private static final String STYLE = "Style";
public final String Name;
public final ZLStringOption FontFamilyOption;
public final ZLIntegerRangeOption FontSizeDeltaOption;
public final ZLBoolean3Option BoldOption;
public final ZLBoolean3Option ItalicOption;
public final ZLBoolean3Option UnderlineOption;
public final ZLBoolean3Option StrikeThroughOption;
public final ZLIntegerOption VerticalAlignOption;
public final ZLBoolean3Option AllowHyphenationsOption;
public final ZLIntegerRangeOption SpaceBeforeOption;
public final ZLIntegerRangeOption SpaceAfterOption;
public final ZLIntegerRangeOption LeftIndentOption;
public final ZLIntegerRangeOption RightIndentOption;
public final ZLIntegerRangeOption FirstLineIndentDeltaOption;
public final ZLIntegerRangeOption AlignmentOption;
public final ZLIntegerOption LineSpacePercentOption;
public ZLTextStyleDecoration(String name, String fontFamily, int fontSizeDelta, ZLBoolean3 bold, ZLBoolean3 italic, ZLBoolean3 underline, ZLBoolean3 strikeThrough, int spaceBefore, int spaceAfter, int leftIndent,int rightIndent, int firstLineIndentDelta, int verticalAlign, byte alignment, int lineSpace, ZLBoolean3 allowHyphenations) {
Name = name;
FontFamilyOption = new ZLStringOption(STYLE, name + ":fontFamily", fontFamily);
FontSizeDeltaOption = new ZLIntegerRangeOption(STYLE, name + ":fontSize", -16, 16, fontSizeDelta);
BoldOption = new ZLBoolean3Option(STYLE, name + ":bold", bold);
ItalicOption = new ZLBoolean3Option(STYLE, name + ":italic", italic);
UnderlineOption = new ZLBoolean3Option(STYLE, name + ":underline", underline);
StrikeThroughOption = new ZLBoolean3Option(STYLE, name + ":strikeThrough", strikeThrough);
VerticalAlignOption = new ZLIntegerOption(STYLE, name + ":vShift", verticalAlign);
AllowHyphenationsOption = new ZLBoolean3Option(STYLE, name + ":allowHyphenations", allowHyphenations);
SpaceBeforeOption = new ZLIntegerRangeOption(STYLE, name + ":spaceBefore", -10, 100, spaceBefore);
SpaceAfterOption = new ZLIntegerRangeOption(STYLE, name + ":spaceAfter", -10, 100, spaceAfter);
LeftIndentOption = new ZLIntegerRangeOption(STYLE, name + ":leftIndent", -300, 300, leftIndent);
RightIndentOption = new ZLIntegerRangeOption(STYLE, name + ":rightIndent", -300, 300, rightIndent);
FirstLineIndentDeltaOption = new ZLIntegerRangeOption(STYLE, name + ":firstLineIndentDelta", -300, 300, firstLineIndentDelta);
AlignmentOption = new ZLIntegerRangeOption(STYLE, name + ":alignment", 0, 4, alignment);
LineSpacePercentOption = new ZLIntegerOption(STYLE, name + ":lineSpacePercent", lineSpace);
}
}