Skip to content

Commit

Permalink
Show lineage as color
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin van der Krieken committed Jun 10, 2016
1 parent 890296b commit 2f7c881
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package nl.tudelft.pl2016gr2.gui.view;

import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
Expand All @@ -8,11 +9,13 @@
import javafx.collections.transformation.SortedList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.SnapshotParameters;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
Expand All @@ -21,13 +24,16 @@
import javafx.scene.input.Dragboard;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;

import nl.tudelft.pl2016gr2.gui.view.graph.GraphPaneController;
import nl.tudelft.pl2016gr2.gui.view.selection.SelectionManager;
import nl.tudelft.pl2016gr2.model.GenomeMap;
import nl.tudelft.pl2016gr2.model.MetaData;
import nl.tudelft.pl2016gr2.model.metadata.LineageColor;
import org.controlsfx.control.CheckComboBox;

import java.net.URL;
Expand Down Expand Up @@ -58,7 +64,7 @@ public class SearchPaneController implements Initializable {

@FXML private TableColumn<MetaData, String> specimenIdColumn;
@FXML private TableColumn<MetaData, String> specimentTypeColumn;
@FXML private TableColumn<MetaData, String> lineageColumn;
@FXML private TableColumn<MetaData, LineageColor> lineageColumn;

@FXML
private GridPane categoricalGridPane;
Expand Down Expand Up @@ -142,8 +148,24 @@ private void initializeTable() {
cellData -> new SimpleStringProperty(cellData.getValue().specimenId));
specimentTypeColumn.setCellValueFactory(
cellData -> new SimpleStringProperty(cellData.getValue().specimenType));
lineageColumn.setCellValueFactory(
cellData -> new SimpleStringProperty(cellData.getValue().lineage));

lineageColumn.setCellValueFactory(cellData ->
new SimpleObjectProperty<>(LineageColor.toLineage(cellData.getValue().lineage)));
lineageColumn.setCellFactory(metaDataStringTableColumn ->
new TableCell<MetaData, LineageColor>() {
@Override
protected void updateItem(LineageColor item, boolean empty) {
super.updateItem(item, empty);
Color color = Color.TRANSPARENT;
if (!empty && item != null) {
color = item.getColor();
}
setBackground(new Background(new BackgroundFill(
color, null, Insets.EMPTY
)));
}
}
);

// Set the filter Predicate whenever the filter changes.
filterField.textProperty().addListener((observable, oldValue, newValue) -> {
Expand Down

0 comments on commit 2f7c881

Please sign in to comment.