/*---------------- FILE HEADER --------------------------------------- This file is part of Geoide. Copyright (C) 2005-2006 by: IDgis B.V. http://www.idgis.nl This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: Herman Assink IDgis bv P.O. Box 15 7450 AA Holten The Netherlands E-Mail: herman.assink@idgis.nl * @version 1.4.0 * @author IDgis team * ------------------------------------------------------------------------*/ import nl.idgis.giclient.geoma.GeometryCollection; import nl.idgis.giclient.geoma.MultiPoint; import nl.idgis.giclient.geoma.Point; import nl.idgis.giclient.gui.mapviewer.MapGeometry; class nl.idgis.giclient.gui.mapviewer.MapGeometryCollection extends MapGeometry { function onLoad():Void { gism.gisEventDispatcher.addZoomListener(this); setMapGeometries(); draw(); } function performEvent(eventObject:Object):MapGeometry { var mapGeometry:MapGeometry = null; var mode:String = eventObject["mode"]; var type:String = eventObject["type"]; if ((mode == "GeneralEdit") && (type == "MouseDown")) { mapGeometry = passEvent(eventObject); } else if ((mode == "Create") && (type == "MouseDown")) { var double:Boolean = Boolean(eventObject["double"]); var backKey:Boolean = Boolean(eventObject["backKey"]); var point:Point = Point(eventObject["point"]); if (!double) { if (backKey) { geometry.removePoint(null, false); } else { geometry.addPoint(point, false); } mapGeometry = this; } else { // Removes the point that was added at the first click of the double click. geometry.removePoint(null, false); _root["apiInterpreter"].onChangeGeometry(geometry, true); // TODO EVENT MODEL mapGeometry = this; } // TODO EVENT MODEL this.onChangeGeometry("ADDREMOVE"); } else if ((mode == "Create") && (type == "MouseMove")) { var point:Point = Point(eventObject["point"]); geometry.setPointXY(point.getX(), point.getY()); // TODO EVENT MODEL this.onChangeGeometry(); mapGeometry = this; } else if (mode == "CreateMember") { var point:Point = Point(eventObject["point"]); GeometryCollection(geometry).addGeometryMember(point); // TODO EVENT MODEL this.onChangeGeometry("ADDREMOVE"); this.draw(); if (geometry instanceof MultiPoint) { mapGeometry = null; _root["apiInterpreter"].onChangeGeometry(geometry, true); // TODO EVENT MODEL geometryLayer.getMapViewer().ruler.setActiveMode(geometryLayer.getMapViewer().ruler.getDefaultEditMode()); } else { mapGeometry = MapGeometry(mapGeometries[mapGeometries.length - 1]); } } else { mapGeometry = passEvent(eventObject); } return mapGeometry; } function setType(type:Number):Void { if ((this.type == SELECTION) || (type == SELECTION)) { // EXCEPTION return; } if (this.type != type) { this.type = type; for (var i:String in mapGeometries) { MapGeometry(mapGeometries[i]).setType(type); } draw(); } } function setLabelText(labelText:String):Void { if (this.labelText == labelText) { return; } this.labelText = labelText; for (var i:Number = 0; i < mapGeometries.length; i++) { MapGeometry(mapGeometries[i]).setLabelText(labelText); } } private function setLabel():Void { for (var i:Number = 0; i < mapGeometries.length; i++) { MapGeometry(mapGeometries[i]).setLabel(); } } }