| 333 | '''Example 6:''' auto-resizing interstate highway symbol |
| 334 | |
| 335 | The highway in example 1 was designed to display 1 or 2 digit interstate numbers. In the case of a 3 digit number you would end up with something like: |
| 336 | |
| 337 | [[Image(ex6a.jpg)]] |
| 338 | |
| 339 | To fix this we can update the symbol to auto-resize based on the text string: |
| 340 | |
| 341 | {{{ |
| 342 | <SymbolDefinition> |
| 343 | <SimpleSymbolDefinition> |
| 344 | <Name>US_Interstate</Name> |
| 345 | <GraphicElement> |
| 346 | <Image> |
| 347 | <Reference>Library%3A%2F%2FHighwaySymbols%2FInterstateImage.png</Reference> |
| 348 | <SizeX>10.8</SizeX> |
| 349 | <SizeY>11.2</SizeY> |
| 350 | <PositionX>0</PositionX> |
| 351 | <PositionY>0.8</PositionY> |
| 352 | </Image> |
| 353 | <ResizeControl>AdjustToResizeBox</ResizeControl> |
| 354 | </GraphicElement> |
| 355 | <GraphicElement> |
| 356 | <Text> |
| 357 | <String>%INTERSTATE_NUMBER%</String> |
| 358 | <FontName>Arial</FontName> |
| 359 | <Height>6</Height> |
| 360 | <PositionX>0</PositionX> |
| 361 | <PositionY>0</PositionY> |
| 362 | <HorizontalAlignment>Center</HorizontalAlignment> |
| 363 | <VerticalAlignment>Halfline</VerticalAlignment> |
| 364 | </Text> |
| 365 | <ResizeControl>AddToResizeBox</ResizeControl> |
| 366 | </GraphicElement> |
| 367 | <ResizeBox> |
| 368 | <PositionX>0</PositionX> |
| 369 | <PositionY>0</PositionY> |
| 370 | <SizeX>6</SizeX> |
| 371 | <SizeY>5</SizeY> |
| 372 | <GrowControl>GrowInX</GrowControl> |
| 373 | </ResizeBox> |
| 374 | <LineUsage> |
| 375 | <AngleControl>FromAngle</AngleControl> |
| 376 | <VertexControl>OverlapNoWrap</VertexControl> |
| 377 | <Angle>0</Angle> |
| 378 | <StartOffset>30</StartOffset> |
| 379 | <EndOffset>30</EndOffset> |
| 380 | <Repeat>100</Repeat> |
| 381 | </LineUsage> |
| 382 | <ParameterDefinition> |
| 383 | <Parameter> |
| 384 | <Identifier>%INTERSTATE_NUMBER%</Identifier> |
| 385 | <DefaultValue>0</DefaultValue> |
| 386 | <DisplayName>Interstate Number</DisplayName> |
| 387 | <Description>The interstate number</Description> |
| 388 | </Parameter> |
| 389 | </ParameterDefinition> |
| 390 | </SimpleSymbolDefinition> |
| 391 | </SymbolDefinition> |
| 392 | }}} |
| 393 | |
| 394 | All we've done is include a !ResizeBox and specify the !ResizeControl for each !GraphicElement. The !ResizeBox is positioned at the same location as the Text element, and has an initial size of 6 mm by 5 mm. This box fits nicely in the Image element - as long as the text does not extend outside of this box then no resizing is needed. The !GrowControl setting for the resize box is GrowInX, which means the box is only allowed to grow horizontally. |
| 395 | |
| 396 | The Text element's !ResizeControl is set to !AddToResizeBox. This means the graphical extent of the element is added to the resize box, and the box will grow, if necessary, to include that extent. In the case of 1 or 2 digit interstate numbers no growth occurs, but in the case of a 3 digit number the box will grow horizontally to fit the text. |
| 397 | |
| 398 | The Image element's !ResizeControl is set to !AdjustToResizeBox. This means the element will be resized and repositioned if the resize box grows in size. For example, if the resize box width grows by 10% then the element will be scaled horizontally by a factor of 1.1. The scaling is done about the center of the resize box. |
| 399 | |
| 400 | Here's what the updated symbol looks like when displaying a 3 digit interstate number. |
| 401 | |
| 402 | [[Image(ex6b.jpg)]] |
| 403 | |