1
2
3
4
5
6
7
8
9
10
11
12 package sk.uniba.euromath.foRenderer.figures;
13
14 import org.apache.fop.datatypes.ColorType;
15 import org.eclipse.draw2d.geometry.Point;
16 import org.eclipse.draw2d.geometry.Rectangle;
17 import org.eclipse.swt.graphics.Color;
18 import org.eclipse.swt.graphics.RGB;
19
20 /***
21 * @author TV
22 * Created on 8.1.2005
23 */
24 public class FOFigureUtils {
25
26 private static final double FOP_DPI = 72.0f;
27 private static final double SCR_DPI = 96.0f;
28 private static final double MP_MULT = 1000.0f;
29
30 /***
31 * @param ct
32 * @return
33 */
34 public static Color getSWTColor(ColorType ct) {
35 return new Color(null, new RGB(ct.getAWTColor().getRed(),
36 ct.getAWTColor().getGreen(), ct.getAWTColor().getBlue()));
37 }
38
39
40
41
42 public static final int mps2pxs(double mps) {
43 return (int)Math.round((mps/MP_MULT)/FOP_DPI*SCR_DPI);
44 }
45
46 public static final Rectangle mps2pxs(int x, int y, int w, int h) {
47 return new Rectangle(mps2pxs(x), mps2pxs(y), mps2pxs(w), mps2pxs(h));
48 }
49
50 public static final Rectangle mps2pxs(Rectangle r) {
51 return mps2pxs(r.x, r.y, r.width, r.height);
52 }
53
54 public static final Point mps2pxs(int x, int y) {
55 return new Point(mps2pxs(x), mps2pxs(y));
56 }
57
58 }