2
* Braille Utils (C) 2010-2011 Daisy Consortium
4
* This library is free software; you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License as published by the Free
6
* Software Foundation; either version 2.1 of the License, or (at your option)
9
* This library is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
* You should have received a copy of the GNU Lesser General Public License
15
* along with this library; if not, write to the Free Software Foundation, Inc.,
16
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
import java.io.OutputStream;
22
import org.daisy.braille.embosser.BufferedVolumeEmbosser;
23
import org.daisy.braille.embosser.EmbosserFactoryException;
24
import org.daisy.braille.embosser.EmbosserTools;
25
import org.daisy.braille.embosser.EmbosserWriter;
26
import org.daisy.braille.embosser.SimpleEmbosserProperties;
27
import org.daisy.braille.embosser.StandardLineBreaks;
28
import org.daisy.braille.table.Table;
29
import org.daisy.braille.table.TableCatalog;
30
import org.daisy.paper.Area;
31
import org.daisy.paper.PageFormat;
32
import org.daisy.paper.PrintPage;
33
import org.daisy.paper.PrintPage.PrintDirection;
34
import org.daisy.printing.Device;
36
import com_braillo.Braillo440VolumeWriter.Mode;
37
import com_braillo.BrailloEmbosserProvider.EmbosserType;
39
public abstract class AbstractBraillo440Embosser extends BrailloEmbosser {
43
private static final long serialVersionUID = 3735464395595074473L;
44
private final static double cellWidth = 19*EmbosserTools.INCH_IN_MM/80d; //6;
45
private final static double cellHeight = 10;
46
private final static double constant = 11*EmbosserTools.INCH_IN_MM/80d;
48
protected boolean saddleStitchEnabled;
50
public AbstractBraillo440Embosser(String name, String desc, Enum<? extends Enum<?>> identifier) {
51
super(name, desc, identifier);
52
saddleStitchEnabled = false;
53
setCellWidth(cellWidth);
57
public boolean supportsPrintPage(PrintPage dim) {
58
int width = (int)Math.floor((dim.getWidth()+constant-EmbosserTools.INCH_IN_MM) / cellWidth);
59
int inchHeight = (int)Math.ceil(dim.getHeight()/EmbosserTools.INCH_IN_MM);
60
if (width > 44 || inchHeight > 13 || width < 10) {
67
public EmbosserWriter newEmbosserWriter(OutputStream os) {
68
throw new IllegalArgumentException(new EmbosserFactoryException(getDisplayName() + " does not support writing to file."));
72
public EmbosserWriter newEmbosserWriter(Device device) {
73
TableCatalog btb = TableCatalog.newInstance();
74
Table tc = btb.get(setTable.getIdentifier());
75
tc.setFeature("fallback", getFeature("fallback"));
76
tc.setFeature("replacement", getFeature("replacement"));
77
Braillo440VolumeWriter bvw;
78
EmbosserType t = EmbosserType.valueOf(getIdentifier().substring(1+getIdentifier().lastIndexOf('.')));
79
PrintPage printPage = getPrintPage(getPageFormat());
80
int width = (int)Math.floor((printPage.getWidth()+constant-EmbosserTools.INCH_IN_MM) / cellWidth);
81
int height = EmbosserTools.getHeight(printPage, cellHeight);
82
double columnWidthMM = width * cellWidth - constant;
83
if (t==EmbosserType.BRAILLO_440_SW && saddleStitchEnabled) {
84
bvw = new Braillo440VolumeWriter(printPage, Mode.SW_FOUR_PAGE, width, height, columnWidthMM);
85
} else if (t==EmbosserType.BRAILLO_440_SW) {
86
bvw = new Braillo440VolumeWriter(printPage, Mode.SW_TWO_PAGE, width, height, columnWidthMM);
87
} else if (t==EmbosserType.BRAILLO_440_SWSF) {
88
bvw = new Braillo440VolumeWriter(printPage, Mode.SWSF, width, height, columnWidthMM);
90
throw new RuntimeException("Unexpected error.");
93
* public boolean supports8dot() {return false;}
95
public boolean supportsAligning() { return true;}
97
public boolean supportsDuplex() {return true;}
99
public int getMaxHeight() {return height; }
100
public int getMaxWidth() { return width;}
102
SimpleEmbosserProperties ep = new SimpleEmbosserProperties(width, height)
104
.supportsAligning(true)
105
.supportsDuplex(true);
106
BufferedVolumeEmbosser.Builder b = new BufferedVolumeEmbosser.Builder(device, tc.newBrailleConverter(), bvw, ep)
107
.breaks(new StandardLineBreaks(StandardLineBreaks.Type.DOS))
108
.padNewline(BufferedVolumeEmbosser.Padding.NONE) // JH100408: changed from BEFORE
109
.autoLineFeedOnEmptyPage(true);
113
public int getMaxWidth(Paper paper) {
114
return (int)Math.floor((paper.getWidth()+constant-EmbosserTools.INCH_IN_MM) / getCellWidth());
117
public boolean supports8dot() {
121
public boolean supportsDuplex() {
125
public boolean supportsAligning() {
129
public boolean supportsVolumes() {
133
public PrintPage getPrintPage(PageFormat pageFormat) {
134
return new PrintPage(pageFormat,
135
PrintDirection.SIDEWAYS,
136
(saddleStitchEnabled?PrintMode.MAGAZINE:PrintMode.REGULAR)
140
public Area getPrintableArea(PageFormat pageFormat) {
141
PrintPage printPage = getPrintPage(pageFormat);
142
return new Area(printPage.getWidth(), printPage.getHeight(), 0, 0);
145
public boolean supportsZFolding() {