Skip to content

Commit

Permalink
Showing 4 changed files with 28 additions and 22 deletions.
24 changes: 13 additions & 11 deletions src/main/java/com/indago/tr2d/plugins/seg/LabkitPanel.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package com.indago.tr2d.plugins.seg;

import com.indago.tr2d.ui.model.Tr2dModel;
@@ -21,14 +22,17 @@ public class LabkitPanel {
public LabkitPanel(Context context, Tr2dModel model, Logger log) {
this.log = log;
boolean isTimeSeries = true;
segmentation = createSegmentationComponent( context, model, isTimeSeries );
segmentation = createSegmentationComponent(context, model, isTimeSeries);
}

private SegmentationComponent createSegmentationComponent( Context context, Tr2dModel model, boolean isTimeSeries )
private SegmentationComponent createSegmentationComponent(Context context,
Tr2dModel model, boolean isTimeSeries)
{
try {
return new SegmentationComponent( context, null, model.getRawData(), isTimeSeries );
} catch ( NoClassDefFoundError e ) {
return new SegmentationComponent(context, null, model.getRawData(),
isTimeSeries);
}
catch (NoClassDefFoundError e) {
return null;
}
}
@@ -38,25 +42,23 @@ public JPanel getPanel() {
JButton store = new JButton("recalculate");
store.addActionListener(l -> this.calculateOutputs());
panel.setLayout(new BorderLayout());
if( isUsable() )
panel.add( segmentation.getComponent());
if (isUsable()) panel.add(segmentation.getComponent());
panel.add(store, BorderLayout.PAGE_END);
return panel;
}

private void calculateOutputs() {
outputs = isUsable() && segmentation.isTrained() ?
Collections.singletonList( segmentation.getSegmentation(new IntType())) :
Collections.emptyList();
outputs = isUsable() && segmentation.isTrained() ? Collections
.singletonList(segmentation.getSegmentation(new IntType())) : Collections
.emptyList();
}

public boolean isUsable() {
return segmentation != null;
}

public List<RandomAccessibleInterval<IntType>> getOutputs() {
if(outputs == null || outputs.isEmpty())
calculateOutputs();
if (outputs == null || outputs.isEmpty()) calculateOutputs();
return outputs;
}
}
7 changes: 4 additions & 3 deletions src/main/java/com/indago/tr2d/plugins/seg/LabkitPlugin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
*
*/

package com.indago.tr2d.plugins.seg;

import com.indago.IndagoLog;
@@ -18,7 +19,7 @@
/**
* @author Matthias Arzt
*/
@Plugin( type = Tr2dSegmentationPlugin.class, name = "Tr2d Labkit Segmentation" )
@Plugin(type = Tr2dSegmentationPlugin.class, name = "Tr2d Labkit Segmentation")
public class LabkitPlugin implements Tr2dSegmentationPlugin {

@Parameter
@@ -34,12 +35,12 @@ public JPanel getInteractionPanel() {
}

@Override
public List< RandomAccessibleInterval< IntType > > getOutputs() {
public List<RandomAccessibleInterval<IntType>> getOutputs() {
return panel.getOutputs();
}

@Override
public void setTr2dModel( final Tr2dModel model ) {
public void setTr2dModel(final Tr2dModel model) {
this.panel = new LabkitPanel(context, model, log);
}

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package com.indago.tr2d.plugins.seg;

import com.indago.io.ProjectFolder;
@@ -53,7 +54,7 @@ private static Tr2dModel getTr2dModel() throws IOException {
}

private static JFrame setupFrame() {
JFrame frame = new JFrame("Tr2d Labkit Segmentation Plugin Demo") ;
JFrame frame = new JFrame("Tr2d Labkit Segmentation Plugin Demo");
frame.setSize(1000, 1000);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
return frame;
16 changes: 9 additions & 7 deletions src/test/java/com/indago/tr2d/plugins/seg/Main.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@

package com.indago.tr2d.plugins.seg;

import net.imagej.ops.OpService;
import net.imagej.ops.thread.chunker.ChunkerOp;
import net.imagej.ops.thread.chunker.CursorBasedChunk;
import org.scijava.Context;


public class Main {

public static void main(String... args) {
Context context = new Context();
context.service(OpService.class).run(ChunkerOp.class, new CursorBasedChunk() {
@Override
public void execute(final int startIndex, final int stepSize,
final int numSteps)
context.service(OpService.class).run(ChunkerOp.class,
new CursorBasedChunk()
{
}
}, 100);

@Override
public void execute(final int startIndex, final int stepSize,
final int numSteps)
{}
}, 100);
}
}

0 comments on commit ca8ec54

Please sign in to comment.