MCPcopy Create free account
hub / github.com/rambaut/figtree / doExportGraphic

Method doExportGraphic

src/figtree/application/FigTreeFrame.java:1208–1239  ·  view source on GitHub ↗
(GraphicFormat format)

Source from the content-addressed store, hash-verified

1206 }
1207
1208 public final void doExportGraphic(GraphicFormat format) {
1209 FileDialog dialog = new FileDialog(this,
1210 "Export " + format.getName() + " File...",
1211 FileDialog.SAVE);
1212
1213 String name = this.getFile().getName() + "." + format.getName().toLowerCase();
1214 dialog.setFile(name);
1215
1216 dialog.setVisible(true);
1217 if (dialog.getFile() != null) {
1218 File file = new File(dialog.getDirectory(), dialog.getFile());
1219
1220 try {
1221 OutputStream stream = new FileOutputStream(file);
1222
1223 exportGraphics(format, treeViewer.getContentPane(), stream);
1224
1225 stream.flush();
1226 stream.close();
1227 } catch(DocumentException de) {
1228 JOptionPane.showMessageDialog(this, "Error writing PDF file: " + de,
1229 "Export PDF Error",
1230 JOptionPane.ERROR_MESSAGE);
1231 } catch (IOException ioe) {
1232 JOptionPane.showMessageDialog(this, "Error writing tree file: " + ioe.getMessage(),
1233 "Export Error",
1234 JOptionPane.ERROR_MESSAGE);
1235 }
1236
1237 }
1238
1239 }
1240
1241 public final static void exportGraphics(GraphicFormat format, JComponent comp, OutputStream stream) throws IOException, DocumentException {
1242 switch (format) {

Callers 1

actionPerformedMethod · 0.95

Calls 7

exportGraphicsMethod · 0.95
setFileMethod · 0.80
closeMethod · 0.80
getNameMethod · 0.65
getFileMethod · 0.45
setVisibleMethod · 0.45
getContentPaneMethod · 0.45

Tested by

no test coverage detected