... | ... | @@ -145,7 +145,7 @@ Andrey, Richard |
|
|
## Package Overview for printerbackend:
|
|
|
![PrinterBackend.svg](uploads/0359a1b084241740a97e5afde116a21e/PrinterBackend.svg)
|
|
|
|
|
|
### Extension
|
|
|
## **Extension**
|
|
|
To add a new printer without any special modes to the system, just use the Printercapability NORMALPRINTER in the config.
|
|
|
|
|
|
If a new printermode is discovered, please inherit from the **AbstractDocumentBuilder** to ensure that your new class has the same *contract* for the **PrintDirector** as all the other builder classes.
|
... | ... | @@ -170,5 +170,70 @@ abstract class AbstractIndexV4Builder<T extends PrintableData> extends AbstractD |
|
|
final byte[] mNewLine = new byte[] {0x0A};
|
|
|
|
|
|
```
|
|
|
|
|
|
To make it visible for the **Printdirector**, please add it in the class:
|
|
|
|
|
|
```java
|
|
|
public PrintDirector(final PrinterCapability printerCap, final Printer printerConfig) {
|
|
|
Objects.requireNonNull(printerCap);
|
|
|
Objects.requireNonNull(printerConfig);
|
|
|
this.mPrinter = printerCap;
|
|
|
mPrinterName = printerConfig.getProperty("name").toString();
|
|
|
mLogger.trace("Using following printercapability {}", printerCap.toString(), " loaded");
|
|
|
mLogger.info("Using the following printer: {}", mPrinterName);
|
|
|
switch (mPrinter) {
|
|
|
case NORMALPRINTER:
|
|
|
mBuilder = new NormalBuilder();
|
|
|
mLogger.trace("Using NormalBuilder as protocol");
|
|
|
break;
|
|
|
case INDEX_EVEREST_D_V4_GRAPHIC_PRINTER:
|
|
|
mBuilder = new GraphicPrintBuilder();
|
|
|
mLogger.trace("Using Index Everest-D V4 graphic print as protocol");
|
|
|
break;
|
|
|
case INDEX_EVEREST_D_V4_FLOATINGDOT_PRINTER:
|
|
|
mBuilder = new FloatingDotAreaBuilder();
|
|
|
mLogger.trace("Using Index Everest-D V4 floatingdot as protocol");
|
|
|
break;
|
|
|
// Here goes the new Builder
|
|
|
// case PRINTERNAME_PROTOCOL:
|
|
|
// mBuilder = new BUILDERCLASS()
|
|
|
default: throw new IllegalArgumentException();
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
... and also in the enumeration:
|
|
|
|
|
|
```java
|
|
|
public enum PrinterCapability {
|
|
|
NORMALPRINTER, INDEX_EVEREST_D_V4_FLOATINGDOT_PRINTER, INDEX_EVEREST_D_V4_GRAPHIC_PRINTER
|
|
|
// PRINTERNAME_PROTOCOL
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## Package Overview for brailleparser:
|
|
|
![brailleparser.svg](uploads/66abd2031fbd218077c664ad1fd99129/brailleparser.svg) |
|
|
\ No newline at end of file |
|
|
![brailleparser.svg](uploads/66abd2031fbd218077c664ad1fd99129/brailleparser.svg)
|
|
|
|
|
|
## **Extension**
|
|
|
If you want to extend the architecture, for example to add support for new fileformats, inherit from **AbstractBrailleTableParser**, adhere to the *contract* and register it in the **AbstractBrailleTableParser**:
|
|
|
|
|
|
```java
|
|
|
public static AbstractBrailleTableParser getParser(final Printer printer, final String property) throws NotSupportedFileExtensionException {
|
|
|
//read braille table path
|
|
|
String brailleTablePath = printer.getProperty(property).toString();
|
|
|
|
|
|
//read which kind of parser is needed (properties, json, xml,...)
|
|
|
String[] parts = brailleTablePath.split("\\.");
|
|
|
String fileEnding = parts[parts.length - 1]; // made safe for relative paths containing "./" or "../"
|
|
|
switch (fileEnding) {
|
|
|
case "properties":
|
|
|
return new PropertiesParser(brailleTablePath);
|
|
|
case "json":
|
|
|
return new JsonParser(brailleTablePath);
|
|
|
case "xml":
|
|
|
return new XmlParser(brailleTablePath);
|
|
|
// Add here a new case with the class
|
|
|
default:
|
|
|
throw new NotSupportedFileExtensionException("The Fileextension " + fileEnding + " is currently not supported.");
|
|
|
}
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |