Statistics
| Revision:

gvsig-sldtools / org.gvsig.sld / org.gvsig.sldconverter / org.gvsig.sldconverter.lib / org.gvsig.sldconverter.lib.impl / src / main / java / org / gvsig / sldconverter / impl / symbol / LineSymbolUtils.java @ 46

History | View | Annotate | Download (2.61 KB)

1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.sldconverter.impl.symbol;
27

    
28
import java.awt.Color;
29

    
30
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
31
import org.gvsig.sldconverter.exception.UnsupportedSymbolException;
32
import org.gvsig.sldconverter.impl.util.BasicUtils;
33
import org.gvsig.sldsupport.exception.UnsupportedSLDObjectException;
34
import org.gvsig.sldsupport.sld.filter.expression.operator.SLDLiteral;
35
import org.gvsig.sldsupport.sld.symbol.SLDLineSymbol;
36
import org.gvsig.sldsupport.sld.symbol.misc.SLDStroke;
37
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol;
38

    
39
public class LineSymbolUtils {
40
        
41
        public static ISymbol toLineSymbol(SLDLineSymbol sym) 
42
                        throws UnsupportedSLDObjectException {
43
                
44
                ILineSymbol resp = BasicUtils.symMan().createSimpleLineSymbol();
45
                SLDStroke stro = sym.getStroke();
46
                
47
                Color col = BasicUtils.toColor(stro.getColor());
48
                if (col != null) {
49
                        resp.setColor(col);
50
                }
51
                Double wi = BasicUtils.toDouble(stro.getWidth());
52
                if (wi != null) {
53
                        resp.setLineWidth(wi);
54
                }
55
                return resp;
56
        }
57
        
58
        
59
        public static SLDLineSymbol toSLDLineSymbol(ILineSymbol sym)
60
                        throws UnsupportedSymbolException {
61
                
62
                Color bcolor = sym.getColor();
63
                double bw = sym.getLineWidth();
64
                
65
                SLDStroke stro = new SLDStroke();
66
                stro.setColor(bcolor);
67
                stro.setWidth(new SLDLiteral(BasicUtils.df.format(bw)));
68
                
69
                SLDLineSymbol resp = new SLDLineSymbol();
70
                resp.setStroke(stro);
71
                return resp;
72
        }
73
        
74
        
75
}