2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
7 // Copyright (C) 2000-2001 Washington University School of Medicine
8 // and Howard Hughes Medical Institute
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 // Contact: phylosoft @ gmail . com
26 // WWW: www.phylosoft.org/forester
28 package org.forester.sdi;
30 class Tuplet implements Comparable<Tuplet> {
32 public static final int DEFAULT = -999;
33 private final String _key;
34 private final double _value1;
35 private final double _value2;
36 private final double _value3;
37 private final double _value4;
38 private int[] _p; // Since
43 _value1 = Tuplet.DEFAULT;
44 _value2 = Tuplet.DEFAULT;
45 _value3 = Tuplet.DEFAULT;
46 _value4 = Tuplet.DEFAULT;
53 // direction than other values, and it is not
54 // known which value will be the distance.
55 Tuplet( final String name,
67 if ( ( c >= 0 ) && ( c <= 3 ) ) {
72 Tuplet( final String name, final double value1, final double value2, final double value3, final int c ) {
78 _value4 = Tuplet.DEFAULT;
79 if ( ( c >= 0 ) && ( c <= 2 ) ) {
84 Tuplet( final String name, final double value1, final double value2, final int c ) {
89 _value3 = Tuplet.DEFAULT;
90 _value4 = Tuplet.DEFAULT;
91 if ( ( c >= 0 ) && ( c <= 1 ) ) {
96 Tuplet( final String name, final double value1, final int c ) {
100 _value2 = Tuplet.DEFAULT;
101 _value3 = Tuplet.DEFAULT;
102 _value4 = Tuplet.DEFAULT;
109 public int compareTo( final Tuplet n ) {
110 if ( ( getValue1() != Tuplet.DEFAULT ) && ( n.getValue1() != Tuplet.DEFAULT ) ) {
111 if ( getValue1() < n.getValue1() ) {
114 if ( getValue1() > n.getValue1() ) {
118 if ( ( getValue2() != Tuplet.DEFAULT ) && ( n.getValue2() != Tuplet.DEFAULT ) ) {
119 if ( getValue2() < n.getValue2() ) {
122 if ( getValue2() > n.getValue2() ) {
126 if ( ( getValue3() != Tuplet.DEFAULT ) && ( n.getValue3() != Tuplet.DEFAULT ) ) {
127 if ( getValue3() < n.getValue3() ) {
130 if ( getValue3() > n.getValue3() ) {
134 if ( ( getValue4() != Tuplet.DEFAULT ) && ( n.getValue4() != Tuplet.DEFAULT ) ) {
135 if ( getValue4() < n.getValue4() ) {
138 if ( getValue4() > n.getValue4() ) {
142 return ( getKey().compareTo( n.getKey() ) );
165 private void setSigns() {
167 _p[ 0 ] = _p[ 1 ] = _p[ 2 ] = _p[ 3 ] = +1;