Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* JasperReports - Free Java Reporting Library.
* Copyright (C) 2001 - 2023 Cloud Software Group, 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.customvisualization.fill;
import static net.sf.jasperreports.web.util.AbstractWebResourceHandler.PROPERTIES_WEB_RESOURCE_PATTERN_PREFIX;
import java.io.File;
import java.io.InputStream;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.sf.jasperreports.components.items.ItemData;
import net.sf.jasperreports.components.items.ItemProperty;
import net.sf.jasperreports.customvisualization.CVComponent;
import net.sf.jasperreports.customvisualization.CVConstants;
import net.sf.jasperreports.customvisualization.CVPrintElement;
import net.sf.jasperreports.customvisualization.CVUtils;
import net.sf.jasperreports.customvisualization.Processor;
import net.sf.jasperreports.engine.JRComponentElement;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRPropertiesUtil;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.JasperReportsContext;
import net.sf.jasperreports.engine.component.BaseFillComponent;
import net.sf.jasperreports.engine.component.FillContext;
import net.sf.jasperreports.engine.component.FillContextProvider;
import net.sf.jasperreports.engine.component.FillPrepareResult;
import net.sf.jasperreports.engine.fill.JRFillObjectFactory;
import net.sf.jasperreports.engine.fill.JRTemplateGenericElement;
import net.sf.jasperreports.engine.fill.JRTemplateGenericPrintElement;
import net.sf.jasperreports.engine.type.EvaluationTimeEnum;
import net.sf.jasperreports.engine.util.JRClassLoader;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.repo.RepositoryContext;
import net.sf.jasperreports.repo.RepositoryUtil;
import net.sf.jasperreports.repo.ResourceInfo;
public class CVFillComponent extends BaseFillComponent implements Serializable, FillContextProvider
{
private static final long serialVersionUID = CVConstants.SERIAL_VERSION_UID;
private static final Log log = LogFactory.getLog(CVFillComponent.class);
private final CVComponent component;
// Fill component elements
private List itemProperties;
private List itemDataList = new ArrayList<>();
private List>> datasetsData = new ArrayList<>();
private Processor processor = null;
private JasperReportsContext context = null;
// private List fillLayers;
// private SVGMapFillDataset dataset;
// private List colorRanges;
public CVFillComponent(CVComponent component, JRFillObjectFactory factory)
{
this.component = component;
this.itemProperties = new ArrayList<>();
if (factory != null)
{
// factory.registerElementDataset(this.dataset);
for (ItemProperty itemProperty : component.getItemProperties())
{
this.itemProperties.add(new CVFillItemProperty(itemProperty, factory));
}
for (ItemData data : component.getItemData())
{
if (data != null)
{
itemDataList.add(new CVFillItemData(this, data, factory));
datasetsData.add(null);
}
}
this.context = factory.getFiller().getJasperReportsContext();
}
String processingClass = component.getProcessingClass();
if (processingClass != null && processingClass.length() > 0)
{
try
{
Class> myClass = JRClassLoader.loadClassForName(processingClass);
processor = (Processor) myClass.getDeclaredConstructor().newInstance();
}
catch (ClassNotFoundException | InvocationTargetException | IllegalAccessException | InstantiationException | NoSuchMethodException e)
{
throw new JRRuntimeException("Could not create processor instance.", e);
}
}
}
protected boolean isEvaluateNow()
{
return getComponent().getEvaluationTime() == EvaluationTimeEnum.NOW;
}
protected CVComponent getComponent()
{
return component;
}
@Override
public void evaluate(byte evaluation) throws JRException
{
if (isEvaluateNow())
{
evaluateComponent(evaluation);
}
}
public void evaluateComponent(byte evaluation) throws JRException
{
if (fillContext != null)
{
for (CVFillItemProperty itemProperty : this.itemProperties)
{
itemProperty.evaluate(fillContext, evaluation);
}
for (int i = 0; i < this.itemDataList.size(); ++i)
{
CVFillItemData itemData = this.itemDataList.get(i);
if (itemData != null)
{
List