diff --git a/src/main/java/btbvv/btcards/BoundedRangeEditorBT.java b/src/main/java/btbvv/btcards/BoundedRangeEditorBT.java index 9199ece..b031cf7 100644 --- a/src/main/java/btbvv/btcards/BoundedRangeEditorBT.java +++ b/src/main/java/btbvv/btcards/BoundedRangeEditorBT.java @@ -1,8 +1,11 @@ package btbvv.btcards; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.List; import java.util.function.Supplier; +import javax.swing.JCheckBox; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.SwingUtilities; @@ -34,6 +37,10 @@ public class BoundedRangeEditorBT { private final ConverterSetupBoundsGamma converterSetupBoundsGamma; private final ConverterSetupBoundsAlpha converterSetupBoundsAlpha; private final ConverterSetupBoundsGammaAlpha converterSetupBoundsGammaAlpha; + + private final JCheckBox cbSync; + + private boolean bSync; public BoundedRangeEditorBT( final SourceTable table, @@ -41,9 +48,10 @@ public BoundedRangeEditorBT( final BoundedRangePanelBT rangePanel, final BoundedValuePanelBT gammaPanel, final BoundedRangePanelBT rangeAlphaPanel, - final BoundedValuePanelBT gammaAlphaPanel) + final BoundedValuePanelBT gammaAlphaPanel, + final JCheckBox cbSync) { - this( table::getSelectedConverterSetups, converterSetups, rangePanel, gammaPanel, rangeAlphaPanel, gammaAlphaPanel); + this( table::getSelectedConverterSetups, converterSetups, rangePanel, gammaPanel, rangeAlphaPanel, gammaAlphaPanel, cbSync); table.getSelectionModel().addListSelectionListener( e -> updateSelection() ); } @@ -53,11 +61,12 @@ public BoundedRangeEditorBT( final BoundedRangePanelBT rangePanel, final BoundedValuePanelBT gammaPanel, final BoundedRangePanelBT rangeAlphaPanel, - final BoundedValuePanelBT gammaAlphaPanel) + final BoundedValuePanelBT gammaAlphaPanel, + final JCheckBox cbSync) { this( () -> converterSetups.getConverterSetups( tree.getSelectedSources() ), - converterSetups, rangePanel, gammaPanel, rangeAlphaPanel,gammaAlphaPanel); + converterSetups, rangePanel, gammaPanel, rangeAlphaPanel,gammaAlphaPanel, cbSync); tree.getSelectionModel().addTreeSelectionListener( e -> updateSelection() ); tree.getModel().addTreeModelListener( new TreeModelListener() { @@ -93,7 +102,8 @@ private BoundedRangeEditorBT( final BoundedRangePanelBT rangePanel, final BoundedValuePanelBT gammaPanel, final BoundedRangePanelBT rangeAlphaPanel, - final BoundedValuePanelBT gammaAlphaPanel) + final BoundedValuePanelBT gammaAlphaPanel, + final JCheckBox cbSync) { this.selectedConverterSetups = selectedConverterSetups; this.rangePanel = rangePanel; @@ -104,6 +114,20 @@ private BoundedRangeEditorBT( this.converterSetupBoundsGamma = converterSetups.getBoundsGamma(); this.converterSetupBoundsAlpha = converterSetups.getBoundsAlpha(); this.converterSetupBoundsGammaAlpha = converterSetups.getBoundsGammaAlpha(); + this.cbSync = cbSync; + this.cbSync.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) + { +// final boolean bSelected = cbSync.isSelected(); +// bSync = bSelected; + bSync = cbSync.isSelected(); + + } + }); + + bSync = this.cbSync.isSelected(); rangePanel.changeListeners().add( this::updateConverterSetupRanges ); gammaPanel.changeListeners().add( this::updateConverterSetupGamma); @@ -264,6 +288,7 @@ private synchronized void updateConverterSetupRanges() return; final BoundedRange range = rangePanel.getRange(); + //boolean bSync = cbSync.isSelected(); for ( final ConverterSetup converterSetup : converterSetups ) { @@ -272,6 +297,16 @@ private synchronized void updateConverterSetupRanges() } updateRangePanel(); + if(bSync) + { + for ( final ConverterSetup converterSetup : converterSetups ) + { + ((GammaConverterSetup)converterSetup).setAlphaRange( range.getMin(), range.getMax() ); + converterSetupBoundsAlpha.setBounds( converterSetup, range.getBounds() ); + } + + updateRangeAlphaPanel(); + } } private synchronized void updateConverterSetupGamma() @@ -279,7 +314,7 @@ private synchronized void updateConverterSetupGamma() if ( blockUpdates || converterSetups == null || converterSetups.isEmpty() ) return; - //final BoundedRange range = gammaPanel.getRange(); + //boolean bSync = cbSync.isSelected(); final BoundedValueDouble model = gammaPanel.getValue(); @@ -293,6 +328,19 @@ private synchronized void updateConverterSetupGamma() } updateGammaPanel(); + if(bSync) + { + for ( final ConverterSetup converterSetup : converterSetups ) + { + if(converterSetup instanceof GammaConverterSetup) + { + ((GammaConverterSetup)converterSetup).setAlphaGamma(model.getCurrentValue()); + converterSetupBoundsGammaAlpha.setBounds(converterSetup, new Bounds(model.getRangeMin(),model.getRangeMax())); + } + } + + updateGammaAlphaPanel(); + } } private synchronized void updateConverterSetupRangesAlpha() { @@ -303,7 +351,6 @@ private synchronized void updateConverterSetupRangesAlpha() for ( final ConverterSetup converterSetup : converterSetups ) { - //converterSetup.setDisplayRange( range.getMin(), range.getMax() ); ((GammaConverterSetup)converterSetup).setAlphaRange( range.getMin(), range.getMax() ); converterSetupBoundsAlpha.setBounds( converterSetup, range.getBounds() ); } @@ -315,8 +362,6 @@ private synchronized void updateConverterSetupGammaAlpha() { if ( blockUpdates || converterSetups == null || converterSetups.isEmpty() ) return; - - //final BoundedRange range = gammaPanel.getRange(); final BoundedValueDouble model = gammaAlphaPanel.getValue(); diff --git a/src/main/java/btbvv/btcards/BtBVVDefaultCards.java b/src/main/java/btbvv/btcards/BtBVVDefaultCards.java index 0315b71..7c21c37 100644 --- a/src/main/java/btbvv/btcards/BtBVVDefaultCards.java +++ b/src/main/java/btbvv/btcards/BtBVVDefaultCards.java @@ -38,14 +38,12 @@ public static void setup( final CardPanel cards, final AbstractViewerPanel viewe table.setPreferredScrollableViewportSize( new Dimension( 300, 200 ) ); table.setFillsViewportHeight( true ); table.setDragEnabled( true ); - //final ConverterSetupEditPanel editPanelTable = new ConverterSetupEditPanel( table, converterSetups ); final ConverterSetupEditPanelBT editPanelTableBT = new ConverterSetupEditPanelBT( table, converterSetups ); final JPanel tablePanel = new JPanel( new BorderLayout() ); //final JPanel tablePanel = new JPanel( ); final JScrollPane scrollPaneTable = new MyScrollPane( table, "Table.background" ); scrollPaneTable.addMouseWheelListener( new MouseWheelScrollListener( scrollPaneTable ) ); tablePanel.add( scrollPaneTable, BorderLayout.CENTER ); - //tablePanel.add( editPanelTable, BorderLayout.CENTER ); tablePanel.add( editPanelTableBT, BorderLayout.SOUTH ); tablePanel.setPreferredSize( new Dimension( 300, 285 ) ); @@ -59,7 +57,8 @@ public static void setup( final CardPanel cards, final AbstractViewerPanel viewe tree.setShowsRootHandles( true ); tree.setExpandsSelectedPaths( true ); tree.getSelectionModel().setSelectionMode( TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION ); - final ConverterSetupEditPanel editPanelTree = new ConverterSetupEditPanel( tree, converterSetups ); + final ConverterSetupEditPanelBT editPanelTree = new ConverterSetupEditPanelBT( tree, converterSetups ); + //final ConverterSetupEditPanel editPanelTree = new ConverterSetupEditPanel( tree, converterSetups ); final JPanel treePanel = new JPanel( new BorderLayout() ); final JScrollPane scrollPaneTree = new MyScrollPane( tree, "Tree.background" ); scrollPaneTree.addMouseWheelListener( new MouseWheelScrollListener( scrollPaneTree ) ); diff --git a/src/main/java/btbvv/btcards/ConverterSetupEditPanelBT.java b/src/main/java/btbvv/btcards/ConverterSetupEditPanelBT.java index e33a68c..3eb49e1 100644 --- a/src/main/java/btbvv/btcards/ConverterSetupEditPanelBT.java +++ b/src/main/java/btbvv/btcards/ConverterSetupEditPanelBT.java @@ -1,5 +1,6 @@ package btbvv.btcards; +import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; @@ -18,13 +19,14 @@ public class ConverterSetupEditPanelBT extends JPanel private final BoundedValuePanelBT gammaPanel; private final BoundedRangePanelBT rangeAlphaPanel; private final BoundedValuePanelBT gammaAlphaPanel; + private final JCheckBox cbSync; public ConverterSetupEditPanelBT( final SourceGroupTree tree, final ConverterSetupsBT converterSetups ) { this(); - new BoundedRangeEditorBT( tree, converterSetups, rangePanel, gammaPanel, rangeAlphaPanel, gammaAlphaPanel); + new BoundedRangeEditorBT( tree, converterSetups, rangePanel, gammaPanel, rangeAlphaPanel, gammaAlphaPanel, cbSync); new ColorEditorBT( tree, converterSetups, colorPanel ); } @@ -33,38 +35,42 @@ public ConverterSetupEditPanelBT( final ConverterSetupsBT converterSetups ) { this(); - new BoundedRangeEditorBT( table, converterSetups, rangePanel, gammaPanel, rangeAlphaPanel,gammaAlphaPanel); + new BoundedRangeEditorBT( table, converterSetups, rangePanel, gammaPanel, rangeAlphaPanel,gammaAlphaPanel, cbSync); new ColorEditorBT( table, converterSetups, colorPanel ); } public ConverterSetupEditPanelBT() { - super( new MigLayout( "ins 0, fillx, hidemode 3", "[]0[]0[]", "[]2[]2[]2[]2[]" ) ); + super( new MigLayout( "ins 0, fillx, hidemode 3", "[min!]0[]0[]", "[]2[]2[]2[]2[]" ) ); colorPanel = new ColorPanelBT(); rangePanel = new BoundedRangePanelBT(); gammaPanel= new BoundedValuePanelBT( new BoundedValueDouble(0.1,5.0,1.0)); rangeAlphaPanel = new BoundedRangePanelBT(); gammaAlphaPanel = new BoundedValuePanelBT( new BoundedValueDouble(0.1,5.0,1.0)); - //gammaPanel = new BoundedRangePanelBT(); + cbSync = new JCheckBox(); + cbSync.setSelected(true); //( ( MigLayout ) rangePanel.getLayout() ).setLayoutConstraints( "fillx, filly, hidemode 3" ); + //( ( MigLayout ) gammaPanel.getLayout() ).setLayoutConstraints( "ins 5 5 5 10, fillx, filly, hidemode 3" ); + String sLayoutConstraints = "ins 0 0 0 5, fillx, filly, hidemode 3" ; ( ( MigLayout ) rangePanel.getLayout() ).setLayoutConstraints( sLayoutConstraints ); ( ( MigLayout ) gammaPanel.getLayout() ).setLayoutConstraints( sLayoutConstraints ); ( ( MigLayout ) rangeAlphaPanel.getLayout() ).setLayoutConstraints(sLayoutConstraints ); ( ( MigLayout ) gammaAlphaPanel.getLayout() ).setLayoutConstraints(sLayoutConstraints ); - //( ( MigLayout ) rangePanel.getLayout() ).setLayoutConstraints( sLayoutConstraints ); - //( ( MigLayout ) gammaPanel.getLayout() ).setLayoutConstraints( "ins 5 5 5 10, fillx, filly, hidemode 3" ); - add( new JLabel(" "), "growy" ); + + add( new JLabel(" "), "" ); add( colorPanel, "growy" ); - add( new JLabel(" Color"), "growy, wrap" ); - add( new JLabel("LUT"), "growy" ); + add( new JLabel(" Color "), "growy" ); + add( cbSync, "growy" ); + add( new JLabel(" Sync LUT -> α "), "growy, wrap" ); + add( new JLabel("LUT"), "" ); add( rangePanel, "growx, span, wrap" ); - add( new JLabel(" γ"), "growy" ); + add( new JLabel(" γ"), "" ); add( gammaPanel, "growx, span, wrap" ); - add( new JLabel(" α"), "growy" ); + add( new JLabel(" α"), "" ); add( rangeAlphaPanel, "growx, span, wrap" ); - add( new JLabel(" γ α"), "growy" ); + add( new JLabel(" γ α"), "" ); add( gammaAlphaPanel, "growx, span" ); }