Skip to content

Commit

Permalink
background color
Browse files Browse the repository at this point in the history
  • Loading branch information
ekatrukha committed Oct 16, 2024
1 parent b9e2c92 commit 9bebec8
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>nl.uu.science.cellbiology</groupId>
<artifactId>bigtrace</artifactId>
<version>0.5.0</version>
<version>0.5.1-SNAPSHOT</version>

<name>BigTrace</name>
<description>Tracing of curvilinear structures in 3D</description>
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/bigtrace/BigTrace.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.formdev.flatlaf.FlatIntelliJLaf;
import com.formdev.flatlaf.FlatLaf;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL3;

import ij.IJ;
Expand Down Expand Up @@ -280,10 +281,11 @@ public void initOriginAndBox(double axis_length)
nDimBox[0][i]=btData.nDimIni[0][i]+0.5f;
nDimBox[1][i]=(btData.nDimIni[1][i]-1.0f);
}
volumeBox = new Box3D(nDimBox,1.0f,0.0f,Color.WHITE,Color.WHITE, 0);
final Color frame = BigTraceData.getInvertedColor(btData.canvasBGColor);
volumeBox = new Box3D(nDimBox,1.0f,0.0f,frame,frame, 0);

// volumeBox = new Box3D(nDimBox,1.0f,0.0f,Color.LIGHT_GRAY,Color.LIGHT_GRAY, 0);
clipBox = new Box3D(nDimBox,1.0f,0.0f,Color.LIGHT_GRAY,Color.LIGHT_GRAY, 0);
clipBox = new Box3D(nDimBox,1.0f,0.0f,frame.darker(),frame.darker(), 0);
}

public void initSourcesCanvas(double origin_axis_length)
Expand Down Expand Up @@ -714,7 +716,8 @@ public void setTraceBoxMode(boolean bStatus)

public void renderScene(final GL3 gl, final RenderData data)
{

gl.glClearColor(btData.canvasBGColor.getRed()/255.0f, btData.canvasBGColor.getGreen()/255.0f, btData.canvasBGColor.getBlue()/255.0f, 0.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
int [] screen_size = new int [] {(int)data.getScreenWidth(), (int) data.getScreenHeight()};
//handl.setRenderScene( ( gl, data ) -> {

Expand Down
37 changes: 37 additions & 0 deletions src/main/java/bigtrace/BigTraceControlPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
Expand All @@ -28,6 +29,7 @@
import javax.swing.JToggleButton;
import javax.swing.SwingConstants;

import bdv.tools.brightness.ColorIcon;
import bdv.util.Affine3DHelpers;
import bigtrace.animation.AnimationPanel;
import bigtrace.gui.AnisotropicTransformAnimator3D;
Expand All @@ -40,6 +42,7 @@
import bigtrace.gui.VoxelSizePanel;
import bigtrace.measure.RoiMeasure3D;
import bigtrace.rois.Box3D;
import bigtrace.rois.ColorUserSettings;
import bigtrace.rois.RoiManager3D;
import bigtrace.tracks.TrackingPanel;
import bigtrace.volume.ExtractClip;
Expand Down Expand Up @@ -82,6 +85,8 @@ public class BigTraceControlPanel< T extends RealType< T > & NativeType< T > > e
public JFrame finFrame;
public JProgressBar progressBar;
JButton butSettings;

public ColorUserSettings selectColors = new ColorUserSettings();


public BigTraceControlPanel(final BigTrace<T> bt_,final BigTraceData<T> btd_, final RoiManager3D<T> roiManager_)//, int locx, int locy)
Expand Down Expand Up @@ -396,6 +401,19 @@ public void dialSettings()

pViewSettings.setLayout(new GridBagLayout());


JButton butCanvasBGColor = new JButton( new ColorIcon( bt.btData.canvasBGColor ) );
butCanvasBGColor.addActionListener( e -> {
Color newColor = JColorChooser.showDialog(bt.btPanel.finFrame, "Choose background color", bt.btData.canvasBGColor );
if (newColor!=null)
{
selectColors.setColor(newColor, 0);

butCanvasBGColor.setIcon(new ColorIcon(newColor));
}

});

NumberField nfClickArea = new NumberField(4);
nfClickArea.setIntegersOnly(true);
nfClickArea.setText(Integer.toString(bt.btData.nHalfClickSizeWindow*2));
Expand Down Expand Up @@ -429,6 +447,13 @@ public void dialSettings()
cd.gridx=0;
cd.gridy=0;
GBCHelper.alighLoose(cd);

pViewSettings.add(new JLabel("Background color: "),cd);
cd.gridx++;
pViewSettings.add(butCanvasBGColor,cd);

cd.gridx=0;
cd.gridy++;
pViewSettings.add(new JLabel("Snap area size on click (screen px): "),cd);
cd.gridx++;
pViewSettings.add(nfClickArea,cd);
Expand Down Expand Up @@ -499,6 +524,18 @@ public void dialSettings()

if (reply == JOptionPane.OK_OPTION)
{
Color tempC;

tempC = selectColors.getColor(0);
if(tempC!=null)
{
bt.btData.canvasBGColor = new Color(tempC.getRed(),tempC.getGreen(),tempC.getBlue(),tempC.getAlpha());
selectColors.setColor(null, 0);
Prefs.set("BigTrace.canvasBGColor", tempC.getRGB());
final Color frame = BigTraceData.getInvertedColor(tempC);
bt.volumeBox.setLineColor( frame );
bt.clipBox.setLineColor( frame.darker() );
}

bt.btData.nHalfClickSizeWindow = (int)(0.5*Integer.parseInt(nfClickArea.getText()));
Prefs.set("BigTrace.nHalfClickSizeWindow",bt.btData.nHalfClickSizeWindow);
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/bigtrace/BigTraceData.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public class BigTraceData < T extends RealType< T > & NativeType< T > > {
/** whether or not display color coded origin of coordinates **/
public boolean bShowOrigin = true;

public Color canvasBGColor = new Color((int)Prefs.get( "BigTrace.canvasBGColor", Color.BLACK.getRGB() ));

/** whether or not display a box around volume/image **/
public boolean bVolumeBox = true;

Expand Down Expand Up @@ -407,4 +409,10 @@ public void setInterpolationFactory()

}
}

public static Color getInvertedColor(Color color_in)
{

return new Color(255-color_in.getRed(),255-color_in.getGreen(),255-color_in.getBlue(),color_in.getAlpha());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void dialUnCoilAnimation(final Roi3D roiIn)

cd.gridy++;
cd.gridx=0;
unCoilSettings.add(new JLabel("Use compression for TIFF?"),cd);
unCoilSettings.add(new JLabel("Output format:"),cd);
cd.gridx++;
unCoilSettings.add(cbUnCoilExport,cd);

Expand Down

0 comments on commit 9bebec8

Please sign in to comment.