net.sf.jasperreports.components.map.MapElementImageProvider Maven / Gradle / Ivy
/*
* JasperReports - Free Java Reporting Library.
* Copyright (C) 2001 - 2014 TIBCO Software Inc. All rights reserved.
* http://www.jaspersoft.com
*
* Unless you have purchased a commercial license agreement from Jaspersoft,
* the following license terms apply:
*
* This program is part of JasperReports.
*
* JasperReports is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* JasperReports is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JasperReports. If not, see .
*/
package net.sf.jasperreports.components.map;
import java.awt.Color;
import java.util.List;
import java.util.Map;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRGenericPrintElement;
import net.sf.jasperreports.engine.JRPrintImage;
import net.sf.jasperreports.engine.JasperReportsContext;
import net.sf.jasperreports.engine.base.JRBasePrintImage;
import net.sf.jasperreports.engine.type.HorizontalImageAlignEnum;
import net.sf.jasperreports.engine.type.OnErrorTypeEnum;
import net.sf.jasperreports.engine.type.ScaleImageEnum;
import net.sf.jasperreports.engine.type.VerticalImageAlignEnum;
import net.sf.jasperreports.engine.util.JRColorUtil;
import net.sf.jasperreports.renderers.Renderable;
import net.sf.jasperreports.renderers.util.RendererUtil;
/**
* @author sanda zaharia ([email protected])
*/
public class MapElementImageProvider
{
/**
* The character count limit for a static map URL request
*/
public static Integer MAX_URL_LENGTH = 2048;
public static JRPrintImage getImage(JasperReportsContext jasperReportsContext, JRGenericPrintElement element) throws JRException
{
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);
String mapScale = (String)element.getParameterValue(MapComponent.ATTRIBUTE_MAP_SCALE);
String mapFormat = (String)element.getParameterValue(MapComponent.ATTRIBUTE_IMAGE_TYPE);
String reqParams = (String)element.getParameterValue(MapComponent.PARAMETER_REQ_PARAMS);
String markers ="";
List