JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
Gap.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 Gap, scaled spacing between (grid) cells not belonging to the cell element.
34 * <p>
35 * The CSS gap property defines the size of the gap between the rows and columns in a grid layout.
36 * </p>
37 */
38public class Gap {
39 /** Zero gap constant. */
40 public static final Gap None = new Gap();
41
42 /** Scaled row gap value, vertical spacing. */
43 public final float row;
44 /** Scaled column gap value, horizontal spacing. */
45 public final float column;
46
47 private Gap() {
48 row = 0f; column = 0f;
49 }
50
51 /**
52 * Ctor
53 * @param row scaled vertical row value
54 * @param column scaled horizontal column value
55 */
56 public Gap(final float row, final float column) {
57 this.row = row; this.column = column;
58 }
59
60 /**
61 * Ctor
62 * @param rc scaled vertical row and horizontal column value
63 */
64 public Gap(final float rc) {
65 this.row = rc; this.column = rc;
66 }
67
68 /** Return scaled width of horizontal value, i.e. 1 * column. */
69 public float width() { return column; }
70
71 /** Return scaled height of vertical value, i.e. 1 * row. */
72 public float height() { return row; }
73
74 public boolean zeroSumWidth() { return FloatUtil.isZero( width() ); };
75
76 public boolean zeroSumHeight() { return FloatUtil.isZero( height() ); };
77
78 public boolean zeroSumSize() { return zeroSumWidth() && zeroSumHeight(); }
79
80 @Override
81 public String toString() { return "Gap[r "+row+", c "+column+"]"; }
82}
GraphUI CSS property Gap, scaled spacing between (grid) cells not belonging to the cell element.
Definition: Gap.java:38
static final Gap None
Zero gap constant.
Definition: Gap.java:40
Gap(final float rc)
Ctor.
Definition: Gap.java:64
final float column
Scaled column gap value, horizontal spacing.
Definition: Gap.java:45
final float row
Scaled row gap value, vertical spacing.
Definition: Gap.java:43
Gap(final float row, final float column)
Ctor.
Definition: Gap.java:56
float height()
Return scaled height of vertical value, i.e.
Definition: Gap.java:72
float width()
Return scaled width of horizontal value, i.e.
Definition: Gap.java:69
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.