/* * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * * (C) 2016, Open Source Geospatial Foundation (OSGeo) * * This library 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; * version 2.1 of the License. * * This library 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. * */ package org.geotools.polylabel; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.geotools.feature.NameImpl; import org.geotools.filter.FunctionFactory; import org.opengis.feature.type.Name; import org.opengis.filter.capability.FunctionName; import org.opengis.filter.expression.Expression; import org.opengis.filter.expression.Function; import org.opengis.filter.expression.Literal; public class PolygonLabelFunctionFactory implements FunctionFactory { public List<FunctionName> getFunctionNames() { List<FunctionName> functionList = new ArrayList<>(); functionList.add(PolygonLabelFunction.NAME); return Collections.unmodifiableList(functionList); } public Function function(String name, List<Expression> args, Literal fallback) { return function(new NameImpl(name), args, fallback); } public Function function(Name name, List<Expression> args, Literal fallback) { if (PolygonLabelFunction.NAME.getFunctionName().equals(name)) { return new PolygonLabelFunction(args, fallback); } return null; // we do not implement that function } }