/*---------------- 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.Circle; import nl.idgis.giclient.geoma.Point; import nl.idgis.giclient.gui.mapviewer.MapGeometry; import nl.idgis.giclient.gui.mapviewer.MapPolygon; import nl.idgis.giclient.util.Pixel; import nl.idgis.giclient.config.Colors; import nl.idgis.giclient.geoma.Geometry; import nl.idgis.giclient.util.Strings; class nl.idgis.giclient.gui.mapviewer.MapCircle extends MapPolygon { private var radiusTextField:MovieClip = null; function setMapGeometries():Void { mapGeometries = new Array(); var radiusPoint:Point = Circle(geometry).getExteriorRing().getPoints()[0]; addMapGeometry(radiusPoint, 0); // Depth is plus 1. } function performEvent(eventObject:Object):MapGeometry { var mapGeometry:MapGeometry = null; var mode:String = eventObject["mode"]; var type:String = eventObject["type"]; if ((mode == "GeneralEdit") && (type == "MouseDown")) { var double:Boolean = Boolean(eventObject["double"]); if (double) { var pixel:Pixel = Pixel(eventObject["pixel"]); if (radiusTextField.hitTest(pixel.getX(), pixel.getY(), true)) { var initObject:Object = new Object(); initObject = { scrollContent: "lib://TextInputFrame", paneTitle: Strings.getFile("Geoide").getString("UserInput"), isScrolling: false, resizable: false, hasShader: false, doorzichtig:false, _x:100, _y:100}; initObject["contentProperties"] = new Object(); initObject["contentProperties"]["question"] = // "Voer de straal van de cirkel in:"; (Strings.getFile("Geoide").getString("InputCircleRadius")) ; initObject["contentProperties"]["inputType"] = "Number"; initObject["contentProperties"]["returnObject"] = this; _root.frameWork.makeFrame("textInputFrame",initObject,200,100); } mapGeometry = this; } else { mapGeometry = passEvent(eventObject); } } else if ((mode == "GeneralEdit") && (type == "MouseMove")) { var dx:Number = eventObject["dx"]; var dy:Number = eventObject["dy"]; geometry.move(dx, dy); // TODO EVENT MODEL this.onChangeGeometry(); mapGeometry = this; } return mapGeometry; } function drawAsActive(geometry:Geometry):Void{ super.drawAsNormal(geometry, Colors.currentColor, Colors.currentFillOpacity, 2); var centerPoint:Point = geometry.getCenterPoint(); var radiusPoint:Point = Circle(geometry).getExteriorRing().getPoints()[0]; var centerPixel:Pixel = geometryLayer.getMapViewer().point2Pixel(centerPoint.getX(), centerPoint.getY()); var radiusPixel:Pixel = geometryLayer.getMapViewer().point2Pixel(radiusPoint.getX(), radiusPoint.getY()); moveTo(centerPixel.getX(),centerPixel.getY()); lineStyle(2, Colors.helperLineColor, 100); lineTo(radiusPixel.getX(), radiusPixel.getY()); drawRadiusTextField(); } function drawAsNormal(geometry:Geometry, color:Number,fillOpacity:Number,lineThickness:Number):Void { super.drawAsNormal(geometry, color, fillOpacity, lineThickness); if ((_root.frameWork["frames"]["textInputFrame"] != null) && (type != SELECTION)) { _root.frameWork["frames"]["textInputFrame"].removeMovieClip(); } radiusTextField.removeMovieClip(); radiusTextField = null; } function drawRadiusTextField():Void{ if (radiusTextField == null) { radiusTextField = createEmptyMovieClip("radiusMC_mc", 2); var textFormat:TextFormat = new TextFormat(); textFormat.font = "_sans"; textFormat.color = Colors.currentTextColor; textFormat.size = 12; radiusTextField.createTextField("textField", 0, 0, 0, 10, 10); radiusTextField.textField.setNewTextFormat(textFormat); radiusTextField.textField.autoSize = "center"; radiusTextField.textField.embedFonts = true; } var circle:Circle = Circle(geometry); var radius:Number = circle.getRadius(); var angle:Number = circle.getAngle(); var centerPoint:Point = circle.getCenterPoint(); var radiusPoint:Point = circle.getExteriorRing().getPoints()[0]; var centerPixel:Pixel = geometryLayer.getMapViewer().point2Pixel(centerPoint.getX(), centerPoint.getY()); var radiusPixel:Pixel = geometryLayer.getMapViewer().point2Pixel(radiusPoint.getX(), radiusPoint.getY()); var x:Number = centerPixel.getX() + ((radiusPixel.getX() - centerPixel.getX()) / 2); var y:Number = centerPixel.getY() + ((radiusPixel.getY() - centerPixel.getY()) / 2); radiusTextField.textField.text = Math.round(radius).toString(); radiusTextField._rotation = 360 - Math.round(angle * 180 / Math.PI); radiusTextField._x = x; radiusTextField._y = y; } function catchUserInput(rad:Number):Void { if (rad == null) { _root.frameWork["frames"]["textInputFrame"].removeMovieClip(); } else { if (rad > 0) { Circle(geometry).setRadius(rad); this.onChangeGeometry(); // TODO EVENT MODEL _root["apiInterpreter"].onChangeGeometry(geometry, true); _root.frameWork["frames"]["textInputFrame"].removeMovieClip(); } } } }