2 * Copyright (C) 2017 EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 package org
.lttng
.scope
.tmf2
.views
.ui
.timeline
.widgets
.timegraph
;
12 import java
.util
.Objects
;
14 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import com
.google
.common
.base
.MoreObjects
;
18 public class VerticalPosition
{
21 * Placeholder for uninitialized vertical positions.
23 public static final VerticalPosition UNINITIALIZED_VP
= new VerticalPosition(0.0, 0.0);
25 private static final double EPSILON
= 0.00001;
27 public final double fTopPos
;
28 public final double fBottomPos
;
30 public VerticalPosition(double topPos
, double bottomPos
) {
32 fBottomPos
= bottomPos
;
36 public int hashCode() {
37 return Objects
.hash(fTopPos
, fBottomPos
);
41 public boolean equals(@Nullable Object obj
) {
48 if (getClass() != obj
.getClass()) {
51 VerticalPosition other
= (VerticalPosition
) obj
;
52 return (doubleEquals(fTopPos
, other
.fTopPos
)
53 && doubleEquals(fBottomPos
, other
.fBottomPos
));
57 public String
toString() {
58 return MoreObjects
.toStringHelper(this)
59 .add("fTopPos", fTopPos
) //$NON-NLS-1$
60 .add("fBottomPos", fBottomPos
) //$NON-NLS-1$
64 private static boolean doubleEquals(double d1
, double d2
) {
65 return (Math
.abs(d1
- d2
) < EPSILON
);