use of org.rstudio.studio.client.workbench.views.plots.model.SavePlotAsPdfOptions in project rstudio by rstudio.
the class Plots method onSavePlotAsPdf.
void onSavePlotAsPdf() {
view_.bringToFront();
final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error");
indicator.onProgress("Preparing to export plot...");
// get the default directory
final FileSystemItem defaultDir = ExportPlotUtils.getDefaultSaveDirectory(workbenchContext_.getCurrentWorkingDir());
// get context
server_.getUniqueSavePlotStem(defaultDir.getPath(), new SimpleRequestCallback<String>() {
@Override
public void onResponseReceived(String stem) {
indicator.onCompleted();
Size size = getPlotSize();
final SavePlotAsPdfOptions currentOptions = uiPrefs_.get().savePlotAsPdfOptions().getValue();
exportPlot_.savePlotAsPdf(globalDisplay_, server_, session_.getSessionInfo(), defaultDir, stem, currentOptions, pixelsToInches(size.width), pixelsToInches(size.height), new OperationWithInput<SavePlotAsPdfOptions>() {
@Override
public void execute(SavePlotAsPdfOptions options) {
if (!SavePlotAsPdfOptions.areEqual(options, currentOptions)) {
UIPrefs prefs = uiPrefs_.get();
prefs.savePlotAsPdfOptions().setGlobalValue(options);
prefs.writeUIPrefs();
}
}
});
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
Aggregations