Stylesheet Development with PTC ALD > Adding PTC ALD Code to Stylesheet Source > Samples > Blocks > Apply Boxing to a Block > Rounded corners with pattern lines
  
Rounded corners with pattern lines
This topic includes some examples on how to create patterned rules with rounded corners for a block.
Refer to the para in sect2 in sect1[4] in appendix context in the Arbortext-path/samples/ALD/Blocks/Boxing/blockBoxing.xml sample file. The context includes a set of conditions based on the value of the role attribute in the associated stylesheet. Each condition refers to a different property set, which in turn provides a different rule effect.
Each property set specifies a single rule for a block, defined in the rule variable.
Each property set defines the same method of applying the rule to the block and the same set of block padding instructions. You will need to include these instructions whenever you create a rule:
block.rules.addRule(rule);
Here you call the addRule() method from the fRules object to apply the rule information contained in the rule variable to a block. Note that block information for any context that references this property set must come from its Structure setting in the Breaks property category in the Arbortext Styler UI. If the context is set as Inline the rule will not be applied.
block.paddingTop = block.paddingBottom = block.paddingLeft
= block.paddingRight = "4pt";
With this phrase you specify that the four padding properties for the fBlock object all share the same value, i.e. 4pt. This setting provides some space between the rule and the block’s content.
The example below describes code that defines a single rule with different patterns, positions, and corners. The rounded corner settings are specified via a combination of the SIDE_NW (top left), SIDE_NE (top right), SIDE_SE (bottom right), and SIDE_SW (bottom left) constants of the fRule object.
Note that you will find many further examples in the blockboxing.xml sample file.
Draw a dashed rule on all sides of a block, with three corners rounded.
role=”tblr123” condition
pattern tblr123 property set
var rule = new fRule;
rule.sides = fRule.SIDE_BOX + fRule.SIDE_NW + fRule.SIDE_NE
+ fRule.SIDE_SW;
rule.radius = "12pt";
rule.thickness = "2pt";
rule.lineColor = "brown";
rule.lineStyle = fRuleLine.LINE_LONGDASH;
Here you have created a new rule based on the fRule object, and set up the variable rule to hold the rule information. You specify the SIDE_BOX, SIDE_NW, SIDE_NE, and SIDE_SW constants from the fRule object to draw the rule around the block and have the top left, top right, and bottom left corners rounded. Any rounded corners of the rule will have a radius of 12pt. The rule is of the Long dashes style, specified via the LINE_LONGDASH constant from the fRuleLine object . You have added size and color values for the thickness and lineColor properties of the fRule object- brown and 2pt thick.