Implement SVG export

This commit is contained in:
2026-03-19 19:06:12 +01:00
parent ad45eddbf5
commit b8ecf9859b
5 changed files with 130 additions and 4 deletions

View File

@@ -15,7 +15,6 @@ import ovh.gasser.newshapes.ui.listeners.SelectionListener;
import javax.swing.*;
import java.awt.*;
import java.io.FileNotFoundException;
import java.util.Optional;
public class App {
private final static Logger logger = LoggerFactory.getLogger(App.class);
@@ -82,6 +81,7 @@ public class App {
JMenuItem addRectItem = new JMenuItem("Add SRectangle");
JMenuItem addCircleItem = new JMenuItem("Add SCircle");
JMenuItem htmlExportItem = new JMenuItem("Export to HTML");
JMenuItem svgExportItem = new JMenuItem("Export to SVG");
JMenuItem exitItem = new JMenuItem("Exit");
addRectItem.addActionListener(new MenuAddListener("SRectangle", model, sview));
addCircleItem.addActionListener(new MenuAddListener("SCircle", model, sview));
@@ -92,11 +92,19 @@ public class App {
logger.error("Could not export as html: {}", e.getMessage());
}
});
svgExportItem.addActionListener(evt -> {
try {
new SVGExporter(model).export();
} catch (FileNotFoundException e) {
logger.error("Could not export as html: {}", e.getMessage());
}
});
exitItem.addActionListener(evt -> System.exit(0));
menuFile.add(addRectItem);
menuFile.add(addCircleItem);
menuFile.addSeparator();
menuFile.add(htmlExportItem);
menuFile.add(svgExportItem);
menuFile.add(exitItem);
return menuFile;
}