Select to view content in your preferred language

SimpleLineSymbol - bug in createSwatch method

956
3
Jump to solution
10-24-2012 12:38 AM
ChristophSchramm
Emerging Contributor
Dear Flex team,

after migrating to API 3.0 I somehow can't help noticing that there seems to be a bug in the createSwatch method for the SimpleLineSymbol (in API 2.5 there was some different bug - the returned swatch had wrong size - but never mind that now...)

If the symbol is not set on a graphic that is displayed on a map, createSwatch() only works correctly if the style of the symbol is set to 'solid'. The use case for me is to display the symbology of a feature in a TOC or a search results list, so putting an actual graphic on a map somewhere first to get to the symbol swatch is right out.

A little app to illustrate the problem - change the style in the dropdown to see what I mean:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags"
xmlns:s="library://ns.adobe.com/flex/spark"
pageTitle="Play with Polyline symbols"
creationComplete="symbolChanged()">
<fx:Script>
  <![CDATA[
   private function toHex(item:Number):String
   {
    var hex:String = item.toString(16);
    return ("00000" + hex.toUpperCase()).substr(-6);
   }
  
   private function symbolChanged():void {
    if(swatchGroup) {
     swatchGroup.removeAllElements();
     swatchGroup.addElement(mySymbol.createSwatch(80,10));
    }
   }
  ]]>
</fx:Script>

<fx:Declarations>
  <esri:SimpleLineSymbol id="mySymbol"
   width="{lineWidth.value}"
   alpha="{lineAlpha.value}"
   color="{lineColor.selectedColor}"
   style="{lineStyle.selectedItem}"
   />
</fx:Declarations>

<mx:Panel left="50" top="50"
  horizontalAlign="right"
  paddingBottom="0"
  paddingTop="0"
  title="Simple Line Properties">
  <mx:Form alpha="0.8"
   backgroundColor="0xEEEEEE"
   paddingBottom="5"
   paddingTop="5">
   <mx:FormItem label="Color">
    <mx:ColorPicker id="lineColor" selectedColor="0x009966" change="symbolChanged()"/>
   </mx:FormItem>
   <mx:FormItem label="Width:">
    <s:HSlider id="lineWidth"
     width="100"
     liveDragging="true"
     maximum="20"
     minimum="0"
     snapInterval="1"
     value="8"
     change="symbolChanged()"/>
   </mx:FormItem>
   <mx:FormItem label="Alpha:">
    <s:HSlider id="lineAlpha"
     width="100"
     liveDragging="true"
     maximum="1"
     minimum="0"
     snapInterval="0.01"
     value="1"
     change="symbolChanged()"/>
   </mx:FormItem>
   <mx:FormItem label="Style:">
    <s:DropDownList id="lineStyle"
     top="35"
     cornerRadius="0"
     fontWeight="normal"
     horizontalCenter="0"
     selectedIndex="4"
     change="symbolChanged()">
     <s:ArrayList>
      <fx:String>dash</fx:String>
      <fx:String>dashdot</fx:String>
      <fx:String>dashdotdot</fx:String>
      <fx:String>dot</fx:String>
      <fx:String>solid</fx:String>
     </s:ArrayList>
    </s:DropDownList>
   </mx:FormItem>
   <s:Spacer height="10"/>
   <mx:FormItem label="Swatch:">
    <s:HGroup id="swatchGroup" verticalAlign="middle"/>
   </mx:FormItem>
  </mx:Form>
</mx:Panel>
</s:Application>


Thank you,
Chris
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
SarthakDatt
Frequent Contributor
We are aware of this bug. It will be fixed in the next version.

Also, note that the height(thickness) of the line in the swatch will be limited to the height passed in createSwatch(). So in the example above it will never be > 10.

View solution in original post

0 Kudos
3 Replies
IvanBespalov
Frequent Contributor
0 Kudos
SarthakDatt
Frequent Contributor
We are aware of this bug. It will be fixed in the next version.

Also, note that the height(thickness) of the line in the swatch will be limited to the height passed in createSwatch(). So in the example above it will never be > 10.
0 Kudos
ChristophSchramm
Emerging Contributor
Ivan,
thanks for looking, but the thread you linked to deals with a somewhat different problem.

Sarthak,
thanks for acknowledging that this is indeed a bug. Is it possible for you to disclose any planned release date for the next version?

Cheers,
Chris
0 Kudos