KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > layoutmgr > inline > ScaledBaselineTableFactory


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: ScaledBaselineTableFactory.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.layoutmgr.inline;
21
22 import org.apache.fop.fo.Constants;
23 import org.apache.fop.fonts.Font;
24
25
26 /**
27  * A factory class for making alignment contexts.
28  * Currently supports alignment contexts for basic fonts
29  * and graphic inlines.
30  */

31 public class ScaledBaselineTableFactory implements Constants {
32
33     /**
34      * Creates a new instance of BasicScaledBaselineTable for the given
35      * font, baseline and writingmode.
36      * @param font the font for which a baseline table is requested
37      * @param dominantBaselineIdentifier the dominant baseline given as an integer constant
38      * @param writingMode the writing mode given as an integer constant
39      * @return a scaled baseline table for the given font
40      */

41     public static ScaledBaselineTable makeFontScaledBaselineTable(Font font
42                                                                   , int dominantBaselineIdentifier
43                                                                   , int writingMode) {
44         return new BasicScaledBaselineTable(font.getAscender(), font.getDescender()
45                                     , font.getXHeight(), dominantBaselineIdentifier, writingMode);
46     }
47     
48     /**
49      * Creates a new instance of BasicScaledBaselineTable for the given
50      * font and writingmode. It assumes an alphabetic baseline.
51      * @param font the font for which a baseline table is requested
52      * @param writingMode the writing mode given as an integer constant
53      * @return a scaled baseline table for the given font
54      */

55     public static ScaledBaselineTable makeFontScaledBaselineTable(Font font, int writingMode) {
56         return makeFontScaledBaselineTable(font, EN_ALPHABETIC, writingMode);
57     }
58     
59     /**
60      * Creates a new instance of BasicScaledBaselineTable for the given
61      * height, baseline and writingmode. This is used for non font based areas like
62      * external graphic or inline foreign object.
63      * @param height the height for which a baseline table is requested
64      * @param dominantBaselineIdentifier the dominant baseline given as an integer constant
65      * @param writingMode the writing mode given as an integer constant
66      * @return a scaled baseline table for the given dimensions
67      */

68     public static ScaledBaselineTable makeGraphicsScaledBaselineTable(int height
69                                                                 , int dominantBaselineIdentifier
70                                                                 , int writingMode) {
71         return new BasicScaledBaselineTable(height, 0, height
72                                             , dominantBaselineIdentifier, writingMode);
73     }
74     
75 }
76
Popular Tags