Stylesheet Development with PTC ALD > Adding PTC ALD Code to Stylesheet Source > Samples > Blocks > Apply Boxing to a Block > Rounded corners with solid lines
  
Rounded corners with solid lines
This topic includes some examples on how to create rules with rounded corners for a block.
Refer to the para in sect2 in sect1[3] 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. The rule is always 2pt thick, red, and based on the Solid line style. The only difference between the property sets is the position they set for the rule in relation to the block, and the corner settings.
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 = "6pt";
With this phrase you specify that the four padding properties for the fBlock object all share the same value, i.e. 6pt. This setting provides some space between the rule and the block’s content.
The examples below describe code that defines a single identical rule with different 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 solid rule on all sides of a block, with top left corner rounded.
role=”tblr1” condition
solid tblr1 property set
var rule = new fRule;
rule.sides = fRule.SIDE_BOX + fRule.SIDE_NW;
rule.radius = "12pt";
rule.thickness = "2pt";
rule.lineColor = "red";
rule.lineStyle = fRuleLine.LINE_SOLID;
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 and SIDE_NW constants from the fRule object to draw the rule around all sides of the block and have the top left corner rounded. Any curved corners of the rule will have a radius of 12pt. The rule is of the Solid line style, specified via the LINE_SOLID constant from the fRuleLine object . You have added size and color values for the thickness and lineColor properties of the fRule object - red and 2pt thick.
Draw a solid rule on the top, left, and right sides of a block, with top right corner rounded
role=”tlr2” condition
solid tlr2 property set
var rule = new fRule;
rule.sides = fRule.SIDE_TOP + fRule.SIDE_LEFT + fRule.SIDE_RIGHT
+ fRule.SIDE_NE;
rule.radius = "12pt";
rule.thickness = "2pt";
rule.lineColor = "red";
rule.lineStyle = fRuleLine.LINE_SOLID;
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_TOP, SIDE_LEFT, SIDE_RIGHT, and SIDE_NE constants from the fRule object to draw the rule around the top, left, and right sides of the block and have the top right corner rounded. Any rounded corners of the rule will have a radius of 12pt. The rule is of the Solid line style, specified via the LINE_SOLID constant from the fRuleLine object . You have added size and color values for the thickness and lineColor properties of the fRule - red and 2pt thick.