JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
Padding.java
Go to the documentation of this file.
1/**
2 * Copyright 2023 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.graph.ui.layout;
29
30import com.jogamp.math.FloatUtil;
31
32/**
33 * GraphUI CSS property Padding, unscaled space belonging to the element and included in the element's size.
34 * <p>
35 * The CSS padding properties are used to generate space around an element's content, inside of any defined borders.
36 * </p>
37 */
38public class Padding {
39 /** Zero padding constant. */
40 public static final Padding None = new Padding();
41
42 /** Top value (unscaled) */
43 public final float top;
44 /** Right value (unscaled) */
45 public final float right;
46 /** Bottom value (unscaled) */
47 public final float bottom;
48 /** Left value (unscaled) */
49 public final float left;
50
51 private Padding() {
52 this(0f);
53 }
54
55 /**
56 * Ctor
57 * @param top unscaled top value
58 * @param right unscaled right value
59 * @param bottom unscaled bottom value
60 * @param left unscaled left value
61 */
62 public Padding(final float top, final float right, final float bottom, final float left) {
63 this.top = top; this.right = right; this.bottom = bottom; this.left = left;
64 }
65
66 /**
67 * Ctor
68 * @param top unscaled top value
69 * @param rl unscaled right and left value
70 * @param bottom unscaled bottom value
71 */
72 public Padding(final float top, final float rl, final float bottom) {
73 this.top = top; this.right = rl; this.bottom = bottom; this.left = rl;
74 }
75
76 /**
77 * Ctor
78 * @param tb unscaled top and bottom value
79 * @param rl unscaled right and left value
80 */
81 public Padding(final float tb, final float rl) {
82 this.top = tb; this.right = rl; this.bottom = tb; this.left = rl;
83 }
84
85 /**
86 * Ctor
87 * @param trbl unscaled top, right, bottom and left value
88 */
89 public Padding(final float trbl) {
90 this.top = trbl; this.right = trbl; this.bottom = trbl; this.left = trbl;
91 }
92
93 /** Return unscaled width of horizontal values top + right. */
94 public float width() { return left + right; }
95
96 /** Return unscaled height of vertical values bottom + top. */
97 public float height() { return bottom + top; }
98
99 public boolean zeroWidth() { return FloatUtil.isZero( width() ); };
100
101 public boolean zeroHeight() { return FloatUtil.isZero( height() ); };
102
103 public boolean zeroSize() { return zeroWidth() && zeroHeight(); }
104
105 @Override
106 public String toString() { return "Padding[t "+top+", r "+right+", b "+bottom+", l "+left+"]"; }
107}
GraphUI CSS property Padding, unscaled space belonging to the element and included in the element's s...
Definition: Padding.java:38
final float top
Top value (unscaled)
Definition: Padding.java:43
final float left
Left value (unscaled)
Definition: Padding.java:49
static final Padding None
Zero padding constant.
Definition: Padding.java:40
Padding(final float trbl)
Ctor.
Definition: Padding.java:89
final float right
Right value (unscaled)
Definition: Padding.java:45
Padding(final float top, final float right, final float bottom, final float left)
Ctor.
Definition: Padding.java:62
float height()
Return unscaled height of vertical values bottom + top.
Definition: Padding.java:97
Padding(final float top, final float rl, final float bottom)
Ctor.
Definition: Padding.java:72
float width()
Return unscaled width of horizontal values top + right.
Definition: Padding.java:94
final float bottom
Bottom value (unscaled)
Definition: Padding.java:47
Padding(final float tb, final float rl)
Ctor.
Definition: Padding.java:81
Basic Float math utility functions.
Definition: FloatUtil.java:83
static boolean isZero(final float a, final float epsilon)
Returns true if value is zero, i.e.