Skip to content
Merged
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 @@ -7,6 +7,10 @@
import org.micromanager.lightsheetmanager.gui.components.Panel;
import org.micromanager.lightsheetmanager.gui.components.TabbedPane;

import javax.swing.JLabel;
import javax.swing.border.EmptyBorder;
import java.awt.Color;
import java.awt.Font;
import java.util.ArrayList;
import java.util.Objects;

Expand Down Expand Up @@ -55,41 +59,93 @@ private void createUserInterface() {
settingsTab_ = new SettingsTab(model_);

// add tabs to the pane
tabbedPane_.addTab(createTabTitle("Navigation"), navigationTab_);
String tabName = "Navigation";
int index = tabbedPane_.getTabCount();
tabbedPane_.addTab(tabName, navigationTab_);
tabbedPane_.setTabComponentAt(index, createTabTitle(tabName));

// create a setup path tab for each imaging path
final int numImagingPaths = devices_.adapter().numImagingPaths();
for (int i = 0; i < numImagingPaths; i++) {
SetupPathTab setupPathTab = new SetupPathTab(model_, i + 1);
final SetupPathTab setupPathTab = new SetupPathTab(model_, i + 1);
if (numImagingPaths > 1) {
tabbedPane_.add(createTabTitle("Setup Path " + (i + 1)), setupPathTab);
tabName = "Setup Path " + (i + 1);
} else {
tabbedPane_.add(createTabTitle("Setup Path"), setupPathTab);
tabName = "Setup Path";
}
index = tabbedPane_.getTabCount();
tabbedPane_.add(tabName, setupPathTab);
tabbedPane_.setTabComponentAt(index, createTabTitle(tabName));
setupPathTabs_.add(setupPathTab);
}

tabbedPane_.addTab(createTabTitle("Acquisition"), acquisitionTab_);
tabbedPane_.addTab(createTabTitle("Autofocus"), autofocusTab_);
tabbedPane_.addTab(createTabTitle("Cameras"), cameraTab_);
tabbedPane_.addTab(createTabTitle("Settings"), settingsTab_);
tabName = "Acquisition";
index = tabbedPane_.getTabCount();
tabbedPane_.addTab(tabName, acquisitionTab_);
tabbedPane_.setTabComponentAt(index, createTabTitle(tabName));

tabName = "Autofocus";
index = tabbedPane_.getTabCount();
tabbedPane_.addTab(tabName, autofocusTab_);
tabbedPane_.setTabComponentAt(index, createTabTitle(tabName));

tabName = "Cameras";
index = tabbedPane_.getTabCount();
tabbedPane_.addTab(tabName, cameraTab_);
tabbedPane_.setTabComponentAt(index, createTabTitle(tabName));

tabName = "Settings";
index = tabbedPane_.getTabCount();
tabbedPane_.addTab(tabName, settingsTab_);
tabbedPane_.setTabComponentAt(index, createTabTitle(tabName));

// set acquisition tab to default
final int tabIndex = findTabNameIndex("Acquisition");
if (tabIndex != -1) {
tabbedPane_.setSelectedIndex(tabIndex);
} else {
tabbedPane_.setSelectedIndex(0); // Navigation Tab
}
tabbedPane_.setSelectedIndex(numImagingPaths + 1);

// add ui elements to the panel
add(tabbedPane_, "growx, growy");
}

/**
* Return a styled HTML String of tab title.
* Returns the index of the tab or -1 if not found.
*
* @param tabName the name of the tab
* @return the index or -1 if not found
*/
private int findTabNameIndex(final String tabName) {
for (int i = 0; i < tabbedPane_.getTabCount(); i++) {
final String title = tabbedPane_.getTitleAt(i);
if (title.equals(tabName)) {
return i;
}
}
return -1;
}

/**
* Returns a styled {@link JLabel} for tab titles.
*
* @param title the text on the tab
* @return an HTML String
* @param title the title text
* @return a styled component
*/
private String createTabTitle(final String title) {
return "<html><body leftmargin=10 topmargin=8 marginwidth=10 marginheight=5><b><font size=4>"
+ title + "</font></b></body></html>";
private JLabel createTabTitle(final String title) {
final JLabel label = new JLabel(title);

// font style
final Font currentFont = label.getFont();
label.setFont(new Font(currentFont.getName(), Font.BOLD, 14));
label.setForeground(Color.BLACK);

// set the margins
label.setBorder(new EmptyBorder(8, 10, 5, 10));

return label;
}

/**
Expand Down
Loading