centre labels, and keep them centred
authorRichard Fairhurst <richard@systemed.net>
Mon, 14 Jun 2010 08:57:52 +0000 (08:57 +0000)
committerRichard Fairhurst <richard@systemed.net>
Mon, 14 Jun 2010 08:57:52 +0000 (08:57 +0000)
TODO.txt
net/systemeD/halcyon/WayUI.as
net/systemeD/halcyon/styleparser/TextStyle.as

index f9544dc..fe2c162 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -63,7 +63,6 @@ Potlatch 2: main outstanding issues
 
 == Rendering (Halcyon) ==
 
-** Centred area text isn't really centred (bottom left remains constant)
 ** Infinite z-indexes
 * Shields
 * More line decoration (cliffs etc.), and implied values for 'dashes' if not supplied
index 959bfb4..70d4317 100755 (executable)
@@ -21,6 +21,7 @@ package net.systemeD.halcyon {
                public var heading:Array=new Array();           // angle at each node
         private var hitzone:Sprite;
                public var nameformat:TextFormat;
+               private var recalculateDue:Boolean=false;
 
                private const NODESIZE:uint=6;
 
@@ -88,6 +89,7 @@ package net.systemeD.halcyon {
             redraw();
         }
         private function nodeMoved(event:NodeMovedEvent):void {
+                       recalculate();
             redraw();
         }
                private function wayDeleted(event:EntityEvent):void {
@@ -107,11 +109,24 @@ package net.systemeD.halcyon {
                        // ** various other stuff
                }
 
+               override public function suspendRedraw(event:EntityEvent):void {
+                       super.suspendRedraw(event);
+                       recalculateDue=false;
+               }
+               
+               override public function resumeRedraw(event:EntityEvent):void {
+                       suspended=false;
+                       if (recalculateDue) { recalculate(); }
+                       super.resumeRedraw(event);
+               }
+
                // ------------------------------------------------------------------------------------------
                // Calculate length etc.
                // ** this could be made scale-independent - would speed up redraw
                
                public function recalculate():void {
+                       if (suspended) { recalculateDue=true; return; }
+                       
                        var lx:Number, ly:Number, sc:Number;
                        var node:Node, latp:Number, lon:Number;
                        var cx:Number=0, cy:Number=0;
index 9226c8c..fc83693 100644 (file)
@@ -70,8 +70,8 @@ package net.systemeD.halcyon.styleparser {
                                tf.height = tf.textHeight+4;
                        }
                        if (text_halo_radius>0) { tf.filters=getHaloFilter(); }
-                       d.x=x;
-                       d.y=y; tf.y=(text_offset ? text_offset : 0);
+                       d.x=x; tf.x=-tf.width/2;
+                       d.y=y; tf.y=(text_offset ? text_offset : 0)-tf.height/2;
                        d.addChild(tf);
 
                        return tf;