LibreOffice Module android (master) 1
FloatSize.java
Go to the documentation of this file.
1/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6package org.mozilla.gecko.gfx;
7
8import org.json.JSONException;
9import org.json.JSONObject;
11
12public class FloatSize {
13 public final float width, height;
14
15 public FloatSize(FloatSize size) { width = size.width; height = size.height; }
16 public FloatSize(IntSize size) { width = size.width; height = size.height; }
17 public FloatSize(float aWidth, float aHeight) { width = aWidth; height = aHeight; }
18
19 public FloatSize(JSONObject json) {
20 try {
21 width = (float)json.getDouble("width");
22 height = (float)json.getDouble("height");
23 } catch (JSONException e) {
24 throw new RuntimeException(e);
25 }
26 }
27
28 @Override
29 public String toString() { return "(" + width + "," + height + ")"; }
30
31 public boolean isPositive() {
32 return (width > 0 && height > 0);
33 }
34
35 public boolean fuzzyEquals(FloatSize size) {
36 return (FloatUtils.fuzzyEquals(size.width, width) &&
38 }
39
40 public FloatSize scale(float factor) {
41 return new FloatSize(width * factor, height * factor);
42 }
43
44 /*
45 * Returns the size that represents a linear transition between this size and `to` at time `t`,
46 * which is on the scale [0, 1).
47 */
48 public FloatSize interpolate(FloatSize to, float t) {
49 return new FloatSize(FloatUtils.interpolate(width, to.width, t),
50 FloatUtils.interpolate(height, to.height, t));
51 }
52}
53
XPropertyListType t
UBlockCode to
FloatSize interpolate(FloatSize to, float t)
Definition: FloatSize.java:48
FloatSize(float aWidth, float aHeight)
Definition: FloatSize.java:17
FloatSize scale(float factor)
Definition: FloatSize.java:40
boolean fuzzyEquals(FloatSize size)
Definition: FloatSize.java:35
static float interpolate(float from, float to, float t)
Definition: FloatUtils.java:26
static boolean fuzzyEquals(float a, float b)
Definition: FloatUtils.java:13
size