Revision 1763 branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/LayoutEditableFeature.java
LayoutEditableFeature.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package com.iver.cit.gvsig.gui.layout; |
42 | 42 |
|
43 |
import java.awt.geom.Rectangle2D; |
|
44 |
import java.io.IOException; |
|
45 |
import java.util.ArrayList; |
|
46 |
import java.util.Hashtable; |
|
47 |
|
|
48 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
49 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
50 |
import com.iver.cit.gvsig.fmap.edition.AddGeometryCommand; |
|
43 | 51 |
import com.iver.cit.gvsig.fmap.edition.DefaultEditableFeatureSource; |
44 | 52 |
import com.iver.cit.gvsig.fmap.edition.ExpansionFile; |
45 | 53 |
import com.iver.cit.gvsig.fmap.edition.MemoryExpansionFile; |
46 | 54 |
import com.iver.cit.gvsig.fmap.edition.OriginalFeatureAdapter; |
47 | 55 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
56 |
import com.iver.cit.gvsig.gui.cad.AddFFrameCommand; |
|
57 |
import com.iver.cit.gvsig.gui.cad.RemoveFFrameCommand; |
|
58 |
import com.iver.cit.gvsig.gui.cad.tools.SelectionCadTool; |
|
59 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView; |
|
60 |
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame; |
|
48 | 61 |
|
62 |
import com.vividsolutions.jts.geom.Envelope; |
|
49 | 63 |
import com.vividsolutions.jts.index.quadtree.Quadtree; |
50 | 64 |
|
51 | 65 |
|
... | ... | |
56 | 70 |
*/ |
57 | 71 |
public class LayoutEditableFeature extends DefaultEditableFeatureSource { |
58 | 72 |
private Layout layout; |
59 |
private Quadtree index; |
|
60 |
private ExpansionFile expansionFile; |
|
61 |
private OriginalFeatureAdapter ofa; |
|
62 |
|
|
73 |
private Hashtable rel = new Hashtable(); |
|
74 |
private int total=0; |
|
75 |
private ArrayList geomComp=new ArrayList(); |
|
76 |
// hay que relacionar lo que se a?ade con lo que se elimina mediante una hashtable y |
|
77 |
// comprobar si nums se esta usando en alg?n sitio y si no se usa eliminarlo. |
|
78 |
|
|
63 | 79 |
/** |
64 | 80 |
* Crea un nuevo DefaultLayoutEditable. |
65 | 81 |
* |
66 | 82 |
* @param l DOCUMENT ME! |
67 | 83 |
*/ |
68 |
public LayoutEditableFeature(Layout l) { |
|
69 |
super(new MemoryExpansionFile(),new LayoutOriginalFeature(l), new FBitSet());
|
|
84 |
public LayoutEditableFeature(Layout l,FBitSet selection) {
|
|
85 |
super(new MemoryExpansionFile(),new LayoutOriginalFeature(l), selection);
|
|
70 | 86 |
layout = l; |
71 | 87 |
} |
88 |
|
|
89 |
public int addFFrame(IFFrame frame) { |
|
90 |
int num=0; |
|
91 |
if (complex) { |
|
92 |
commands.add(new AddFFrameCommand(this,frame,num)); |
|
93 |
} else { |
|
94 |
try { |
|
95 |
cr.pushCommand(new AddFFrameCommand(this, frame,num)); |
|
96 |
} catch (IOException e) { |
|
97 |
e.printStackTrace(); |
|
98 |
} catch (DriverIOException e) { |
|
99 |
e.printStackTrace(); |
|
100 |
} |
|
101 |
} |
|
102 |
num=doAddFFrame(frame); |
|
103 |
return num; |
|
104 |
} |
|
105 |
public int doAddFFrame(IFFrame frame){ |
|
106 |
int num=0; |
|
107 |
num=layout.addFFrame(frame,true); |
|
108 |
rel.put(new Integer(total),new Integer(num)); |
|
109 |
total++; |
|
110 |
return num; |
|
111 |
} |
|
112 |
public void undoAddFFrame(int index){ |
|
113 |
int i=((Integer)rel.get(new Integer(index))).intValue(); |
|
114 |
if (i!=-1) |
|
115 |
layout.getFFrames().remove(i); |
|
116 |
total--; |
|
72 | 117 |
} |
118 |
|
|
119 |
|
|
120 |
public int undoRemoveFFrame(IFFrame frame,int index) { |
|
121 |
//int num=0; |
|
122 |
layout.getFFrames().add(frame); |
|
123 |
//num=layout.addFFrame(frame,true); |
|
124 |
rel.put(new Integer(total),new Integer(index)); |
|
125 |
total++; |
|
126 |
return index; |
|
127 |
} |
|
128 |
|
|
129 |
|
|
130 |
public void removeFFrame(int index) { |
|
131 |
IFFrame frame=(IFFrame)layout.getFFrames().get(index); |
|
132 |
if (complex) { |
|
133 |
commands.add(new RemoveFFrameCommand(this,frame,index)); |
|
134 |
} else { |
|
135 |
try { |
|
136 |
cr.pushCommand(new RemoveFFrameCommand(this,frame,index)); |
|
137 |
} catch (IOException e) { |
|
138 |
e.printStackTrace(); |
|
139 |
} catch (DriverIOException e) { |
|
140 |
e.printStackTrace(); |
|
141 |
} |
|
142 |
} |
|
143 |
doRemoveFFrame(index); |
|
144 |
|
|
145 |
} |
|
146 |
public void doRemoveFFrame(int index){ |
|
147 |
layout.getFFrames().remove(index); |
|
148 |
rel.put(new Integer(index),new Integer(-1)); |
|
149 |
total--; |
|
150 |
} |
|
151 |
public int modifyFFrame(IFFrame framenew,int indexant,int indexnew){ |
|
152 |
IFFrame frameant=((IFFrame)layout.getFFrames().get(indexant)).cloneFFrame(layout,null); |
|
153 |
if (complex) { |
|
154 |
commands.add(new ModifyFFrameCommand(this,frameant,framenew,indexant,indexnew)); |
|
155 |
} else { |
|
156 |
try { |
|
157 |
cr.pushCommand(new ModifyFFrameCommand(this,frameant,framenew,indexant,indexnew)); |
|
158 |
} catch (IOException e) { |
|
159 |
e.printStackTrace(); |
|
160 |
} catch (DriverIOException e) { |
|
161 |
e.printStackTrace(); |
|
162 |
} |
|
163 |
} |
|
164 |
return doModifyFFrame(framenew,indexant,indexnew); |
|
165 |
} |
|
166 |
public int doModifyFFrame(IFFrame framenew,int indexant,int indexnew){ |
|
167 |
//int numant=((Integer)relations.get(new Integer(indexnew))).intValue(); |
|
168 |
rel.put(new Integer(indexant),new Integer(-1)); |
|
169 |
layout.getFFrames().remove(indexant); |
|
170 |
int num=layout.addFFrame(framenew,true); |
|
171 |
rel.put(new Integer(indexnew),new Integer(num)); |
|
172 |
//total++; |
|
173 |
return num; |
|
174 |
} |
|
175 |
public int undoModifyFFrame(IFFrame frameant,int indexant,int indexnew){ |
|
176 |
// int numant=((Integer)relations.get(new Integer(indexnew))).intValue(); |
|
177 |
layout.getFFrames().remove(indexnew); |
|
178 |
rel.put(new Integer(indexnew),new Integer(-1)); |
|
179 |
int num=layout.addFFrame(frameant,true); |
|
180 |
rel.put(new Integer(indexant),new Integer(num)); |
|
181 |
|
|
182 |
return num; |
|
183 |
} |
|
184 |
public void addGeometry(IGeometry g) throws DriverIOException, IOException { |
|
185 |
int virtualIndex = doAddGeometry(g); |
|
186 |
|
|
187 |
if (complex) { |
|
188 |
commands.add(new AddGeometryCommand(this, g, virtualIndex)); |
|
189 |
} else { |
|
190 |
cr.pushCommand(new AddGeometryCommand(this, g, virtualIndex)); |
|
191 |
} |
|
192 |
geomComp.add(new GeometryComposite(SelectionCadTool.drawingSymbol,g)); |
|
193 |
} |
|
194 |
} |
Also available in: Unified diff