KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jgoodies > forms > util > UnitConverter


1 /*
2  * Copyright (c) 2003 JGoodies Karsten Lentzsch. All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * o Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  *
10  * o Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * o Neither the name of JGoodies Karsten Lentzsch nor the names of
15  * its contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */

30
31 package com.jgoodies.forms.util;
32
33 import java.awt.Component JavaDoc;
34
35 /**
36  * An interface that describes how to convert general sizes to pixel sizes.
37  * For example, <i>dialog units</i> require a conversion that honors
38  * the font and resolution. The {@link com.jgoodies.forms.layout.Sizes} class
39  * delegates all size conversions to an implementation of this interface.
40  *
41  * @author Karsten Lentzsch
42  * @version $Revision: 1.2 $
43  * @see com.jgoodies.forms.layout.Sizes
44  * @see com.jgoodies.forms.layout.ConstantSize
45  * @see AbstractUnitConverter
46  * @see DefaultUnitConverter
47  */

48 public interface UnitConverter {
49     
50     
51     /**
52      * Converts Inches and answers pixels using the specified resolution.
53      *
54      * @param in the Inches
55      * @param component the component that provides the graphics object
56      * @return the given Inches as pixels
57      */

58     public int inchAsPixel(double in, Component JavaDoc component);
59     
60
61     /**
62      * Converts Millimeters and answers pixels using the resolution of the
63      * given component's graphics object.
64      *
65      * @param mm Millimeters
66      * @param component the component that provides the graphics object
67      * @return the given Millimeters as pixels
68      */

69     public int millimeterAsPixel(double mm, Component JavaDoc component);
70
71
72     /**
73      * Converts Centimeters and answers pixels using the resolution of the
74      * given component's graphics object.
75      *
76      * @param cm Centimeters
77      * @param component the component that provides the graphics object
78      * @return the given Centimeters as pixels
79      */

80     public int centimeterAsPixel(double cm, Component JavaDoc component);
81     
82
83     /**
84      * Converts DTP Points and answers pixels using the resolution of the
85      * given component's graphics object.
86      *
87      * @param pt DTP Points
88      * @param component the component that provides the graphics object
89      * @return the given Points as pixels
90      */

91     public int pointAsPixel(int pt, Component JavaDoc component);
92     
93     
94     /**
95      * Converts horizontal dialog units and answers pixels.
96      * Honors the resolution, dialog font size, platform and look&amp;feel.
97      *
98      * @param dluX the horizontal dialog units
99      * @param component a component that provides the font and graphics
100      * @return the given horizontal dialog units as pixels
101      */

102     public int dialogUnitXAsPixel(int dluX, Component JavaDoc component);
103             
104                     
105     /**
106      * Converts vertical dialog units and answers pixels.
107      * Honors the resolution, dialog font size, platform and look&amp;feel.
108      *
109      * @param dluY the vertical dialog units
110      * @param component a component that provides the font and graphics
111      * @return the given vertical dialog units as pixels
112      */

113     public int dialogUnitYAsPixel(int dluY, Component JavaDoc component);
114     
115     
116 }
Popular Tags