comparison src/java/de/intevation/mxd/reader/MXDReader.java @ 31:40c0b4e5f91a

Added utility class to store map attributes.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 11 Apr 2011 16:04:03 +0200
parents c34c450edb06
children c51376f8e24c
comparison
equal deleted inserted replaced
30:c34c450edb06 31:40c0b4e5f91a
34 34
35 //Member 35 //Member
36 private String filename = ""; 36 private String filename = "";
37 private ArcGISInitializer initializer = null; 37 private ArcGISInitializer initializer = null;
38 private IMap map; 38 private IMap map;
39 private Document mapInfo;
40 39
41 private static final Logger logger = Logger.getLogger(MXDReader.class); 40 private static final Logger logger = Logger.getLogger(MXDReader.class);
42 41
43 //Constructor 42 //Constructor
44 public MXDReader() throws IOException{ 43 public MXDReader() throws IOException{
45 logger.debug("constructor()"); 44 logger.debug("constructor()");
46 initializer = new ArcGISInitializer(); 45 initializer = new ArcGISInitializer();
47 mapInfo = XMLUtils.newDocument();
48 } 46 }
49 47
50 48
51 //Methods 49 //Methods
52 50
100 throw new IOException("Please set filename!"); 98 throw new IOException("Please set filename!");
101 } 99 }
102 else{ 100 else{
103 openMapDocument(); 101 openMapDocument();
104 MapReader mreader = new MapReader (map); 102 MapReader mreader = new MapReader (map);
105 mreader.setDocument(mapInfo); 103 MapToXMLUtils util = new MapToXMLUtils();
104 mreader.setUtil(util);
106 mreader.read(); 105 mreader.read();
107 106
108 for(int i = 0; i < map.getLayerCount();i++){ 107 for(int i = 0; i < map.getLayerCount();i++){
109 ILayer layer = map.getLayer(i); 108 ILayer layer = map.getLayer(i);
110 try{ 109 try{
111 FeatureLayerReader lr = new FeatureLayerReader(layer); 110 FeatureLayerReader lr = new FeatureLayerReader(layer);
112 lr.setDocument(mapInfo); 111 lr.setUtil(util);
113 lr.read(); 112 Element layerElement = lr.read();
114 if (layer instanceof FeatureLayer){ 113 if (layer instanceof FeatureLayer){
115 IFeatureClass fc = ((FeatureLayer)layer).getFeatureClass();
116 IClassReader creader = new FeatureClassReader(fc);
117
118 IFeatureRenderer renderer = ((FeatureLayer)layer).getRenderer(); 114 IFeatureRenderer renderer = ((FeatureLayer)layer).getRenderer();
119 IRendererReader rreader; 115 IRendererReader rreader;
120 if(renderer instanceof SimpleRenderer){ 116 if(renderer instanceof SimpleRenderer){
121 rreader = new SimpleRendererReader(renderer); 117 rreader = new SimpleRendererReader(renderer);
118 rreader.setParent(layerElement);
119 rreader.setUtil(util);
122 rreader.read(); 120 rreader.read();
123 } 121 }
124 else if(renderer instanceof ClassBreaksRenderer){ 122 else if(renderer instanceof ClassBreaksRenderer){
125 rreader = new ClassBreakRendererReader(renderer); 123 rreader = new ClassBreakRendererReader(renderer);
124 rreader.setParent(layerElement);
125 rreader.setUtil(util);
126 rreader.read(); 126 rreader.read();
127 } 127 }
128 else if(renderer instanceof UniqueValueRenderer){ 128 else if(renderer instanceof UniqueValueRenderer){
129 rreader = new UniqueValueRendererReader(renderer); 129 rreader = new UniqueValueRendererReader(renderer);
130 rreader.setParent(layerElement);
131 rreader.setUtil(util);
130 rreader.read(); 132 rreader.read();
131 } 133 }
132 else{ 134 else{
133 System.out.println("No known renderer!"); 135 System.out.println("No known renderer!");
134 System.out.println("Implement new renderer for " + 136 System.out.println("Implement new renderer for " +
138 } 140 }
139 catch(Exception e){ 141 catch(Exception e){
140 e.printStackTrace(); 142 e.printStackTrace();
141 } 143 }
142 } 144 }
143 XMLUtils.toStream(mapInfo, System.out); 145 util.print();
144 } 146 }
145 return true; 147 return true;
146 } 148 }
147 149
148 150
149 /**
150 * Get the mapinformation as DOM document. TODO: implement me!
151 */
152 public Document getMapDocument(){ 151 public Document getMapDocument(){
153 logger.debug("getMapDocument()"); 152 logger.debug("getMapDocument()");
154 return mapInfo; 153 return null;
155 } 154 }
156 } 155 }
157 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 156 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)