diff --git a/.gitignore b/.gitignore index f930235d667b3385e9c0d64eccd425e3f1dc0d7e..36111bc1a41b6dd6012549b0af28a2848ee83581 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ build out *gradle* !build.gradle +!integrationTest.gradle # IntelliJ .idea diff --git a/build.gradle b/build.gradle index 07913862defdced45dbfe29afee8a5bb49cb2dd5..acf86f9c71d2b05cf613b6f2f7ee237d47df3d78 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ dependencies { compile "com.opencsv:opencsv:4.6" } -test { +tasks.withType(Test) { useJUnitPlatform() } @@ -60,7 +60,11 @@ jar { } } -checkstyleTest{ +checkstyleTest { showViolations = true checkstyleTest.enabled = false -} \ No newline at end of file +} + + // Needed for Integrationtests + +apply from: "$rootDir/integrationTest.gradle" \ No newline at end of file diff --git a/integrationTest.gradle b/integrationTest.gradle new file mode 100644 index 0000000000000000000000000000000000000000..a38fe5639576302fc3041ec0f312a7e7e822cbff --- /dev/null +++ b/integrationTest.gradle @@ -0,0 +1,17 @@ +sourceSets { + integrationTest { + java.srcDir 'src/integrationTest' + resources.srcDir 'src/test/resources' + compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath + runtimeClasspath += output + compileClasspath + } +} + +task integrationTest(type: Test) { + group = 'verification' + description = 'Runs Integrationtests.' + testClassesDirs = sourceSets.integrationTest.output.classesDirs + classpath = sourceSets.integrationTest.runtimeClasspath + mustRunAfter test + checkstyleIntegrationTest.enabled = false +} \ No newline at end of file diff --git a/src/integrationTest/java/PrintableDataExporterIntegTest.java b/src/integrationTest/java/PrintableDataExporterIntegTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5d887597aed7972e852c97e3c6d3e2acfeac750e --- /dev/null +++ b/src/integrationTest/java/PrintableDataExporterIntegTest.java @@ -0,0 +1,206 @@ +import de.tudresden.inf.mci.brailleplot.commandline.CommandLineParser; +import de.tudresden.inf.mci.brailleplot.commandline.SettingsReader; +import de.tudresden.inf.mci.brailleplot.commandline.SettingsWriter; +import de.tudresden.inf.mci.brailleplot.configparser.Format; +import de.tudresden.inf.mci.brailleplot.configparser.JavaPropertiesConfigurationParser; +import de.tudresden.inf.mci.brailleplot.configparser.Printer; +import de.tudresden.inf.mci.brailleplot.printerbackend.PrintDirector; +import de.tudresden.inf.mci.brailleplot.printerbackend.PrinterCapability; +import de.tudresden.inf.mci.brailleplot.printabledata.MatrixData; +import de.tudresden.inf.mci.brailleplot.printabledata.SimpleMatrixDataImpl; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import javax.print.DocFlavor; +import java.io.File; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * Integrationtests for the components PrintableData and Exporter. + * Because most of the Exporter Unit tests depend heavily on the packages PrintableData and configParser, + * these are also located here. Most, if not all unittests for the exporter are tested via Reflection. It is + * contestable if these tests are really needed, but the with more LOC Coverage, there comes more possible stability. + * @author Andrey Ruzhanskiy + * @version 30.07.2019 + */ + +public class PrintableDataExporterIntegTest { + + private static String[] args; + private static CommandLineParser cliParser; + private static SettingsWriter settings; + private static SettingsReader settingsReader; + private static Printer printer; + private static Format format; + private static MatrixData<Boolean> data; + + + /** + * Setup Method for testing the exporter package. + */ + @BeforeAll + public static void setUp() { + Assertions.assertDoesNotThrow(() -> { + String correct = getResource("config/correct.properties").getAbsolutePath(); + String standard = getResource("config/default.properties").getAbsolutePath(); + JavaPropertiesConfigurationParser configParser = new JavaPropertiesConfigurationParser(correct, standard); + printer = configParser.getPrinter(); + printer.getProperty("brailletable").toString(); + format = configParser.getFormat("A4"); + data = new SimpleMatrixDataImpl<>(printer, format, 18, 20, true); + }); + } + + public static File getResource(String fileName) { + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + File resourceFile = new File(classLoader.getResource(fileName).getFile()); + return resourceFile; + } + /** + * Unittest/Integrationtest for the private Print method with a Null Servive. + * Expected: Nullpointerexception. + */ + @Test + public void testPrivatePrintWithNullService() { + Assertions.assertThrows(NullPointerException.class, () -> { + Method privatePrint = PrintDirector.class.getDeclaredMethod("print", byte[].class); + privatePrint.setAccessible(true); + try { + privatePrint.invoke(new PrintDirector(PrinterCapability.NORMALPRINTER,printer), new byte[] {0x55}); + } catch (InvocationTargetException e) { + throw e.getTargetException(); + } + }); + } + + /** + * Unittest/Integrationtest for private print method with a null byte. + * Expected: Nullpointerexception. + */ + @Test + public void testPrivatePrintWithNullByte() { + Assertions.assertThrows(NullPointerException.class, () -> { + Method privatePrint = PrintDirector.class.getDeclaredMethod("print", byte[].class); + privatePrint.setAccessible(true); + try { + privatePrint.invoke(new PrintDirector(PrinterCapability.NORMALPRINTER,printer), (Object) null); + } catch (InvocationTargetException e) { + throw e.getTargetException(); + } + }); + } + + /** + * Unittest/Integrationtest for private print method with non existing Docflavour. + * Expected: Nullpointerexception. + */ + @Test + public void testPrivatePrintWithNoDocFlavour() { + Assertions.assertThrows(NullPointerException.class, () -> { + Method privatePrint = PrintDirector.class.getDeclaredMethod("print", byte[].class); + privatePrint.setAccessible(true); + Method setUpService = PrintDirector.class.getDeclaredMethod("setUpService"); + setUpService.setAccessible(true); + try { + PrintDirector printD = new PrintDirector(PrinterCapability.NORMALPRINTER,printer); + setUpService.invoke(printD); + privatePrint.invoke(printD, new byte[] {0x55}); + } catch (InvocationTargetException e) { + throw e.getTargetException(); + } + }); + } + + /** + * Unittest/Integrationtest for private print Method with non existing Printer. + * Expected: RuntimeException + */ + + @Test + public void testPrivateSetUpServiceWithNotExistentPrinter() { + Assertions.assertThrows(RuntimeException.class, () -> { + Method setUpService = PrintDirector.class.getDeclaredMethod("setUpService"); + setUpService.setAccessible(true); + Field mPrinterName = PrintDirector.class.getDeclaredField("mPrinterName"); + mPrinterName.setAccessible(true); + try { + PrintDirector printD = new PrintDirector(PrinterCapability.NORMALPRINTER, printer); + mPrinterName.set(printD, "please dont exist, please please please"); + setUpService.invoke(printD); + } catch (InvocationTargetException e) { + throw e.getTargetException(); + } + }); + } + + /** + * Unittest/Integrationtest for Method SetUpService with NullPrinter. + * Expected: Nullpointerexception. + */ + @Test + public void testPrivateSetUpServiceWithNullPrinter() { + Assertions.assertThrows(NullPointerException.class, () -> { + Method setUpService = PrintDirector.class.getDeclaredMethod("setUpService"); + setUpService.setAccessible(true); + Field mPrinterName = PrintDirector.class.getDeclaredField("mPrinterName"); + mPrinterName.setAccessible(true); + try { + PrintDirector printD = new PrintDirector(PrinterCapability.NORMALPRINTER, printer); + mPrinterName.set(printD, (Object)null); + setUpService.invoke(printD); + } catch (InvocationTargetException e) { + throw e.getTargetException(); + } + }); + } + + + /** + * Unittest/Integrationtest for setting a Wrong Doc Flavor and trying to print with it. + * Expected: RuntimeException. + */ + @Test + public void testWrongDocFlavor() { + Assertions.assertThrows(RuntimeException.class, () -> { + Field mDocflavor = PrintDirector.class.getDeclaredField("mDocflavor"); + mDocflavor.setAccessible(true); + PrintDirector printD = new PrintDirector(PrinterCapability.NORMALPRINTER, printer); + mDocflavor.set(printD, new DocFlavor("text/html", "[B")); + Method setUpService = PrintDirector.class.getDeclaredMethod("setUpService"); + setUpService.setAccessible(true); + Method privatePrint = PrintDirector.class.getDeclaredMethod("print", byte[].class); + privatePrint.setAccessible(true); + try { + setUpService.invoke(printD); + privatePrint.invoke(printD, new byte[] {0x50}); + } catch (InvocationTargetException e){ + throw e.getTargetException(); + } + }); + } + + // Positve Testcases + + @Test + public void testFloatingDotCapability() { + Assertions.assertDoesNotThrow(() -> { + PrintDirector printD = new PrintDirector(PrinterCapability.INDEX_EVEREST_D_V4_FLOATINGDOT_PRINTER, printer); + }); + } + + @Test + public void testGraphicPrintCapability() { + Assertions.assertDoesNotThrow(() -> { + PrintDirector printD = new PrintDirector(PrinterCapability.INDEX_EVEREST_D_V4_GRAPHIC_PRINTER, printer); + }); + } + + @Test + public void testIsPrintServiceOn() { + Assertions.assertTrue(PrintDirector.isPrintServiceOn()); + } +} diff --git a/src/integrationTest/resources/config/correct.properties b/src/integrationTest/resources/config/correct.properties new file mode 100644 index 0000000000000000000000000000000000000000..37a86c5180c0f857e12dbd66ca502b76bd806523 --- /dev/null +++ b/src/integrationTest/resources/config/correct.properties @@ -0,0 +1,69 @@ +# JProperties Printer & Format Configuration +# +# Embosser: Index Everest-D V4 +# Version 1 Rev. 8 (19-07-19) +# +# Description: +# This is the main configuration file for use with the braille plot application +# when embossing with the 'Index Everest-D V4'. +# The configuration specifies the general printer abilities and defines +# pre-selectable formats for this embosser. +# +# https://gitlab.hrz.tu-chemnitz.de/s9444737--tu-dresden.de/brailleplot/wikis/Software%20Design#configuration-files +# ============================================================================= + +### General Printer Properties +### ========================== + +printer.name=Dummy Printer +printer.mode=normalprinter +printer.brailletable=src/integrationTest/resources/mapping/eurobraille.properties +printer.floatingDot.support=true +printer.floatingDot.resolution=0.05 + +# The following values represent the fixed indentation and maximum technical printing area of the embosser. +# If the outputs don't fit on the page you might want to tweak this values. (Check the format too.) +printer.constraint.top=5.0 +printer.constraint.left=0 +#printer.constraint.width=? TODO: Check out manual, Conduct printing tests with bigger formats +#printer.constraint.height=? +# The second constraint in the printer.raster namespace helps to limit the available printing area in steps of +# whole cells, for example if the printer enforces a maximum char per line limit or borders are activated. +printer.raster.constraint.top=0 +printer.raster.constraint.left=1 +printer.raster.constraint.width=35 +printer.raster.constraint.height=29 + +# The following properties define the exact grid spacing. +printer.raster.cellDistance.horizontal=3.6 +printer.raster.cellDistance.vertical=4.8 +printer.raster.dotDistance.horizontal=2.5 +printer.raster.dotDistance.vertical=2.5 +printer.raster.dotDiameter=1.5 + +### Format Definitions +### ================== + +# A4 Format +format.A4.page.width=210 +format.A4.page.height=297 +format.A4.margin.top=0 +format.A4.margin.left=0 +format.A4.margin.bottom=0 +format.A4.margin.right=0 + +# A5 Format +format.A5.page.width=148 +format.A5.page.height=210 +format.A5.margin.top=0 +format.A5.margin.left=0 +format.A5.margin.bottom=0 +format.A5.margin.right=0 + +# Wide Format +format.wide.page.width=272 +format.wide.page.height=210 +format.wide.margin.top=0 +format.wide.margin.left=0 +format.wide.margin.bottom=0 +format.wide.margin.right=0 \ No newline at end of file diff --git a/src/integrationTest/resources/config/default.properties b/src/integrationTest/resources/config/default.properties new file mode 100644 index 0000000000000000000000000000000000000000..f6405e0725ba3b349f015066b619f4ce41847f52 --- /dev/null +++ b/src/integrationTest/resources/config/default.properties @@ -0,0 +1,55 @@ +# JProperties Printer & Format Configuration +# +# Embosser: Dummy Default +# Test Revision (19-07-18) (DON'T USE FOR PRINTING) +# +# Description: +# This is the default configuration file for the braille plot application. +# The configuration specifies the default values of required properties. +# +# https://gitlab.hrz.tu-chemnitz.de/s9444737--tu-dresden.de/brailleplot/wikis/Software%20Design#configuration-files +# ============================================================================= + +# ATTENTION: Changes to this configuration will affect settings for ALL printer and format definitions which +# are not overriding the defaults. + +printer.mode=normalprinter +printer.brailletable=src/test/resources/mapping/eurobraille.properties +printer.floatingDot.support=false + +# The following values represent the fixed indentation and maximum technical printing area of the embosser. +# If the outputs don't fit on the page you might want to tweak this values. (Check the format too.) +printer.constraint.top=0 +printer.constraint.left=0 +# The second constraint in the printer.raster namespace helps to limit the available printing area in steps of +# whole cells, for example if the printer enforces a maximum char per line limit or borders are activated. +printer.raster.constraint.top=0 +printer.raster.constraint.left=0 +printer.raster.constraint.width=200 +printer.raster.constraint.height=300 + +# Overall grid layout / type +printer.raster.type=6-dot + +# The following properties define the exact grid spacing. Standard values based on the +# 'Marburg Medium' publication standard as described in the FFI braille technical guideline: +# https://www.ffi.de/assets/Uploads/Technische-Richtlinie-Blindenschrift.pdf +# See also: # https://codes.iccsafe.org/content/ICCA117_12003/chapter-7-communication-elements-and-features#ICCA117.1_2003_Ch07_Sec703 +printer.raster.cellDistance.horizontal=3.5 +printer.raster.cellDistance.vertical=5.0 +printer.raster.dotDistance.horizontal=2.5 +printer.raster.dotDistance.vertical=2.5 +printer.raster.dotDiameter=1.5 + + +### Format Definitions +### ================== + +# Default Format Definition +format.default.page.height=297 +format.default.margin.top=10 +format.default.margin.left=10 +format.default.margin.bottom=10 +format.default.margin.right=10 + +# This is a template. Do not define concrete formats in this file. Use the specific user config file for this purpose. \ No newline at end of file diff --git a/src/integrationTest/resources/config/false.properties b/src/integrationTest/resources/config/false.properties new file mode 100644 index 0000000000000000000000000000000000000000..4f0fc93c70d3dc2567a3a1eabaab26b299b5a313 --- /dev/null +++ b/src/integrationTest/resources/config/false.properties @@ -0,0 +1,69 @@ +# JProperties Printer & Format Configuration +# +# Embosser: Index Everest-D V4 +# Version 1 Rev. 8 (19-07-19) +# +# Description: +# This is the main configuration file for use with the braille plot application +# when embossing with the 'Index Everest-D V4'. +# The configuration specifies the general printer abilities and defines +# pre-selectable formats for this embosser. +# +# https://gitlab.hrz.tu-chemnitz.de/s9444737--tu-dresden.de/brailleplot/wikis/Software%20Design#configuration-files +# ============================================================================= + +### General Printer Properties +### ========================== + +printer.name=Index Everest-D V4 +printer.mode=normalKek +printer.brailletable=src/main/resources/mapping/eurobraille.propertiesKek +printer.floatingDot.support=true +printer.floatingDot.resolution=0.05 + +# The following values represent the fixed indentation and maximum technical printing area of the embosser. +# If the outputs don't fit on the page you might want to tweak this values. (Check the format too.) +printer.constraint.top=5.0 +printer.constraint.left=0 +#printer.constraint.width=? TODO: Check out manual, Conduct printing tests with bigger formats +#printer.constraint.height=? +# The second constraint in the printer.raster namespace helps to limit the available printing area in steps of +# whole cells, for example if the printer enforces a maximum char per line limit or borders are activated. +printer.raster.constraint.top=0 +printer.raster.constraint.left=1 +printer.raster.constraint.width=35 +printer.raster.constraint.height=29 + +# The following properties define the exact grid spacing. +printer.raster.cellDistance.horizontal=3.6 +printer.raster.cellDistance.vertical=4.8 +printer.raster.dotDistance.horizontal=2.5 +printer.raster.dotDistance.vertical=2.5 +printer.raster.dotDiameter=1.5 + +### Format Definitions +### ================== + +# A4 Format +format.A4.page.width=210 +format.A4.page.height=297 +format.A4.margin.top=0 +format.A4.margin.left=0 +format.A4.margin.bottom=0 +format.A4.margin.right=0 + +# A5 Format +format.A5.page.width=148 +format.A5.page.height=210 +format.A5.margin.top=0 +format.A5.margin.left=0 +format.A5.margin.bottom=0 +format.A5.margin.right=0 + +# Wide Format +format.wide.page.width=272 +format.wide.page.height=210 +format.wide.margin.top=0 +format.wide.margin.left=0 +format.wide.margin.bottom=0 +format.wide.margin.right=0 \ No newline at end of file diff --git a/src/integrationTest/resources/config/false2.properties b/src/integrationTest/resources/config/false2.properties new file mode 100644 index 0000000000000000000000000000000000000000..5287b37acf6a4868392b9c7ae713707a36a7db3b --- /dev/null +++ b/src/integrationTest/resources/config/false2.properties @@ -0,0 +1,69 @@ +# JProperties Printer & Format Configuration +# +# Embosser: Index Everest-D V4 +# Version 1 Rev. 8 (19-07-19) +# +# Description: +# This is the main configuration file for use with the braille plot application +# when embossing with the 'Index Everest-D V4'. +# The configuration specifies the general printer abilities and defines +# pre-selectable formats for this embosser. +# +# https://gitlab.hrz.tu-chemnitz.de/s9444737--tu-dresden.de/brailleplot/wikis/Software%20Design#configuration-files +# ============================================================================= + +### General Printer Properties +### ========================== + +printer.name=Index Everest-D V4 +printer.mode=normalKek +printer.brailletable=src/main/resources/mapping/eurobraille.properties +printer.floatingDot.support=true +printer.floatingDot.resolution=0.05 + +# The following values represent the fixed indentation and maximum technical printing area of the embosser. +# If the outputs don't fit on the page you might want to tweak this values. (Check the format too.) +printer.constraint.top=5.0 +printer.constraint.left=0 +#printer.constraint.width=? TODO: Check out manual, Conduct printing tests with bigger formats +#printer.constraint.height=? +# The second constraint in the printer.raster namespace helps to limit the available printing area in steps of +# whole cells, for example if the printer enforces a maximum char per line limit or borders are activated. +printer.raster.constraint.top=0 +printer.raster.constraint.left=1 +printer.raster.constraint.width=35 +printer.raster.constraint.height=29 + +# The following properties define the exact grid spacing. +printer.raster.cellDistance.horizontal=3.6 +printer.raster.cellDistance.vertical=4.8 +printer.raster.dotDistance.horizontal=2.5 +printer.raster.dotDistance.vertical=2.5 +printer.raster.dotDiameter=1.5 + +### Format Definitions +### ================== + +# A4 Format +format.A4.page.width=210 +format.A4.page.height=297 +format.A4.margin.top=0 +format.A4.margin.left=0 +format.A4.margin.bottom=0 +format.A4.margin.right=0 + +# A5 Format +format.A5.page.width=148 +format.A5.page.height=210 +format.A5.margin.top=0 +format.A5.margin.left=0 +format.A5.margin.bottom=0 +format.A5.margin.right=0 + +# Wide Format +format.wide.page.width=272 +format.wide.page.height=210 +format.wide.margin.top=0 +format.wide.margin.left=0 +format.wide.margin.bottom=0 +format.wide.margin.right=0 \ No newline at end of file diff --git a/src/integrationTest/resources/mapping/eurobraille.properties b/src/integrationTest/resources/mapping/eurobraille.properties new file mode 100644 index 0000000000000000000000000000000000000000..5a20a38bf440814956105a068e9f49d5234d9862 --- /dev/null +++ b/src/integrationTest/resources/mapping/eurobraille.properties @@ -0,0 +1,146 @@ +# JProperties Mapping BrailleTable +# +# Table: eurobraille +# Version 1 Rev. 3 (19-07-18) +# +# Description: +# This table contains a mapping from 6-bit-strings to decimal ascii byte values. +# It is used by the printer backend to encode data sent to the embosser. +# The pairs are ordered by ascending ascii byte value. +# +# ============================================================================= + +# 0-31:NUL-US (non visible characters) +# Space +000000=32 +# ! +000010=33 +# " +000100=34 +# # +001111=35 +# $ +000101=36 +# % +111111=37 +# & +111101=38 +# ' +000001=39 +# ( +011001=40 +# ) +001011=41 +# * +001010=42 +# + +011010=43 +# , +010000=44 +# - +001001=45 +# . +001000=46 +# / +010011=47 +# 0 +001101=48 +# 1 +100001=49 +# 2 +110001=50 +# 3 +100101=51 +# 4 +100111=52 +# 5 +100011=53 +# 6 +110101=54 +# 7 +110111=55 +# 8 +110011=56 +# 9 +010101=57 +# : +010010=58 +# ; +011000=59 +# < +000011=60 +# = +011011=61 +# > +000110=62 +# ? +010001=63 +# 64-90:@-Z +# [ +111011=91 +# 92:\ +# 93:] +# 94:^ +# _ +000111=95 +# ` +001110=96 +# a +100000=97 +# b +110000=98 +# c +100100=99 +# d +100110=100 +# e +100010=101 +# f +110100=102 +# g +110110=103 +# h +110010=104 +# i +010100=105 +# j +010110=106 +# k +101000=107 +# l +111000=108 +# m +101100=109 +# n +101110=110 +# o +101010=111 +# p +111100=112 +# q +111110=113 +# r +111010=114 +# s +011100=115 +# t +011110=116 +# u +101001=117 +# v +111001=118 +# w +010111=119 +# x +101101=120 +# y +101111=121 +# z +101011=122 +# { +011111=123 +# | +001100=124 +# ~ +011101=126 +# 127:DEL \ No newline at end of file diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/App.java b/src/main/java/de/tudresden/inf/mci/brailleplot/App.java index fa831a78bcc2b6982d6597edeaf6f4fce0e74c28..fed8896e17624d44a1aa974a03297930db038d31 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/App.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/App.java @@ -1,5 +1,15 @@ package de.tudresden.inf.mci.brailleplot; +import de.tudresden.inf.mci.brailleplot.configparser.Format; +import de.tudresden.inf.mci.brailleplot.configparser.JavaPropertiesConfigurationParser; +import de.tudresden.inf.mci.brailleplot.configparser.Printer; + +import de.tudresden.inf.mci.brailleplot.printerbackend.PrintDirector; +import de.tudresden.inf.mci.brailleplot.printerbackend.PrinterCapability; + +import de.tudresden.inf.mci.brailleplot.printabledata.MatrixData; +import de.tudresden.inf.mci.brailleplot.printabledata.SimpleMatrixDataImpl; + import de.tudresden.inf.mci.brailleplot.commandline.CommandLineParser; import de.tudresden.inf.mci.brailleplot.commandline.SettingType; import de.tudresden.inf.mci.brailleplot.commandline.SettingsReader; @@ -30,7 +40,7 @@ import java.util.concurrent.ConcurrentLinkedDeque; /** * Main class. * Set up the application and run it. - * @author Georg Graßnick + * @author Georg Graßnick, Andrey Ruzhanskiy * @version 06.06.19 */ @@ -165,7 +175,26 @@ public final class App { SimpleMatrixDataImpl<Boolean> mat = (SimpleMatrixDataImpl<Boolean>) canvas.getCurrentPage(); mLogger.debug("Render preview:\n" + mat.toBoolString()); - // ... + // Config Parsing + + // Check if some SpoolerService/Printservice exists + if (!PrintDirector.isPrintServiceOn()) { + throw new Exception("Can't find any Printservices on this System."); + } + + // Parse properties File + Optional<String> configPath = settingsReader.getSetting(SettingType.PRINTER_CONFIG_PATH); + JavaPropertiesConfigurationParser configParser = new JavaPropertiesConfigurationParser(configPath.get(), "src/main/resources/config/default.properties"); + Printer printer = configParser.getPrinter(); + printer.getProperty("brailletable").toString(); + Format formatA4 = configParser.getFormat("A4"); + + // Last Step: Printing + @SuppressWarnings("checkstyle:MagicNumber") + MatrixData<Boolean> data = new SimpleMatrixDataImpl<>(printer, formatA4, 18, 20, true); + String printerConfigUpperCase = printer.getProperty("mode").toString().toUpperCase(); + PrintDirector printD = new PrintDirector(PrinterCapability.valueOf(printerConfigUpperCase), printer); + printD.print(data); } catch (final Exception e) { terminateWithException(e); @@ -175,5 +204,4 @@ public final class App { return EXIT_SUCCESS; } - } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/AbstractBrailleTableParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/AbstractBrailleTableParser.java new file mode 100644 index 0000000000000000000000000000000000000000..f4496c627e261f7989b2222bdcd4ef2013543b4e --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/AbstractBrailleTableParser.java @@ -0,0 +1,15 @@ +package de.tudresden.inf.mci.brailleplot.brailleparser; + +/** + * Defines an interface which should be implemented in all parsers of braille tables. + */ +public interface AbstractBrailleTableParser { + + /** + * Common method for querying the braille table. + * @param key Braille cell, represented as string ("111000). + * @return Byte, represented as int, corresponding to the given braille cell. + */ + int getValue(String key); + +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/JsonParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/JsonParser.java new file mode 100644 index 0000000000000000000000000000000000000000..7f7c990528135262979e8f45627bb7d2b242ee8f --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/JsonParser.java @@ -0,0 +1,28 @@ +package de.tudresden.inf.mci.brailleplot.brailleparser; + +/** + * Class representing a Json parser entity. + * @author Andrey Ruzhanskiy + * @version 12.07.2019 + */ +public class JsonParser implements AbstractBrailleTableParser { + + /** + * Currently not supported. + * @param filePath File path to the braille table. + */ + public JsonParser(final String filePath) { + throw new UnsupportedOperationException(); + } + + + /** + * Currently not supported. + * @param key Braille cell, represented as string ("111000). + * @return The byte(int) representing the Braille cell specified in the braille table. + */ + @Override + public int getValue(final String key) { + throw new UnsupportedOperationException(); + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/PropertiesParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/PropertiesParser.java new file mode 100644 index 0000000000000000000000000000000000000000..1b7e7db24c7ad8d703d1f949c34287b5f6e7d833 --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/PropertiesParser.java @@ -0,0 +1,45 @@ +package de.tudresden.inf.mci.brailleplot.brailleparser; + +import java.io.FileInputStream; +import java.util.Objects; +import java.util.Properties; + +/** + * Class representing a properties parser. + * @author Andrey Ruzhanskiy + * @version 12.07.2019 + */ + +public class PropertiesParser implements AbstractBrailleTableParser { + private Properties mProperties = new Properties(); + + /** + * Constructor for properties parser. Takes a filePath to the braille table file with the .properties file extension. + * @param filePath The path to the braille table. + * @throws RuntimeException If the file Path does not exists. + */ + public PropertiesParser(final String filePath) { + Objects.requireNonNull(filePath); + + FileInputStream stream; + try { + stream = new FileInputStream(filePath); + mProperties.load(stream); + stream.close(); + } catch (java.io.IOException e) { + throw new RuntimeException(e); + } + + } + + /** + * Method for querying the byte (represented via int) for a given cell from the braille table. + * @param key The braille cell, represented as a string (for example "111000" for 6 braille cell). + * @return The byte(int) representing the braille cell specified in the braille table, + */ + @Override + public int getValue(final String key) { + Objects.requireNonNull(key); + return Integer.parseInt(mProperties.getProperty(key)); + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/XmlParser.java b/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/XmlParser.java new file mode 100644 index 0000000000000000000000000000000000000000..6a6109e7a677176f6ac37c688786a3dd88c37d82 --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/XmlParser.java @@ -0,0 +1,31 @@ +package de.tudresden.inf.mci.brailleplot.brailleparser; + + +/** + * Class representing a XML parser entity. + * @author Andrey Ruzhanskiy + * @version 12.07.2019 + */ +public class XmlParser implements AbstractBrailleTableParser { + + + /** + * Currently not supported. + * + * @param filePath Path to the braille table. + */ + public XmlParser(final String filePath) { + throw new UnsupportedOperationException(); + } + + + /** + * Currently not supported. + * @param key braille cell, represented as String ("111000). + * @return The byte(int) representing the braille cell specified in the braille table. + */ + @Override + public int getValue(final String key) { + throw new UnsupportedOperationException(); + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/package-info.java b/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..78d84e8809471555a34f28987c562b6388878f02 --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/brailleparser/package-info.java @@ -0,0 +1,4 @@ +/** + * This package contains all the required classes and interfaces for braille table parsing. + */ +package de.tudresden.inf.mci.brailleplot.brailleparser; \ No newline at end of file diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java index 19d61e8b8e4e6c3315eac6857ba8f4975123e1f8..1aa3d30673e6686ab5298559b6c6cebcb68d8393 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationValidator.java @@ -1,5 +1,8 @@ package de.tudresden.inf.mci.brailleplot.configparser; + +import de.tudresden.inf.mci.brailleplot.printerbackend.PrinterCapability; + import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.ArrayList; @@ -11,8 +14,8 @@ import java.util.regex.Pattern; /** * Concrete validator for properties parsed from configuration files in Java Property File format. - * @author Leonard Kupper - * @version 2019.07.18 + * @author Leonard Kupper, Andrey Ruzhanskiy + * @version 2019.07.30 */ class JavaPropertiesConfigurationValidator implements ConfigurationValidator { @@ -240,4 +243,29 @@ class JavaPropertiesConfigurationValidator implements ConfigurationValidator { } return true; } + + + + private static boolean checkIfEnum(final String name) { + for (PrinterCapability p : PrinterCapability.values()) { + if (p.toString().toLowerCase().equals(name)) { + return true; + } + } + PrinterCapability[] possibleValues = PrinterCapability.values(); + StringBuilder sBuilder = new StringBuilder(); + for (int i = 0; i < possibleValues.length; i++) { + sBuilder.append(possibleValues[i]).append(","); + } + String result = sBuilder.deleteCharAt(sBuilder.length() - 1).toString(); + throw new RuntimeException("The given mode '" + + name + "' is currently not supported/not found in" + + " the system. Currently, the possible values are: " + result); + } + + /** + * Static method for checking if the printer, which was given, exists in the Printer System Dialog. + * @param printerName The name of the printer to check. + * @return True if printer exists. False if not. + */ } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/BrailleCell6.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/BrailleCell6.java index 37e75db44ade2a67cfc735c5c5ffe67dcdb67fd1..fc32e673cc68ab70fff1b92f8c4f30a89065441d 100644 --- a/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/BrailleCell6.java +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printabledata/BrailleCell6.java @@ -101,4 +101,20 @@ public final class BrailleCell6<T> { } return sb.toString(); } + /** + * Method for getting the Bit Representation of the Cell (110001). Should only be used if T is boolean. + * @return String containing the Bit Representation. + */ + public String getBitRepresentationFromBool() { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < mDots.length; i++) { + if (Boolean.parseBoolean(mDots[i].toString())) { + sb.append("1"); + } else { + sb.append("0"); + } + + } + return sb.toString(); + } } diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/AbstractDocumentBuilder.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/AbstractDocumentBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..c16ce44b1fd0002ebff4eecf5a21bb38d1187479 --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/AbstractDocumentBuilder.java @@ -0,0 +1,52 @@ +package de.tudresden.inf.mci.brailleplot.printerbackend; +import de.tudresden.inf.mci.brailleplot.brailleparser.AbstractBrailleTableParser; +import de.tudresden.inf.mci.brailleplot.brailleparser.JsonParser; +import de.tudresden.inf.mci.brailleplot.brailleparser.PropertiesParser; +import de.tudresden.inf.mci.brailleplot.brailleparser.XmlParser; +import de.tudresden.inf.mci.brailleplot.configparser.Printer; +import de.tudresden.inf.mci.brailleplot.printabledata.MatrixData; + +/** + * This class provides an extension point for further implementation + * and protocol building for documents that need to be send to the printer. + * The common Interface is the getDocument() and assemble() method. + * Its usable for all braille printers. + * @param <T> Type of MatrixData. + * @author Andrey Ruzhanskiy + * @version 28.05.2019 + */ + +abstract class AbstractDocumentBuilder<T> { + + MatrixData<T> mData; + + + AbstractBrailleTableParser mParser; + + /** + * Complex method for complex construction of an document for the printer. + * @param data Raw data to be printed without any escapes equences + * @return Fully build document as byte[] + */ + abstract byte[] assemble(MatrixData<T> data); + + /** + * Method for setting the correct parser. Reads the file from the printer configuration, then checks + * if the file extension is supported. + * @throws NotSupportedFileExtensionException If the file extension is not supported. + */ + void setParser() throws NotSupportedFileExtensionException { + //read braille table path + Printer printer = mData.getPrinterConfig(); + String brailleTablePath = printer.getProperty("brailletable").toString(); + + //read which kind of parser is needed (properties, json, xml,...) + String fileEnding = brailleTablePath.split("\\.")[1]; + switch (fileEnding) { + case "properties": mParser = new PropertiesParser(printer.getProperty("brailletable").toString()); break; + case "json": mParser = new JsonParser(printer.getProperty("brailletable").toString()); break; + case "xml": mParser = new XmlParser(printer.getProperty("brailletable").toString()); break; + default: throw new NotSupportedFileExtensionException("The Fileextension " + fileEnding + "is currently not supported."); + } + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/AbstractIndexV4Builder.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/AbstractIndexV4Builder.java new file mode 100644 index 0000000000000000000000000000000000000000..b79ba6a7bd627ac0db6f1adb17ecf564ad7b1c7b --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/AbstractIndexV4Builder.java @@ -0,0 +1,262 @@ +package de.tudresden.inf.mci.brailleplot.printerbackend; + +/** + * Abstract class for Documents, that need special escape sequences for the Index Everest-V4. + * All special documents (i.e. Floating Dot Area) should implement this class. All information taken + * from the Index PrinterCapability Interface Protocol V5_V4 2ß16-05-13. All the variables with the respective values have no + * particular order (except mStartTemporaryDoc, which must be at the beginning). All the variable names are set to + * final, these are PrinterCapability specific values that should not be changed. + * @author Andrey Ruzhanskiy + * @version 31.05.2019 + */ + +@SuppressWarnings("checkstyle:MagicNumber") +abstract class AbstractIndexV4Builder extends AbstractDocumentBuilder { + + + + /** + * Standard byte Sequence to announce StartTemporary document ([ESC]D). + * Must be always at the beginning. + */ + + final byte[] mStartTemporaryDoc = new byte[] {0x1B, 0x44}; + + /** + * Standard variable name for binding margin (BI). + */ + + final byte[] mBindingMarginName = new byte[] {0x42, 0x49}; + + /** + * Standard value for Everest-V4 A4 Paper Size(4). Possible Values: + * 0 + * to + * 10, + * whereas the number encodes the #charracters to leave empty on the line to the + * left and right. + */ + + byte[] mBindingMarginValue = new byte[] {0x34}; + + /** + * Standard variable name for characters per line (CH). + */ + + final byte[] mCharsPerLineName = new byte[] {0x43, 0x48}; + + /** + * Standard value for Everest-V4 A4 Paper Size(30).If used, there must be also + * a corresponding binding margin. Possible values are: + * 0: may not be usefull + * to + * 48:Absolute maximum due to printer heads total movement and only applicable to the printers + * that can use papers that big. + */ + + byte[] mCharsPerLineValue = new byte[] {0x33, 0x30}; + + /** + * Standard variable name for PageMode (Duplex) (DP). + */ + + final byte[] mPageModeName = new byte[] {0x44, 0x50}; + + /** + * Standard value for page mode (2, double sided). + * Possible values are: + * 1 Single sided (normal horizontal printing) + * 2 Double sided (normal horizontal printing) + * 3 Double sided z-folding (normal horizontal printing) + * 5 Single sided z-folding (normal horizontal printing) + * 6 Double sided sideways z-folding (vertical printing) + * 7 Single sided sideways z-folding (vertical printing) + */ + + byte[] mPageModeValue = new byte[] {0x32}; + + /** + * Standard variable name for braille table (BT). + */ + + final byte[] mBrailleTableName = new byte[] {0x42, 0x54}; + + /** + * Currently, there is no standard braille table. + */ + byte[] mBrailleTableValue = null; + + /** + * Standard variable name for Driver Version (DV). + */ + + final byte[] mDriverVersionName = new byte[] {0x44, 0x56}; + + /** + * Standard value for driver version (not used currently TODO). + */ + + byte[] mDriverVersion = null; + + /** + * Standard variable name for first line offset (FO). + */ + + final byte[] mFirstLineOffsetName = new byte[] {0x46, 0x4F}; + + /** + * Standard value for first line offset (~50/60). + * Possible values: equal or greater then 0. + * The value is specified in tenths of mm. + * + */ + + byte[] mFirstLineOffsetValue = null; + + /** + * Standard variable name for graphic dot distance (GD). + */ + + final byte[] mGraphicDotDistanceName = new byte[] {0x47, 0x44}; + + /** + * Standard value for graphic dot distance. Possible values are 0, 1, 2. + * 0 = 2.0 mm + * 1 = 2.5 mm + * 2 = 1.6 mm + * Standard is 1 (2.5 mm). + */ + + byte[] mGraphicDotDistanceValue = new byte[] {0x31}; + + /** + * Standard variable name for lines per page (LP). + */ + + final byte[] mLinesPerPageName = new byte[] {0x4C, 0x50}; + + /** + * Standard value for lines per page (28). If this parameter is set, one must include + * the TM parameter as well. + */ + + byte[] mLinesPerPageValue = new byte[] {0x32, 0x38}; + + /** + * Standard variable name for line spacing (LS). + */ + + final byte[] mLineSpacingName = new byte[] {0x4C, 0x53}; + + /** + * Standard value for line spacing (GD). This parameter can only be specified in the beginning of a document + * and is ignored if a row has been added to the first page. Line spacing is ignored if DP is set to DP4 and DP8. + * Possible values are: + * 50: 5.0 mm (single -normal) + * to + * 100: 10.0 mm (double) + */ + + byte[] mLineSpacingValue = new byte[] {0x35, 0x30}; + + /** + * Standard variable name for multiple copies (MC). + */ + + final byte[] mMultipleCopiesName = new byte[] {0x4D, 0x43}; + + /** + * Standard value for multiple copies (1). Possible values are: + * 1 + * to + * 10000 + */ + + byte[] mMultipleCopiesValue = new byte[] {0x31}; + + /** + * Standard variable name for multiple impact (MI). + */ + + final byte[] mMultipleImpactName = new byte[] {0x4D, 0x49}; + + /** + * Standard value for multiple impact (1).To impact the hammers multiple times + * for a braille row this parameter can be specified. Possible values are: + * 1 + * to + * 3. + */ + + byte[] mMultipleImpactValue = new byte[] {0x31}; + + /** + * Standard variable name for page number (PN). + */ + + final byte[] mPageNumberName = new byte[] {0x50, 0x4E}; + + /** + * Standard value for page number (0). This parameter needs to be specified before the first row is added + * to the first page. Possible values are: + * 0: None + * 1: Top (require top margin greater than 0) + * 2: Top-left (require top margin greater than 0) + * 3: Top-right (require top margin greater than 0) + * 4: Bottom (require bottom margin greater than 0) + * 5: Bottom left (require bottom margin greater than 0) + * 6: Bottom right (require bottom margin greater than 0) + */ + + byte[] mPageNumberValue = new byte[] {0x30}; + + /** + * Standard variable name for braille cell size (TD). + */ + + final byte[] mBrailleCellSizeName = new byte[] {0x54, 0x44}; + + /** + * Standard value for braille cell size (0). Possible values are: + * 0: 2.5 mm + * 1: 2.2 mm + * 2: 3.2 mm + */ + + byte[] mBrailleCellSizeValue = new byte[] {0x30}; + + /** + * Standard variable name for top margin (TM). + */ + + final byte[] mTopMarginName = new byte[] {0x54, 0x4D}; + + /** + * Standard value for top margin(not researched). The top margin is + * always specified in lines. Possible values are: + * 0 + * to + * 10 + */ + + byte[] mTopMarginValue = null; + + /** + * Separator for values (,). + */ + final byte[] mComma = new byte[] {0x2C}; + + + /** + * Colon character. + */ + final byte[] mColon = new byte[] {0x3A}; + + + + /** + * End of escape sequence (;). Must be always at the end. + */ + + final byte[] mSemicolon = new byte[] {0x3B}; +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/FloatingDotAreaBuilder.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/FloatingDotAreaBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..b16826be2e92e2ace441eafc47927548f932a5f1 --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/FloatingDotAreaBuilder.java @@ -0,0 +1,28 @@ +package de.tudresden.inf.mci.brailleplot.printerbackend; + + +import de.tudresden.inf.mci.brailleplot.printabledata.MatrixData; + +/** + * Class representing the FloatingDotAre protocol for the braille Index Everest V4 for printing + * variable areas on paper via coordinates. + * @author Andrey Ruzhanskiy, Leonard Kupper + * @version 29.05.2019 + */ + +class FloatingDotAreaBuilder extends AbstractIndexV4Builder { + + /** + * Constructor. Does not have any functionality. Should only be used in {@link PrintDirector} + */ + FloatingDotAreaBuilder() { } + + /** + * Currently not implemented. + * @param data Raw data to be printed without any escape sequences + * @return Exception. + */ + byte[] assemble(final MatrixData data) { + throw new UnsupportedOperationException(); + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/GraphicPrintBuilder.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/GraphicPrintBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..a51107b5ca0fa00cee02ff52dc7ef6038d187afd --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/GraphicPrintBuilder.java @@ -0,0 +1,26 @@ +package de.tudresden.inf.mci.brailleplot.printerbackend; + + +import de.tudresden.inf.mci.brailleplot.printabledata.MatrixData; + +/** + * Class representing the graphic mode protocol from braille Index Everest D4. + * @author Andrey Ruzhanskiy + */ +class GraphicPrintBuilder extends AbstractIndexV4Builder { + + /** + * Constructor. Does not have any functionality. Should only be used in {@link PrintDirector} + */ + GraphicPrintBuilder() { } + + /** + * Currently not implemented. + * @param data Raw data to be printed without any escape sequences + * @return Exception. + */ + @Override + byte[] assemble(final MatrixData data) { + throw new UnsupportedOperationException(); + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/NormalBuilder.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/NormalBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..f33d1060dc507e74111463b67bd1160177fa6781 --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/NormalBuilder.java @@ -0,0 +1,80 @@ +package de.tudresden.inf.mci.brailleplot.printerbackend; + +import de.tudresden.inf.mci.brailleplot.printabledata.BrailleCell6; +import de.tudresden.inf.mci.brailleplot.printabledata.MatrixData; + +import java.io.ByteArrayOutputStream; +import java.util.Iterator; +import java.util.Objects; + + +/** + * Class representing a normal document (for example a .txt) that should be printed without + * any escape sequences. + * @author Andrey Ruzhanskiy + * @version 12.07.2019 + */ +@SuppressWarnings("checkstyle:MagicNumber") +class NormalBuilder extends AbstractDocumentBuilder<Boolean> { + + + /** + * Constructor. Does not have any functionality. Should only be used in {@link PrintDirector} + */ + NormalBuilder() { } + + /** + * Method for assembling the final document from the data parameter. + * In normalbuilder, it first sets the correct parser according to the file extension, then initializes the iterator + * from the {@link MatrixData} object and the stream for writing bytes into an array and lastly loops through the {@link MatrixData} + * to build the correct document. + * @param data Raw data to be printed without any escape sequences + * @return the final, printable document. + */ + @Override + byte[] assemble(final MatrixData<Boolean> data) { + + + //Check if null object was given. + mData = Objects.requireNonNull(data); + // Setting the right parser, catch if not found and throw RuntimeException which can be handled. + try { + setParser(); + } catch (NotSupportedFileExtensionException e) { + throw new RuntimeException(); + } + + // Get iterator for cells. + Iterator<BrailleCell6<Boolean>> iter = mData.getBrailleCell6Iterator(); + + // Set stream for final output. + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + + // Getting width in braille cells. + int width = mData.getColumnCount() / 2; + + // Declaration of local variables for better readability. + BrailleCell6 current; + String key; + int value; + + // Count variable for the loop + int i = 0; + + // Loop through data and write to stream. + while (iter.hasNext()) { + current = iter.next(); + key = current.getBitRepresentationFromBool(); + value = mParser.getValue(key); + stream.write(value); + i++; + // Setting the Linebreaks + if (i == width) { + i = 0; + stream.write(0x0D); + stream.write(0x0A); + } + } + return stream.toByteArray(); + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/NotSupportedFileExtensionException.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/NotSupportedFileExtensionException.java new file mode 100644 index 0000000000000000000000000000000000000000..1f2042e02d7a61c5bee54f27e96e92da8d64564b --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/NotSupportedFileExtensionException.java @@ -0,0 +1,25 @@ +package de.tudresden.inf.mci.brailleplot.printerbackend; + +/** + * Exception class for not recogniced/not supported file extension for braille tables. + * Used in {@link NormalBuilder}. + * @author Andrey Ruzhanskiy + * @version 11.07.2019 + */ + +public class NotSupportedFileExtensionException extends Exception { + + public NotSupportedFileExtensionException() { } + + public NotSupportedFileExtensionException(final String message) { + super(message); + } + + public NotSupportedFileExtensionException(final Throwable cause) { + super(cause); + } + + public NotSupportedFileExtensionException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/PrintDirector.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/PrintDirector.java new file mode 100644 index 0000000000000000000000000000000000000000..501450bfef4078c97f60741b6bda2180c3c70ed1 --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/PrintDirector.java @@ -0,0 +1,145 @@ +package de.tudresden.inf.mci.brailleplot.printerbackend; + + +import de.tudresden.inf.mci.brailleplot.configparser.Printer; +import de.tudresden.inf.mci.brailleplot.printabledata.MatrixData; + +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.PrintException; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.Doc; + +import javax.print.SimpleDoc; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.JobName; +import java.util.Objects; +/** + * Implements a variation of the GoF design pattern Builder. This class is used for setting the printer configuration and + * for printing. + * @author Andrey Ruzhanskiy + * @version 17.07.2019 + */ +public class PrintDirector { + + private AbstractDocumentBuilder mBuilder; + private final PrinterCapability mPrinter; + private PrintService mService; + private String mPrinterName; + private DocFlavor mDocflavor; + private DocPrintJob mPrintJob; + + + /** + * Constructor for the PrintDirector. Main class for printing. The class takes care of the complex Protocol to build + * the document for the given configuration. + * @param printerCap Which {@link PrinterCapability} should be used. Normal printer assumes that no special features like + * GraphicMode or FloatindDotArea will be used. + * @param printerConfig The {@link Printer} object, used for extracting the name of the printer. + */ + public PrintDirector(final PrinterCapability printerCap, final Printer printerConfig) { + Objects.requireNonNull(printerCap); + Objects.requireNonNull(printerConfig); + this.mPrinter = printerCap; + mPrinterName = printerConfig.getProperty("name").toString(); + switch (mPrinter) { + case NORMALPRINTER: + mBuilder = new NormalBuilder(); break; + case INDEX_EVEREST_D_V4_GRAPHIC_PRINTER: + mBuilder = new GraphicPrintBuilder(); + break; + case INDEX_EVEREST_D_V4_FLOATINGDOT_PRINTER: + mBuilder = new FloatingDotAreaBuilder(); + break; + default: throw new IllegalArgumentException(); + } + + } + + /** + * Public method for printing the given document with the given data. + * @param data {@link de.tudresden.inf.mci.brailleplot.printabledata.MatrixData} to be printed. + * @param <T> The type of {@link MatrixData}. + */ + + + // Needed if someone tries to use a normal builder with something that is not a boolean. + + @SuppressWarnings("unchecked") + public <T> void print(final MatrixData<T> data) { + Objects.requireNonNull(data); + setUpDoc(); + setUpService(); + byte[] result; + try { + result = mBuilder.assemble(data); + } catch (ClassCastException e) { + throw new IllegalArgumentException(e.getMessage(), e); + } + print(result); + } + + /** + * Method for setting up the DocFlavor for printing. Currently, not parameterised because the printer can + * (hopefully) understand raw bytes with an octet stream. + */ + private void setUpDoc() { + mDocflavor = new DocFlavor("application/octet-stream", "[B"); + } + + + /** + * Method for setting the correct printer service for the printer name. + * @throws RuntimeException If the system cant find the service. + */ + + private void setUpService() { + Objects.requireNonNull(mPrinterName); + PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); + for (PrintService service: services) { + if (service.getName().equals(mPrinterName) || mPrinterName.equals("Dummy Printer")) { + mService = service; + return; + } + } + throw new RuntimeException("Cant register Printerservice for the printername : " + mPrinterName); + } + + /** + * Private method for sending the data to the printer. Separated from the public method so that the assemble process + * and the printing process are separated logically, but from outside it looks like it all happens in one method. + * @param data Data to be printed. + * @throws PrintException If the printing job could not be completed. + */ + + private void print(final byte[] data) { + Objects.requireNonNull(data); + Objects.requireNonNull(mService); + Objects.requireNonNull(mDocflavor); + Doc doc = new SimpleDoc(data, mDocflavor, null); + PrintRequestAttributeSet asset = new HashPrintRequestAttributeSet(); + DocPrintJob job = mService.createPrintJob(); + asset.add(new JobName("Braille Printing", null)); + try { + job.print(doc, asset); + mPrintJob = job; + } catch (PrintException pe) { + throw new RuntimeException(pe); + } + + } + + /** + * Static method to verify if the print service is activated on the system. + * @return true, if activated, false if not. + */ + public static boolean isPrintServiceOn() { + PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); + if (services.length == 0) { + return false; + } + return true; + } +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/PrinterCapability.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/PrinterCapability.java new file mode 100644 index 0000000000000000000000000000000000000000..5f29934cccab8711712527d8eabf3e33fdcd23ba --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/PrinterCapability.java @@ -0,0 +1,16 @@ +package de.tudresden.inf.mci.brailleplot.printerbackend; + +/** + * This enum provides means to differentiate between printer capabilities. + * This should be extended if new printers are supported. If its unknown, the standard should be NormalPrinter. This + * assumes that no special features are supported and hence, normal braille should be printed. + * Because not every printer supports the same functionality or uses the same Protocol for the same functionality, the + * names are embedded in the values (for example INDEX_EVEREST_D_V4_EXAMPLE_CAPABILITY). + * Currently used in {@link PrintDirector}. + * @author Andrey Ruzhanskiy + * @version 17.07.2019 + */ + +public enum PrinterCapability { + NORMALPRINTER, INDEX_EVEREST_D_V4_FLOATINGDOT_PRINTER, INDEX_EVEREST_D_V4_GRAPHIC_PRINTER +} diff --git a/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/package-info.java b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..f14d3f1dacb3af8301ab36ee6d2a03771b22dbeb --- /dev/null +++ b/src/main/java/de/tudresden/inf/mci/brailleplot/printerbackend/package-info.java @@ -0,0 +1,4 @@ +/** + * This package contains all the requiered classes and interfaces for printing and braille table parsing. + */ +package de.tudresden.inf.mci.brailleplot.printerbackend; diff --git a/src/main/resources/config/default.properties b/src/main/resources/config/default.properties index fec2bdb6e2941fd9ba093f381f5317a099c5553e..0c016eff33d647637a5e6a6289cc72a437d771bd 100644 --- a/src/main/resources/config/default.properties +++ b/src/main/resources/config/default.properties @@ -13,7 +13,7 @@ # ATTENTION: Changes to this configuration will affect settings for ALL printer and format definitions which # are not overriding the defaults. -printer.mode=normal +printer.mode=normalprinter printer.brailletable=src/main/resources/mapping/eurobraille.properties printer.floatingDot.support=false diff --git a/src/main/resources/config/dummyPrinterConfig.properties b/src/main/resources/config/dummyPrinterConfig.properties new file mode 100644 index 0000000000000000000000000000000000000000..c079e544814bfa4455adee8281f2f62d9fde9913 --- /dev/null +++ b/src/main/resources/config/dummyPrinterConfig.properties @@ -0,0 +1,69 @@ +# JProperties Printer & Format Configuration +# +# Embosser: Index Everest-D V4 +# Version 1 Rev. 8 (19-07-19) +# +# Description: +# This is the main configuration file for use with the braille plot application +# when embossing with the 'Index Everest-D V4'. +# The configuration specifies the general printer abilities and defines +# pre-selectable formats for this embosser. +# +# https://gitlab.hrz.tu-chemnitz.de/s9444737--tu-dresden.de/brailleplot/wikis/Software%20Design#configuration-files +# ============================================================================= + +### General Printer Properties +### ========================== + +printer.name=Index Everest-D V4 +printer.mode=normalprinter +printer.brailletable=src/main/resources/mapping/eurobraille.properties +printer.floatingDot.support=true +printer.floatingDot.resolution=0.05 + +# The following values represent the fixed indentation and maximum technical printing area of the embosser. +# If the outputs don't fit on the page you might want to tweak this values. (Check the format too.) +printer.constraint.top=5.0 +printer.constraint.left=0 +#printer.constraint.width=? TODO: Check out manual, Conduct printing tests with bigger formats +#printer.constraint.height=? +# The second constraint in the printer.raster namespace helps to limit the available printing area in steps of +# whole cells, for example if the printer enforces a maximum char per line limit or borders are activated. +printer.raster.constraint.top=0 +printer.raster.constraint.left=1 +printer.raster.constraint.width=35 +printer.raster.constraint.height=29 + +# The following properties define the exact grid spacing. +printer.raster.cellDistance.horizontal=3.6 +printer.raster.cellDistance.vertical=4.8 +printer.raster.dotDistance.horizontal=2.5 +printer.raster.dotDistance.vertical=2.5 +printer.raster.dotDiameter=1.5 + +### Format Definitions +### ================== + +# A4 Format +format.A4.page.width=210 +format.A4.page.height=297 +format.A4.margin.top=0 +format.A4.margin.left=0 +format.A4.margin.bottom=0 +format.A4.margin.right=0 + +# A5 Format +format.A5.page.width=148 +format.A5.page.height=210 +format.A5.margin.top=0 +format.A5.margin.left=0 +format.A5.margin.bottom=0 +format.A5.margin.right=0 + +# Wide Format +format.wide.page.width=272 +format.wide.page.height=210 +format.wide.margin.top=0 +format.wide.margin.left=0 +format.wide.margin.bottom=0 +format.wide.margin.right=0 \ No newline at end of file diff --git a/src/main/resources/config/index_basic_d.properties b/src/main/resources/config/index_basic_d.properties index 0c98fba6901e5c999ba4d3621fc49593026d9e53..7cba7190b2273dc8ec201693411bbe62d20bd3c7 100644 --- a/src/main/resources/config/index_basic_d.properties +++ b/src/main/resources/config/index_basic_d.properties @@ -16,7 +16,7 @@ ### ========================== printer.name=Index Basic-D V3 -printer.mode=normal +printer.mode=normalprinter printer.brailletable=src/main/resources/mapping/mapping.properties printer.floatingDot.support=false diff --git a/src/main/resources/config/index_everest_d_v4.properties b/src/main/resources/config/index_everest_d_v4.properties index 3d6ad7a39662d5f08ea72f6ffe910daa926d4b09..24f7e749c193ad6b3ff3ac90d021720ba813680f 100644 --- a/src/main/resources/config/index_everest_d_v4.properties +++ b/src/main/resources/config/index_everest_d_v4.properties @@ -16,7 +16,7 @@ ### ========================== printer.name=Index Everest-D V4 -printer.mode=normal +printer.mode=normalprinter printer.brailletable=src/main/resources/mapping/eurobraille.properties printer.floatingDot.support=true printer.floatingDot.resolution=0.05 diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/AppTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/AppTest.java index 51ffe22bd2420dc57ba9fbe53f92e4a577a2f31b..b21ded69f42fc0361d53be1ffeb75b3bcd488404 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/AppTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/AppTest.java @@ -1,5 +1,6 @@ package de.tudresden.inf.mci.brailleplot; +import de.tudresden.inf.mci.brailleplot.App; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/brailleparser/PropertiesParserTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/brailleparser/PropertiesParserTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c5ff403a49c3c1d72740f6338e5b4d64a9985e20 --- /dev/null +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/brailleparser/PropertiesParserTest.java @@ -0,0 +1,34 @@ +package de.tudresden.inf.mci.brailleplot.brailleparser; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Unit Tests for the PropertiesParser Class. + * @author Andrey Ruzhanskiy + * @version 15.07.2019 + */ +public class PropertiesParserTest { + + /** + * Test for giving a Null to the PropertiesParser Constructor. + * Expected: NullPointerException. + */ + @Test + public void testNullInConstructor(){ + Assertions.assertThrows(NullPointerException.class, () -> { + PropertiesParser parserF1 = new PropertiesParser(null); + }); + } + + /** + * Test for giving a non-existing Path to the PropertiesParser Constructor. + * Expected: RuntimeException. + */ + @Test + public void testNonValidPath(){ + Assertions.assertThrows(RuntimeException.class, () -> { + PropertiesParser parserF1 = new PropertiesParser("/C/D/E/F/G"); + }); + } +} diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationParserTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationParserTest.java index 2f49d59921288404fde73597d30aaa04bec440fb..f6851d38c53ba4c12f3dabed75599b140e9cf48b 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationParserTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/configparser/JavaPropertiesConfigurationParserTest.java @@ -28,12 +28,12 @@ public class JavaPropertiesConfigurationParserTest { @Test @BeforeAll public static void testSuccessfulParsing() { Assertions.assertDoesNotThrow(() -> { - // Parse concrete properties and defaults - ConfigurationParser parser = new JavaPropertiesConfigurationParser(mConcreteConfigPath, mDefaultConfigPath); - mPrinterConfig = parser.getPrinter(); - Set<String> properties = mPrinterConfig.getPropertyNames(); - Set<String> formats = parser.getFormatNames(); - mFormatConfig = parser.getFormat("A4"); + // Parse concrete properties and defaults + ConfigurationParser parser = new JavaPropertiesConfigurationParser(mConcreteConfigPath, mDefaultConfigPath); + mPrinterConfig = parser.getPrinter(); + Set<String> properties = mPrinterConfig.getPropertyNames(); + Set<String> formats = parser.getFormatNames(); + mFormatConfig = parser.getFormat("A4"); }); } @Test @@ -129,5 +129,4 @@ public class JavaPropertiesConfigurationParserTest { Assertions.assertThrows(NumberFormatException.class, () -> mPrinterConfig.getProperty("raster.cellDistance.horizontal").toInt()); Assertions.assertThrows(NumberFormatException.class, () -> mPrinterConfig.getProperty("name").toDouble()); } - } diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/printerbackend/NormalBuilderTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/printerbackend/NormalBuilderTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ec37261b780eadad41e4049b6dd9bc70d4fe5be6 --- /dev/null +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/printerbackend/NormalBuilderTest.java @@ -0,0 +1,25 @@ +package de.tudresden.inf.mci.brailleplot.printerbackend; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Unit Tests for the NormalBuilder Class. + * @author Andrey Ruzhanskiy + * @version 15.07.2019 + */ +public class NormalBuilderTest { + + + /** + * Test for giving a Null to the NormalBuilder assemble Method. + * Expected: NullPointerException. + */ + @Test + public void testAssembleWithNull(){ + Assertions.assertThrows(NullPointerException.class, () -> { + NormalBuilder normalF1 = new NormalBuilder(); + normalF1.assemble(null); + }); + } +} diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/printerbackend/PrintDirectorTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/printerbackend/PrintDirectorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..aa03f8c4eca555539429b295adee799accb3cae7 --- /dev/null +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/printerbackend/PrintDirectorTest.java @@ -0,0 +1,32 @@ +package de.tudresden.inf.mci.brailleplot.printerbackend; + + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + + + +/** + * Unit Tests for the PrintDirector Class. + * @author Andrey Ruzhanskiy + * @version 15.07.2019 + */ + +public class PrintDirectorTest { + + /* Negative Tests + Because this componend depends heavily on almost all other components, the testcases will be more integration + tests then unittests. + */ + + /** + * Test for giving a Null to the PrintDirector-Constructor. + * Expected: NullPointerException. + */ + @Test + public void testNullInConstructor(){ + Assertions.assertThrows(NullPointerException.class, () -> { + PrintDirector printF1 = new PrintDirector(null, null); + }); + } +} diff --git a/src/test/resources/config/concrete.properties b/src/test/resources/config/concrete.properties index ae38765f32eda38856761c4cee4ebdcf10648804..404bd9c56a5031f31f3e7d7dc5220bc9642e42fd 100644 --- a/src/test/resources/config/concrete.properties +++ b/src/test/resources/config/concrete.properties @@ -16,7 +16,7 @@ ### ========================== printer.name=Dummy Printer -printer.mode=normal +printer.mode=normalprinter printer.brailletable=src/test/resources/mapping/mapping.properties printer.floatingDot.support=true printer.floatingDot.resolution=0.05 diff --git a/src/test/resources/config/default.properties b/src/test/resources/config/default.properties index 0ddc21c523dc8f81f018d8b6066d51f6fba2a8f9..beaf967cfa2b1489a984922cfb9f508466ee764e 100644 --- a/src/test/resources/config/default.properties +++ b/src/test/resources/config/default.properties @@ -13,7 +13,8 @@ # ATTENTION: Changes to this configuration will affect settings for ALL printer and format definitions which # are not overriding the defaults. -printer.mode=normal + +printer.mode=normalprinter printer.brailletable=src/test/resources/mapping/mapping.properties printer.floatingDot.support=false diff --git a/src/test/resources/config/illegalPropertyNameExample.properties b/src/test/resources/config/illegalPropertyNameExample.properties index c4418b850108ca3d3af4cb64d5bc1724df00088c..655c5559f060a614e334d2fa88b56afc134442f6 100644 --- a/src/test/resources/config/illegalPropertyNameExample.properties +++ b/src/test/resources/config/illegalPropertyNameExample.properties @@ -13,7 +13,8 @@ # ATTENTION: Changes to this configuration will affect settings for ALL printer and format definitions which # are not overriding the defaults. -printer.mode=normal + +printer.mode=normalprinter printer.brailletable=src/test/resources/mapping/mapping.properties printer.floatingDot.support=false diff --git a/src/test/resources/config/illegalPropertyValueExample.properties b/src/test/resources/config/illegalPropertyValueExample.properties index fb25331a6a6b51e1fb628c5c49fc0bd270ae49e5..d4adb7784a163e5a692af4234e02c65f0d0b40c9 100644 --- a/src/test/resources/config/illegalPropertyValueExample.properties +++ b/src/test/resources/config/illegalPropertyValueExample.properties @@ -13,7 +13,7 @@ # ATTENTION: Changes to this configuration will affect settings for ALL printer and format definitions which # are not overriding the defaults. -printer.mode=normal +printer.mode=normalprinter printer.brailletable=src/test/resources/mapping/mapping.properties printer.floatingDot.support=false diff --git a/src/test/resources/config/missingRequiredPropertyExample.properties b/src/test/resources/config/missingRequiredPropertyExample.properties index 8692f1bb122ee19fa58dafb6070dcac27c9faa45..35f9233d2627888a7fcf2a50e22d6bbba8d750f6 100644 --- a/src/test/resources/config/missingRequiredPropertyExample.properties +++ b/src/test/resources/config/missingRequiredPropertyExample.properties @@ -17,7 +17,7 @@ # Missing required property (not specified by default): # printer.name=Dummy Printer -printer.mode=normal +printer.mode=normalprinter printer.brailletable=src/test/resources/mapping/mapping.properties printer.floatingDot.support=true printer.floatingDot.resolution=0.05 diff --git a/src/test/resources/config/rasterizer_test_default.properties b/src/test/resources/config/rasterizer_test_default.properties index 27e44ceac3328bccd0b01f2f8bb07a7dc35600a1..71e78830bb16765ca3a5a33ef1bfe1751599ca25 100644 --- a/src/test/resources/config/rasterizer_test_default.properties +++ b/src/test/resources/config/rasterizer_test_default.properties @@ -9,8 +9,8 @@ # ============================================================================= # Define these here to have neat small concrete test configs. -printer.name=Dummy Default -printer.mode=normal +printer.name=Dummy Printer +printer.mode=normalprinter printer.brailletable=src/test/resources/mapping/eurobraille.properties printer.floatingDot.support=false printer.raster.type=6-dot diff --git a/src/test/resources/config/wrongPrinterModeExample.properties b/src/test/resources/config/wrongPrinterModeExample.properties new file mode 100644 index 0000000000000000000000000000000000000000..61e331d4e0e7487cfd42cd58f70d7daaef7a0b9b --- /dev/null +++ b/src/test/resources/config/wrongPrinterModeExample.properties @@ -0,0 +1,52 @@ +# JProperties Printer & Format Configuration +# +# Embosser: Dummy Printer +# Test Revision (19-07-18) (DON'T USE FOR PRINTING) +# +# Description: +# This is the main configuration file for use with the braille plot application +# when embossing with the 'Index Everest-D V4'. +# The configuration specifies the general printer abilities and defines +# pre-selectable formats for this embosser. +# +# https://gitlab.hrz.tu-chemnitz.de/s9444737--tu-dresden.de/brailleplot/wikis/Software%20Design#configuration-files +# ============================================================================= + +### General Printer Properties +### ========================== + +# Missing required property (not specified by default): +printer.name=Dummy Printer +printer.mode=normalprinterKek +printer.brailletable=src/test/resources/mapping.properties +printer.floatingDot.support=true +printer.floatingDot.resolution=0.05 + +# The following values represent the fixed indentation and maximum technical printing area of the embosser. +# If the outputs don't fit on the page you might want to tweak this values. (Check the format too.) +printer.constraint.top=5.0 +printer.constraint.left=0 + +# The following properties define the exact grid spacing. +printer.raster.cellDistance.horizontal=3.6 +printer.raster.cellDistance.vertical=4.8 +printer.raster.dotDistance.horizontal=2.5 +printer.raster.dotDistance.vertical=2.5 +printer.raster.dotDiameter=1.5 + +### Format Definitions +### ================== + +# A4 Format +format.A4.page.width=210 +format.A4.page.height=297 +format.A4.margin.left=0 + +# A5 Format +# Missing required property (not specified by default): +# format.A5.page.width=148 +format.A5.page.height=210 +format.A5.margin.top=0 +format.A5.margin.left=0 +format.A5.margin.bottom=0 +format.A5.margin.right=0 \ No newline at end of file