Search in sources :

Example 1 with IDataTableView

use of de.unijena.cheminf.mortar.gui.views.IDataTableView in project MORTAR by FelixBaensch.

the class GuiUtil method setImageStructureHeight.

// 
/**
 * Sets the height for structure images to each MoleculeDataModel object of the items list of the tableView.
 * If image height is too small it will be set to GuiDefinitions.GUI_STRUCTURE_IMAGE_MIN_HEIGHT (50.0)
 *
 * @param aTableView TableView
 * @param aHeight double
 * @param aSettingsContainer SettingsContainer
 */
public static void setImageStructureHeight(TableView aTableView, double aHeight, SettingsContainer aSettingsContainer) {
    double tmpHeight = (aHeight - GuiDefinitions.GUI_TABLE_VIEW_HEADER_HEIGHT - GuiDefinitions.GUI_PAGINATION_CONTROL_PANEL_HEIGHT) / aSettingsContainer.getRowsPerPageSetting();
    if (aTableView.getClass().equals(ItemizationDataTableView.class)) {
        tmpHeight = (aHeight - 2 * GuiDefinitions.GUI_TABLE_VIEW_HEADER_HEIGHT - GuiDefinitions.GUI_PAGINATION_CONTROL_PANEL_HEIGHT) / aSettingsContainer.getRowsPerPageSetting();
    }
    if (tmpHeight < GuiDefinitions.GUI_STRUCTURE_IMAGE_MIN_HEIGHT) {
        tmpHeight = GuiDefinitions.GUI_STRUCTURE_IMAGE_MIN_HEIGHT;
    }
    if (aTableView.getClass().equals(ItemizationDataTableView.class)) {
        for (MoleculeDataModel tmpMoleculeDataModel : ((IDataTableView) aTableView).getItemsList()) {
            tmpMoleculeDataModel.setStructureImageHeight(tmpHeight);
            String tmpFragmentationName = ((ItemizationDataTableView) aTableView).getFragmentationName();
            if (!tmpMoleculeDataModel.hasMoleculeUndergoneSpecificFragmentation(tmpFragmentationName)) {
                continue;
            }
            for (FragmentDataModel tmpFragmentDataModel : tmpMoleculeDataModel.getFragmentsOfSpecificAlgorithm(tmpFragmentationName)) {
                tmpFragmentDataModel.setStructureImageHeight(tmpHeight);
            }
        }
    } else {
        for (MoleculeDataModel tmpMoleculeDataModel : ((IDataTableView) aTableView).getItemsList()) {
            tmpMoleculeDataModel.setStructureImageHeight(tmpHeight);
        }
    }
}
Also used : FragmentDataModel(de.unijena.cheminf.mortar.model.data.FragmentDataModel) MoleculeDataModel(de.unijena.cheminf.mortar.model.data.MoleculeDataModel) ItemizationDataTableView(de.unijena.cheminf.mortar.gui.views.ItemizationDataTableView) IDataTableView(de.unijena.cheminf.mortar.gui.views.IDataTableView)

Example 2 with IDataTableView

use of de.unijena.cheminf.mortar.gui.views.IDataTableView in project MORTAR by FelixBaensch.

the class MainViewController method openGlobalSettingsView.

// 
/**
 * Opens settings view for global settings
 */
private void openGlobalSettingsView() {
    SettingsViewController tmpSettingsViewController = new SettingsViewController(this.primaryStage, this.settingsContainer);
    Platform.runLater(() -> {
        if (tmpSettingsViewController.hasRowsPerPageChanged()) {
            for (Tab tmpTab : this.mainTabPane.getTabs()) {
                TableView tmpTableView = ((GridTabForTableView) tmpTab).getTableView();
                int tmpListSize = 0;
                tmpListSize = ((IDataTableView) tmpTableView).getItemsList().size();
                int tmpPageIndex = ((GridTabForTableView) tmpTab).getPagination().getCurrentPageIndex();
                int tmpRowsPerPage = this.settingsContainer.getRowsPerPageSetting();
                int tmpPageCount = tmpListSize / tmpRowsPerPage;
                if (tmpListSize % tmpRowsPerPage > 0) {
                    tmpPageCount++;
                }
                if (tmpPageIndex > tmpPageCount) {
                    tmpPageIndex = tmpPageCount;
                }
                ((GridTabForTableView) tmpTab).getPagination().setPageCount(tmpPageCount);
                ((GridTabForTableView) tmpTab).getPagination().setCurrentPageIndex(tmpPageIndex);
                ((GridTabForTableView) tmpTab).getTableView().refresh();
                GuiUtil.setImageStructureHeight(((GridTabForTableView) tmpTab).getTableView(), ((GridTabForTableView) tmpTab).getTableView().getHeight(), this.settingsContainer);
                ((GridTabForTableView) tmpTab).getTableView().refresh();
            }
        }
        if (tmpSettingsViewController.hasKeepAtomContainerInDataModelChanged()) {
            for (MoleculeDataModel tmpMoleculeDataModel : this.moleculeDataModelList) {
                tmpMoleculeDataModel.setKeepAtomContainer(this.settingsContainer.getKeepAtomContainerInDataModelSetting());
            }
            for (ObservableList<FragmentDataModel> tmpFragmentDataModelList : this.mapOfFragmentDataModelLists.values()) {
                for (FragmentDataModel tmpFragmentDataModel : tmpFragmentDataModelList) {
                    tmpFragmentDataModel.setKeepAtomContainer(this.settingsContainer.getKeepAtomContainerInDataModelSetting());
                }
            }
        }
    });
}
Also used : FragmentDataModel(de.unijena.cheminf.mortar.model.data.FragmentDataModel) Tab(javafx.scene.control.Tab) GridTabForTableView(de.unijena.cheminf.mortar.gui.panes.GridTabForTableView) MoleculeDataModel(de.unijena.cheminf.mortar.model.data.MoleculeDataModel) IDataTableView(de.unijena.cheminf.mortar.gui.views.IDataTableView) FragmentsDataTableView(de.unijena.cheminf.mortar.gui.views.FragmentsDataTableView) TableView(javafx.scene.control.TableView) MoleculesDataTableView(de.unijena.cheminf.mortar.gui.views.MoleculesDataTableView) ItemizationDataTableView(de.unijena.cheminf.mortar.gui.views.ItemizationDataTableView) IDataTableView(de.unijena.cheminf.mortar.gui.views.IDataTableView) GridTabForTableView(de.unijena.cheminf.mortar.gui.panes.GridTabForTableView)

Aggregations

IDataTableView (de.unijena.cheminf.mortar.gui.views.IDataTableView)2 ItemizationDataTableView (de.unijena.cheminf.mortar.gui.views.ItemizationDataTableView)2 FragmentDataModel (de.unijena.cheminf.mortar.model.data.FragmentDataModel)2 MoleculeDataModel (de.unijena.cheminf.mortar.model.data.MoleculeDataModel)2 GridTabForTableView (de.unijena.cheminf.mortar.gui.panes.GridTabForTableView)1 FragmentsDataTableView (de.unijena.cheminf.mortar.gui.views.FragmentsDataTableView)1 MoleculesDataTableView (de.unijena.cheminf.mortar.gui.views.MoleculesDataTableView)1 Tab (javafx.scene.control.Tab)1 TableView (javafx.scene.control.TableView)1