Skip to content

Commit

Permalink
add comments and TODO #453
Browse files Browse the repository at this point in the history
  • Loading branch information
walterxie committed Apr 4, 2024
1 parent 265069c commit f4b43a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
17 changes: 12 additions & 5 deletions lphy-studio/src/main/java/lphystudio/spi/StudioViewerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
public class StudioViewerImpl implements ViewerExtension {

/**TODO protected ?
/**TODO this should be Map<T, Viewer> where T is the class, e.g. Alignment, Double, ...
* LPhy studio {@link Viewer}
*/
protected static List<Viewer> viewerList;
Expand All @@ -33,22 +33,29 @@ public StudioViewerImpl() {

/**
* Check {@link ViewerRegister} how to create the viewers.
* @return a list viewers to register
* @return a list viewers to register in this extension
*/
@Override
public List<Viewer> getViewers() {
return Arrays.stream(ViewerRegister.viewers).toList();
}

/**
* this must be overwritten in each lphy extension.
*/
@Override
public void register() {

// Map<String, ? extends Viewer> newTypes = declareViewers();

// TODO add should check if viewer for a type already exists, after getViewers() changes to Map<T, Viewer>.
addViewers(getViewers(), viewerList, "LPhy studio viewers : ");
}

/**
* Call this in the panel to show the corresponding viewer given a value.
* @param object a value
* @return the corresponding viewer
*/
public static JComponent getJComponentForValue(Object object) {
// loop through all viewers.
for (Viewer viewer : viewerList) {
if (viewer.match(object)) return viewer.getViewer(object);
}
Expand Down
5 changes: 2 additions & 3 deletions lphy-studio/src/main/java/lphystudio/spi/ViewerExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
public interface ViewerExtension extends Extension {

/**
* @return the map of new {@link Viewer} implemented in the LPhy extension.
* The string key is a keyword to represent this Viewer.
* The keyword can be used to identify and initialise the corresponding Viewer.
* @return the list of new {@link Viewer} implemented in the LPhy extension,
* which have been initialised as static class instances.
*/
List<Viewer> getViewers();

Expand Down

0 comments on commit f4b43a5

Please sign in to comment.