Select to view content in your preferred language

better way to monkeypatch print task & CompositeSymbol?

502
0
06-14-2013 03:45 AM
PaulHastings1
Deactivated User
we have composite symbol redlines which worked when we handled our own printing but now that we swapped to the ESRI printTask, we've had to monkeypatch the app to handle them, basically it hides the existing composite symbols & then "explodes" them into their simpler symbol components.
protected function monkeyPatchPrint(): void {    
 monkeyPatched=true;
 var cSymbol:CompositeSymbol;
 var monkeyPatchedRedlines:ArrayCollection=new ArrayCollection();
 var i:int;
 var thisGraphic:Graphic;
 for each(var graphic:Graphic in redline.graphicProvider) {
  if (graphic.symbol is CompositeSymbol) {
   cSymbol=graphic.symbol as CompositeSymbol;
   for (i=0; i < cSymbol.symbols.length; i++) {
    thisGraphic=new Graphic();
    thisGraphic.geometry=graphic.geometry;
    thisGraphic.symbol=cSymbol.symbols;
    monkeyPatchedRedlines.addItem(thisGraphic);
   }     
   graphic.visible=false;
  }
 }
 if (monkeyPatchedRedlines.length >0) {
  monkeyPatchLayer=new GraphicsLayer();
  monkeyPatchLayer.graphicProvider=monkeyPatchedRedlines;
  theMap.addLayer(monkeyPatchLayer);
 }
}


where "redline" is the redline graphics layer in the map & "monkeyPatched" is a boolean flag indicating if the monkey patch process has been run. and there's a corresponding unMonkeyPatchPrint method that returns the graphics to visible & removes the monkeyPatchLayer from the map object when printing is completed, cancelled or fails.

while this works, wondering if there's a better approach?

thanks.
Tags (2)
0 Kudos
0 Replies