2
* Copyright (c) 2002-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
7
* o Redistributions of source code must retain the above copyright notice,
8
* this list of conditions and the following disclaimer.
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.
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.
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.
31
package com.jgoodies.forms.util;
33
import java.awt.Component;
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.
41
* @author Karsten Lentzsch
42
* @version $Revision: 1.5 $
43
* @see com.jgoodies.forms.layout.Sizes
44
* @see com.jgoodies.forms.layout.ConstantSize
45
* @see AbstractUnitConverter
46
* @see DefaultUnitConverter
48
public interface UnitConverter {
52
* Converts Inches and returns pixels using the specified resolution.
54
* @param in the Inches
55
* @param component the component that provides the graphics object
56
* @return the given Inches as pixels
58
int inchAsPixel(double in, Component component);
62
* Converts Millimeters and returns pixels using the resolution of the
63
* given component's graphics object.
65
* @param mm Millimeters
66
* @param component the component that provides the graphics object
67
* @return the given Millimeters as pixels
69
int millimeterAsPixel(double mm, Component component);
73
* Converts Centimeters and returns pixels using the resolution of the
74
* given component's graphics object.
76
* @param cm Centimeters
77
* @param component the component that provides the graphics object
78
* @return the given Centimeters as pixels
80
int centimeterAsPixel(double cm, Component component);
84
* Converts DTP Points and returns pixels using the resolution of the
85
* given component's graphics object.
87
* @param pt DTP Points
88
* @param component the component that provides the graphics object
89
* @return the given Points as pixels
91
int pointAsPixel(int pt, Component component);
95
* Converts horizontal dialog units and returns pixels.
96
* Honors the resolution, dialog font size, platform and look&feel.
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
102
int dialogUnitXAsPixel(int dluX, Component component);
106
* Converts vertical dialog units and returns pixels.
107
* Honors the resolution, dialog font size, platform and look&feel.
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
113
int dialogUnitYAsPixel(int dluY, Component component);