当前位置: 首页>>代码示例>>Java>>正文


Java JRHtmlExporterContext类代码示例

本文整理汇总了Java中net.sf.jasperreports.engine.export.JRHtmlExporterContext的典型用法代码示例。如果您正苦于以下问题:Java JRHtmlExporterContext类的具体用法?Java JRHtmlExporterContext怎么用?Java JRHtmlExporterContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JRHtmlExporterContext类属于net.sf.jasperreports.engine.export包,在下文中一共展示了JRHtmlExporterContext类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetHtmlFragment

import net.sf.jasperreports.engine.export.JRHtmlExporterContext; //导入依赖的package包/类
@Ignore("Moved test from generic element")
@Test
public void testGetHtmlFragment() {
  JRGenericPrintElement element = mock(JRGenericPrintElement.class);
  when(element.getParameterNames()).thenReturn(parameters.keySet());
  when(element.getParameterValue(WmsRequestParameter.WMS_URL.name()))
      .thenReturn(BASE_URL);
  when(element.getParameterValue(WmsRequestParameter.LAYERS.name()))
      .thenReturn("Hintergrund");
  when(element.getParameterValue(WmsRequestParameter.BBOX.name()))
      .thenReturn("1,1,1,1");
  when(element.getParameterValue(WmsRequestParameter.SRS_CRS.name()))
      .thenReturn("EPSG:21781");
  when(element.getWidth()).thenReturn(100);
  when(element.getHeight()).thenReturn(100);
  String htmlFragment = handler.getHtmlFragment(
      mock(JRHtmlExporterContext.class), element);
  assertThat(htmlFragment, startsWith("<img "));
  assertThat(htmlFragment, containsString(BASE_URL));
  assertThat(htmlFragment, containsString("WIDTH=100"));
  assertThat(htmlFragment, containsString("HEIGHT=100"));
}
 
开发者ID:sourcepole,项目名称:jasperreports-wms-component,代码行数:23,代码来源:WmsMapElementHtmlHandlerTest.java

示例2: getHtmlFragment

import net.sf.jasperreports.engine.export.JRHtmlExporterContext; //导入依赖的package包/类
@Override
public String getHtmlFragment(JRHtmlExporterContext context, JRGenericPrintElement element)
{
	StringBuilder script = new StringBuilder(128);
	script.append("<script type='text/javascript' src='https://www.openhub.net/p/");
	script.append(getProjectID(element));
	script.append("/widgets/");
	script.append(getWidgetName());
	script.append("?format=js'></script>");
	return script.toString();
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:12,代码来源:OhlohWidgetHtmlHandler.java

示例3: getHtmlFragment

import net.sf.jasperreports.engine.export.JRHtmlExporterContext; //导入依赖的package包/类
@Override
public String getHtmlFragment(JRHtmlExporterContext context, JRGenericPrintElement element)	{
	String id = (String) element.getParameterValue("id");
	String data = (String) element.getParameterValue("data");	
	StringBuffer script = new StringBuffer();
	script.append("<div id=\"" + id + "\">" + data + "</div>");
	return script.toString();
}
 
开发者ID:svn2github,项目名称:dynamicreports-jasper,代码行数:9,代码来源:CustomHtmlHandler.java

示例4: getHtmlFragment

import net.sf.jasperreports.engine.export.JRHtmlExporterContext; //导入依赖的package包/类
@Override
public String getHtmlFragment(JRHtmlExporterContext exporterContext, JRGenericPrintElement element)	{
	StringBuilder result = new StringBuilder();
	result.append("<div style=\"position: absolute; left: ");
	result.append(element.getX() + "px; top: ");
	result.append(element.getY() + "px; width: ");
	result.append(element.getWidth() + "px; height: ");
	result.append(element.getHeight() + "px;\">");
	result.append(super.getHtmlFragment(exporterContext, element));
	result.append("</div>");
	return result.toString();
}
 
开发者ID:svn2github,项目名称:dynamicreports-jasper,代码行数:13,代码来源:OpenFlashChartXhtmlHandler.java

示例5: getHtmlFragment

import net.sf.jasperreports.engine.export.JRHtmlExporterContext; //导入依赖的package包/类
@Override
public String getHtmlFragment(JRHtmlExporterContext exporterContext, JRGenericPrintElement element) {
	String divID = "ofc" + System.identityHashCode(element);
	int width = element.getWidth();
	int height = element.getHeight();
	Color backcolor = element.getBackcolor();
	String chartData = ((ChartGenerator) element.getParameterValue(ChartGenerator.PARAMETER_CHART_GENERATOR)).generateChart();
	String chartEncodedData = JRStringUtil.htmlEncode(chartData);

	StringBuffer result = new StringBuffer();
	result.append("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" ");
	result.append("width=\"" + width + "\" ");
	result.append("height=\"" + height + "\" ");
	result.append("id=\"" + divID + "\" ");
	result.append("align=\"middle\">");
	result.append("<param name=\"allowScriptAccess\" value=\"sameDomain\" /> ");
	result.append("<param name=\"movie\" value=\"");
	result.append(getSwfLocation());
	result.append("?width=" + width);
	result.append("&height=" + height);
	result.append("&inline_data=" + chartEncodedData);
	result.append("\" /> ");
	result.append("<param name=\"quality\" value=\"high\" />");
	result.append("<param name=\"bgcolor\" value=\"#" + JRColorUtil.getColorHexa(backcolor) + "\" /> ");
	result.append("<embed src=\"");
	result.append(getSwfLocation());
	result.append("?width=" + width);
	result.append("&height=" + height);
	result.append("&inline_data=" + chartEncodedData);
	result.append("\" quality=\"high\" ");
	result.append("bgcolor=\"#" + JRColorUtil.getColorHexa(backcolor) + "\" ");
	result.append("width=\"" + width + "\" ");
	result.append("height=\"" + height + "\" ");
	result.append("name=\"open-flash-chart\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /> </object> ");

	return result.toString();
}
 
开发者ID:svn2github,项目名称:dynamicreports-jasper,代码行数:38,代码来源:OpenFlashChartHtmlHandler.java

示例6: getHtmlFragment

import net.sf.jasperreports.engine.export.JRHtmlExporterContext; //导入依赖的package包/类
@Override
public String getHtmlFragment(JRHtmlExporterContext context,
    JRGenericPrintElement element) {

  Map<String, Object> contextMap = new HashMap<String, Object>();
  contextMap.put("mapCanvasId", "map_canvas_" + element.hashCode());

  if (context.getExporter() instanceof JRXhtmlExporter) {
    contextMap.put("xhtml", "xhtml");
    JRXhtmlExporter xhtmlExporter = (JRXhtmlExporter) context.getExporter();
    contextMap.put("elementX", xhtmlExporter.toSizeUnit(element.getX()));
    contextMap.put("elementY", xhtmlExporter.toSizeUnit(element.getY()));
  } else {
    JRHtmlExporter htmlExporter = (JRHtmlExporter) context.getExporter();
    contextMap.put("elementX", htmlExporter.toSizeUnit(element.getX()));
    contextMap.put("elementY", htmlExporter.toSizeUnit(element.getY()));
  }
  contextMap.put("elementId", element.getKey());
  contextMap.put("elementWidth", element.getWidth());
  contextMap.put("elementHeight", element.getHeight());

  if (element.getModeValue() == ModeEnum.OPAQUE) {
    contextMap.put("backgroundColor",
        JRColorUtil.getColorHexa(element.getBackcolor()));
  }
  WmsRequestBuilder requestBuilder =
      WmsMapElementImageProvider.mapRequestBuilder(element);
  try {
    contextMap.put("wmsMapUrl", requestBuilder.toMapUrl());
  } catch (MalformedURLException e) {
    throw new RuntimeException("Unable to build WMS map service url", e);
  }

  return VelocityUtil.processTemplate(MAP_ELEMENT_HTML_TEMPLATE, contextMap);
}
 
开发者ID:sourcepole,项目名称:jasperreports-wms-component,代码行数:36,代码来源:WmsMapElementHtmlHandler.java

示例7: getHtmlFragment

import net.sf.jasperreports.engine.export.JRHtmlExporterContext; //导入依赖的package包/类
public String getHtmlFragment(JRHtmlExporterContext exporterContext, JRGenericPrintElement element)
{
	String divID = "ofc" + System.identityHashCode(element);
	int width = element.getWidth();
	int height = element.getHeight();
	Color backcolor = element.getBackcolor();
	String swfLocation = "openflashchart/open-flash-chart.swf";
	String chartData = (String) element.getParameterValue(PARAMETER_CHART_DATA);
	String chartEncodedData = JRStringUtil.htmlEncode(chartData);

	return 
		"<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"" +
			width +
			"\" height=\"" +
			height +
			"\" id=\"" +
			divID +
			"\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /> <param name=\"movie\" value=\"" +
			swfLocation +
			"?width=" +
			width +
			"&height=" +
			height +
			"&inline_data=" +
			chartEncodedData +
			"\" /> <param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"" +
			"#" + JRColorUtil.getColorHexa(backcolor) +
			"\" /> <embed src=\"" +
			swfLocation +
			"?width=" +
			width +
			"&height=" +
			height +
			"&inline_data=" +
			chartEncodedData +
			"\" quality=\"high\" bgcolor=\"" +
			"#" + JRColorUtil.getColorHexa(backcolor) +
			"\" width=\"" +
			width +
			"\" height=\"" +
			height +
			"\" name=\"open-flash-chart\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /> </object> ";
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:44,代码来源:ChartHtmlHandler.java

示例8: getHtmlFragment

import net.sf.jasperreports.engine.export.JRHtmlExporterContext; //导入依赖的package包/类
@Override
public String getHtmlFragment(JRHtmlExporterContext context, JRGenericPrintElement element)
{
       ReportContext reportContext = context.getExporterRef().getReportContext();
	Map<String, Object> contextMap = new HashMap<String, Object>();

       contextMap.put("mapCanvasId", "map_canvas_" + element.hashCode());

       HtmlExporter htmlExporter = (HtmlExporter)context.getExporterRef();

       contextMap.put("elementX", htmlExporter.toSizeUnit((float)element.getX()));
       contextMap.put("elementY", htmlExporter.toSizeUnit((float)element.getY()));
       contextMap.put("elementWidth", element.getWidth());
       contextMap.put("elementHeight", element.getHeight());

       if (element.getModeValue() == ModeEnum.OPAQUE)
       {
           contextMap.put("backgroundColor", JRColorUtil.getColorHexa(element.getBackcolor()));
       }

       contextMap.put("gotReportContext", reportContext != null);

       if (reportContext == null)
       {
           Float latitude = (Float)element.getParameterValue(MapComponent.ITEM_PROPERTY_latitude);
           latitude = latitude == null ? MapComponent.DEFAULT_LATITUDE : latitude;

           Float longitude = (Float)element.getParameterValue(MapComponent.ITEM_PROPERTY_longitude);
           longitude = longitude == null ? MapComponent.DEFAULT_LONGITUDE : longitude;

           Integer zoom = (Integer)element.getParameterValue(MapComponent.PARAMETER_ZOOM);
           zoom = zoom == null ? MapComponent.DEFAULT_ZOOM : zoom;

           String mapType = (String)element.getParameterValue(MapComponent.ATTRIBUTE_MAP_TYPE);
           mapType = (mapType == null ? MapComponent.DEFAULT_MAP_TYPE.getName() : mapType).toUpperCase();

           contextMap.put("latitude", latitude);
           contextMap.put("longitude", longitude);
           contextMap.put("zoom", zoom);
           contextMap.put("mapType", mapType);

           List<Map<String,Object>> markerList = (List<Map<String,Object>>)element.getParameterValue(MapComponent.PARAMETER_MARKERS);
           String markers = markerList == null || markerList.isEmpty() ? "[]" : JacksonUtil.getInstance(context.getJasperReportsContext()).getJsonString(markerList);
           contextMap.put("markerList", markers);

           List<Map<String,Object>> pathList = (List<Map<String,Object>>)element.getParameterValue(MapComponent.PARAMETER_PATHS);
           String paths = pathList == null || pathList.isEmpty() ? "[]" : JacksonUtil.getInstance(context.getJasperReportsContext()).getJsonString(pathList);
           contextMap.put("pathsList", paths);

           String reqParams = (String)element.getParameterValue(MapComponent.PARAMETER_REQ_PARAMS);
           if(reqParams != null)
           {
               contextMap.put(MapComponent.PARAMETER_REQ_PARAMS, reqParams);
           }

           if (context.getValue(FIRST_ATTEMPT_PARAM) == null)
           {
               context.setValue(FIRST_ATTEMPT_PARAM, true);

               //FIXME: support for parametrized http://maps.google.com/maps/api/js script (see MapElementHtmlTemplate.vm)
               contextMap.put("exporterFirstAttempt", true);
           }
       }
	
	return VelocityUtil.processTemplate(MAP_ELEMENT_HTML_TEMPLATE, contextMap);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:67,代码来源:MapElementHtmlHandler.java

示例9: getHtmlFragment

import net.sf.jasperreports.engine.export.JRHtmlExporterContext; //导入依赖的package包/类
@Override
public String getHtmlFragment(JRHtmlExporterContext context, JRGenericPrintElement element)
{
	JRPrintText labelPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_LABEL_TEXT_ELEMENT);
	if (labelPrintText == null)
	{
		return null;
	}

	JRBasePrintFrame frame = new JRBasePrintFrame(element.getDefaultStyleProvider());
	frame.setX(element.getX());
	frame.setY(element.getY());
	frame.setWidth(element.getWidth());
	frame.setHeight(element.getHeight());
	frame.setStyle(element.getStyle());
	frame.setBackcolor(element.getBackcolor());
	frame.setForecolor(element.getForecolor());
	frame.setMode(element.getModeValue());
	JRLineBox lineBox = (JRLineBox)element.getParameterValue(IconLabelElement.PARAMETER_LINE_BOX);
	if (lineBox != null)
	{
		frame.copyBox(lineBox);
	}
	
	frame.addElement(labelPrintText);
	
	JRPrintText iconPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_ICON_TEXT_ELEMENT);
	if (iconPrintText != null)
	{
		frame.addElement(iconPrintText);
	}

	HtmlExporter htmlExporter = (HtmlExporter)context.getExporterRef();
	List<JRPrintElement> elements = new ArrayList<JRPrintElement>();
	elements.add(frame);

	try
	{
		htmlExporter.exportElements(elements);
	}
	catch (IOException e)
	{
		throw new JRRuntimeException(e);
	}
	
	return "";
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:48,代码来源:IconLabelElementHtmlHandler.java

示例10: getHtmlFragment

import net.sf.jasperreports.engine.export.JRHtmlExporterContext; //导入依赖的package包/类
@Override
public String getHtmlFragment(JRHtmlExporterContext context, JRGenericPrintElement element)	{
	Boolean showLegend = (Boolean) element.getParameterValue(GeoMapPrintElement.PARAMETER_SHOW_LEGEND);
	GeoMapDataMode dataMode = (GeoMapDataMode) element.getParameterValue(GeoMapPrintElement.PARAMETER_DATA_MODE);
	String region = (String) element.getParameterValue(GeoMapPrintElement.PARAMETER_REGION);
	String valueLabel = (String) element.getParameterValue(GeoMapPrintElement.PARAMETER_VALUE_LABEL);
	if (valueLabel == null) {
		valueLabel = "";
	}
	@SuppressWarnings("unchecked")
	List<Color> colors = (List<Color>) element.getParameterValue(GeoMapPrintElement.PARAMETER_COLORS);
	String stringColors = null;
	if (colors != null && !colors.isEmpty()) {
		stringColors = "";
		for (Color color : colors) {
			stringColors += "," + getColorString(color);
		}
		stringColors = StringUtils.removeStart(stringColors, ",");
	}
	@SuppressWarnings("unchecked")
	Set<GeoMapData> dataset = (Set<GeoMapData>) element.getParameterValue(GeoMapPrintElement.PARAMETER_DATASET);

	VelocityContext velocityContext = new VelocityContext();
	velocityContext.put("showLegend", showLegend);
	if (dataMode != null) {
		switch (dataMode) {
		case REGIONS:
			velocityContext.put("dataMode", "regions");
			break;
		case MARKERS:
			velocityContext.put("dataMode", "markers");
			break;
		default:
			break;
		}
	}
	velocityContext.put("id", "map_" + element.hashCode());
	velocityContext.put("region", region);
	velocityContext.put("valueLabel", valueLabel);
	velocityContext.put("colors", stringColors);
	velocityContext.put("dataset", dataset);
   @SuppressWarnings("unchecked")
	Exporter<ExporterInput, ? extends HtmlReportConfiguration, ? extends HtmlExporterConfiguration, HtmlExporterOutput> exporter = context.getExporterRef();
   HtmlExporter htmlExporter2 = exporter instanceof HtmlExporter ? (HtmlExporter)exporter : null;
	if(htmlExporter2 == null) {
		velocityContext.put("xhtml", "xhtml");
		velocityContext.put("elementX", ((HtmlExporter)context.getExporterRef()).toSizeUnit((float) element.getX()));
		velocityContext.put("elementY", ((HtmlExporter)context.getExporterRef()).toSizeUnit((float) element.getY()));
	}
	else {
		velocityContext.put("elementX", ((HtmlExporter)context.getExporterRef()).toSizeUnit((float) element.getX()));
		velocityContext.put("elementY", ((HtmlExporter)context.getExporterRef()).toSizeUnit((float) element.getY()));
	}
	velocityContext.put("elementWidth", element.getWidth());
	velocityContext.put("elementHeight", element.getHeight());

	if (element.getModeValue() == ModeEnum.OPAQUE) {
		velocityContext.put("backgroundColor", JRColorUtil.getColorHexa(element.getBackcolor()));
	}
	return VelocityUtil.processTemplate(GEOMAP_ELEMENT_HTML_TEMPLATE, velocityContext);
}
 
开发者ID:svn2github,项目名称:dynamicreports-jasper,代码行数:62,代码来源:GeoMapElementHtmlHandler.java


注:本文中的net.sf.jasperreports.engine.export.JRHtmlExporterContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。