<commit_before>//$HeadURL$
/*----------------------------------------------------------------------------
 This file is part of deegree, http://deegree.org/
 Copyright (C) 2001-2009 by:
 Department of Geography, University of Bonn
 and
 lat/lon GmbH

 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; either version 2.1 of the License, or (at your option)
 any later version.
 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.
 You should have received a copy of the GNU Lesser General Public License
 along with this library; if not, write to the Free Software Foundation, Inc.,
 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

 Contact information:

 lat/lon GmbH
 Aennchenstr. 19, 53177 Bonn
 Germany
 http://lat-lon.de/

 Department of Geography, University of Bonn
 Prof. Dr. <NAME>
 Postfach 1147, 53001 Bonn
 Germany
 http://www.geographie.uni-bonn.de/deegree/

 e-mail: <EMAIL>
 ----------------------------------------------------------------------------*/

package org.deegree.rendering.r2d.se.unevaluated;

import static java.awt.Color.black;
import static java.lang.Double.NEGATIVE_INFINITY;
import static java.lang.Double.POSITIVE_INFINITY;
import static org.deegree.commons.utils.CollectionUtils.unzip;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

import javax.xml.namespace.QName;

import org.deegree.commons.utils.DoublePair;
import org.deegree.commons.utils.Pair;
import org.deegree.commons.utils.Triple;
import org.deegree.feature.Feature;
import org.deegree.feature.property.Property;
import org.deegree.filter.XPathEvaluator;
import org.deegree.filter.function.geometry.IsCurve;
import org.deegree.filter.function.geometry.IsPoint;
import org.deegree.filter.function.geometry.IsSurface;
import org.deegree.geometry.Envelope;
import org.deegree.geometry.Geometry;
import org.deegree.geometry.multi.MultiCurve;
import org.deegree.geometry.multi.MultiLineString;
import org.deegree.geometry.multi.MultiPoint;
import org.deegree.geometry.multi.MultiPolygon;
import org.deegree.geometry.multi.MultiSurface;
import org.deegree.geometry.primitive.Curve;
import org.deegree.geometry.primitive.LineString;
import org.deegree.geometry.primitive.Point;
import org.deegree.geometry.primitive.Polygon;
import org.deegree.geometry.primitive.Surface;
import org.deegree.rendering.r2d.se.parser.SymbologyParser.FilterContinuation;
import org.deegree.rendering.r2d.styling.LineStyling;
import org.deegree.rendering.r2d.styling.PointStyling;
import org.deegree.rendering.r2d.styling.PolygonStyling;
import org.deegree.rendering.r2d.styling.Styling;
import org.deegree.rendering.r2d.styling.TextStyling;
import org.deegree.rendering.r2d.styling.components.Fill;
import org.deegree.rendering.r2d.styling.components.Stroke;
import org.slf4j.Logger;

/**
 * <code>Style</code>
 * 
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @author last edited by: $Author$
 * 
 * @version $Revision$, $Date$
 */
public class Style {

    private static final Logger LOG = getLogger( Style.class );

    private LinkedList<Pair<Continuation<LinkedList<Symbolizer<?>>>, DoublePair>> rules = new LinkedList<Pair<Continuation<LinkedList<Symbolizer<?>>>, DoublePair>>();

    private HashMap<Symbolizer<TextStyling>, Continuation<StringBuffer>> labels = new HashMap<Symbolizer<TextStyling>, Continuation<StringBuffer>>();

    private HashMap<Symbolizer<TextStyling>, String> labelXMLTexts = new HashMap<Symbolizer<TextStyling>, String>();

    private String name;

    private boolean useDefault;

    private PointStyling defaultPointStyle;

    private LineStyling defaultLineStyle;

    private PolygonStyling defaultPolygonStyle;

    private QName featureType;

    private File legendFile;

    /**
     * @param rules
     * @param labels
     * @param xmlTexts
     * @param name
     * @param featureTypeName
     */
    public Style( Collection<Pair<Continuation<LinkedList<Symbolizer<?>>>, DoublePair>> rules,
                  Map<Symbolizer<TextStyling>, Continuation<StringBuffer>> labels,
                  Map<Symbolizer<TextStyling>, String> xmlTexts, String name, QName featureTypeName ) {
        this.rules.addAll( rules );
        this.labels.putAll( labels );
        this.name = name;
        if ( xmlTexts != null ) {
            this.labelXMLTexts.putAll( xmlTexts );
        }
        featureType = featureTypeName;
    }

    /**
     * @param symbolizer
     * @param label
     * @param name
     * @param xmlText
     */
    public Style( Symbolizer<?> symbolizer, Continuation<StringBuffer> label, String name, String xmlText ) {
        InsertContinuation<LinkedList<Symbolizer<?>>, Symbolizer<?>> contn;
        contn = new InsertContinuation<LinkedList<Symbolizer<?>>, Symbolizer<?>>( symbolizer );
        rules.add( new Pair<Continuation<LinkedList<Symbolizer<?>>>, DoublePair>( contn,
                                                                                  new DoublePair( NEGATIVE_INFINITY,
                                                                                                  POSITIVE_INFINITY ) ) );
        if ( label != null ) {
            labels.put( (Symbolizer) symbolizer, label );
        }
        if ( xmlText != null ) {
            labelXMLTexts.put( (Symbolizer) symbolizer, xmlText );
        }
        this.name = name;
    }

    /**
     * Uses first geometry and default style.
     */
    public Style() {
        useDefault = true;
        defaultPointStyle = new PointStyling();
        defaultLineStyle = new LineStyling();
        defaultPolygonStyle = new PolygonStyling();

        defaultPolygonStyle.fill = new Fill();
        defaultPolygonStyle.stroke = new Stroke();
        defaultPolygonStyle.stroke.color = black;
    }

    /**
     * @param scale
     * @return a filtered list of symbolizers
     */
    public Style filter( double scale ) {
        if ( useDefault ) {
            return this;
        }<commit_msg>new constructor for colored default style<commit_after>//$HeadURL$
/*----------------------------------------------------------------------------
 This file is part of deegree, http://deegree.org/
 Copyright (C) 2001-2009 by:
 Department of Geography, University of Bonn
 and
 lat/lon GmbH

 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; either version 2.1 of the License, or (at your option)
 any later version.
 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.
 You should have received a copy of the GNU Lesser General Public License
 along with this library; if not, write to the Free Software Foundation, Inc.,
 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

 Contact information:

 lat/lon GmbH
 Aennchenstr. 19, 53177 Bonn
 Germany
 http://lat-lon.de/

 Department of Geography, University of Bonn
 Prof. Dr. <NAME>
 Postfach 1147, 53001 Bonn
 Germany
 http://www.geographie.uni-bonn.de/deegree/

 e-mail: <EMAIL>
 ----------------------------------------------------------------------------*/

package org.deegree.rendering.r2d.se.unevaluated;

import static java.awt.Color.black;
import static java.lang.Double.NEGATIVE_INFINITY;
import static java.lang.Double.POSITIVE_INFINITY;
import static org.deegree.commons.utils.CollectionUtils.unzip;
import static org.slf4j.LoggerFactory.getLogger;

import java.awt.Color;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

import javax.xml.namespace.QName;

import org.deegree.commons.utils.DoublePair;
import org.deegree.commons.utils.Pair;
import org.deegree.commons.utils.Triple;
import org.deegree.feature.Feature;
import org.deegree.feature.property.Property;
import org.deegree.filter.XPathEvaluator;
import org.deegree.filter.function.geometry.IsCurve;
import org.deegree.filter.function.geometry.IsPoint;
import org.deegree.filter.function.geometry.IsSurface;
import org.deegree.geometry.Envelope;
import org.deegree.geometry.Geometry;
import org.deegree.geometry.multi.MultiCurve;
import org.deegree.geometry.multi.MultiLineString;
import org.deegree.geometry.multi.MultiPoint;
import org.deegree.geometry.multi.MultiPolygon;
import org.deegree.geometry.multi.MultiSurface;
import org.deegree.geometry.primitive.Curve;
import org.deegree.geometry.primitive.LineString;
import org.deegree.geometry.primitive.Point;
import org.deegree.geometry.primitive.Polygon;
import org.deegree.geometry.primitive.Surface;
import org.deegree.rendering.r2d.se.parser.SymbologyParser.FilterContinuation;
import org.deegree.rendering.r2d.styling.LineStyling;
import org.deegree.rendering.r2d.styling.PointStyling;
import org.deegree.rendering.r2d.styling.PolygonStyling;
import org.deegree.rendering.r2d.styling.Styling;
import org.deegree.rendering.r2d.styling.TextStyling;
import org.deegree.rendering.r2d.styling.components.Fill;
import org.deegree.rendering.r2d.styling.components.Stroke;
import org.slf4j.Logger;

/**
 * <code>Style</code>
 * 
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @author last edited by: $Author$
 * 
 * @version $Revision$, $Date$
 */
public class Style {

    private static final Logger LOG = getLogger( Style.class );

    private LinkedList<Pair<Continuation<LinkedList<Symbolizer<?>>>, DoublePair>> rules = new LinkedList<Pair<Continuation<LinkedList<Symbolizer<?>>>, DoublePair>>();

    private HashMap<Symbolizer<TextStyling>, Continuation<StringBuffer>> labels = new HashMap<Symbolizer<TextStyling>, Continuation<StringBuffer>>();

    private HashMap<Symbolizer<TextStyling>, String> labelXMLTexts = new HashMap<Symbolizer<TextStyling>, String>();

    private String name;

    private boolean useDefault;

    private PointStyling defaultPointStyle;

    private LineStyling defaultLineStyle;

    private PolygonStyling defaultPolygonStyle;

    private QName featureType;

    private File legendFile;

    /**
     * @param rules
     * @param labels
     * @param xmlTexts
     * @param name
     * @param featureTypeName
     */
    public Style( Collection<Pair<Continuation<LinkedList<Symbolizer<?>>>, DoublePair>> rules,
                  Map<Symbolizer<TextStyling>, Continuation<StringBuffer>> labels,
                  Map<Symbolizer<TextStyling>, String> xmlTexts, String name, QName featureTypeName ) {
        this.rules.addAll( rules );
        this.labels.putAll( labels );
        this.name = name;
        if ( xmlTexts != null ) {
            this.labelXMLTexts.putAll( xmlTexts );
        }
        featureType = featureTypeName;
    }

    /**
     * @param symbolizer
     * @param label
     * @param name
     * @param xmlText
     */
    public Style( Symbolizer<?> symbolizer, Continuation<StringBuffer> label, String name, String xmlText ) {
        InsertContinuation<LinkedList<Symbolizer<?>>, Symbolizer<?>> contn;
        contn = new InsertContinuation<LinkedList<Symbolizer<?>>, Symbolizer<?>>( symbolizer );
        rules.add( new Pair<Continuation<LinkedList<Symbolizer<?>>>, DoublePair>( contn,
                                                                                  new DoublePair( NEGATIVE_INFINITY,
                                                                                                  POSITIVE_INFINITY ) ) );
        if ( label != null ) {
            labels.put( (Symbolizer) symbolizer, label );
        }
        if ( xmlText != null ) {
            labelXMLTexts.put( (Symbolizer) symbolizer, xmlText );
        }
        this.name = name;
    }

    /**
     * Uses first geometry and default style.
     */
    public Style() {
        useDefault = true;
        defaultPointStyle = new PointStyling();
        defaultLineStyle = new LineStyling();
        defaultPolygonStyle = new PolygonStyling();

        defaultPolygonStyle.fill = new Fill();
        defaultPolygonStyle.stroke = new Stroke();
        defaultPolygonStyle.stroke.color = black;
    }

    /**
     * Uses first geometry and default style in specified color.
     */
    public Style( Color c ) {
        useDefault = true;
        defaultPointStyle = new PointStyling();
        defaultLineStyle = new LineStyling();
        defaultPolygonStyle = new PolygonStyling();

        defaultLineStyle.stroke.color = c;

        defaultPolygonStyle.fill = new Fill();
        defaultPolygonStyle.fill.color = c;
        defaultPolygonStyle.stroke = new Stroke();
        defaultPolygonStyle.stroke.color = black;
    }

    /**
     * @param scale
     * @return a filtered list of symbolizers
     */
    public Style filter( double scale ) {
        if ( useDefault ) {
            return this;
        }
{'fraction_non_alphanumeric': 0.1200868458486187, 'fraction_numerical': 0.007636445309575504, 'mean_word_length': 2.9696879643387817, 'pattern_counts': {'":': 0, '<': 107, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 18}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7062368', 'n_tokens_mistral': 3919, 'n_tokens_neox': 3773, 'n_words': 947}