本文整理汇总了Java中org.geomajas.plugin.printing.command.dto.PrintTemplateInfo类的典型用法代码示例。如果您正苦于以下问题:Java PrintTemplateInfo类的具体用法?Java PrintTemplateInfo怎么用?Java PrintTemplateInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrintTemplateInfo类属于org.geomajas.plugin.printing.command.dto包,在下文中一共展示了PrintTemplateInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printWithTemplateArgumentTest
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
@Test
public void printWithTemplateArgumentTest() {
PrintTemplateInfo printTemplateInfo = new PrintTemplateInfo();
PrintRequestInfo createInfo = new PrintRequestInfo();
createInfo.setPrintTemplateInfo(printTemplateInfo);
createInfo.setFileName("test.pdf");
createInfo.setPostPrintAction(PostPrintAction.OPEN);
Callback<PrintFinishedInfo, Void> callbackMock = mock(Callback.class);
printService.print(createInfo, callbackMock);
ArgumentCaptor<GwtCommand> commandCaptor = ArgumentCaptor.forClass(GwtCommand.class);
ArgumentCaptor<CommandCallback> callbackCaptor = ArgumentCaptor.forClass(CommandCallback.class);
verify(commandServiceMock).execute(commandCaptor.capture(), callbackCaptor.capture());
// assert command
GwtCommand command = commandCaptor.getValue();
Assert.assertEquals(PrintGetTemplateRequest.COMMAND, command.getCommandName());
Assert.assertTrue(command.getCommandRequest() instanceof PrintGetTemplateRequest);
PrintGetTemplateRequest request = (PrintGetTemplateRequest) command.getCommandRequest();
Assert.assertEquals(printTemplateInfo, request.getTemplate());
// assert callback
//callbackCaptor.getValue().execute();
}
示例2: execute
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
/**
* Perform the first step in generating a template-based printout of for instance the specified map view,
* the map's legend,....
*
* @param request
* (Input) It specifies the template and the output format of the document
* @param response
* (Output) On return, it contains the id of the document (possibly the rendering step is not yet
* completed)
*
* @param converterService
* @param printService
* @throws GeomajasException
*/
public static void execute(PrintGetTemplateExtRequest request, PrintGetTemplateExtResponse response,
PrintDtoConverterService converterService, PrintService printService) throws GeomajasException {
PrintTemplateInfo template = request.getTemplate();
PageComponent page = (PageComponent) converterService.toInternal(template.getPage());
// Adjust the title text of the legend component if present
updateLegendChildren(request, page);
if (request.getPageSize() != null) {
page.setSize(request.getPageSize(), true);
}
SinglePageDocument pdfDoc = new SinglePageDocument(page, null);
pdfDoc.layout();
// Add document to container
String documentId = printService.putDocument(pdfDoc);
response.setDocumentId(documentId);
}
示例3: buildTemplate
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
@Override
public PrintTemplateInfo buildTemplate() {
PrintTemplateInfo template = super.buildTemplate();
template.setId(1L);
template.setName("default");
return template;
}
示例4: runSync
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
private void runSync(Callback<PrintFinishedInfo, Void> callback, PrintRequestInfo printRequestInfo) {
// prepare common url and parameters
PrintFinishedInfo printFinishedInfo = prepareInfo(printRequestInfo);
// method = POST
printFinishedInfo.setMethod(HttpMethod.POST);
// add the JSON-ized template
PrintTemplateInfo printTemplateInfo = printRequestInfo.getPrintTemplateInfo();
printFinishedInfo.addParam(PrintUrlParameterKey.URL_TEMPLATE, JsonMapper.toJson(printTemplateInfo));
// synchronous call
callback.onSuccess(printFinishedInfo);
}
示例5: createPrintTemplateInfo
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
@Override
public PrintTemplateInfo createPrintTemplateInfo(MapPresenter mapPresenter,
String applicationId,
TemplateBuilder builder,
TemplateBuilderDataProvider templateBuilderDataProvider) {
builder.setApplicationId(applicationId);
builder.setMapPresenter(mapPresenter);
builder.setMarginX((int) PrintLayout.templateMarginX);
builder.setMarginY((int) PrintLayout.templateMarginY);
copyProviderDataToBuilder(builder, templateBuilderDataProvider);
return builder.buildTemplate();
}
示例6: captureServiceCallAndAssertTemplate
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
protected void captureServiceCallAndAssertTemplate() {
//attempt to get data from view
ArgumentCaptor<PrintRequestInfo> templateCaptor = ArgumentCaptor.forClass(PrintRequestInfo.class);
ArgumentCaptor<Callback> callbackCaptor = ArgumentCaptor.forClass(Callback.class);
verify(printServiceMock).print(templateCaptor.capture(), callbackCaptor.capture());
// assert command
PrintTemplateInfo templateInfo = templateCaptor.getValue().getPrintTemplateInfo();
assertPageComponentInfo(templateInfo.getPage());
}
示例7: printPost
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
@RequestMapping(value = "/printing", method = RequestMethod.POST)
public ModelAndView printPost(
@RequestParam(value = "download", defaultValue = DOWNLOAD_METHOD_SAVE, required = false) String download,
@RequestParam(value = "name", defaultValue = "geomajas.pdf", required = false) String fileName,
@RequestParam(value = "template") String templateJson,
@RequestParam(value = "pageSize", required = false) String pageSize,
@RequestParam(value = "dpi", defaultValue = "72", required = false) int dpi) throws GeomajasException,
JsonProcessingException, IOException {
// parse as a generic tree, sufficient to remove the nulls first
JsonNode tree = objectMapper.readTree(templateJson);
// remove the nulls first, some SLD classes fail when setting null
// preferably the client should not sent nulls, but gwt-jackson has no support for this
removeNulls(tree);
if (log.isTraceEnabled()) {
log.trace("");
log.trace("start json template :");
log.trace(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(tree));
log.trace("stop json template :");
log.trace("");
}
// reuse the null-safe tree to do the actual parsing
PrintTemplateInfo template = fromJson(tree);
PrintGetTemplateExtRequest request = new PrintGetTemplateExtRequest();
request.setOutputFormat(Format.decode(fileName).getExtension());
request.setPageSize(pageSize);
request.setTemplate(template);
PrintGetTemplateExtResponse response = new PrintGetTemplateExtResponse();
LayoutAsSinglePageDoc.execute(request, response, converterService, printService);
ModelAndView mav = new ModelAndView();
mav.setViewName(DOCUMENT_VIEW_NAME);
mav.addObject(DOCUMENT_KEY, printService.removeDocument(response.getDocumentId()));
mav.addObject(DOWNLOAD_KEY, download);
mav.addObject(FILENAME_KEY, fileName);
mav.addObject(FORMAT_KEY, Format.decode(fileName));
mav.addObject(DPI_KEY, dpi);
return mav;
}
示例8: testPost
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
@Test
public void testPost() throws Exception {
TestTemplateBuilder builder = new TestTemplateBuilder();
builder.setApplicationId(app.getId());
builder.setBounds(new Bbox(-31.44, -37.43, 80.83f, 80.83f));
builder.setMapInfo(app.getMaps().get(0));
builder.setMarginX(10);
builder.setMarginY(10);
builder.setPageHeight(PageSize.A4.getWidth());
builder.setPageWidth(PageSize.A4.getHeight());
builder.setRasterDpi(96);
builder.setTitleText("My map");
builder.setWithArrow(true);
builder.setWithScaleBar(true);
PrintTemplateInfo templateInfo = builder.buildTemplate();
ObjectMapper mapper = printingController.getObjectMapper();
String json = mapper.writer().writeValueAsString(templateInfo);
ModelAndView mv = printingController.printPost(PrintingController.DOWNLOAD_METHOD_SAVE, "mydoc.pdf",json,"A4", 200);
Document document = (Document) mv.getModel().get(PrintingController.DOCUMENT_KEY);
Assert.assertNotNull(document);
FileOutputStream fo = new FileOutputStream("target/mydoc.pdf");
document.render(fo, Format.PDF, 200);
fo.flush();
fo.close();
Assert.assertEquals("mydoc.pdf", mv.getModel().get(PrintingController.FILENAME_KEY));
Assert.assertEquals(Format.PDF, mv.getModel().get(PrintingController.FORMAT_KEY));
}
示例9: buildTemplate
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
public PrintTemplateInfo buildTemplate() {
PrintTemplateInfo template = new PrintTemplateInfo();
template.setPage(buildPage());
template.setId(1L);
template.setName("default");
return template;
}
示例10: buildTemplate
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
protected PrintTemplateInfo buildTemplate() {
PrintTemplateInfo template = new PrintTemplateInfo();
template.setPage(buildPage());
return template;
}
示例11: getPrintTemplateInfo
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
public PrintTemplateInfo getPrintTemplateInfo() {
return printTemplateInfo;
}
示例12: setPrintTemplateInfo
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
public void setPrintTemplateInfo(PrintTemplateInfo printTemplateInfo) {
this.printTemplateInfo = printTemplateInfo;
}
示例13: toJson
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
public static String toJson(PrintTemplateInfo printTemplate) {
return printTemplateInfoMapper.write(printTemplate);
}
示例14: asWidget
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
public Widget asWidget() {
Widget layout = UI_BINDER.createAndBindUi(this);
RESOURCE.css().ensureInjected();
// Create the mapPresenter and add an InitializationHandler:
mapPresenter = GeomajasImpl.getInstance().createMapPresenter();
mapPresenter.setSize(480, 480);
// Define the whole layout:
MapLayoutPanel mapLayout = new MapLayoutPanel();
mapLayout.setPresenter(mapPresenter);
mapPanel.add(mapLayout);
// Initialize the map, and return the layout:
GeomajasServerExtension.getInstance().initializeMap(mapPresenter, APPLICATION_ID, MAP_ID);
panel = new FlowPanel();
Button button = new Button();
button.addStyleName(RESOURCE.css().printPanelButton());
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
PrintRequestInfo printRequestInfo = new PrintRequestInfo();
printRequestInfo.setFileName(MESSAGES.printServiceExampleFixedFileName());
printRequestInfo.setPostPrintAction(PrintConfiguration.PostPrintAction.SAVE);
PrintTemplateInfo printTemplateInfo = Print.getInstance().getPrintUtil().
createPrintTemplateInfo(mapPresenter, APPLICATION_ID,
new DefaultTemplateBuilder(),
new TemplateBuilderDataProviderImpl());
printRequestInfo.setPrintTemplateInfo(printTemplateInfo);
Print.getInstance().getPrintService().print(printRequestInfo, new CustomPrintRequestHandler());
}
});
panel.add(button);
panel.setStyleName(RESOURCE.css().printPanel());
mapPresenter.getWidgetPane().add(panel.asWidget());
return layout;
}
示例15: fromJson
import org.geomajas.plugin.printing.command.dto.PrintTemplateInfo; //导入依赖的package包/类
private PrintTemplateInfo fromJson(JsonNode template) throws JsonProcessingException, IOException {
ObjectReader reader = objectMapper.reader(PrintTemplateInfo.class);
return reader.readValue(template);
}