Skip to content

Commit bf6c64f

Browse files
committed
Make TextDisplay handle all Objects
Any Object can be converted to a String, so this is feasible. Much better than a "no compatible displays found" error. With this change, DefaultDisplay is no longer needed, because DefaultTextDisplay will pick up everything instead, in the way originally intended for DefaultDisplay. This is a breaking API change.
1 parent 7538b25 commit bf6c64f

File tree

7 files changed

+11
-62
lines changed

7 files changed

+11
-62
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111

1212
<artifactId>scijava-common</artifactId>
13-
<version>2.28.2-SNAPSHOT</version>
13+
<version>3.0.0-SNAPSHOT</version>
1414

1515
<name>SciJava Common</name>
1616
<description>SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO.</description>

src/main/java/org/scijava/display/DefaultDisplay.java

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/main/java/org/scijava/display/DefaultTextDisplay.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@
3939
*
4040
* @author Curtis Rueden
4141
*/
42-
@Plugin(type = Display.class, priority = Priority.LOW_PRIORITY)
43-
public class DefaultTextDisplay extends AbstractDisplay<String> implements
42+
@Plugin(type = Display.class, priority = Priority.VERY_LOW_PRIORITY)
43+
public class DefaultTextDisplay extends AbstractDisplay<Object> implements
4444
TextDisplay
4545
{
4646

4747
public DefaultTextDisplay() {
48-
super(String.class);
48+
super(Object.class);
4949
}
5050

51+
// -- TextDisplay methods --
52+
5153
@Override
5254
public void append(final String text) {
5355
add(text);

src/main/java/org/scijava/display/TextDisplay.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* @author Curtis Rueden
3838
*/
39-
public interface TextDisplay extends Display<String> {
39+
public interface TextDisplay extends Display<Object> {
4040

4141
/**
4242
* Add a line to the display.

src/main/java/org/scijava/ui/viewer/text/AbstractTextDisplayViewer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* @author Lee Kamentsky
4242
*/
4343
public abstract class AbstractTextDisplayViewer extends
44-
AbstractDisplayViewer<String>
44+
AbstractDisplayViewer<Object>
4545
{
4646

4747
@Override

src/main/java/org/scijava/ui/viewer/text/TextDisplayViewer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
import org.scijava.ui.viewer.DisplayViewer;
3636

3737
/**
38-
* A display viewer for {@link String}s.
38+
* A display viewer for {@link TextDisplay}s.
3939
*
4040
* @author Lee Kamentsky
4141
*/
42-
public interface TextDisplayViewer extends DisplayViewer<String> {
42+
public interface TextDisplayViewer extends DisplayViewer<Object> {
4343

4444
@Override
4545
TextDisplay getDisplay();

src/test/java/org/scijava/display/DisplayTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void testText() {
129129
final TextDisplay textDisplay = (TextDisplay) d;
130130

131131
// does the display contain the required text string?
132-
final String result = textDisplay.get(0);
132+
final Object result = textDisplay.get(0);
133133
assertNotNull(result);
134134
assertEquals(value, result);
135135
}

0 commit comments

Comments
 (0)