1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 17:59:33 +02:00

obsolete code

This commit is contained in:
Nikolay Pultsin 2014-06-06 03:12:30 +01:00
parent fb574f159a
commit 8a0c09c934
7 changed files with 79 additions and 200 deletions

View file

@ -296,12 +296,12 @@ public class PreferenceActivity extends ZLPreferenceActivity {
continue;
}
final ZLTextFullStyleDecoration decoration = collection.getDecoration(styles[i]);
final ZLTextStyleDecoration decoration = collection.getDecoration(styles[i]);
if (decoration == null) {
continue;
}
final Screen formatScreen = moreStylesScreen.createPreferenceScreen(decoration.getName());
final Screen formatScreen = moreStylesScreen.createPreferenceScreen(decoration.Name);
formatScreen.addPreference(new FontPreference(
this, textScreen.Resource, "font",
decoration.FontFamilyOption, true

View file

@ -151,22 +151,16 @@ abstract class ZLTextViewBase extends ZLView {
private void applyControl(ZLTextControlElement control) {
if (control.IsStart) {
final ZLTextHyperlink hyperlink = control instanceof ZLTextHyperlinkControlElement
? ((ZLTextHyperlinkControlElement)control).Hyperlink : null;
final ZLTextNGStyleDescription description =
getTextStyleCollection().getDescription(control.Kind);
if (description != null) {
if (control instanceof ZLTextHyperlinkControlElement) {
setTextStyle(new ZLTextNGStyle(myTextStyle, description, ((ZLTextHyperlinkControlElement)control).Hyperlink));
} else {
setTextStyle(new ZLTextNGStyle(myTextStyle, description, null));
}
setTextStyle(new ZLTextNGStyle(myTextStyle, description, hyperlink));
} else {
final ZLTextStyleDecoration decoration =
getTextStyleCollection().getDecoration(control.Kind);
if (control instanceof ZLTextHyperlinkControlElement) {
setTextStyle(decoration.createDecoratedStyle(myTextStyle, ((ZLTextHyperlinkControlElement)control).Hyperlink));
} else {
setTextStyle(decoration.createDecoratedStyle(myTextStyle));
}
setTextStyle(new ZLTextSimpleDecoratedStyle(myTextStyle, decoration, hyperlink));
}
} else {
setTextStyle(myTextStyle.Parent);

View file

@ -1,55 +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 ZLTextFullStyleDecoration extends ZLTextStyleDecoration {
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 ZLTextFullStyleDecoration(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 verticalShift, byte alignment, int lineSpace, ZLBoolean3 allowHyphenations) {
super(name, fontFamily, fontSizeDelta, bold, italic, underline, strikeThrough, verticalShift, 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);
}
@Override
public ZLTextStyle createDecoratedStyle(ZLTextStyle base, ZLTextHyperlink hyperlink) {
return new ZLTextFullyDecoratedStyle(base, this, hyperlink);
}
}

View file

@ -1,71 +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.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 ZLTextFullyDecoratedStyle extends ZLTextPartiallyDecoratedStyle {
private final ZLTextFullStyleDecoration myFullDecoration;
ZLTextFullyDecoratedStyle(ZLTextStyle parent, ZLTextFullStyleDecoration decoration, ZLTextHyperlink hyperlink) {
super(parent, decoration, hyperlink);
myFullDecoration = decoration;
}
@Override
public int getLeftIndent() {
return Parent.getLeftIndent() + myFullDecoration.LeftIndentOption.getValue();
}
@Override
public int getRightIndent() {
return Parent.getRightIndent() + myFullDecoration.RightIndentOption.getValue();
}
@Override
public int getFirstLineIndentDelta() {
return (getAlignment() == ZLTextAlignmentType.ALIGN_CENTER) ? 0 : Parent.getFirstLineIndentDelta() + myFullDecoration.FirstLineIndentDeltaOption.getValue();
}
@Override
public int getLineSpacePercent() {
int value = myFullDecoration.LineSpacePercentOption.getValue();
return (value != -1) ? value : Parent.getLineSpacePercent();
}
@Override
protected int getSpaceBeforeInternal(ZLTextMetrics metrics, int fontSize) {
return myFullDecoration.SpaceBeforeOption.getValue();
}
@Override
protected int getSpaceAfterInternal(ZLTextMetrics metrics, int fontSize) {
return myFullDecoration.SpaceAfterOption.getValue();
}
@Override
public byte getAlignment() {
byte value = (byte)myFullDecoration.AlignmentOption.getValue();
return (value == ZLTextAlignmentType.ALIGN_UNDEFINED) ? Parent.getAlignment() : value;
}
}

View file

@ -23,14 +23,15 @@ 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.ZLTextStyle;
import org.geometerplus.zlibrary.text.view.ZLTextHyperlink;
import org.geometerplus.zlibrary.text.view.ZLTextStyle;
class ZLTextPartiallyDecoratedStyle extends ZLTextDecoratedStyle {
private final ZLTextStyleDecoration myDecoration;
public class ZLTextSimpleDecoratedStyle extends ZLTextDecoratedStyle {
protected final ZLTextStyleDecoration myDecoration;
ZLTextPartiallyDecoratedStyle(ZLTextStyle parent, ZLTextStyleDecoration decoration, ZLTextHyperlink hyperlink) {
public ZLTextSimpleDecoratedStyle(ZLTextStyle parent, ZLTextStyleDecoration decoration, ZLTextHyperlink hyperlink) {
super(parent, hyperlink);
myDecoration = decoration;
}
@ -57,6 +58,11 @@ class ZLTextPartiallyDecoratedStyle extends ZLTextDecoratedStyle {
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()) {
@ -105,46 +111,6 @@ class ZLTextPartiallyDecoratedStyle extends ZLTextDecoratedStyle {
}
}
@Override
public int getLeftIndent() {
return Parent.getLeftIndent();
}
@Override
public int getRightIndent() {
return Parent.getRightIndent();
}
@Override
public int getFirstLineIndentDelta() {
return Parent.getFirstLineIndentDelta();
}
@Override
public int getLineSpacePercent() {
return Parent.getLineSpacePercent();
}
@Override
protected int getVerticalAlignInternal(ZLTextMetrics metrics, int fontSize) {
return Parent.getVerticalAlign(metrics) + myDecoration.VerticalAlignOption.getValue();
}
@Override
protected int getSpaceBeforeInternal(ZLTextMetrics metrics, int fontSize) {
return Parent.getSpaceBefore(metrics);
}
@Override
protected int getSpaceAfterInternal(ZLTextMetrics metrics, int fontSize) {
return Parent.getSpaceAfter(metrics);
}
@Override
public byte getAlignment() {
return Parent.getAlignment();
}
@Override
public boolean allowHyphenations() {
switch (myDecoration.AllowHyphenationsOption.getValue()) {
@ -156,4 +122,41 @@ class ZLTextPartiallyDecoratedStyle extends ZLTextDecoratedStyle {
return Parent.allowHyphenations();
}
}
@Override
public int getLeftIndent() {
return Parent.getLeftIndent() + myDecoration.LeftIndentOption.getValue();
}
@Override
public int getRightIndent() {
return Parent.getRightIndent() + myDecoration.RightIndentOption.getValue();
}
@Override
public int getFirstLineIndentDelta() {
return (getAlignment() == ZLTextAlignmentType.ALIGN_CENTER) ? 0 : Parent.getFirstLineIndentDelta() + 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

@ -32,7 +32,7 @@ public class ZLTextStyleCollection {
private int myDefaultFontSize;
private ZLTextBaseStyle myBaseStyle;
private final ZLTextNGStyleDescription[] myDescriptionMap = new ZLTextNGStyleDescription[256];
private final ZLTextFullStyleDecoration[] myDecorationMap = new ZLTextFullStyleDecoration[256];
private final ZLTextStyleDecoration[] myDecorationMap = new ZLTextStyleDecoration[256];
public ZLTextStyleCollection(String screen) {
Screen = screen;
@ -56,7 +56,7 @@ public class ZLTextStyleCollection {
return myDescriptionMap[kind & 0xFF];
}
public ZLTextFullStyleDecoration getDecoration(byte kind) {
public ZLTextStyleDecoration getDecoration(byte kind) {
return myDecorationMap[kind & 0xFF];
}
@ -138,7 +138,7 @@ public class ZLTextStyleCollection {
}
final int lineSpacePercent = intValue(attributes, "lineSpacingPercent", -1);
myDecorationMap[id & 0xFF] = new ZLTextFullStyleDecoration(name, null, fontSizeDelta, bold, italic, ZLBoolean3.B3_UNDEFINED, ZLBoolean3.B3_UNDEFINED, spaceBefore, spaceAfter, leftIndent, rightIndent, firstLineIndentDelta, 0, alignment, lineSpacePercent, allowHyphenations);
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

@ -25,8 +25,11 @@ import org.geometerplus.zlibrary.core.options.*;
import org.geometerplus.zlibrary.text.view.ZLTextStyle;
import org.geometerplus.zlibrary.text.view.ZLTextHyperlink;
public class ZLTextStyleDecoration {
static final String STYLE = "Style";
private static final String STYLE = "Style";
public final String Name;
public final ZLStringOption FontFamilyOption;
public final ZLIntegerRangeOption FontSizeDeltaOption;
@ -37,10 +40,19 @@ public class ZLTextStyleDecoration {
public final ZLIntegerOption VerticalAlignOption;
public final ZLBoolean3Option AllowHyphenationsOption;
private final String myName;
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;
public ZLTextStyleDecoration(String name, String fontFamily, int fontSizeDelta, ZLBoolean3 bold, ZLBoolean3 italic, ZLBoolean3 underline, ZLBoolean3 strikeThrough, int verticalAlign, ZLBoolean3 allowHyphenations) {
myName = name;
FontFamilyOption = new ZLStringOption(STYLE, name + ":fontFamily", fontFamily);
FontSizeDeltaOption = new ZLIntegerRangeOption(STYLE, name + ":fontSize", -16, 16, fontSizeDelta);
BoldOption = new ZLBoolean3Option(STYLE, name + ":bold", bold);
@ -49,17 +61,13 @@ public class ZLTextStyleDecoration {
StrikeThroughOption = new ZLBoolean3Option(STYLE, name + ":strikeThrough", strikeThrough);
VerticalAlignOption = new ZLIntegerOption(STYLE, name + ":vShift", verticalAlign);
AllowHyphenationsOption = new ZLBoolean3Option(STYLE, name + ":allowHyphenations", allowHyphenations);
}
public ZLTextStyle createDecoratedStyle(ZLTextStyle base) {
return createDecoratedStyle(base, null);
}
public ZLTextStyle createDecoratedStyle(ZLTextStyle base, ZLTextHyperlink hyperlink) {
return new ZLTextPartiallyDecoratedStyle(base, this, hyperlink);
}
public String getName() {
return myName;
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);
}
}