Skip to content

Commit

Permalink
review #1
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenHeu committed Aug 29, 2023
1 parent d556a9e commit b90d879
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import io.github.mzmine.datamodel.features.types.modifiers.GraphicalColumType;
import io.github.mzmine.datamodel.features.types.numbers.IDType;
import io.github.mzmine.datamodel.features.types.tasks.NodeGenerationThread;
import io.github.mzmine.datamodel.features.types.tasks.NodeRequest;
import io.github.mzmine.main.MZmineCore;
import io.github.mzmine.modules.io.projectload.CachedIMSFrame;
import io.github.mzmine.modules.io.projectload.CachedIMSRawDataFile;
Expand All @@ -65,7 +64,6 @@
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Logger;
import java.util.stream.Collectors;
Expand All @@ -76,7 +74,6 @@
import javafx.collections.ObservableMap;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -122,6 +119,15 @@ public class ModularFeatureList implements FeatureList {
// grouping
private List<RowGroup> groups;

/**
* Used to buffer charts of rows and features to display in the
* {@link io.github.mzmine.modules.visualization.featurelisttable_modular.FeatureTableFX}. The key
* is of the following format: "<row id>-<DataType.getUniqueID()>-<raw file name or empty
* string>:
* <p>
* final String key = "%d-%s-%s".formatted(row.getID(), type.getUniqueID(), (file != null ?
* file.getName() : ""));
*/
private final Map<String, Node> bufferedCharts = new HashMap<>();

public ModularFeatureList(String name, @Nullable MemoryMapStorage storage,
Expand Down Expand Up @@ -881,9 +887,9 @@ public <S, T extends DataType<S>> Node getChartForRow(FeatureListRow row, T type
}

final StackPane parentPane = new StackPane(new Label("Preparing content..."));
parentPane.setPrefHeight(((GraphicalColumType)type).getCellHeight());
parentPane.setMinHeight(((GraphicalColumType)type).getCellHeight());
parentPane.setMaxHeight(((GraphicalColumType)type).getCellHeight());
parentPane.setPrefHeight(((GraphicalColumType) type).getCellHeight());
parentPane.setMinHeight(((GraphicalColumType) type).getCellHeight());
parentPane.setMaxHeight(((GraphicalColumType) type).getCellHeight());
bufferedCharts.putIfAbsent(key, parentPane);

ensureNodeThreadRunnning();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2023 The MZmine Development Team
* Copyright (c) 2004-2022 The MZmine Development Team
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -75,12 +75,6 @@ public String getHeaderString() {
return null;
}

/*StackPane node = (StackPane) row.getBufferedColChart(getHeaderString());
if (node == null) {
logger.info("Cannot create mobilogram chart, no buffered chart available for row.");
return null;
}*/

if (!(feature.getFeatureData() instanceof IonMobilogramTimeSeries)) {
Label label = new Label("Processed with\nLC-MS workflow");
label.setTextAlignment(TextAlignment.CENTER);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2023 The MZmine Development Team
* Copyright (c) 2004-2022 The MZmine Development Team
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -68,11 +68,6 @@ public String getHeaderString() {
if (row == null || cellData == null || !cellData) {
return null;
}
/*StackPane node = (StackPane) row.getBufferedColChart(getHeaderString());
if (node == null) {
logger.info("Cannot create shape chart, no buffered chart available for row.");
return null;
}*/

var chart = new FeatureShapeChart(row, progress);
return chart;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2023 The MZmine Development Team
* Copyright (c) 2004-2022 The MZmine Development Team
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -70,12 +70,6 @@ public String getHeaderString() {
return null;
}

// StackPane node = (StackPane) row.getBufferedColChart(getHeaderString());
// if (node == null) {
// logger.info("Cannot create mobilogram chart, no buffered chart available for row.");
// return null;
// }

var chart = new ImageChart(feature, progress);
return chart;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2023 The MZmine Development Team
* Copyright (c) 2004-2022 The MZmine Development Team
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -76,8 +76,6 @@ public double getFinishedPercentage() {
public void run() {
setStatus(TaskStatus.PROCESSING);

// generateAllCharts();

// if there was no chart request for this time, stop the thread
final PauseTransition waitTimer = new PauseTransition(new Duration(500));
waitTimer.setOnFinished(e -> setStatus(TaskStatus.CANCELED));
Expand All @@ -89,7 +87,9 @@ public void run() {
try {
TimeUnit.MILLISECONDS.sleep(10);
} catch (InterruptedException e) {
throw new RuntimeException(e);
logger.log(Level.WARNING, e.getMessage(), e);
setStatus(TaskStatus.CANCELED);
return;
}
continue;
}
Expand Down Expand Up @@ -135,76 +135,6 @@ public void run() {
setStatus(TaskStatus.FINISHED);
}

/* private boolean generateAllCharts() {
final List<LinkedGraphicalType> rowTypes = flist.getRowTypes().values().stream()
.filter(type -> type instanceof LinkedGraphicalType).map(t -> (LinkedGraphicalType) t)
.toList();
final List<LinkedGraphicalType> featureTypes = flist.getFeatureTypes().values().stream()
.filter(type -> type instanceof LinkedGraphicalType).map(t -> (LinkedGraphicalType) t)
.toList();
for (FeatureListRow row : flist.getRows()) {
for (LinkedGraphicalType rowType : rowTypes) {
final String header = rowType.getHeaderString();
Node base = ((ModularFeatureListRow) row).getBufferedColChart(header);
if (base == null) {
base = new StackPane(new Label("Preparing content..."));
((ModularFeatureListRow) row).addBufferedColChart(header, base);
}
try {
var chart = rowType.createCellContent((ModularFeatureListRow) row, row.get(rowType), null,
new AtomicDouble());
nodeChartMap.put(base, chart);
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot create chart " + ex.getMessage(), ex);
nodeChartMap.put(base, new Label("Failed to create chart"));
}
}
for (LinkedGraphicalType featureType : featureTypes) {
for (ModularFeature feature : row.getFeatures()) {
if (feature != null && feature.getFeatureStatus() != FeatureStatus.UNKNOWN) {
final String header = featureType.getHeaderString();
Node base = ((ModularFeature) feature).getBufferedColChart(header);
if (base == null) {
base = new StackPane(new Label("Preparing content..."));
((ModularFeature) feature).addBufferedColChart(header, base);
}
try {
var chart = featureType.createCellContent((ModularFeatureListRow) row,
row.get(featureType), feature.getRawDataFile(), new AtomicDouble());
nodeChartMap.put(base, chart);
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot create chart " + ex.getMessage(), ex);
nodeChartMap.put(base, new Label("Failed to create chart"));
}
}
}
}
if (isCanceled()) {
return true;
}
rows++;
}
Platform.runLater(() -> {
logger.info("Updating all charts.");
nodeChartMap.forEach((node, chart) -> {
if (chart == null) {
return;
}
try {
((StackPane) node).getChildren().clear();
((StackPane) node).getChildren().add(chart);
} catch (ClassCastException e) {
logger.log(Level.INFO, e.getMessage(), e);
}
});
logger.info("All charts updated.");
});
return false;
}*/

public <T> void requestNode(@NotNull ModularFeatureListRow row, DataType<T> type, T value,
RawDataFile raw, Pane parentNode) {
nodeRequestQueue.add(new NodeRequest<>(row, type, value, raw, parentNode));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2023 The MZmine Development Team
* Copyright (c) 2004-2022 The MZmine Development Team
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -27,12 +27,9 @@

import io.github.mzmine.datamodel.RawDataFile;
import io.github.mzmine.datamodel.features.FeatureList;
import io.github.mzmine.datamodel.features.types.tasks.NodeGenerationThread;
import io.github.mzmine.gui.mainwindow.MZmineTab;
import io.github.mzmine.main.MZmineCore;
import io.github.mzmine.util.javafx.FxIconUtil;
import java.io.IOException;
import java.time.Instant;
import java.util.Collection;
import java.util.Collections;
import java.util.logging.Level;
Expand Down Expand Up @@ -76,9 +73,6 @@ public FeatureTableTab(FeatureList flist) {
controller = loader.getController();

controller.setFeatureList(flist);
//final NodeGenerationThread nodeGenerationThread = new NodeGenerationThread(null, Instant.now(),
// flist);
//MZmineCore.getTaskController().addTask(nodeGenerationThread);

// TODO: if there would be only selectColumnsButton in the toolbar, then remove toolbar and
// improve "+" button behaviour of the feature table header
Expand Down

0 comments on commit b90d879

Please sign in to comment.