|
|
|
|
|
## Package Overview for printerbackend:
|
|
|
![PrinterBackend.svg](uploads/0359a1b084241740a97e5afde116a21e/PrinterBackend.svg)
|
|
|
|
|
|
## **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.
|
|
|
If would be beneficial to make a abstract class representing the printer itself, so let it inherit from **AbstractDocumentBuilder**, name it accordingly (e.g. PRINTERNAME_BUILDER), then create an class representing the protocol for the desired printermode, and inherit from the logical abstract class representing the printer.
|
|
|
You can add all the special byte sequences for the printer in the logical class, so that you do not need to use specific byte, but human readable abbreviations.
|
|
|
You can also set defaults if the documentation of the printer is verbose enough.
|
|
|
|
|
|
For example like in the **AbstractIndexV4Builder**:
|
|
|
|
|
|
```java
|
|
|
abstract class AbstractIndexV4Builder<T extends PrintableData> extends AbstractDocumentBuilder<T> {
|
|
|
|
|
|
/**
|
|
|
* Standard byte Sequence to announce StartTemporary document ([ESC]D).
|
|
|
* Must be always at the beginning.
|
|
|
*/
|
|
|
|
|
|
final byte[] mStartTemporaryDoc = new byte[] {0x1B, 0x44};
|
|
|
|
|
|
final byte[] mStartFloatingMode = new byte[] {0x1B, 0x46};
|
|
|
|
|
|
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)
|
|
|
|
|
|
## **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.");
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## Package Overview for rendering:
|
|
|
![rendering_detail.svg](uploads/a5c9fa84a7de13a68d7c2d4d65dd0941/rendering_detail.svg)
|
|
|
![rendering_basic.svg](uploads/c37a67538cdfa24942301508418c02f3/rendering_basic.svg)
|
... | ... | |