home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Software / Utils / Livebrush / Install-LivebrushLite.air / livebrush.swf / scripts / com / livebrush / graphics / Line.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  22.0 KB  |  742 lines

  1. package com.livebrush.graphics
  2. {
  3.    import com.livebrush.data.Settings;
  4.    import com.livebrush.data.StateManager;
  5.    import com.livebrush.data.Storable;
  6.    import com.livebrush.graphics.canvas.Canvas;
  7.    import com.livebrush.graphics.canvas.Layer;
  8.    import com.livebrush.graphics.canvas.LineLayer;
  9.    import com.livebrush.styles.DecoAsset;
  10.    import com.livebrush.styles.Style;
  11.    import flash.display.Sprite;
  12.    import flash.events.Event;
  13.    import flash.events.EventDispatcher;
  14.    import flash.geom.Point;
  15.    
  16.    public class Line extends EventDispatcher implements Storable
  17.    {
  18.       public static const SMOOTH_LINE:String = "smooth";
  19.       
  20.       public static const STRAIGHT_LINE:String = "straight";
  21.       
  22.       public var newStrokeCount:int = 0;
  23.       
  24.       public var decoLoadCount:int;
  25.       
  26.       public var style:Style = null;
  27.       
  28.       public var changed:Boolean = false;
  29.       
  30.       public var type:String = "solid";
  31.       
  32.       public var strokes:Array;
  33.       
  34.       public var edges:Array;
  35.       
  36.       public var decoCount:int;
  37.       
  38.       public var created:Boolean = false;
  39.       
  40.       public var weight:Number = 1;
  41.       
  42.       public var lastStrokeLength:int = 0;
  43.       
  44.       public var lines:int = 2;
  45.       
  46.       public function Line(type:String = "solid", lines:int = 2, weight:Number = 1)
  47.       {
  48.          super();
  49.          this.lastStrokeLength = 0;
  50.          this.decoCount = 0;
  51.          this.decoLoadCount = 0;
  52.          this.lines = lines;
  53.          this.type = type;
  54.          this.weight = weight;
  55.          this.strokes = [];
  56.          this.edges = [];
  57.       }
  58.       
  59.       public static function toStraightLine(line:Line) : Line
  60.       {
  61.          return convertLine(line,false);
  62.       }
  63.       
  64.       public static function newLine(smooth:Boolean, type:String, lines:int, weight:Number) : Line
  65.       {
  66.          var line:Line = null;
  67.          if(smooth)
  68.          {
  69.             line = new SmoothLine(type,lines,weight);
  70.          }
  71.          else
  72.          {
  73.             line = new Line(type,lines,weight);
  74.          }
  75.          return line;
  76.       }
  77.       
  78.       public static function xmlToLine(xml:XML) : Line
  79.       {
  80.          var line:Line = Line.newLine(xml.@smooth == "true" ? true : false,xml.@type,Number(xml.@lines),Number(xml.@weight));
  81.          line.setXML(xml.toXMLString());
  82.          return line;
  83.       }
  84.       
  85.       public static function convertLine(line:Line, smooth:Boolean) : Line
  86.       {
  87.          var newLine:Line = Line.newLine(smooth,line.type,line.lines,line.weight);
  88.          for(var i:int = 0; i < line.length; newLine.edges.push(line.edges[i].copy()),i++)
  89.          {
  90.          }
  91.          newLine.rebuild();
  92.          return newLine;
  93.       }
  94.       
  95.       public static function isSmoothLine(line:Line) : Boolean
  96.       {
  97.          return line is SmoothLine;
  98.       }
  99.       
  100.       public static function toSmoothLine(line:Line) : SmoothLine
  101.       {
  102.          return SmoothLine(convertLine(line,true));
  103.       }
  104.       
  105.       public function die() : void
  106.       {
  107.          this.created = false;
  108.          while(this.edges.length > 0)
  109.          {
  110.             this.edges.pop().die();
  111.          }
  112.          while(this.strokes.length > 0)
  113.          {
  114.             this.strokes.pop().dieDecos();
  115.          }
  116.          this.lastStrokeLength = 0;
  117.          this.changed = true;
  118.          this.decoLoadCount = 0;
  119.       }
  120.       
  121.       protected function invalidateEdgeStrokes(edgeIndex:int) : Array
  122.       {
  123.          var aStrokes:Array = this.getStrokeIndicesUsingEdge(edgeIndex);
  124.          for(var i:int = 0; i < aStrokes.length; i++)
  125.          {
  126.             this.strokes[aStrokes[i]].changed = true;
  127.          }
  128.          return aStrokes;
  129.       }
  130.       
  131.       public function removeEdgeDecos(indices:Array) : void
  132.       {
  133.          var edge:Edge = null;
  134.          for(var i:int = 0; i < indices.length; i++)
  135.          {
  136.             edge = this.edges[indices[i]];
  137.             if(edge.hasDecos)
  138.             {
  139.                edge.removeDecos();
  140.                edge.decoGroup = null;
  141.             }
  142.          }
  143.          this.changed = true;
  144.       }
  145.       
  146.       public function get secondLastEdge() : Edge
  147.       {
  148.          return this.edges[Math.max(0,this.edges.length - 2)];
  149.       }
  150.       
  151.       public function get firstStroke() : Stroke
  152.       {
  153.          return this.strokes[0];
  154.       }
  155.       
  156.       public function simplify() : void
  157.       {
  158.          var newEdges:Array = null;
  159.          if(this.length > 2)
  160.          {
  161.             newEdges = [];
  162.             while(this.edges.length > 2)
  163.             {
  164.                newEdges.push(this.edges.shift());
  165.                this.edges.shift().die();
  166.             }
  167.             if(this.edges.length > 1)
  168.             {
  169.                this.edges.shift().die();
  170.             }
  171.             newEdges.push(this.edges.shift());
  172.             this.edges = newEdges;
  173.             this.rebuild();
  174.          }
  175.       }
  176.       
  177.       public function get decosLoaded() : Boolean
  178.       {
  179.          return this.decoLoadCount == this.decoCount;
  180.       }
  181.       
  182.       public function modifyEdgeColor(index:int, value:Number) : void
  183.       {
  184.          this.edges[index].color = value;
  185.       }
  186.       
  187.       public function get firstEdge() : Edge
  188.       {
  189.          return this.edges[0];
  190.       }
  191.       
  192.       public function modifyEdgeAlpha(index:int, value:Number) : void
  193.       {
  194.          this.edges[index].alpha = value;
  195.       }
  196.       
  197.       public function deleteEdge(edge:Edge = null, i:int = -5) : void
  198.       {
  199.          var index:int = edge == null ? i : this.getEdgeIndex(edge);
  200.          var aStrokes:Array = this.invalidateEdgeStrokes(index);
  201.          if(this.length > 1)
  202.          {
  203.             if(aStrokes.length > 1)
  204.             {
  205.                this.strokes[aStrokes[1]].edge2 = this.strokes[aStrokes[0]].edge2;
  206.             }
  207.             this.strokes.splice(aStrokes[0],1)[0].die();
  208.          }
  209.          this.edges.splice(index,1)[0].die();
  210.          this.lastStrokeLength = this.strokes.length;
  211.          this.applyProps();
  212.       }
  213.       
  214.       protected function decoComplete() : void
  215.       {
  216.          ++this.decoLoadCount;
  217.          if(this.decoLoadCount == this.decoCount)
  218.          {
  219.             this.lineComplete();
  220.          }
  221.       }
  222.       
  223.       public function addEdge(edge:Edge, lockStart:Boolean = false) : void
  224.       {
  225.          var stroke:Stroke = null;
  226.          this.edges.push(edge);
  227.          if(this.edges.length == 3 && this is SmoothLine && !lockStart)
  228.          {
  229.             this.edges[0].angle = edge.angle;
  230.             this.edges[1].angle = edge.angle;
  231.             this.edges[0].applyProps();
  232.             this.edges[1].applyProps();
  233.          }
  234.          else if(this.edges.length == 2 && !lockStart)
  235.          {
  236.             this.edges[0].angle = edge.angle;
  237.             this.edges[0].applyProps();
  238.          }
  239.          if(this.length > 2)
  240.          {
  241.             stroke = this.addStroke([this.length - 1,this.length - 2,this.length - 3]);
  242.          }
  243.          else if(this.length > 1)
  244.          {
  245.             stroke = this.addStroke([this.length - 1,this.length - 2]);
  246.          }
  247.          this.created = this is SmoothLine ? this.edges.length > 2 : this.edges.length > 1;
  248.          if(stroke != null)
  249.          {
  250.             if(stroke.decoGroup != null)
  251.             {
  252.                ++this.decoCount;
  253.                if(!stroke.decoGroup.loaded)
  254.                {
  255.                   stroke.decoGroup.addEventListener(Event.COMPLETE,this.decoCompleteHandler);
  256.                }
  257.                else
  258.                {
  259.                   this.decoComplete();
  260.                }
  261.             }
  262.             ++this.newStrokeCount;
  263.             this.lastStrokeLength = this.strokes.length;
  264.          }
  265.       }
  266.       
  267.       public function modifyEdge(index:int, c:Point, a:Point, b:Point) : void
  268.       {
  269.          this.edges[index].transformEdge(c,a,b);
  270.          this.invalidateEdgeIndex(index);
  271.       }
  272.       
  273.       protected function deleteAllEdges() : void
  274.       {
  275.          this.die();
  276.       }
  277.       
  278.       public function invalidateEdgeIndex(edgeIndex:int) : void
  279.       {
  280.          this.changed = true;
  281.          if(this.length > 1)
  282.          {
  283.             this.invalidateEdgeStrokes(edgeIndex);
  284.          }
  285.       }
  286.       
  287.       public function rebuild() : void
  288.       {
  289.          this.created = false;
  290.          for(var i:int = 0; i < this.edges.length; i++)
  291.          {
  292.             if(this.edges[i].decoGroup != null)
  293.             {
  294.                this.edges[i].decoGroup = this.edges[i].decoGroup.copy();
  295.             }
  296.          }
  297.          var tempEdges:Array = this.edges.slice();
  298.          while(this.strokes.length > 0)
  299.          {
  300.             this.strokes.pop().dieDecos();
  301.          }
  302.          this.edges = [];
  303.          this.strokes = [];
  304.          this.lastStrokeLength = 0;
  305.          this.decoLoadCount = 0;
  306.          for(i = 0; i < tempEdges.length; i++)
  307.          {
  308.             this.addEdge(tempEdges[i],true);
  309.          }
  310.          this.changed = true;
  311.       }
  312.       
  313.       public function get lastEdgeIndex() : int
  314.       {
  315.          return this.length - 1;
  316.       }
  317.       
  318.       protected function getEdgeIndices(edgeList:Array = null) : Array
  319.       {
  320.          var a:Array = [];
  321.          var i:int = 0;
  322.          if(edgeList == null)
  323.          {
  324.             for(i = 0; i < this.length; i++)
  325.             {
  326.                a.push(i);
  327.             }
  328.          }
  329.          else
  330.          {
  331.             for(i = 0; i < edgeList.length; i++)
  332.             {
  333.                a.push(this.getEdgeIndex(edgeList[i]));
  334.             }
  335.          }
  336.          return a;
  337.       }
  338.       
  339.       public function applyProps() : void
  340.       {
  341.          this.changed = true;
  342.          for(var i:int = 0; i < this.strokes.length; i++)
  343.          {
  344.             if(this.strokes[i].changed)
  345.             {
  346.                this.strokes[i].applyProps();
  347.             }
  348.          }
  349.       }
  350.       
  351.       public function drawWireframe() : void
  352.       {
  353.          var vectors:Sprite = null;
  354.          var s:int = 0;
  355.          if(this.edges.length > 1)
  356.          {
  357.             vectors = Canvas.GLOBAL_CANVAS.wireframe;
  358.             for(s = 0; s < this.strokes.length; s++)
  359.             {
  360.                if(s == 0)
  361.                {
  362.                   this.strokes[s].drawWireframe(Stroke.START);
  363.                }
  364.                else if(s == this.strokes.length - 1)
  365.                {
  366.                   this.strokes[s].drawWireframe(Stroke.END);
  367.                }
  368.                else
  369.                {
  370.                   this.strokes[s].drawWireframe(Stroke.MIDDLE);
  371.                }
  372.             }
  373.             vectors.graphics.moveTo(this.firstStroke.edge2.a.x,this.firstStroke.edge2.a.y);
  374.             vectors.graphics.lineTo(this.firstStroke.edge2.b.x,this.firstStroke.edge2.b.y);
  375.             vectors.graphics.moveTo(this.lastStroke.edge1.a.x,this.lastStroke.edge1.a.y);
  376.             vectors.graphics.lineTo(this.lastStroke.edge1.b.x,this.lastStroke.edge1.b.y);
  377.          }
  378.       }
  379.       
  380.       public function invalidateEdge(edge:Edge) : void
  381.       {
  382.          this.changed = true;
  383.          if(this.length > 1)
  384.          {
  385.             this.invalidateEdgeStrokes(this.getEdgeIndex(edge));
  386.          }
  387.       }
  388.       
  389.       public function getSVG() : XML
  390.       {
  391.          return new XML(<g/>);
  392.       }
  393.       
  394.       protected function addStroke(edgeIndices:Array) : Stroke
  395.       {
  396.          var stroke:Stroke = null;
  397.          if(this.length > 3 && this is SmoothLine)
  398.          {
  399.             stroke = new SmoothStroke(this.edges[edgeIndices[0]],this.edges[edgeIndices[1]],this.edges[edgeIndices[2]],this.type,this.weight);
  400.             this.strokes.push(stroke);
  401.          }
  402.          else if(this.length > 2 && !(this is SmoothLine))
  403.          {
  404.             stroke = new Stroke(this.edges[edgeIndices[0]],this.edges[edgeIndices[1]],this.edges[edgeIndices[2]],this.type,this.weight);
  405.             this.strokes.push(stroke);
  406.          }
  407.          else if(this.length == 2)
  408.          {
  409.             stroke = new Stroke(this.edges[edgeIndices[0]],this.edges[edgeIndices[1]],null,this.type,this.weight);
  410.             this.strokes.push(stroke);
  411.          }
  412.          else if(this.length == 3 && this is SmoothLine)
  413.          {
  414.             this.strokes[0].die();
  415.             stroke = this.strokes[0] = new SmoothStroke(this.edges[edgeIndices[0]],this.edges[edgeIndices[1]],this.edges[edgeIndices[2]],this.type,this.weight);
  416.          }
  417.          return stroke;
  418.       }
  419.       
  420.       public function drawNew(layer:Layer) : void
  421.       {
  422.          var s:int = 0;
  423.          if(this.length > 1)
  424.          {
  425.             for(s = this.lastStrokeLength - 1; s < this.strokes.length; s++)
  426.             {
  427.                if(s == 0)
  428.                {
  429.                   this.strokes[s].draw(layer,Stroke.START);
  430.                }
  431.                else
  432.                {
  433.                   this.strokes[s].draw(layer);
  434.                }
  435.             }
  436.          }
  437.          this.newStrokeCount = 0;
  438.       }
  439.       
  440.       public function subdivide() : void
  441.       {
  442.          var edge1:Edge = null;
  443.          var edge2:Edge = null;
  444.          var newEdge:Edge = null;
  445.          var subEdges:Array = null;
  446.          var newEdges:Array = null;
  447.          var i:int = 0;
  448.          if(this.length > 1)
  449.          {
  450.             subEdges = [];
  451.             newEdges = [];
  452.             for(i = 1; i < this.length; i++)
  453.             {
  454.                edge1 = this.edges[i - 1];
  455.                edge2 = this.edges[i];
  456.                newEdge = Edge.interpolate(edge1,edge2,0.5);
  457.                subEdges.push(newEdge);
  458.             }
  459.             do
  460.             {
  461.                newEdges.push(this.edges.shift());
  462.                if(subEdges.length > 0)
  463.                {
  464.                   newEdges.push(subEdges.shift());
  465.                }
  466.             }
  467.             while(this.edges.length > 0);
  468.             
  469.             this.edges = newEdges;
  470.             this.rebuild();
  471.          }
  472.       }
  473.       
  474.       protected function getStrokeIndicesUsingEdge(edgeIndex:int) : Array
  475.       {
  476.          var edgeStrokes:Array = [];
  477.          if(!(this is SmoothLine))
  478.          {
  479.             if(edgeIndex > 0 && edgeIndex < this.lastEdgeIndex)
  480.             {
  481.                edgeStrokes = [edgeIndex - 1,edgeIndex];
  482.             }
  483.             else if(edgeIndex == 0)
  484.             {
  485.                edgeStrokes.push(0);
  486.             }
  487.             else if(edgeIndex == this.lastEdgeIndex)
  488.             {
  489.                edgeStrokes.push(edgeIndex - 1);
  490.             }
  491.          }
  492.          else if(this is SmoothLine)
  493.          {
  494.             if(this.length < 4)
  495.             {
  496.                edgeStrokes = [0];
  497.             }
  498.             else if(edgeIndex > 1 && edgeIndex < this.lastEdgeIndex - 1)
  499.             {
  500.                edgeStrokes = [edgeIndex - 2,edgeIndex - 1,edgeIndex];
  501.             }
  502.             else if(edgeIndex == 0)
  503.             {
  504.                edgeStrokes.push(0);
  505.             }
  506.             else if(edgeIndex == this.lastEdgeIndex)
  507.             {
  508.                edgeStrokes.push(edgeIndex - 2);
  509.             }
  510.             else if(edgeIndex == 1)
  511.             {
  512.                edgeStrokes = [0,1];
  513.             }
  514.             else if(edgeIndex == this.lastEdgeIndex - 1)
  515.             {
  516.                edgeStrokes = [this.strokes.length - 2,this.strokes.length - 1];
  517.             }
  518.          }
  519.          return edgeStrokes;
  520.       }
  521.       
  522.       public function draw(layer:Layer) : void
  523.       {
  524.          var s:int = 0;
  525.          if(this.length > 1)
  526.          {
  527.             for(s = 0; s < this.strokes.length; s++)
  528.             {
  529.                if(s == 0)
  530.                {
  531.                   this.strokes[s].draw(layer,Stroke.START);
  532.                }
  533.                else if(s == this.strokes.length - 1)
  534.                {
  535.                   this.strokes[s].draw(layer,Stroke.END);
  536.                }
  537.                else
  538.                {
  539.                   this.strokes[s].draw(layer,Stroke.MIDDLE);
  540.                }
  541.             }
  542.             this.newStrokeCount = 0;
  543.          }
  544.          this.changed = false;
  545.       }
  546.       
  547.       protected function lineComplete() : void
  548.       {
  549.          dispatchEvent(new Event(Event.COMPLETE,true,false));
  550.       }
  551.       
  552.       public function addEdgeAt(index:int, pt:Point = null) : void
  553.       {
  554.          var aStrokes:Array = null;
  555.          var newEdge:Edge = null;
  556.          var newStroke:Stroke = null;
  557.          if(index != this.lastEdgeIndex)
  558.          {
  559.             aStrokes = this.invalidateEdgeStrokes(index);
  560.             newEdge = Edge.interpolate(this.edges[index],this.edges[index + 1],0.5);
  561.             if(pt != null)
  562.             {
  563.                newEdge.modify(pt,newEdge.angleRads,newEdge.width);
  564.                newEdge.applyProps();
  565.             }
  566.             this.edges.splice(index + 1,0,newEdge);
  567.             if(aStrokes.length > 1)
  568.             {
  569.                newStroke = new Stroke(this.edges[index + 1],this.edges[index],null,this.type,this.weight);
  570.                this.strokes[aStrokes[1]].edge2 = newEdge;
  571.             }
  572.             else
  573.             {
  574.                newStroke = new Stroke(this.edges[index + 2],this.edges[index + 1],null,this.type,this.weight);
  575.                this.strokes[aStrokes[0]].edge1 = newEdge;
  576.             }
  577.             this.strokes.splice(aStrokes[0] + 1,0,newStroke);
  578.             this.lastStrokeLength = this.strokes.length;
  579.             this.applyProps();
  580.          }
  581.       }
  582.       
  583.       public function addEdgeDeco(index:int, decoAsset:DecoAsset, initObj:Settings) : void
  584.       {
  585.          this.invalidateEdgeStrokes(index);
  586.          this.edges[index].addDeco(decoAsset,initObj);
  587.          this.applyProps();
  588.       }
  589.       
  590.       public function setXML(xml:String) : void
  591.       {
  592.          var stroke:XML = null;
  593.          var newEdge:Edge = null;
  594.          var lineXML:XML = new XML(xml);
  595.          try
  596.          {
  597.             this.die();
  598.          }
  599.          catch(e:Error)
  600.          {
  601.          }
  602.          for each(stroke in lineXML.*)
  603.          {
  604.             stroke.@lines = Number(lineXML.@lines);
  605.             newEdge = Edge.xmlToEdge(stroke.toXMLString());
  606.             this.addEdge(newEdge,true);
  607.          }
  608.       }
  609.       
  610.       public function setEdgeXML(index:int, xml:String, setDecos:Boolean = false) : void
  611.       {
  612.          var xmlObj:XML = new XML(xml);
  613.          xmlObj.@lines = this.lines;
  614.          this.edges[index].setXMLDecoBool(xmlObj.toXMLString(),setDecos);
  615.          this.invalidateEdgeIndex(index);
  616.       }
  617.       
  618.       protected function getEdgeIndex(edge:Edge) : int
  619.       {
  620.          return this.edges.indexOf(edge);
  621.       }
  622.       
  623.       public function getXML() : XML
  624.       {
  625.          var lineXML:XML = new XML(<line lines={this.lines} type={this.type} smooth={this is SmoothLine} weight={this.weight}/>);
  626.          for(var i:int = 0; i < this.edges.length; i++)
  627.          {
  628.             lineXML.appendChild(this.edges[i].getXML());
  629.          }
  630.          return lineXML;
  631.       }
  632.       
  633.       public function applyStyle(style:Style) : void
  634.       {
  635.          this.weight = style.strokeStyle.weight;
  636.          this.lines = style.strokeStyle.lines;
  637.          this.type = style.strokeStyle.strokeType;
  638.          for(var i:int = 0; i < this.length; i++)
  639.          {
  640.             this.edges[i].lines = this.lines;
  641.             this.edges[i].applyProps();
  642.          }
  643.       }
  644.       
  645.       protected function decoCompleteHandler(e:Event) : void
  646.       {
  647.          e.target.removeEventListener(e.type,this.decoCompleteHandler);
  648.          this.decoComplete();
  649.       }
  650.       
  651.       public function get length() : int
  652.       {
  653.          return this.edges.length;
  654.       }
  655.       
  656.       public function deleteEdges(delEdgeList:Array, indices:Boolean = false) : void
  657.       {
  658.          var edgeIndices:Array = null;
  659.          var i:int = 0;
  660.          if(!indices)
  661.          {
  662.             edgeIndices = this.getEdgeIndices(delEdgeList);
  663.          }
  664.          else
  665.          {
  666.             edgeIndices = delEdgeList.slice();
  667.          }
  668.          StateManager.addItem(function(state:Object):void
  669.          {
  670.             var l:LineLayer = LineLayer(state.canvasManager.getLayer(state.activeLayerDepth));
  671.             l.line.setXML(state.data.lineXML.toXMLString());
  672.             l.setup();
  673.          },function(state:Object):void
  674.          {
  675.             var l:LineLayer = LineLayer(state.canvasManager.getLayer(state.activeLayerDepth));
  676.             l.line.deleteEdges(state.data.edgeIndices,true);
  677.             l.setup();
  678.          },-1,{
  679.             "lineXML":this.getXML(),
  680.             "edgeIndices":edgeIndices
  681.          });
  682.          if(delEdgeList.length == this.edges.length)
  683.          {
  684.             this.deleteAllEdges();
  685.          }
  686.          else
  687.          {
  688.             for(i = int(delEdgeList.length - 1); i >= 0; i--)
  689.             {
  690.                if(!indices)
  691.                {
  692.                   this.deleteEdge(delEdgeList[i]);
  693.                }
  694.                else
  695.                {
  696.                   this.deleteEdge(null,delEdgeList[i]);
  697.                }
  698.             }
  699.          }
  700.       }
  701.       
  702.       public function get hasDecos() : Boolean
  703.       {
  704.          return this.decoCount > 0;
  705.       }
  706.       
  707.       public function stringType() : String
  708.       {
  709.          return this is SmoothLine ? SMOOTH_LINE : STRAIGHT_LINE;
  710.       }
  711.       
  712.       public function get lastEdge() : Edge
  713.       {
  714.          return this.edges[this.edges.length - 1];
  715.       }
  716.       
  717.       public function get lastStroke() : Stroke
  718.       {
  719.          return this.strokes[this.strokes.length - 1];
  720.       }
  721.       
  722.       public function copy(includeDecos:Boolean = true, basic:Boolean = false) : Line
  723.       {
  724.          var newLine:Line = null;
  725.          if(basic)
  726.          {
  727.             newLine = new Line(this.type,2,1);
  728.          }
  729.          else
  730.          {
  731.             newLine = new Line(this.type,this.lines,this.weight);
  732.          }
  733.          for(var i:int = 0; i < this.edges.length; i++)
  734.          {
  735.             newLine.addEdge(this.edges[i].copy(includeDecos,basic),true);
  736.          }
  737.          return newLine;
  738.       }
  739.    }
  740. }
  741.  
  742.