Skip to content

Commit 7848f15

Browse files
authored
Merge pull request #2 from scijava/migrate-tables-with-history
Migrate tables from imagej-common
2 parents e019fd6 + 0f80ce4 commit 7848f15

40 files changed

+5983
-0
lines changed

src/main/java/org/scijava/table/AbstractTable.java

Lines changed: 559 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* #%L
3+
* ImageJ software for multidimensional image processing and analysis.
4+
* %%
5+
* Copyright (C) 2009 - 2017 Board of Regents of the University of
6+
* Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
7+
* Institute of Molecular Cell Biology and Genetics.
8+
* %%
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice,
13+
* this list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
* #L%
30+
*/
31+
32+
package org.scijava.table;
33+
34+
import org.scijava.util.BoolArray;
35+
36+
/**
37+
* Efficient implementation of {@link Column} for {@code boolean} primitives.
38+
*
39+
* @author Alison Walter
40+
*/
41+
public class BoolColumn extends BoolArray implements
42+
PrimitiveColumn<boolean[], Boolean>
43+
{
44+
45+
/** The column header. */
46+
private String header;
47+
48+
public BoolColumn() {}
49+
50+
public BoolColumn(final String header) {
51+
this.header = header;
52+
}
53+
54+
// -- Column methods --
55+
56+
@Override
57+
public String getHeader() {
58+
return header;
59+
}
60+
61+
@Override
62+
public void setHeader(final String header) {
63+
this.header = header;
64+
}
65+
66+
@Override
67+
public Class<Boolean> getType() {
68+
return Boolean.class;
69+
}
70+
71+
// -- PrimitiveColumn methods --
72+
73+
@Override
74+
public void fill(final boolean[] values) {
75+
setArray(values.clone());
76+
setSize(values.length);
77+
}
78+
79+
@Override
80+
public void fill(final boolean[] values, final int offset) {
81+
// Check if array has been initialized
82+
if (getArray() == null) setArray(values.clone());
83+
else {
84+
System.arraycopy(values, 0, getArray(), offset, values.length);
85+
}
86+
setSize(values.length);
87+
}
88+
89+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* #%L
3+
* ImageJ software for multidimensional image processing and analysis.
4+
* %%
5+
* Copyright (C) 2009 - 2017 Board of Regents of the University of
6+
* Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
7+
* Institute of Molecular Cell Biology and Genetics.
8+
* %%
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice,
13+
* this list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
* #L%
30+
*/
31+
32+
package org.scijava.table;
33+
34+
/**
35+
* A table of {@code boolean} values.
36+
*
37+
* @author Alison Walter
38+
*/
39+
public interface BoolTable extends Table<BoolColumn, Boolean> {
40+
41+
/** Gets the value of the given table cell. */
42+
default boolean getValue(final int col, final int row) {
43+
return get(col).getValue(row);
44+
}
45+
46+
/** Sets the value of the given table cell. */
47+
default void setValue(final int col, final int row, final boolean value) {
48+
get(col).setValue(row, value);
49+
}
50+
51+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* #%L
3+
* ImageJ software for multidimensional image processing and analysis.
4+
* %%
5+
* Copyright (C) 2009 - 2017 Board of Regents of the University of
6+
* Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
7+
* Institute of Molecular Cell Biology and Genetics.
8+
* %%
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice,
13+
* this list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
* #L%
30+
*/
31+
32+
package org.scijava.table;
33+
34+
import org.scijava.util.ByteArray;
35+
36+
/**
37+
* Efficient implementation of {@link Column} for {@code byte} primitives.
38+
*
39+
* @author Alison Walter
40+
*/
41+
public class ByteColumn extends ByteArray implements
42+
PrimitiveColumn<byte[], Byte>
43+
{
44+
45+
/** The column header. */
46+
private String header;
47+
48+
public ByteColumn() {}
49+
50+
public ByteColumn(final String header) {
51+
this.header = header;
52+
}
53+
54+
// -- Column methods --
55+
56+
@Override
57+
public String getHeader() {
58+
return header;
59+
}
60+
61+
@Override
62+
public void setHeader(final String header) {
63+
this.header = header;
64+
}
65+
66+
@Override
67+
public Class<Byte> getType() {
68+
return Byte.class;
69+
}
70+
71+
// -- PrimitiveColumn methods --
72+
73+
@Override
74+
public void fill(final byte[] values) {
75+
setArray(values.clone());
76+
setSize(values.length);
77+
}
78+
79+
@Override
80+
public void fill(final byte[] values, final int offset) {
81+
// Check if array has been initialized
82+
if (getArray() == null) setArray(values.clone());
83+
else {
84+
System.arraycopy(values, 0, getArray(), offset, values.length);
85+
}
86+
setSize(values.length);
87+
}
88+
89+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* #%L
3+
* ImageJ software for multidimensional image processing and analysis.
4+
* %%
5+
* Copyright (C) 2009 - 2017 Board of Regents of the University of
6+
* Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
7+
* Institute of Molecular Cell Biology and Genetics.
8+
* %%
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice,
13+
* this list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
* #L%
30+
*/
31+
32+
package org.scijava.table;
33+
34+
/**
35+
* A table of byte-precision integer values.
36+
*
37+
* @author Alison Walter
38+
*/
39+
public interface ByteTable extends Table<ByteColumn, Byte> {
40+
41+
/** Gets the value of the given table cell. */
42+
default byte getValue(int col, int row) {
43+
return get(col).getValue(row);
44+
}
45+
46+
/** Sets the value of the given table cell. */
47+
default void setValue(int col, int row, byte value) {
48+
get(col).setValue(row, value);
49+
}
50+
51+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* #%L
3+
* ImageJ software for multidimensional image processing and analysis.
4+
* %%
5+
* Copyright (C) 2009 - 2017 Board of Regents of the University of
6+
* Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
7+
* Institute of Molecular Cell Biology and Genetics.
8+
* %%
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice,
13+
* this list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
* #L%
30+
*/
31+
32+
package org.scijava.table;
33+
34+
import org.scijava.util.CharArray;
35+
36+
/**
37+
* Efficient implementation of {@link Column} for {@code char} primitives.
38+
*
39+
* @author Alison Walter
40+
*/
41+
public class CharColumn extends CharArray implements
42+
PrimitiveColumn<char[], Character>
43+
{
44+
45+
/** The column header. */
46+
private String header;
47+
48+
public CharColumn() {}
49+
50+
public CharColumn(final String header) {
51+
this.header = header;
52+
}
53+
54+
// -- Column methods --
55+
56+
@Override
57+
public String getHeader() {
58+
return header;
59+
}
60+
61+
@Override
62+
public void setHeader(final String header) {
63+
this.header = header;
64+
}
65+
66+
@Override
67+
public Class<Character> getType() {
68+
return Character.class;
69+
}
70+
71+
// -- PrimitiveColumn methods --
72+
73+
@Override
74+
public void fill(final char[] values) {
75+
setArray(values.clone());
76+
setSize(values.length);
77+
}
78+
79+
@Override
80+
public void fill(final char[] values, final int offset) {
81+
// Check if array has been initialized
82+
if (getArray() == null) setArray(values.clone());
83+
else {
84+
System.arraycopy(values, 0, getArray(), offset, values.length);
85+
}
86+
setSize(values.length);
87+
}
88+
89+
}

0 commit comments

Comments
 (0)