super(parent, propertyList);
this.name = "fo:leader";
}
public Status layout(Area area) throws FOPException {
BlockArea blockArea;
//restriction in this version
if (!(area instanceof BlockArea)) {
MessageHandler.errorln("WARNING: in this version of Fop fo:leader must be a direct child of fo:block ");
return new Status(Status.OK);
} else {
blockArea = (BlockArea) area;
}
//retrieving font property information for fo:leader
String fontFamily = this.properties.get("font-family").getString();
String fontStyle = this.properties.get("font-style").getString();
String fontWeight = this.properties.get("font-weight").getString();
int fontSize =
this.properties.get("font-size").getLength().mvalue();
//wrapping it up into Fontstate
FontState fontstate = new FontState(area.getFontInfo(), fontFamily,
fontStyle, fontWeight, fontSize);
//color properties
ColorType c = this.properties.get("color").getColorType();
float red = c.red();
float green = c.green();
float blue = c.blue();
//fo:leader specific properties
//determines the pattern of leader; allowed values: space, rule,dots, use-content
int leaderPattern = this.properties.get("leader-pattern").getEnum();
//length of the leader
int leaderLengthOptimum = this.properties.get(
"leader-length.optimum").getLength().mvalue();
int leaderLengthMinimum = this.properties.get(
"leader-length.minimum").getLength().mvalue();
//brute force method to set default, because default values cannot be set
//in the properties classes for all subtypes
if (leaderLengthMinimum == 12000) {
leaderLengthMinimum = 0;
}
int leaderLengthMaximum = this.properties.get(
"leader-length.maximum").getLength().mvalue();
//here too
if (leaderLengthMaximum == 12000) {
leaderLengthMaximum = 24000;
}
//the following properties only apply for leader-pattern = "rule"
int ruleThickness = this.properties.get(
"rule-thickness").getLength().mvalue();
int ruleStyle = this.properties.get("rule-style").getEnum();
// if leaderPatternWidth = 0 = default = use-font-metric
int leaderPatternWidth = this.properties.get(
"leader-pattern-width").getLength().mvalue();
int leaderAlignment =
this.properties.get("leader-alignment").getEnum();
// initialize id
String id = this.properties.get("id").getString();
blockArea.getIDReferences().initializeID(id, blockArea);
//adds leader to blockarea, there the leaderArea is generated
int succeeded = blockArea.addLeader(fontstate, red, green, blue,
leaderPattern, leaderLengthMinimum,
leaderLengthOptimum, leaderLengthMaximum,
ruleThickness, ruleStyle, leaderPatternWidth,
leaderAlignment);
if (succeeded == 1) {