use of com.willwinder.universalgcodesender.gcode.processors.Translator in project Universal-G-Code-Sender by winder.
the class GcodeTilerTopComponent method generateOneTile.
private void generateOneTile(double offsetX, double offsetY, PrintWriter output) {
String gcodeFile = backend.getGcodeFile().getAbsolutePath();
UnitUtils.Units u = selectedUnit(this.units.getSelectedIndex());
GcodeParser parser = new GcodeParser();
parser.addCommandProcessor(new Translator(new Position(offsetX, offsetY, 0.0, u)));
parser.addCommandProcessor(new M30Processor());
output.println(GcodeUtils.unitCommand(u) + "G90");
output.println("G0X" + offsetX + "Y" + offsetY);
try {
File file = new File(gcodeFile);
try {
try (GcodeStreamReader gsr = new GcodeStreamReader(file)) {
while (gsr.getNumRowsRemaining() > 0) {
GcodeCommand next = gsr.getNextCommand();
applyTranslation(next.getCommandString(), parser, output);
}
}
} catch (GcodeStreamReader.NotGcodeStreamFile e) {
try (FileInputStream fstream = new FileInputStream(file);
DataInputStream dis = new DataInputStream(fstream);
BufferedReader fileStream = new BufferedReader(new InputStreamReader(dis))) {
String line;
while ((line = fileStream.readLine()) != null) {
applyTranslation(line, parser, output);
}
}
}
} catch (GcodeParserException | IOException ex) {
Exceptions.printStackTrace(ex);
}
}
Aggregations