~ubuntu-branches/ubuntu/trusty/libjgoodies-forms-java/trusty

« back to all changes in this revision

Viewing changes to src/core/com/jgoodies/forms/util/UnitConverter.java

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2008-02-25 10:57:07 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080225105707-pe51fdbcq1dt3vi6
Tags: 1.2.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2002-2008 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;
 
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.5 $
 
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 returns 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
    int inchAsPixel(double in, Component component);
 
59
 
 
60
 
 
61
    /**
 
62
     * Converts Millimeters and returns 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
    int millimeterAsPixel(double mm, Component component);
 
70
 
 
71
 
 
72
    /**
 
73
     * Converts Centimeters and returns 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
    int centimeterAsPixel(double cm, Component component);
 
81
 
 
82
 
 
83
    /**
 
84
     * Converts DTP Points and returns 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
    int pointAsPixel(int pt, Component component);
 
92
 
 
93
 
 
94
    /**
 
95
     * Converts horizontal dialog units and returns 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
    int dialogUnitXAsPixel(int dluX, Component component);
 
103
 
 
104
 
 
105
    /**
 
106
     * Converts vertical dialog units and returns 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
    int dialogUnitYAsPixel(int dluY, Component component);
 
114
 
 
115
 
 
116
}