Package org.apache.fop.layout

Examples of org.apache.fop.layout.BlockArea


            // initialize id
            String id = this.properties.get("id").getString();
            area.getIDReferences().initializeID(id, area);
        }

        BlockArea blockArea = new BlockArea(fs, area.getAllocationWidth(),
                                            area.spaceLeft(), startIndent, endIndent, 0, align,
                                            alignLast, lineHeight);
        blockArea.setPage(area.getPage());
        blockArea.setBackgroundColor(backgroundColor);
        blockArea.start();

        blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
        blockArea.setIDReferences(area.getIDReferences());

        int numChildren = this.children.size();
        for (int i = this.marker; i < numChildren; i++) {
            if (!(children.elementAt(i) instanceof ListItem)) {
                MessageHandler.errorln("WARNING: This version of FOP requires list-items inside list-blocks");
                return new Status(Status.OK);
            }
            ListItem listItem = (ListItem) children.elementAt(i);
            listItem.setDistanceBetweenStarts(
              this.provisionalDistanceBetweenStarts);
            listItem.setLabelSeparation(this.provisionalLabelSeparation);
            listItem.setBodyIndent(this.bodyIndent);
            Status status;
            if ((status = listItem.layout(blockArea)).isIncomplete()) {
                this.marker = i;
                blockArea.end();
                area.addChild(blockArea);
                area.increaseHeight(blockArea.getHeight());
                area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
                return status;
            }
        }

        blockArea.end();
        area.addChild(blockArea);
        area.increaseHeight(blockArea.getHeight());
        area.setAbsoluteHeight(blockArea.getAbsoluteHeight());

        if (spaceAfter != 0) {
            area.addDisplaySpace(spaceAfter);
        }
View Full Code Here


        }
    }


    public Status layout(Area area) throws FOPException {
        BlockArea blockArea;
        blockArea = (BlockArea) area;
        boolean textDecoration;

        //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();

        int whiteSpaceCollapse = this.properties.get(
                                    "white-space-collapse").getEnum();
        int wrapOption = this.parent.properties.get("wrap-option").getEnum();

        int tmp = this.properties.get("text-decoration").getEnum();
        if (tmp == org.apache.fop.fo.properties.TextDecoration.UNDERLINE) {
          textDecoration = true;
        } else {
          textDecoration = false;
        }

        //Character specific properties
        char characterValue = this.properties.get("character").getCharacter();


        // initialize id
        String id = this.properties.get("id").getString();
        blockArea.getIDReferences().initializeID(id, blockArea);
        blockArea.addCharacter(fontstate,red,green,blue,wrapOption,this.getLinkSet(),
                               whiteSpaceCollapse,characterValue,textDecoration);
        return new Status(Status.OK);


    }
View Full Code Here

      area.addDisplaySpace(spaceBefore);
  }

  startIndent += this.bodyIndent;

  BlockArea blockArea =
      new BlockArea(fs, area.getAllocationWidth(),
        area.spaceLeft(), startIndent, endIndent,
        0, align, alignLast, lineHeight);
  blockArea.setPage(area.getPage());
  blockArea.start();

        blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
        blockArea.setIDReferences(area.getIDReferences());

  int numChildren = this.children.size();
  if (numChildren != 2) {
      throw new FOPException("list-item must have exactly two children");
  }
  ListItemLabel label = (ListItemLabel) children.elementAt(0);
  ListItemBody body = (ListItemBody) children.elementAt(1);

  label.setDistanceBetweenStarts(this.distanceBetweenStarts);
  label.setLabelSeparation(this.labelSeparation);
  label.setBodyIndent(this.bodyIndent);

  body.setDistanceBetweenStarts(this.distanceBetweenStarts);
  body.setBodyIndent(this.bodyIndent);

  /* this doesn't actually do anything */
  body.setLabelSeparation(this.labelSeparation);

  Status status;

  // what follows doesn't yet take into account whether the
  // body failed completely or only got some text in

  if (this.marker == 0) {
            // configure id                                              
            area.getIDReferences().configureID(id,area);

      status = label.layout(blockArea);
      if (status.isIncomplete()) {
    return status;
      }
  }

  status = body.layout(blockArea);
  if (status.isIncomplete()) {
      blockArea.end();
      area.addChild(blockArea);
      area.increaseHeight(blockArea.getHeight());
            area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
      this.marker = 1;
      return status;
  }

  blockArea.end();
  area.addChild(blockArea);
  area.increaseHeight(blockArea.getHeight());
        area.setAbsoluteHeight(blockArea.getAbsoluteHeight());

  if (spaceAfter != 0) {
      area.addDisplaySpace(spaceAfter);
  }

View Full Code Here

        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();
        int leaderLengthMaximum = this.properties.get(
                                    "leader-length.maximum").getLength().mvalue();
        //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) {
View Full Code Here

        if (spaceBefore != 0) {
            area.addDisplaySpace(spaceBefore);
        }

        this.blockArea =
            new BlockArea(propMgr.getFontState(area.getFontInfo()),
                          area.getAllocationWidth(), area.spaceLeft(), 0, 0,
                          0, align, alignLast, lineHeight);
        this.blockArea.setGeneratedBy(this);
        this.areasGenerated++;
        if (this.areasGenerated == 1)
View Full Code Here

        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;
        }

        // Common Accessibility Properties
        AccessibilityProps mAccProps = propMgr.getAccessibilityProps();

        // Common Aural Properties
        AuralProps mAurProps = propMgr.getAuralProps();

        // Common Border, Padding, and Background Properties
        BorderAndPadding bap = propMgr.getBorderAndPadding();
        BackgroundProps bProps = propMgr.getBackgroundProps();

        // Common Font Properties
        //this.fontState = propMgr.getFontState(area.getFontInfo());

        // Common Margin Properties-Inline
        MarginInlineProps mProps = propMgr.getMarginInlineProps();

        // Common Relative Position Properties
        RelativePositionProps mRelProps = propMgr.getRelativePositionProps();

        // this.properties.get("alignment-adjust");
        // this.properties.get("alignment-baseline");
        // this.properties.get("baseline-shift");
        // this.properties.get("color");
        // this.properties.get("dominant-baseline");
        // this.properties.get("text-depth");
        // this.properties.get("text-altitude");
        // this.properties.get("id");
        // this.properties.get("leader-alignment");
        // this.properties.get("leader-length");
        // this.properties.get("leader-pattern");
        // this.properties.get("leader-pattern-width");
        // this.properties.get("rule-style");
        // this.properties.get("rule-thickness");
        // this.properties.get("letter-spacing");
        // this.properties.get("line-height");
        // this.properties.get("line-height-shift-adjustment");
        // this.properties.get("text-shadow");
        // this.properties.get("visibility");
        // this.properties.get("word-spacing");
        // this.properties.get("z-index");

        // 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();
        int leaderLengthMaximum =
            this.properties.get("leader-length.maximum").getLength().mvalue();
        // 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 = addLeader(blockArea,
                                  propMgr.getFontState(area.getFontInfo()),
                                  red, green, blue, leaderPattern,
View Full Code Here

        if (this.areaCurrent == null) {
            return new Status(Status.OK);
        }

        if (area instanceof BlockArea) {
            BlockArea ba = (BlockArea)area;
            LineArea la = ba.getCurrentLineArea();
            if (la == null) {
                return new Status(Status.AREA_FULL_NONE);
            }
            la.addPending();
            if (areaCurrent.getEffectiveWidth() > la.getRemainingWidth()) {
                la = ba.createNextLineArea();
                if (la == null) {
                    return new Status(Status.AREA_FULL_NONE);
                }
            }
            la.addInlineArea(areaCurrent);
View Full Code Here

            // initialize id
            String id = this.properties.get("id").getString();
            area.getIDReferences().initializeID(id, area);
        }

        BlockArea blockArea =
            new BlockArea(propMgr.getFontState(area.getFontInfo()),
                          area.getAllocationWidth(), area.spaceLeft(),
                          startIndent, endIndent, 0, align, alignLast,
                          lineHeight);
        blockArea.setGeneratedBy(this);
        this.areasGenerated++;
        if (this.areasGenerated == 1)
            blockArea.isFirst(true);
            // for normal areas this should be the only pair
        blockArea.addLineagePair(this, this.areasGenerated);

        // markers
        if (this.hasMarkers())
            blockArea.addMarkers(this.getMarkers());


        blockArea.setPage(area.getPage());
        blockArea.setBackgroundColor(backgroundColor);
        blockArea.start();

        blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
        blockArea.setIDReferences(area.getIDReferences());

        int numChildren = this.children.size();
        for (int i = this.marker; i < numChildren; i++) {
            if (!(children.elementAt(i) instanceof ListItem)) {
                MessageHandler.errorln("children of list-blocks must be list-items");
                return new Status(Status.OK);
            }
            ListItem listItem = (ListItem)children.elementAt(i);
            Status status;
            if ((status = listItem.layout(blockArea)).isIncomplete()) {
                if (status.getCode() == Status.AREA_FULL_NONE && i > 0) {
                    status = new Status(Status.AREA_FULL_SOME);
                }
                this.marker = i;
                blockArea.end();
                area.addChild(blockArea);
                area.increaseHeight(blockArea.getHeight());
                area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
                return status;
            }
        }

        blockArea.end();
        area.addChild(blockArea);
        area.increaseHeight(blockArea.getHeight());
        area.setAbsoluteHeight(blockArea.getAbsoluteHeight());

        if (spaceAfter != 0) {
            area.addDisplaySpace(spaceAfter);
        }

        if (area instanceof BlockArea) {
            area.start();
        }

        blockArea.isLast(true);
        return new Status(Status.OK);
    }
View Full Code Here

    }


    public Status layout(Area area) throws FOPException {
        BlockArea blockArea;
        if (!(area instanceof BlockArea)) {
            MessageHandler.errorln("WARNING: currently Character can only be in a BlockArea");
            return new Status(Status.OK);
        }
        blockArea = (BlockArea)area;
        boolean textDecoration;

        // Common Aural Properties
        AuralProps mAurProps = propMgr.getAuralProps();

        // Common Border, Padding, and Background Properties
        BorderAndPadding bap = propMgr.getBorderAndPadding();
        BackgroundProps bProps = propMgr.getBackgroundProps();

        // Common Font Properties
        //this.fontState = propMgr.getFontState(area.getFontInfo());

        // Common Hyphenation Properties
        HyphenationProps mHyphProps = propMgr.getHyphenationProps();

        // Common Margin Properties-Inline
        MarginInlineProps mProps = propMgr.getMarginInlineProps();

        // Common Relative Position Properties
        RelativePositionProps mRelProps = propMgr.getRelativePositionProps();

        // this.properties.get("alignment-adjust");
        // this.properties.get("treat-as-word-space");
        // this.properties.get("alignment-baseline");
        // this.properties.get("baseline-shift");
        // this.properties.get("character");
        // this.properties.get("color");
        // this.properties.get("dominant-baseline");
        // this.properties.get("text-depth");
        // this.properties.get("text-altitude");
        // this.properties.get("glyph-orientation-horizontal");
        // this.properties.get("glyph-orientation-vertical");
        // this.properties.get("id");
        // this.properties.get("keep-with-next");
        // this.properties.get("keep-with-previous");
        // this.properties.get("letter-spacing");
        // this.properties.get("line-height");
        // this.properties.get("line-height-shift-adjustment");
        // this.properties.get("score-spaces");
        // this.properties.get("suppress-at-line-break");
        // this.properties.get("text-decoration");
        // this.properties.get("text-shadow");
        // this.properties.get("text-transform");
        // this.properties.get("word-spacing");

        // color properties
        ColorType c = this.properties.get("color").getColorType();
        float red = c.red();
        float green = c.green();
        float blue = c.blue();

        int whiteSpaceCollapse =
            this.properties.get("white-space-collapse").getEnum();
        int wrapOption = this.parent.properties.get("wrap-option").getEnum();

        int tmp = this.properties.get("text-decoration").getEnum();
        if (tmp == org.apache.fop.fo.properties.TextDecoration.UNDERLINE) {
            textDecoration = true;
        } else {
            textDecoration = false;
        }

        // Character specific properties
        char characterValue = this.properties.get("character").getCharacter();


        // initialize id
        String id = this.properties.get("id").getString();
        blockArea.getIDReferences().initializeID(id, blockArea);

        LineArea la = blockArea.getCurrentLineArea();
        if (la == null) {
            return new Status(Status.AREA_FULL_NONE);
        }
        la.changeFont(propMgr.getFontState(area.getFontInfo()));
        la.changeColor(red, green, blue);
        la.changeWrapOption(wrapOption);
        la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
        blockArea.setupLinkSet(this.getLinkSet());
        int result = la.addCharacter(characterValue, this.getLinkSet(),
                                     textDecoration);
        if (result == Character.DOESNOT_FIT) {
            la = blockArea.createNextLineArea();
            if (la == null) {
                return new Status(Status.AREA_FULL_NONE);
            }
            la.changeFont(propMgr.getFontState(area.getFontInfo()));
            la.changeColor(red, green, blue);
            la.changeWrapOption(wrapOption);
            la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
            blockArea.setupLinkSet(this.getLinkSet());
            la.addCharacter(characterValue, this.getLinkSet(),
                            textDecoration);
        }
        return new Status(Status.OK);
View Full Code Here

            // initialize id
            String id = this.properties.get("id").getString();
            area.getIDReferences().initializeID(id, area);
        }

        BlockArea blockArea =
            new BlockArea(propMgr.getFontState(area.getFontInfo()),
                          area.getAllocationWidth(), area.spaceLeft(),
                          startIndent, endIndent, 0, align, alignLast,
                          lineHeight);
        blockArea.setGeneratedBy(this);
        this.areasGenerated++;
        if (this.areasGenerated == 1)
            blockArea.isFirst(true);
            // for normal areas this should be the only pair
        blockArea.addLineagePair(this, this.areasGenerated);

        // markers
        if (this.hasMarkers())
            blockArea.addMarkers(this.getMarkers());


        blockArea.setPage(area.getPage());
        blockArea.setBackgroundColor(backgroundColor);
        blockArea.start();

        blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
        blockArea.setIDReferences(area.getIDReferences());

        int numChildren = this.children.size();
        for (int i = this.marker; i < numChildren; i++) {
            if (!(children.elementAt(i) instanceof ListItem)) {
                log.error("children of list-blocks must be list-items");
                return new Status(Status.OK);
            }
            ListItem listItem = (ListItem)children.elementAt(i);
            Status status;
            if ((status = listItem.layout(blockArea)).isIncomplete()) {
                if (status.getCode() == Status.AREA_FULL_NONE && i > 0) {
                    status = new Status(Status.AREA_FULL_SOME);
                }
                this.marker = i;
                blockArea.end();
                area.addChild(blockArea);
                area.increaseHeight(blockArea.getHeight());
                area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
                return status;
            }
        }

        blockArea.end();
        area.addChild(blockArea);
        area.increaseHeight(blockArea.getHeight());
        area.setAbsoluteHeight(blockArea.getAbsoluteHeight());

        if (spaceAfter != 0) {
            area.addDisplaySpace(spaceAfter);
        }

        if (area instanceof BlockArea) {
            area.start();
        }

        blockArea.isLast(true);
        return new Status(Status.OK);
    }
View Full Code Here

TOP

Related Classes of org.apache.fop.layout.BlockArea

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.