diff --git a/src/main/java/org/mastodon/mamut/feature/SpotPositionFeature.java b/src/main/java/org/mastodon/mamut/feature/SpotPositionFeature.java index b5eff98a0..e559e0110 100644 --- a/src/main/java/org/mastodon/mamut/feature/SpotPositionFeature.java +++ b/src/main/java/org/mastodon/mamut/feature/SpotPositionFeature.java @@ -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++ ) diff --git a/src/main/java/org/mastodon/mamut/views/AbstractMamutViewFactory.java b/src/main/java/org/mastodon/mamut/views/AbstractMamutViewFactory.java index 4ed35466b..a8f491f77 100644 --- a/src/main/java/org/mastodon/mamut/views/AbstractMamutViewFactory.java +++ b/src/main/java/org/mastodon/mamut/views/AbstractMamutViewFactory.java @@ -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 ) diff --git a/src/main/java/org/mastodon/mamut/views/grapher/GrapherInitializer.java b/src/main/java/org/mastodon/mamut/views/grapher/GrapherInitializer.java index e4f05cd6d..5f6ef4f98 100644 --- a/src/main/java/org/mastodon/mamut/views/grapher/GrapherInitializer.java +++ b/src/main/java/org/mastodon/mamut/views/grapher/GrapherInitializer.java @@ -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 diff --git a/src/main/java/org/mastodon/mamut/views/table/MamutViewTable.java b/src/main/java/org/mastodon/mamut/views/table/MamutViewTable.java index 2c82ca6f7..c3d94c306 100644 --- a/src/main/java/org/mastodon/mamut/views/table/MamutViewTable.java +++ b/src/main/java/org/mastodon/mamut/views/table/MamutViewTable.java @@ -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 }; @@ -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 ); diff --git a/src/main/java/org/mastodon/views/bdv/SharedBigDataViewerData.java b/src/main/java/org/mastodon/views/bdv/SharedBigDataViewerData.java index f38d1c208..ca6fb05bf 100644 --- a/src/main/java/org/mastodon/views/bdv/SharedBigDataViewerData.java +++ b/src/main/java/org/mastodon/views/bdv/SharedBigDataViewerData.java @@ -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(); diff --git a/src/main/java/org/mastodon/views/grapher/display/DataDisplayFrame.java b/src/main/java/org/mastodon/views/grapher/display/DataDisplayFrame.java index b1dad7f92..aea86d8fd 100644 --- a/src/main/java/org/mastodon/views/grapher/display/DataDisplayFrame.java +++ b/src/main/java/org/mastodon/views/grapher/display/DataDisplayFrame.java @@ -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" ); @@ -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 ), @@ -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() diff --git a/src/main/java/org/mastodon/views/grapher/display/DataDisplayOptions.java b/src/main/java/org/mastodon/views/grapher/display/DataDisplayOptions.java index ce248e583..a2f53a938 100644 --- a/src/main/java/org/mastodon/views/grapher/display/DataDisplayOptions.java +++ b/src/main/java/org/mastodon/views/grapher/display/DataDisplayOptions.java @@ -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<>(); } /** @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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 ); } @@ -268,7 +274,7 @@ public DataDisplayOverlayFactory getDataDisplayOverlayFactory() return dataDisplayOverlayFactory; } - public GraphColorGenerator< DataVertex, DataEdge > getGraphColorGenerator() + public GraphColorGenerator< V, E > getGraphColorGenerator() { return graphColorGenerator; } diff --git a/src/main/java/org/mastodon/views/grapher/display/DataDisplayOverlay.java b/src/main/java/org/mastodon/views/grapher/display/DataDisplayOverlay.java index 134ecdbf0..486150786 100644 --- a/src/main/java/org/mastodon/views/grapher/display/DataDisplayOverlay.java +++ b/src/main/java/org/mastodon/views/grapher/display/DataDisplayOverlay.java @@ -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; @@ -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, diff --git a/src/main/java/org/mastodon/views/grapher/display/DataDisplayPanel.java b/src/main/java/org/mastodon/views/grapher/display/DataDisplayPanel.java index 1d555704a..ef3fb4429 100644 --- a/src/main/java/org/mastodon/views/grapher/display/DataDisplayPanel.java +++ b/src/main/java/org/mastodon/views/grapher/display/DataDisplayPanel.java @@ -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(); /* @@ -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. */ diff --git a/src/main/java/org/mastodon/views/grapher/display/DataDisplayZoom.java b/src/main/java/org/mastodon/views/grapher/display/DataDisplayZoom.java index 37c01fcb7..5792ad9f0 100644 --- a/src/main/java/org/mastodon/views/grapher/display/DataDisplayZoom.java +++ b/src/main/java/org/mastodon/views/grapher/display/DataDisplayZoom.java @@ -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; @@ -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 @@ -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() ); @@ -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; @@ -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(); diff --git a/src/main/java/org/mastodon/views/grapher/display/GrapherSidePanel.java b/src/main/java/org/mastodon/views/grapher/display/GrapherSidePanel.java index db610bc85..c5ae2e7b7 100644 --- a/src/main/java/org/mastodon/views/grapher/display/GrapherSidePanel.java +++ b/src/main/java/org/mastodon/views/grapher/display/GrapherSidePanel.java @@ -100,7 +100,7 @@ public class GrapherSidePanel extends JPanel private final JRadioButton rdbtnContext; - final JButton btnPlot; + private final JButton btnPlot; public GrapherSidePanel( final int nSources, final ContextChooser< ? > contextChooser ) { @@ -254,6 +254,16 @@ public GrapherSidePanel( final int nSources, final ContextChooser< ? > contextCh rdbtnContext.addChangeListener( e -> contextEnabler.setEnabled( rdbtnContext.isSelected() ) ); } + /** + * Exposes the plot button of this panel. + * + * @return the plot button. + */ + public JButton getBtnPlot() + { + return btnPlot; + } + public < V, E > void setFeatures( final Map< FeatureSpec< ?, V >, Feature< V > > vertexFeatures, final Map< FeatureSpec< ?, E >, Feature< E > > edgeFeatures ) diff --git a/src/main/java/org/mastodon/views/grapher/display/InertialScreenTransformEventHandler.java b/src/main/java/org/mastodon/views/grapher/display/InertialScreenTransformEventHandler.java index 4b1579800..b4aad0929 100644 --- a/src/main/java/org/mastodon/views/grapher/display/InertialScreenTransformEventHandler.java +++ b/src/main/java/org/mastodon/views/grapher/display/InertialScreenTransformEventHandler.java @@ -31,8 +31,8 @@ import java.util.Timer; import java.util.TimerTask; -import org.mastodon.ui.keymap.KeyConfigScopes; import org.mastodon.ui.keymap.KeyConfigContexts; +import org.mastodon.ui.keymap.KeyConfigScopes; import org.mastodon.views.grapher.datagraph.DataGraphLayout; import org.mastodon.views.grapher.datagraph.DataGraphLayout.LayoutListener; import org.mastodon.views.grapher.datagraph.ScreenTransform; @@ -298,25 +298,50 @@ private void updateTransformScreenSize() @Override public synchronized void layoutChanged( final DataGraphLayout< ?, ? > layout ) { - final ScreenTransform transform = transformState.get(); + final double minX = layout.getCurrentLayoutMinX(); + final double maxX = layout.getCurrentLayoutMaxX(); + final double minY = layout.getCurrentLayoutMinY(); + final double maxY = layout.getCurrentLayoutMaxY(); + layoutChanged( minX, maxX, minY, maxY ); + } - boundXMin = layout.getCurrentLayoutMinX() - boundXLayoutBorder; - boundXMax = layout.getCurrentLayoutMaxX() + boundXLayoutBorder; - boundYMin = layout.getCurrentLayoutMinY() - boundYLayoutBorder; - boundYMax = layout.getCurrentLayoutMaxY() + boundYLayoutBorder; + /** + * Updates the handler so that it accommodates data contained in the + * specified bounds. + * + * @param minX + * min X bound. + * @param maxX + * max X bound. + * @param minY + * min Y bound. + * @param maxY + * max Y bound. + */ + protected synchronized void layoutChanged( + double minX, + double maxX, + double minY, + double maxY ) + { + this.boundXMin = minX - boundXLayoutBorder; + this.boundXMax = maxX + boundXLayoutBorder; + this.boundYMin = minY - boundYLayoutBorder; + this.boundYMax = maxY + boundYLayoutBorder; - if ( boundXMax - boundXMin < minScaleX ) + final ScreenTransform transform = transformState.get(); + if ( maxX - minX < minScaleX ) { - final double c = ( boundXMax + boundXMin ) / 2; - boundXMin = c - minScaleX / 2; - boundXMax = c + minScaleX / 2; + final double c = ( maxX + minX ) / 2; + minX = c - minScaleX / 2; + maxX = c + minScaleX / 2; } updateMaxSizeX( transform.getScreenWidth() ); - if ( boundYMax - boundYMin < minScaleX ) + if ( maxY - minY < minScaleX ) { - final double c = ( boundYMax + boundYMin ) / 2; - boundYMin = c - minScaleX / 2; - boundYMax = c + minScaleX / 2; + final double c = ( maxY + minY ) / 2; + minY = c - minScaleX / 2; + maxY = c + minScaleX / 2; } updateMaxSizeY( transform.getScreenHeight() ); diff --git a/src/main/java/org/mastodon/views/grapher/display/style/DataDisplayStyleEditorPanel.java b/src/main/java/org/mastodon/views/grapher/display/style/DataDisplayStyleEditorPanel.java index d77170cec..1b265b059 100644 --- a/src/main/java/org/mastodon/views/grapher/display/style/DataDisplayStyleEditorPanel.java +++ b/src/main/java/org/mastodon/views/grapher/display/style/DataDisplayStyleEditorPanel.java @@ -135,7 +135,8 @@ public DataDisplayStyleEditorPanel( final DataDisplayStyle style ) final SelectionModel< DataVertex, DataEdge > selection = new SelectionModelAdapter<>( ex.getSelectionModel(), vertexMap, edgeMap ); final NavigationHandler< DataVertex, DataEdge > navigation = new DefaultNavigationHandler<>(); - final DataDisplayOptions options = DataDisplayOptions.options().style( style ); + final DataDisplayOptions< DataVertex, DataEdge > options = DataDisplayOptions.options(); + options.style( style ); // Layout. diff --git a/src/main/java/org/mastodon/views/table/TableViewFrameBuilder.java b/src/main/java/org/mastodon/views/table/TableViewFrameBuilder.java index a1838c5f1..969a92acd 100644 --- a/src/main/java/org/mastodon/views/table/TableViewFrameBuilder.java +++ b/src/main/java/org/mastodon/views/table/TableViewFrameBuilder.java @@ -97,6 +97,14 @@ public class TableViewFrameBuilder private final ArrayList< Runnable > runOnClose = new ArrayList<>(); + private int x = 0; + + private int y = 0; + + private int width = 500; + + private int height = 300; + public TableViewFrameBuilder title( final String title ) { this.title = title; @@ -123,6 +131,30 @@ public TableViewFrameBuilder undo( final UndoPointMarker undo ) return this; } + public TableViewFrameBuilder x( final int x ) + { + this.x = x; + return this; + } + + public TableViewFrameBuilder y( final int y ) + { + this.y = y; + return this; + } + + public TableViewFrameBuilder width( final int width ) + { + this.width = width; + return this; + } + + public TableViewFrameBuilder height( final int height ) + { + this.height = height; + return this; + } + public MyTableViewFrame get() { final MyTableViewFrame frame = new MyTableViewFrame( title ); @@ -164,6 +196,16 @@ public void windowClosing( final WindowEvent e ) frame.contextChoosers.add( bundle.contextChooser ); } + /* + * Size and position. + */ + + frame.setSize( width, height ); + if ( x <= 0 && y <= 0 ) + frame.setLocationRelativeTo( null ); + else + frame.setLocation( x, y ); + return frame; } diff --git a/src/main/java/org/mastodon/views/trackscheme/display/TrackSchemeFrame.java b/src/main/java/org/mastodon/views/trackscheme/display/TrackSchemeFrame.java index 67e6c3de2..3529ce87e 100644 --- a/src/main/java/org/mastodon/views/trackscheme/display/TrackSchemeFrame.java +++ b/src/main/java/org/mastodon/views/trackscheme/display/TrackSchemeFrame.java @@ -123,8 +123,14 @@ public void windowClosing( final WindowEvent e ) mouseAndKeyHandler.setBehaviourMap( triggerbindings.getConcatenatedBehaviourMap() ); mouseAndKeyHandler.setKeypressManager( optional.values.getKeyPressedManager(), trackschemePanel.getDisplay() ); trackschemePanel.getDisplay().addHandler( mouseAndKeyHandler ); - setLocation( optional.values.getX(), optional.values.getY() ); setIconImages( TRACKSCHEME_VIEW_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 TrackSchemePanel getTrackschemePanel()