-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better SPI for Viewer in the lphy extension (popsizefunc) LinguaPhylo…
- Loading branch information
Showing
5 changed files
with
53 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 0 additions & 76 deletions
76
popsizefunc-lphy-studio/src/main/java/popsizefunc/lphystudio/spi/PopSizeFuncViewerImpl.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
popsizefunc-lphy-studio/src/main/java/popsizefunc/lphystudio/viewer/PopSizeFuncViewer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package popsizefunc.lphystudio.viewer; | ||
|
||
import lphy.core.model.Value; | ||
import lphystudio.app.graphicalmodelpanel.viewer.Viewer; | ||
import popsizefunc.lphy.evolution.popsize.PopulationFunction; | ||
|
||
import javax.swing.*; | ||
|
||
public class PopSizeFuncViewer implements Viewer { | ||
|
||
/** | ||
* Required by ServiceLoader. | ||
*/ | ||
public PopSizeFuncViewer() { | ||
} | ||
|
||
@Override | ||
public boolean match(Object value) { | ||
return value instanceof PopulationFunction || | ||
(value instanceof Value && ((Value) value).value() instanceof PopulationFunction); | ||
} | ||
|
||
@Override | ||
public JComponent getViewer(Object value) { | ||
//TODO create PopulationFunctionComponent((Value<PopulationFunction>) value) | ||
if (value instanceof PopulationFunction) { | ||
return new JLabel("PopulationFunction TODO : " + value.toString()); | ||
} | ||
return new JLabel("Value<PopulationFunction> TODO : " + ((Value<PopulationFunction>) value).value().toString()); | ||
} | ||
@Override | ||
public String toString() { | ||
return "Pop-size function Viewer"; | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...udio/app/PopulationFunctionComponent.java → ...o/viewer/PopulationFunctionComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package popsizefunc.lphystudio.app; | ||
package popsizefunc.lphystudio.viewer; | ||
|
||
import javax.swing.*; | ||
|
||
|
10 changes: 10 additions & 0 deletions
10
...-lphy-studio/src/main/resources/services/lphystudio.app.graphicalmodelpanel.viewer.Viewer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This is important for deploying service providers on the class path | ||
# https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/ServiceLoader.html | ||
# META-INF/services must be under src for Intellij | ||
# Class requires a public no-args constructor | ||
|
||
# the core uses hard core to register all internal Viewers, | ||
# but extensions need to declare what service interface the provider intends to use for new Viewers. | ||
# for example, lphystudio.app.graphicalmodelpanel.viewer.???Viewer | ||
|
||
popsizefunc.lphystudio.viewer.PopSizeFuncViewer |