Skip to content

Commit

Permalink
v.0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ekatrukha committed Nov 10, 2023
1 parent fa4f815 commit 75bbd42
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 24 deletions.
63 changes: 54 additions & 9 deletions src/main/java/btbvv/btcards/BoundedRangeEditorBT.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -34,16 +37,21 @@ 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,
final ConverterSetupsBT converterSetups,
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() );
}

Expand All @@ -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()
{
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -264,6 +288,7 @@ private synchronized void updateConverterSetupRanges()
return;

final BoundedRange range = rangePanel.getRange();
//boolean bSync = cbSync.isSelected();

for ( final ConverterSetup converterSetup : converterSetups )
{
Expand All @@ -272,14 +297,24 @@ 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()
{
if ( blockUpdates || converterSetups == null || converterSetups.isEmpty() )
return;

//final BoundedRange range = gammaPanel.getRange();
//boolean bSync = cbSync.isSelected();

final BoundedValueDouble model = gammaPanel.getValue();

Expand All @@ -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()
{
Expand All @@ -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() );
}
Expand All @@ -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();

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/btbvv/btcards/BtBVVDefaultCards.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );

Expand All @@ -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 ) );
Expand Down
30 changes: 18 additions & 12 deletions src/main/java/btbvv/btcards/ConverterSetupEditPanelBT.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package btbvv.btcards;

import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

Expand All @@ -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 );
}

Expand All @@ -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" );

}
Expand Down

0 comments on commit 75bbd42

Please sign in to comment.