Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.symbology / org.gvsig.symbology.swing / org.gvsig.symbology.swing.api / src / main / java / org / gvsig / app / gui / styling / PictureLine.java @ 45526

History | View | Annotate | Download (4.62 KB)

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

    
26
import java.io.IOException;
27
import java.net.URL;
28

    
29
import org.gvsig.fmap.mapcontext.MapContextLocator;
30
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
31
import org.gvsig.fmap.mapcontext.rendering.symbols.IWarningSymbol;
32
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException;
33
import org.gvsig.i18n.Messages;
34
import org.gvsig.symbology.SymbologyLocator;
35
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.IPictureLineSymbol;
36

    
37
/**
38
 * PictureLine initializes the properties that define a
39
 * <b>picture marker symbol</b> and are showed in the tab created by
40
 * PictureMarker which is called simple marker.<p>
41
 * <p>
42
 * Moreover, PictureLine has other methods such as getSymbolClass,getName,
43
 * refreshControls and getLayer.
44
 *
45
 *
46
 * @author jaume dominguez faus - jaume.dominguez@iver.es
47
 */
48
public class PictureLine extends PictureMarker {
49

    
50
    public PictureLine(SymbolEditor owner) {
51
        super(owner);
52
    }
53

    
54
    @Override
55
    public String getName() {
56
        return Messages.getText("picture_line_symbol");
57
    }
58

    
59
    @Override
60
    public void refreshControls(ISymbol layer) {
61
        try {
62
            if (layer == null) {
63
                setValues(1d, 0d, 0d, null, null); //, sym.getOffsetXExpression(), sym.getOffsetYExpression(), sym.getLineToOffsetColor(), sym.getLineToOffsetColorExpression(), sym.getRotation(), sym.getRotationExpression());
64
            } else {
65
                IPictureLineSymbol sym = (IPictureLineSymbol) layer;
66
                setValues(sym.getLineWidth(), 
67
                        sym.getXScale(), 
68
                        sym.getYScale(), 
69
                        sym.getSource(), 
70
                        sym.getSelectedSource() //, 
71
//                        sym.getOffsetXExpression(), 
72
//                        sym.getOffsetYExpression(), 
73
//                        sym.getLineToOffsetColor(), 
74
//                        sym.getLineToOffsetColorExpression(), 
75
//                        sym.getRotation(), 
76
//                        sym.getRotationExpression()
77
                );
78
            }
79
        } catch (Exception ex) {
80
            LOGGER.warn("Can't refresh picture line symbol panel.", ex);
81
        }
82
            
83
    }
84
    
85
        protected void setValues(
86
            double size, 
87
            double xOffset, 
88
            double yOffset, 
89
            URL picture, 
90
            URL selectedPicture) {
91
        
92
        setSize(size);
93
        setX(xOffset);
94
        setY(yOffset);
95
        
96
        setPicture(picture);
97
        setSelectedPicture(selectedPicture);
98
    }
99

    
100

    
101
    @Override
102
    public ISymbol getLayer() {
103
        try {
104
            IPictureLineSymbol layer = null;
105
            if (this.getPictureFile() != null) {
106
                layer = SymbologyLocator.getSymbologyManager().createPictureLineSymbol(
107
                        this.getPictureURL(),
108
                        this.getSelectedPictureURL()
109
                );
110
                layer.setLineWidth(this.getSize());
111
                layer.setXScale(this.getX());
112
                layer.setYScale(this.getY());
113
            }
114
            return layer;
115
        } catch (IOException e) {
116
            IWarningSymbol warning
117
                    = (IWarningSymbol) MapContextLocator.getSymbolManager()
118
                            .getWarningSymbol(
119
                                    SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS,
120
                                    Messages.getText("failed_acessing_files"),
121
                                    SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS);
122
            return warning;
123

    
124
        }
125

    
126
    }
127

    
128
    @Override
129
    public boolean canManageSymbol(ISymbol symbol) {
130
        return symbol instanceof IPictureLineSymbol;
131
    }
132

    
133
}