JAL-3032 adds Java 8 functionality (2/2)
[jalview.git] / src2 / net / miginfocom / layout / UnitConverter.java
1 package net.miginfocom.layout;
2 /*
3  * License (BSD):
4  * ==============
5  *
6  * Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com)
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without modification,
10  * are permitted provided that the following conditions are met:
11  * Redistributions of source code must retain the above copyright notice, this list
12  * of conditions and the following disclaimer.
13  * Redistributions in binary form must reproduce the above copyright notice, this
14  * list of conditions and the following disclaimer in the documentation and/or other
15  * materials provided with the distribution.
16  * Neither the name of the MiG InfoCom AB nor the names of its contributors may be
17  * used to endorse or promote products derived from this software without specific
18  * prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
29  * OF SUCH DAMAGE.
30  *
31  * @version 1.0
32  * @author Mikael Grev, MiG InfoCom AB
33  *         Date: 2006-sep-08
34  */
35
36 /**
37  */
38 public abstract class UnitConverter
39 {
40         /** Value to return if this converter can not handle the <code>unit</code> sent in as an argument
41          * to the convert method.
42          */
43         public static final int UNABLE = -87654312;
44
45         /** Converts <code>value</code> to pixels.
46          * @param value The value to be converted.
47          * @param unit The unit of <code>value</code>. Never <code>null</code> and at least one character.
48          * @param refValue Some reference value that may of may not be used. If the unit is percent for instance this value
49          * is the value to take the percent from. Usually the size of the parent component in the appropriate dimension.
50          * @param isHor If the value is horizontal (<code>true</code>) or vertical (<code>false</code>).
51          * @param parent The parent of the target component that <code>value</code> is to be applied to.
52          * Might for instance be needed to get the screen that the component is on in a multi screen environment.
53          * <p>
54          * May be <code>null</code> in which case a "best guess" value should be returned.
55          * @param comp The component, if applicable, or <code>null</code> if none.
56          * @return The number of pixels if <code>unit</code> is handled by this converter, <code>UnitConverter.UNABLE</code> if not.
57          */
58         public abstract int convertToPixels(float value, String unit, boolean isHor, float refValue, ContainerWrapper parent, ComponentWrapper comp);
59 }