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.

InlineArea.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * $Id$
  3. * Copyright (C) 2002 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.area.inline;
  8. import org.apache.fop.area.Area;
  9. import org.apache.fop.area.MinOptMax;
  10. import org.apache.fop.area.Trait;
  11. import org.apache.fop.render.Renderer;
  12. import org.apache.fop.traits.BorderProps;
  13. import org.apache.fop.fo.properties.VerticalAlign;
  14. import java.util.ArrayList;
  15. /**
  16. * Inline Area
  17. * This area is for all inline areas that can be placed
  18. * in a line area.
  19. * Extensions of this class should render themselves with the
  20. * requested renderer.
  21. */
  22. public class InlineArea extends Area {
  23. // int width;
  24. int height;
  25. protected int contentIPD = 0;
  26. // offset position from top of parent area
  27. int verticalPosition = 0;
  28. // store properties in array list, need better solution
  29. ArrayList props = null;
  30. // inline areas are expected to implement this method
  31. // to render themselves
  32. public void render(Renderer renderer) {
  33. }
  34. public void setWidth(int w) {
  35. contentIPD = w;
  36. }
  37. public int getWidth() {
  38. return contentIPD;
  39. }
  40. public void setIPD(int ipd) {
  41. this.contentIPD = ipd;
  42. }
  43. public int getIPD() {
  44. return this.contentIPD;
  45. }
  46. public void increaseIPD(int ipd) {
  47. this.contentIPD += ipd;
  48. }
  49. public void setHeight(int h) {
  50. height = h;
  51. }
  52. public int getHeight() {
  53. return height;
  54. }
  55. public int getAllocIPD() {
  56. // If start or end border or padding is non-zero, add to content IPD
  57. int iBP = contentIPD;
  58. Object t;
  59. if ((t = getTrait(Trait.PADDING_START)) != null) {
  60. iBP += ((Integer) t).intValue();
  61. }
  62. if ((t = getTrait(Trait.PADDING_END)) != null) {
  63. iBP += ((Integer) t).intValue();
  64. }
  65. if ((t = getTrait(Trait.BORDER_START)) != null) {
  66. iBP += ((BorderProps) t).width;
  67. }
  68. if ((t = getTrait(Trait.BORDER_END)) != null) {
  69. iBP += ((BorderProps) t).width;
  70. }
  71. return iBP;
  72. }
  73. public MinOptMax getAllocationIPD() {
  74. return new MinOptMax(getAllocIPD());
  75. }
  76. public void setOffset(int v) {
  77. verticalPosition = v;
  78. }
  79. public int getOffset() {
  80. return verticalPosition;
  81. }
  82. }