Stylesheet Development with PTC ALD > Adding PTC ALD Code to Stylesheet Source > Samples > Blocks > Apply Boxing to a Block > Patterned boxing
  
Patterned boxing
This topic includes some examples on how to create rules based on a patterned line style for a block.
Refer to the para in sect2 in sect1[2] 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. Constants from the fRuleLine object call the different line styles provided by PTC ALD.
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 = "3pt";
With this phrase you specify that the four padding properties for the fBlock object all share the same value, i.e. 3pt. This setting provides some space between the rule and the block’s content.
The examples below describe code that defines different patterned rules with different positions. Some samples use multiple rules to ensure the rule pattern goes into the corner of the block.
Note that you will find many further examples in the blockboxing.xml sample file.
Draw a curvy wave rule on the right side of a block
role=”r” condition
pattern r property set
var rule = new fRule;
rule.sides = fRule.SIDE_RIGHT;
rule.thickness = "6pt";
rule.lineColor = "red";
rule.lineStyle = fRuleLine.LINE_CURVYWAVE;
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_RIGHT constant from the fRule object and the LINE_CURVYWAVE constant from the fRuleLine object to draw the curvy wave rule on the right side of the block only. You have added size and color values for the thickness and lineColor properties of the fRule object - red and 6pt thick.
Draw a short dot-dash rule on the top and bottom sides of a block
role=”tb” condition
pattern tb property set
var rule = new fRule;
rule.sides = fRule.SIDE_TOP + fRule.SIDE_BOTTOM;
rule.thickness = "2pt";
rule.lineColor = "orange";
rule.lineStyle = fRuleLine.LINE_SHORTDASHDOT;
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 and SIDE_BOTTOM constants from the fRule object and the LINE_SHORTDASHDOT constant from the fRuleLine object to draw a short dot-dash style rule on the top and bottom sides of the block. You have added size and color values for the thickness and lineColor properties of the rule - orange and 2pt thick.