1
2
3
4
5
6
7
8
9
10
11
12 package sk.uniba.euromath.foRenderer.figures;
13
14 import org.apache.fop.area.RegionViewport;
15 import org.eclipse.draw2d.geometry.Dimension;
16 import org.eclipse.draw2d.geometry.Rectangle;
17
18 /***
19 * @author TV
20 * Created on 20.1.2004
21 *
22 * RegionFigure is built from a RegionViewport object. RegionViewport has
23 * absolute coordinates in its page.
24 *
25 */
26 public class RegionFigure extends BasicFOPFigure {
27
28 protected Rectangle viewportRect = null;
29
30 protected int leftMargin = 0;
31 protected int topMargin = 0;
32 protected int bottomMargin = 0;
33 protected int rightMargin = 0;
34
35 /***
36 * Constructor
37 *
38 * @param viewport RegionViewport
39 * @see RegionViewport
40 */
41 public RegionFigure(RegionViewport viewport){
42 super(viewport);
43
44 }
45
46 /***
47 * Returns area from that was this figure created
48 * @return RegionViewport
49 */
50 public RegionViewport getRegionVieport() {
51 return (RegionViewport)getArea();
52 }
53
54 /***
55 *
56 * @return width and height (in pixels) of area designed to place children
57 * (content rectangle) of the body region
58 */
59 public Dimension getContentSize() {
60 return new Dimension(viewportRect.width - leftMargin - rightMargin,
61 viewportRect.height - topMargin - bottomMargin);
62 }
63
64
65 /***
66 * @return
67 */
68 public int getMarginBottom() {
69 return bottomMargin;
70 }
71
72 /***
73 * @return
74 */
75 public int getMarginLeft() {
76 return leftMargin;
77 }
78
79 /***
80 * @return
81 */
82 public int getMarginRight() {
83 return rightMargin;
84 }
85
86 /***
87 * @return
88 */
89 public int getMarginTop() {
90 return topMargin;
91 }
92
93 /***
94 *
95 * @return view area of the viewport
96 */
97 public Rectangle getViewportRectangle() {
98 return this.viewportRect.getCopy();
99 }
100
101 /***
102 * Sets Margins
103 *
104 * @param r Rectangle is just a structure to store 4 values
105 */
106 public void setMargins(Rectangle r) {
107 leftMargin = r.x;
108 topMargin = r.y;
109 rightMargin = r.width;
110 bottomMargin = r.height;
111 }
112
113 /***
114 *
115 * @param viewportRect view area of the viewport
116 */
117 public void setViewportRectangle(Rectangle viewportRect) {
118 this.viewportRect = viewportRect.getCopy();
119 }
120 }