Skip to content

Commit

Permalink
Simplify generics
Browse files Browse the repository at this point in the history
  • Loading branch information
tpietzsch committed Nov 14, 2023
1 parent 1fe4f80 commit 9ee43d0
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ private static int prod(int ... v)
}

public static <AS extends AbstractSpimData<?> > void applyToSpimData(
AS data,
List<? extends Group< ? extends BasicViewDescription< ? extends BasicViewSetup > > > viewDescriptions,
AS data,
List<? extends Group< ? extends BasicViewDescription< ? > > > viewDescriptions,
RegularTranslationParameters params,
boolean applyToAllTimePoints)
{
Expand Down Expand Up @@ -313,8 +313,8 @@ private static int getRotationAxisFromUnitVector(double[] axis)
}

private static <AS extends AbstractSpimData<?> > void applyToSpimDataSingleTP(
AS data,
List< ? extends Group< ? extends BasicViewDescription< ? extends BasicViewSetup > > > viewDescriptions,
AS data,
List< ? extends Group< ? extends BasicViewDescription< ? > > > viewDescriptions,
RegularTranslationParameters params,
TimePoint tp)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.List;
import java.util.Map;

import java.util.Set;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
Expand Down Expand Up @@ -97,7 +98,7 @@ public abstract class FilteredAndGroupedExplorerPanel< AS extends AbstractSpimDa
protected boolean colorMode = false;

final protected HashSet< List< BasicViewDescription< ? > > > selectedRows;
protected BasicViewDescription< ? extends BasicViewSetup > firstSelectedVD;
protected BasicViewDescription< ? > firstSelectedVD;

public FilteredAndGroupedExplorerPanel(final FilteredAndGroupedExplorer< AS > explorer, final AS data,
final String xml, final XmlIoAbstractSpimData< ?, AS > io)
Expand Down Expand Up @@ -373,7 +374,7 @@ public static void updateBDV(
final BigDataViewer bdv,
final boolean colorMode,
final AbstractSpimData< ? > data,
BasicViewDescription< ? extends BasicViewSetup > firstVD,
BasicViewDescription< ? > firstVD,
final Collection< List< BasicViewDescription< ? > > > selectedRows )
{

Expand All @@ -399,7 +400,7 @@ public static void updateBDV(

final boolean[] active = new boolean[data.getSequenceDescription().getViewSetupsOrdered().size()];

for ( final List< ? extends BasicViewDescription< ? extends BasicViewSetup > > vds : selectedRows )
for ( final List< ? extends BasicViewDescription< ? > > vds : selectedRows )
for ( BasicViewDescription< ? > vd : vds){
if ( vd.getTimePointId() == firstTP.getId() )
active[getBDVSourceIndex( vd.getViewSetup(), data )] = true;
Expand Down Expand Up @@ -477,7 +478,7 @@ public static int getBDVSourceIndex( final BasicViewSetup vs, final AbstractSpim
return 0;
}

public HashSet< List< BasicViewDescription< ? extends BasicViewSetup > > > getSelectedRows()
public Set< List< BasicViewDescription< ? > > > getSelectedRows()
{
return selectedRows;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ public FilteredAndGroupedTableModel( final ExplorerWindow< AS > panel )
elements();
}

protected List<List< BasicViewDescription< ? extends BasicViewSetup > >> elements()
protected List<List< BasicViewDescription< ? > >> elements()
{
return elements(false);
}

protected List<List< BasicViewDescription< ? extends BasicViewSetup > >> elements( boolean forceUpdate )
protected List<List< BasicViewDescription< ? > >> elements( boolean forceUpdate )
{
if (!forceUpdate && elements != null)
return elements;
Expand Down Expand Up @@ -235,12 +235,12 @@ public boolean isCellEditable( final int row, final int column )
@Override
public Object getValueAt( final int row, final int column )
{
final List<BasicViewDescription< ? extends BasicViewSetup >> vds = elements().get( row );
final List<BasicViewDescription< ? >> vds = elements().get( row );

Class <? extends Entity> c = columnClasses.get(column);
final HashSet<Entity> entries = new HashSet<>();
for (BasicViewDescription< ? extends BasicViewSetup > vd : vds)

for (BasicViewDescription< ? > vd : vds)
{
if ( c == TimePoint.class )
entries.add(vd.getTimePoint());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public Object getValueAt(int rowIndex, int columnIndex) {

if ( vds.size() == 1 )
{
final BasicViewDescription< ? extends BasicViewSetup > vd = vds.get( 0 );
final BasicViewDescription< ? > vd = vds.get( 0 );

if ( vd.isPresent() )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,9 @@ public void valueChanged(final ListSelectionEvent arg0)

selectedRows.add( tableModel.getElements().get( row ) );
}
List<List<BasicViewDescription< ? extends BasicViewSetup >>> selectedList = new ArrayList<>();
for (List<BasicViewDescription< ? extends BasicViewSetup >> selectedI : selectedRows)

List<List<BasicViewDescription< ? >>> selectedList = new ArrayList<>();
for (List<BasicViewDescription< ? >> selectedI : selectedRows)
selectedList.add( selectedI );

for ( int i = 0; i < listeners.size(); ++i )
Expand Down Expand Up @@ -415,8 +415,8 @@ public void valueChanged(final ListSelectionEvent arg0)
}

public static void updateBDV(final BigDataViewer bdv, final boolean colorMode, final AbstractSpimData< ? > data,
BasicViewDescription< ? extends BasicViewSetup > firstVD,
final Collection< List< BasicViewDescription< ? extends BasicViewSetup >> > selectedRows)
BasicViewDescription< ? > firstVD,
final Collection< List< BasicViewDescription< ? >> > selectedRows)
{
// we always set the fused mode
setFusedModeSimple( bdv, data );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public void windowClosing(WindowEvent e)
public JFrame frame() { return frame; }

@Override
public void selectedViewDescriptions( final List< List< BasicViewDescription< ? extends BasicViewSetup > > > viewDescriptions )
public void selectedViewDescriptions( final List< List< BasicViewDescription< ? > > > viewDescriptions )
{
final ArrayList< BasicViewDescription< ? extends BasicViewSetup > > fullList = new ArrayList<>();
final ArrayList< BasicViewDescription< ? > > fullList = new ArrayList<>();

for ( final List< BasicViewDescription< ? extends BasicViewSetup > > list : viewDescriptions )
for ( final BasicViewDescription< ? extends BasicViewSetup > vd : list )
for ( final List< BasicViewDescription< ? > > list : viewDescriptions )
for ( final BasicViewDescription< ? > vd : list )
if ( vd.isPresent() )
fullList.add( vd );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ public InterestPointExplorerPanel( final ViewInterestPoints viewInterestPoints,

public InterestPointTableModel getTableModel() { return tableModel; }
public JTable getTable() { return table; }
public void updateViewDescription( final List< BasicViewDescription< ? extends BasicViewSetup > > viewDescriptionsUnfiltered )

public void updateViewDescription( final List< BasicViewDescription< ? > > viewDescriptionsUnfiltered )
{
final ArrayList< BasicViewDescription< ? extends BasicViewSetup > > viewDescriptions = new ArrayList<>();
final ArrayList< BasicViewDescription< ? > > viewDescriptions = new ArrayList<>();

for ( final BasicViewDescription< ? extends BasicViewSetup > vd : viewDescriptionsUnfiltered )
for ( final BasicViewDescription< ? > vd : viewDescriptionsUnfiltered )
if ( vd.isPresent() )
viewDescriptions.add( vd );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public RegistrationExplorer( final String xml, final XmlIoAbstractSpimData< ?, A
public void save() {}

@Override
public void selectedViewDescriptions( final List<List< BasicViewDescription< ? extends BasicViewSetup > >> viewDescriptions )
public void selectedViewDescriptions( final List<List< BasicViewDescription< ? > >> viewDescriptions )
{
List<BasicViewDescription< ? extends BasicViewSetup >> vdsFlat = new ArrayList<>();
for (List<BasicViewDescription< ? extends BasicViewSetup >> vdsI : viewDescriptions)
List<BasicViewDescription< ? >> vdsFlat = new ArrayList<>();
for (List<BasicViewDescription< ? >> vdsI : viewDescriptions)
vdsFlat.addAll( vdsI );
panel.updateViewDescriptions( vdsFlat );
System.out.println( viewDescriptions );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public DHMImgLoader(
final String extension,
final int ampChannelId,
final int phaseChannelId,
final AbstractSequenceDescription< ? extends BasicViewSetup, ? extends BasicViewDescription< ? >, ? > sd )
final AbstractSequenceDescription< ?, ?, ? > sd )
{
super( new LegacyDHMImgLoader( directory, stackDir, amplitudeDir, phaseDir, timepoints, zPlanes, extension, ampChannelId, phaseChannelId, sd ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
public class LegacyDHMImgLoader extends AbstractImgLoader
{
final File directory;
final AbstractSequenceDescription< ? extends BasicViewSetup, ? extends BasicViewDescription< ? >, ? > sd;
final AbstractSequenceDescription< ?, ?, ? > sd;
final List< String > timepoints;
final List< String > zPlanes;
final String stackDir;
Expand All @@ -71,7 +71,7 @@ public LegacyDHMImgLoader(
final String extension,
final int ampChannelId,
final int phaseChannelId,
final AbstractSequenceDescription< ? extends BasicViewSetup, ? extends BasicViewDescription< ? >, ? > sd )
final AbstractSequenceDescription< ?, ?, ? > sd )
{
this.directory = directory;
this.stackDir = stackDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
public class LegacyMicroManagerImgLoader extends AbstractImgLoader
{
final File mmFile;
final AbstractSequenceDescription< ? extends BasicViewSetup, ? extends BasicViewDescription< ? >, ? > sequenceDescription;
final AbstractSequenceDescription< ?, ?, ? > sequenceDescription;

public LegacyMicroManagerImgLoader(
final File mmFile,
final AbstractSequenceDescription< ? extends BasicViewSetup, ? extends BasicViewDescription< ? >, ? > sequenceDescription )
final AbstractSequenceDescription< ?, ?, ? > sequenceDescription )
{
super();
this.mmFile = mmFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class MicroManagerImgLoader extends LegacyImgLoaderWrapper< UnsignedShort
{
public MicroManagerImgLoader(
final File mmFile,
final AbstractSequenceDescription< ? extends BasicViewSetup, ? extends BasicViewDescription< ? >, ? > sequenceDescription )
final AbstractSequenceDescription< ?, ?, ? > sequenceDescription )
{
super( new LegacyMicroManagerImgLoader( mmFile, sequenceDescription ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

public class ProcessInputImages< V extends ViewId >
{
final AbstractSpimData< ? extends AbstractSequenceDescription< ? extends BasicViewSetup, ? extends BasicViewDescription< ? >, ? extends BasicImgLoader > > spimData;
final AbstractSpimData< ? > spimData;
final ArrayList< Group< V > > groups;
final Interval bb;
Interval downsampledBB;
Expand All @@ -81,7 +81,7 @@ public class ProcessInputImages< V extends ViewId >
final Map< ? extends ViewId, AffineModel1D > intensityAdjustments;

public ProcessInputImages(
final AbstractSpimData< ? extends AbstractSequenceDescription< ? extends BasicViewSetup, ? extends BasicViewDescription< ? >, ? extends BasicImgLoader > > spimData,
final AbstractSpimData< ? > spimData,
final Collection< Group< V > > groups,
final ExecutorService service,
final Interval bb,
Expand Down Expand Up @@ -116,7 +116,7 @@ public ProcessInputImages(
}

public ProcessInputImages(
final AbstractSpimData< ? extends AbstractSequenceDescription< ? extends BasicViewSetup, ? extends BasicViewDescription< ? >, ? extends BasicImgLoader > > spimData,
final AbstractSpimData< ? > spimData,
final Collection< Group< V > > groups,
final ExecutorService service,
final Interval bb,
Expand All @@ -131,7 +131,7 @@ public ProcessInputImages(
}

public ProcessInputImages(
final AbstractSpimData< ? extends AbstractSequenceDescription< ? extends BasicViewSetup, ? extends BasicViewDescription< ? >, ? extends BasicImgLoader > > spimData,
final AbstractSpimData< ? > spimData,
final Collection< Group< V > > groups,
final ExecutorService service,
final Interval bb,
Expand Down Expand Up @@ -275,7 +275,7 @@ public static < V extends ViewId > void copyRandomAccessibleInterval(
}

public static < V extends ViewId > Interval fuseGroups(
final AbstractSpimData< ? extends AbstractSequenceDescription< ? extends BasicViewSetup, ? extends BasicViewDescription< ? >, ? extends BasicImgLoader > > spimData,
final AbstractSpimData< ? > spimData,
final HashMap< Group< V >, RandomAccessibleInterval< FloatType > > tImgs,
final HashMap< Group< V >, RandomAccessibleInterval< FloatType > > tWeights,
final HashMap< V, AffineTransform3D > models,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ else if ( imgType == ImgDataType.PRECOMPUTED )
* @param border - the target blending border, e.g. 0
* @param transformationModel - the transformation model used to map from the (downsampled) input to the output
*/
public static void adjustBlending( final BasicViewDescription< ? extends BasicViewSetup > vd, final float[] blending, final float[] border, final AffineTransform3D transformationModel )
public static void adjustBlending( final BasicViewDescription< ? > vd, final float[] blending, final float[] border, final AffineTransform3D transformationModel )
{
adjustBlending( vd.getViewSetup().getSize(), Group.pvid( vd ), blending, border, transformationModel );
}
Expand Down Expand Up @@ -691,7 +691,7 @@ public static void adjustBlending( final Dimensions dim, final String name, fina
* @param sigma2 - the target sigma2 for entropy approximation, e.g. 40
* @param usedDownsampleFactors - the downsampling factors used to load the input image
*/
public static void adjustContentBased( final BasicViewDescription< ? extends BasicViewSetup > vd, final double[] sigma1, final double[] sigma2, final double[] usedDownsampleFactors )
public static void adjustContentBased( final BasicViewDescription< ? > vd, final double[] sigma1, final double[] sigma2, final double[] usedDownsampleFactors )
{
for ( int d = 0; d < sigma1.length; ++d )
{
Expand All @@ -700,7 +700,7 @@ public static void adjustContentBased( final BasicViewDescription< ? extends Bas
}
}

public static double getMinRes( final BasicViewDescription< ? extends BasicViewSetup > desc )
public static double getMinRes( final BasicViewDescription< ? > desc )
{
final VoxelDimensions size = ViewSetupUtils.getVoxelSize( desc.getViewSetup() );

Expand Down

0 comments on commit 9ee43d0

Please sign in to comment.