You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TraitSetter.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.layoutmgr;
  8. import org.apache.fop.layout.BorderAndPadding;
  9. import org.apache.fop.traits.BorderProps;
  10. import org.apache.fop.area.Area;
  11. import org.apache.fop.area.Trait;
  12. public class TraitSetter {
  13. public static void setBorderPaddingTraits(Area area,
  14. BorderAndPadding bpProps, boolean bNotFirst, boolean bNotLast) {
  15. int iBP;
  16. iBP = bpProps.getPadding(BorderAndPadding.START, bNotFirst);
  17. if (iBP > 0) {
  18. //area.addTrait(new Trait(Trait.PADDING_START, new Integer(iBP)));
  19. area.addTrait(Trait.PADDING_START, new Integer(iBP));
  20. }
  21. iBP = bpProps.getPadding(BorderAndPadding.END, bNotLast);
  22. if (iBP > 0) {
  23. //area.addTrait(new Trait(Trait.PADDING_END, new Integer(iBP)));
  24. area.addTrait(Trait.PADDING_END, new Integer(iBP));
  25. }
  26. iBP = bpProps.getPadding(BorderAndPadding.BEFORE, false);
  27. if (iBP > 0) {
  28. // area.addTrait(new Trait(Trait.PADDING_BEFORE, new Integer(iBP)));
  29. area.addTrait(Trait.PADDING_BEFORE, new Integer(iBP));
  30. }
  31. iBP = bpProps.getPadding(BorderAndPadding.AFTER, false);
  32. if (iBP > 0) {
  33. //area.addTrait(new Trait(Trait.PADDING_AFTER, new Integer(iBP)));
  34. area.addTrait(Trait.PADDING_AFTER, new Integer(iBP));
  35. }
  36. addBorderTrait(area, bpProps, bNotFirst,
  37. BorderAndPadding.START, Trait.BORDER_START);
  38. addBorderTrait(area, bpProps, bNotLast, BorderAndPadding.END,
  39. Trait.BORDER_END);
  40. addBorderTrait(area, bpProps, false, BorderAndPadding.BEFORE,
  41. Trait.BORDER_BEFORE);
  42. addBorderTrait(area, bpProps, false, BorderAndPadding.AFTER,
  43. Trait.BORDER_AFTER);
  44. }
  45. private static void addBorderTrait(Area area,
  46. BorderAndPadding bpProps, boolean bDiscard, int iSide,
  47. Object oTrait) {
  48. int iBP = bpProps.getBorderWidth(iSide, bDiscard);
  49. if (iBP > 0) {
  50. // area.addTrait(new Trait(oTrait,
  51. // new BorderProps(bpProps.getBorderStyle(iSide),
  52. // iBP,
  53. // bpProps.getBorderColor(iSide))));
  54. area.addTrait(oTrait,
  55. new BorderProps(bpProps.getBorderStyle(iSide),
  56. iBP, bpProps.getBorderColor(iSide)));
  57. }
  58. }
  59. }