Statistics
| Revision:

root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.core / src / main / java / es / unex / sextante / outputs / OutputVectorLayer.java @ 187

History | View | Annotate | Download (3.17 KB)

1
package es.unex.sextante.outputs;
2

    
3
import es.unex.sextante.core.Sextante;
4
import es.unex.sextante.dataObjects.IVectorLayer;
5

    
6
/**
7
 * An output representing a vector layer
8
 *
9
 * @author volaya
10
 *
11
 */
12
public class OutputVectorLayer
13
         extends
14
            Output {
15

    
16
   public static final int SHAPE_TYPE_POLYGON   = IVectorLayer.SHAPE_TYPE_POLYGON;
17
   public static final int SHAPE_TYPE_POINT     = IVectorLayer.SHAPE_TYPE_POINT;
18
   public static final int SHAPE_TYPE_LINE      = IVectorLayer.SHAPE_TYPE_LINE;
19
   public static final int SHAPE_TYPE_UNDEFINED = -1;
20

    
21
   private int             m_iShapeType;
22
   private int             m_subType;
23
   private String          m_sInputLayerToOverwrite;
24

    
25

    
26
   @Override
27
   public void setOutputObject(final Object obj) {
28

    
29
      if ((obj instanceof IVectorLayer) || (obj == null)) {
30
         m_Object = obj;
31
      }
32

    
33
   }
34

    
35

    
36
   @Override
37
   public String getCommandLineParameter() {
38

    
39
      if (m_OutputChannel == null) {
40
         return "\"#\"";
41
      }
42
      else {
43
         return "\"" + m_OutputChannel.getAsCommandLineParameter() + "\"";
44
      }
45

    
46
   }
47

    
48

    
49
   /**
50
    * Returns the shape type of this output vector layer
51
    *
52
    * @return the shape type of this output vector layer
53
    */
54
   public int getShapeType() {
55

    
56
      return m_iShapeType;
57

    
58
   }
59

    
60

    
61
   /**
62
    * Sets the shape type of this output vector layer
63
    *
64
    * @param shapeType
65
    *                The shape type of this output
66
    */
67
   public void setShapeType(final int shapeType) {
68

    
69
      m_iShapeType = shapeType;
70

    
71
   }
72

    
73

    
74
   @Override
75
   public Output getNewInstance() {
76

    
77
      final Output out = super.getNewInstance();
78
      ((OutputVectorLayer) out).setShapeType(m_iShapeType);
79
      ((OutputVectorLayer) out).setInputLayerToOverwrite(m_sInputLayerToOverwrite);
80
      ((OutputVectorLayer) out).setSubType(m_subType);
81

    
82
      return out;
83

    
84
   }
85

    
86

    
87
   @Override
88
   public void setObjectData(final Output output) {
89

    
90
      super.setObjectData(output);
91
      if (output instanceof OutputVectorLayer) {
92
         this.setShapeType(((OutputVectorLayer) output).getShapeType());
93
         this.setSubType(((OutputVectorLayer) output).getSubType());
94
      }
95

    
96
   }
97

    
98

    
99
   @Override
100
   public String getTypeDescription() {
101

    
102
      return Sextante.getText("vector");
103

    
104
   }
105

    
106

    
107
   /**
108
    * Returns the name of the input parameter that this output can overwrite
109
    *
110
    * @return the name of the input parameter that this output can overwrite
111
    */
112
   public String getInputLayerToOverwrite() {
113

    
114
      return m_sInputLayerToOverwrite;
115

    
116
   }
117

    
118

    
119
   /**
120
    * Sets the name of the input parameter that this output can overwrite. Returns null if it cannot overwrite.
121
    *
122
    * @param inputLayerToOverwrite
123
    *                the name of the input parameter that this output can overwrite
124
    */
125
   public void setInputLayerToOverwrite(final String inputLayerToOverwrite) {
126

    
127
      m_sInputLayerToOverwrite = inputLayerToOverwrite;
128

    
129
   }
130

    
131

    
132
   public boolean canOverwrite() {
133

    
134
      return m_sInputLayerToOverwrite != null;
135

    
136
   }
137

    
138

    
139
/**
140
 * @return the m_subType
141
 */
142
public int getSubType() {
143
    return m_subType;
144
}
145

    
146

    
147
/**
148
 * @param m_subType the m_subType to set
149
 */
150
public void setSubType(int m_subType) {
151
    this.m_subType = m_subType;
152
}
153

    
154

    
155
}