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 @ 45523

History | View | Annotate | Download (3.78 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

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

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

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

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

    
58
    @Override
59
    public void refreshControls(ISymbol layer) {
60
        try {
61
            if (layer == null) {
62
                setValues(1d, 0d, 0d, null, null);
63
            } else {
64
                IPictureLineSymbol sym = (IPictureLineSymbol) layer;
65
                setValues(
66
                        sym.getLineWidth(), 
67
                        sym.getXScale(), 
68
                        sym.getYScale(), 
69
                        sym.getSource(), 
70
                        sym.getSelectedSource()
71
                );
72
            }
73
        } catch (Exception ex) {
74
            LOGGER.warn("Can't refresh picture line symbol panel.", ex);
75
        }
76
            
77
    }
78

    
79
    @Override
80
    public ISymbol getLayer() {
81
        try {
82
            IPictureLineSymbol layer = null;
83
            if (this.getPictureFile() != null) {
84
                layer = SymbologyLocator.getSymbologyManager().createPictureLineSymbol(
85
                        this.getPictureURL(),
86
                        this.getSelectedPictureURL()
87
                );
88
                layer.setLineWidth(this.getSize());
89
                layer.setXScale(this.getX());
90
                layer.setYScale(this.getY());
91
            }
92
            return layer;
93
        } catch (IOException e) {
94
            IWarningSymbol warning
95
                    = (IWarningSymbol) MapContextLocator.getSymbolManager()
96
                            .getWarningSymbol(
97
                                    SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS,
98
                                    Messages.getText("failed_acessing_files"),
99
                                    SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS);
100
            return warning;
101

    
102
        }
103

    
104
    }
105

    
106
    @Override
107
    public boolean canManageSymbol(ISymbol symbol) {
108
        return symbol instanceof IPictureLineSymbol;
109
    }
110

    
111
}