View Javadoc

1   /*
2    * Copyright 2006-2016 The JGUIraffe Team.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License")
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.jguiraffe.gui.layout;
17  
18  /**
19   * <p>
20   * Definition of an interface for performing size calculations in a manner
21   * independent of a certain component model.
22   * </p>
23   * <p>
24   * This interface is used by the {@code Unit} class to perform unit to pixel
25   * calculations. For some unit types access to certain internal details of the
26   * affected components is needed, e.g. to the font for determining the font
27   * size. This interface has the purpose of abstracting such direct accesses, so
28   * that there can be multiple implementations for different GUI libraries (e.g.
29   * Swing and SWT).
30   * </p>
31   *
32   * @author Oliver Heger
33   * @version $Id: UnitSizeHandler.java 205 2012-01-29 18:29:57Z oheger $
34   */
35  public interface UnitSizeHandler
36  {
37      /**
38       * Determines the font size of the given component for the specified
39       * orientation. An implementation must extract the font of the passed in
40       * component (after it has been correctly casted) and then determine the
41       * average font size either in X- or Y-direction.
42       *
43       * @param component the component
44       * @param y the orientation flag ( <b>true</b> for Y or vertical,
45       *        <b>false</b> for X or horizontal
46       * @return the font size
47       */
48      double getFontSize(Object component, boolean y);
49  
50      /**
51       * Returns the screen resolution in dots per inch (dpi).
52       *
53       * @return the screen resolution in dpi
54       */
55      int getScreenResolution();
56  }