Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required changes for the OpenGL grapher in the core #327

Merged
merged 6 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class SpotPositionFeature implements Feature< Spot >

private final LinkedHashMap< FeatureProjectionKey, FeatureProjection< Spot > > projections;

private static final List< FeatureProjectionSpec > PROJECTION_SPECS = new ArrayList<>( 3 );
public static final List< FeatureProjectionSpec > PROJECTION_SPECS = new ArrayList<>( 3 );
static
{
for ( int d = 0; d < 3; d++ )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ private static void restoreFramePosition( final Window frame, final Map< String,
final int[] pos = ( int[] ) guiState.get( FRAME_POSITION_KEY );
if ( null != pos )
frame.setBounds( pos[ 0 ], pos[ 1 ], pos[ 2 ], pos[ 3 ] );
else
{
frame.setSize( 650, 400 );
frame.setLocationRelativeTo( null );
}
}

private static void restoreGroupHandle( final GroupHandle groupHandle, final Map< String, Object > guiState )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ public class GrapherInitializer< V extends Vertex< E > & HasTimepoint & HasLabel
coloringAdapter = new GraphColorGeneratorAdapter<>( viewGraph.getVertexMap(), viewGraph.getEdgeMap() );

// Options
final DataDisplayOptions options = DataDisplayOptions.options()
.shareKeyPressedEvents( appModel.getKeyPressedManager() )
.style( forwardDefaultStyle )
final DataDisplayOptions< DataVertex, DataEdge > options = DataDisplayOptions.options();
options.shareKeyPressedEvents( appModel.getKeyPressedManager() ).style( forwardDefaultStyle )
.graphColorGenerator( coloringAdapter );

// Navigation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public class MamutViewTable extends MamutView< ViewGraph< Spot, Link, Spot, Link
implements HasContextChooser< Spot >, HasColoringModel
{

private static final int DEFAULT_WIDTH = 500;

private static final int DEFAULT_HEIGHT = 300;

public static String csvExportPath = null;

private static final String[] CONTEXTS = new String[] { KeyConfigContexts.TABLE };
Expand Down Expand Up @@ -163,6 +167,10 @@ protected MamutViewTable( final ProjectModel projectModel, final boolean selecti
.navigationHandler( branchGraphNavigation( projectModel, navigationHandler ) )
.done()
.title( selectionTable ? "Selection table" : "Data table" )
.x( -1 )
.y( -1 )
.width( DEFAULT_WIDTH )
.height( DEFAULT_HEIGHT )
.get();
setFrame( frame );
frame.setIconImages( TABLE_VIEW_ICON );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ private SharedBigDataViewerData(
this.setups = setups;
this.cache = cache;

final ViewerOptions lvo = new ViewerOptions();
final ViewerOptions lvo = new ViewerOptions()
.width( 650 )
.height( 400 );
this.inputTriggerConfig = ( lvo.values.getInputTriggerConfig() != null )
? lvo.values.getInputTriggerConfig()
: new InputTriggerConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public DataDisplayFrame(
final UndoPointMarker undoPointMarker,
final GroupHandle groupHandle,
final ContextChooser< V > contextChooser,
final DataDisplayOptions optional )
final DataDisplayOptions< DataVertex, DataEdge > optional )
{
super( "Grapher" );

Expand Down Expand Up @@ -112,7 +112,7 @@ public DataDisplayFrame(
*/

sidePanel = new GrapherSidePanel( nSources, contextChooser );
sidePanel.btnPlot.addActionListener( e -> dataDisplayPanel.plot( sidePanel.getGraphConfig(), featureModel ) );
sidePanel.getBtnPlot().addActionListener( e -> dataDisplayPanel.plot( sidePanel.getGraphConfig(), featureModel ) );

final FeatureModelListener featureModelListener = () -> sidePanel.setFeatures(
FeatureUtils.collectFeatureMap( featureModel, vertexClass ),
Expand Down Expand Up @@ -163,8 +163,14 @@ public void windowClosing( final WindowEvent e )
mouseAndKeyHandler.setBehaviourMap( triggerbindings.getConcatenatedBehaviourMap() );
mouseAndKeyHandler.setKeypressManager( optional.values.getKeyPressedManager(), dataDisplayPanel.getDisplay() );
dataDisplayPanel.getDisplay().addHandler( mouseAndKeyHandler );
setLocation( optional.values.getX(), optional.values.getY() );
setIconImages( FEATURES_ICON );

final int x = optional.values.getX();
final int y = optional.values.getY();
if ( x <= 0 && y <= 0 )
setLocationRelativeTo( null );
else
setLocation( x, y );
}

public DataDisplayPanel< V, E > getDataDisplayPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@

import java.awt.event.KeyListener;

import org.mastodon.graph.Edge;
import org.mastodon.graph.Vertex;
import org.mastodon.ui.NavigationEtiquette;
import org.mastodon.ui.coloring.DefaultGraphColorGenerator;
import org.mastodon.ui.coloring.GraphColorGenerator;
import org.mastodon.views.grapher.datagraph.DataEdge;
import org.mastodon.views.grapher.datagraph.DataVertex;
import org.mastodon.views.grapher.display.DataDisplayOverlay.DataDisplayOverlayFactory;
import org.mastodon.views.grapher.display.style.DataDisplayStyle;
import org.mastodon.views.trackscheme.display.TrackSchemeFrame;
import org.mastodon.views.trackscheme.display.TrackSchemePanel;
import org.scijava.ui.behaviour.KeyPressedManager;

public class DataDisplayOptions
public class DataDisplayOptions< V extends Vertex< E >, E extends Edge< V > >
{
public final Values values = new Values();
public final Values< V, E > values = new Values<>();

public static DataDisplayOptions options()
public static < V extends Vertex< E >, E extends Edge< V > > DataDisplayOptions< V, E > options()
{
return new DataDisplayOptions();
return new DataDisplayOptions<>();
}

/**
Expand All @@ -58,7 +58,7 @@ public static DataDisplayOptions options()
* the X position.
* @return this instance.
*/
public DataDisplayOptions x( final int x )
public DataDisplayOptions< V, E > x( final int x )
{
values.x = x;
return this;
Expand All @@ -72,7 +72,7 @@ public DataDisplayOptions x( final int x )
* the Y position.
* @return this instance.
*/
public DataDisplayOptions y( final int y )
public DataDisplayOptions< V, E > y( final int y )
{
values.y = y;
return this;
Expand All @@ -85,7 +85,7 @@ public DataDisplayOptions y( final int y )
* the width.
* @return this instance.
*/
public DataDisplayOptions width( final int w )
public DataDisplayOptions< V, E > width( final int w )
{
values.width = w;
return this;
Expand All @@ -98,7 +98,7 @@ public DataDisplayOptions width( final int w )
* the height.
* @return this instance.
*/
public DataDisplayOptions height( final int h )
public DataDisplayOptions< V, E > height( final int h )
{
values.height = h;
return this;
Expand All @@ -111,7 +111,7 @@ public DataDisplayOptions height( final int h )
* the animation time in milliseconds.
* @return this instance.
*/
public DataDisplayOptions animationDurationMillis( final long ms )
public DataDisplayOptions< V, E > animationDurationMillis( final long ms )
{
values.animationDurationMillis = ms;
return this;
Expand All @@ -131,7 +131,7 @@ public DataDisplayOptions animationDurationMillis( final long ms )
* the key-pressed manager.
* @return this instance.
*/
public DataDisplayOptions shareKeyPressedEvents( final KeyPressedManager manager )
public DataDisplayOptions< V, E > shareKeyPressedEvents( final KeyPressedManager manager )
{
values.keyPressedManager = manager;
return this;
Expand All @@ -144,7 +144,7 @@ public DataDisplayOptions shareKeyPressedEvents( final KeyPressedManager manager
* the navigation etiquette.
* @return this instance.
*/
public DataDisplayOptions navigationEtiquette( final NavigationEtiquette navigationEtiquette )
public DataDisplayOptions< V, E > navigationEtiquette( final NavigationEtiquette navigationEtiquette )
{
values.navigationEtiquette = navigationEtiquette;
return this;
Expand All @@ -157,7 +157,7 @@ public DataDisplayOptions navigationEtiquette( final NavigationEtiquette navigat
* the style.
* @return this instance.
*/
public DataDisplayOptions style( final DataDisplayStyle style )
public DataDisplayOptions< V, E > style( final DataDisplayStyle style )
{
values.style = style;
return this;
Expand All @@ -170,7 +170,7 @@ public DataDisplayOptions style( final DataDisplayStyle style )
* the factory.
* @return this instance.
*/
public DataDisplayOptions dataDisplayOverlayFactory( final DataDisplayOverlayFactory factory )
public DataDisplayOptions< V, E > dataDisplayOverlayFactory( final DataDisplayOverlayFactory factory )
{
values.dataDisplayOverlayFactory = factory;
return this;
Expand All @@ -184,7 +184,7 @@ public DataDisplayOptions dataDisplayOverlayFactory( final DataDisplayOverlayFac
* the color generator.
* @return this instance.
*/
public DataDisplayOptions graphColorGenerator( final GraphColorGenerator< DataVertex, DataEdge > generator )
public DataDisplayOptions< V, E > graphColorGenerator( final GraphColorGenerator< V, E > generator )
{
values.graphColorGenerator = generator;
return this;
Expand All @@ -193,15 +193,15 @@ public DataDisplayOptions graphColorGenerator( final GraphColorGenerator< DataVe
/**
* Read-only {@link DataDisplayOptions} values.
*/
public static class Values
public static class Values< V extends Vertex< E >, E extends Edge< V > >
{
private int x = 0;

private int y = 0;

private int width = 700;
private int width = 400;

private int height = 450;
private int height = 400;

private long animationDurationMillis = 500;

Expand All @@ -213,13 +213,19 @@ public static class Values

private DataDisplayOverlayFactory dataDisplayOverlayFactory = new DataDisplayOverlayFactory();

private GraphColorGenerator< DataVertex, DataEdge > graphColorGenerator = new DefaultGraphColorGenerator<>();
private GraphColorGenerator< V, E > graphColorGenerator = new DefaultGraphColorGenerator<>();

public DataDisplayOptions optionsFromValues()
public DataDisplayOptions< V, E > optionsFromValues()
{
return new DataDisplayOptions().x( x ).y( y ).width( width ).height( height )
.animationDurationMillis( animationDurationMillis ).navigationEtiquette( navigationEtiquette )
.style( style ).dataDisplayOverlayFactory( dataDisplayOverlayFactory )
return new DataDisplayOptions< V, E >()
.x( x )
.y( y )
.width( width )
.height( height )
.animationDurationMillis( animationDurationMillis )
.navigationEtiquette( navigationEtiquette )
.style( style )
.dataDisplayOverlayFactory( dataDisplayOverlayFactory )
.graphColorGenerator( graphColorGenerator );
}

Expand Down Expand Up @@ -268,7 +274,7 @@ public DataDisplayOverlayFactory getDataDisplayOverlayFactory()
return dataDisplayOverlayFactory;
}

public GraphColorGenerator< DataVertex, DataEdge > getGraphColorGenerator()
public GraphColorGenerator< V, E > getGraphColorGenerator()
{
return graphColorGenerator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public DataDisplayOverlay(
final FocusModel< DataVertex > focus,
final PaintDecorations paintDecorations,
final PaintGraph paintGraph,
final DataDisplayOptions options )
final DataDisplayOptions< DataVertex, DataEdge > options )
{
this.graph = graph;
this.highlight = highlight;
Expand Down Expand Up @@ -380,7 +380,7 @@ public DataDisplayOverlay create(
final DataGraph< ?, ? > graph,
final HighlightModel< DataVertex, DataEdge > highlight,
final FocusModel< DataVertex > focus,
final DataDisplayOptions options )
final DataDisplayOptions< DataVertex, DataEdge > options )
{
return new DataDisplayOverlay(
graph,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ public DataDisplayPanel(
final FocusModel< DataVertex > focus,
final SelectionModel< DataVertex, DataEdge > selection,
final NavigationHandler< DataVertex, DataEdge > navigation,
final DataDisplayOptions optional )
final DataDisplayOptions< DataVertex, DataEdge > optional )
{
super( new BorderLayout(), false );
this.graph = graph;
this.layout = layout;
this.selection = selection;

final Values options = optional.values;
final Values< DataVertex, DataEdge > options = optional.values;
animationMilleseconds = options.getAnimationDurationMillis();

/*
Expand All @@ -225,6 +225,8 @@ public DataDisplayPanel(
screenTransform.listeners().add( this );
transformEventHandler = new InertialScreenTransformEventHandler( screenTransform );

setPreferredSize( new Dimension( w, h ) );

/*
* Make this instance listen to data graph and UI objects.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

import org.mastodon.graph.Edge;
import org.mastodon.graph.Vertex;
import org.mastodon.ui.keymap.KeyConfigScopes;
import org.mastodon.model.HasLabel;
import org.mastodon.spatial.HasTimepoint;
import org.mastodon.ui.keymap.KeyConfigContexts;
import org.mastodon.ui.keymap.KeyConfigScopes;
import org.mastodon.views.grapher.datagraph.ScreenTransform;
import org.mastodon.views.grapher.display.OffsetAxes.OffsetAxesListener;
import org.mastodon.views.trackscheme.display.TrackSchemeZoom;
Expand All @@ -65,9 +66,10 @@ public class DataDisplayZoom< V extends Vertex< E > & HasTimepoint & HasLabel, E
extends AbstractNamedBehaviour
implements DragBehaviour, OffsetAxesListener, TransformListener< ScreenTransform >
{
private static final String TOGGLE_ZOOM = "box zoom";

private static final String[] TOGGLE_ZOOM_KEYS = new String[] { "Z" };
public static final String TOGGLE_ZOOM = "box zoom";

public static final String[] TOGGLE_ZOOM_KEYS = new String[] { "Z" };

/*
* Command descriptions for all provided commands
Expand All @@ -90,7 +92,7 @@ public void getCommandDescriptions( final CommandDescriptions descriptions )
public static < V extends Vertex< E > & HasTimepoint & HasLabel, E extends Edge< V > > void
install( final Behaviours behaviours, final DataDisplayPanel< V, E > panel )
{
final DataDisplayZoom< V, E > zoom = new DataDisplayZoom<>( panel );
final DataDisplayZoom< V, E > zoom = new DataDisplayZoom<>( panel, panel.getTransformEventHandler() );

// Create and register overlay.
zoom.transformChanged( panel.getScreenTransform().get() );
Expand All @@ -107,7 +109,7 @@ public void getCommandDescriptions( final CommandDescriptions descriptions )

public static final Color ZOOM_GRAPH_OVERLAY_COLOR = Color.BLUE.darker();

private final DataDisplayPanel< V, E > panel;
private final JPanel panel;

private final InertialScreenTransformEventHandler transformEventHandler;

Expand All @@ -119,11 +121,11 @@ public void getCommandDescriptions( final CommandDescriptions descriptions )

private final ZoomOverlay overlay;

private DataDisplayZoom( final DataDisplayPanel< V, E > panel )
private DataDisplayZoom( final JPanel panel, final InertialScreenTransformEventHandler transformEventHandler )
{
super( TOGGLE_ZOOM );
this.panel = panel;
this.transformEventHandler = panel.getTransformEventHandler();
this.transformEventHandler = transformEventHandler;

dragging = false;
screenTransform = new ScreenTransform();
Expand Down
Loading
Loading