use of javafx.scene.control.TableView in project financial by greatkendy123.
the class TgWaizhaiService method get_SSJE_Gudong_Map.
/**
* 获取每个托管团队的实时金额
* 备注:不包括个人和存在于左边的团队
*/
public static Map<String, List<CurrentMoneyInfo>> get_SSJE_Gudong_Map(TableView<CurrentMoneyInfo> tableCurrentMoneyInfo) {
int pageIndex = DataConstans.Index_Table_Id_Map.size();
if (pageIndex < 0) {
return new HashMap<>();
}
// 获取托管团队ID
Set<String> tgTeamIdSet = getTGTeamId();
// 获取实时金额数据
List<CurrentMoneyInfo> CurrentMoneyInfoList = new ArrayList<>();
for (CurrentMoneyInfo infos : tableCurrentMoneyInfo.getItems()) {
CurrentMoneyInfoList.add(infos);
}
// 情况2:从最新的锁定表中获取数据
// CurrentMoneyInfoList = JSON.parseObject(MoneyService.getJsonString(map,"实时金额"), new TypeReference<List<CurrentMoneyInfo>>() {});
// 添加只属于托管的团队和个人信息
List<CurrentMoneyInfo> SSJE_obList = new LinkedList<>();
for (CurrentMoneyInfo infos : CurrentMoneyInfoList) {
if (!StringUtil.isAnyBlank(infos.getWanjiaId(), infos.getMingzi())) {
String playerId = infos.getWanjiaId();
Player player = DataConstans.membersMap.get(playerId);
if (player == null || StringUtil.isBlank(player.getTeamName()) || !tgTeamIdSet.contains(player.getTeamName().toUpperCase())) {
continue;
} else if (tgTeamIdSet.contains(player.getTeamName().toUpperCase())) {
// 深层克隆
SSJE_obList.add(copyCurrentMoneyInfo(infos));
}
}
}
// 获取每个股东的实时金额数据
List<String> gudongList = DataConstans.gudongList;
int gudongSize = gudongList.size();
List<CurrentMoneyInfo> eachGudongList = null;
// 托管团队的实时金额信息{ 托管团队:托管团队金额列表List}
String playerId;
Player player;
// 步骤1:添加玩家
Map<String, List<CurrentMoneyInfo>> tgTeamCMIMap = SSJE_obList.stream().filter(infos -> {
boolean isSuperId = DataConstans.Combine_Super_Id_Map.containsKey(infos.getWanjiaId());
if (!isSuperId) {
// 为解决联合ID的问题,在这里把父节点信息加了进来,后面会把父节点的联合额度为0或空的清除掉,问题:能否在此处就过滤过??
if (StringUtil.isBlank(infos.getShishiJine()) || "0".equals(infos.getShishiJine()) || !infos.getShishiJine().contains("-")) {
return false;
}
}
return true;
}).collect(Collectors.groupingBy(info -> {
CurrentMoneyInfo cmi = (CurrentMoneyInfo) info;
Player p = DataConstans.membersMap.get(cmi.getWanjiaId());
if (p == null) {
return UNKNOW_TG_TEAM;
} else {
return p.getTeamName();
}
}));
// 步骤2:处理个人外债和有联合额度的外债
// Map<String,CurrentMoneyInfo> ssje_map = get_SSJE_Map(SSJE_obList);
// handlePersonWaizhai(tgTeamIdMap,ssje_map); TODO
System.out.println("===============================================以上外债信息为:处理个人外债和有联合额度的外债finishes");
tgTeamCMIMap = getFinalTGTeamMap(SSJE_obList);
return tgTeamCMIMap;
}
use of javafx.scene.control.TableView in project financial by greatkendy123.
the class WaizhaiService method get_SSJE_Gudong_Map.
/**
* 获取每个股东的实时金额
* 包括个人和存在于左边的团队
* @time 2017年12月27日
* @param tableCurrentMoneyInfo
* @param tableTeam
* @return
*/
public static Map<String, List<CurrentMoneyInfo>> get_SSJE_Gudong_Map(TableView<CurrentMoneyInfo> tableCurrentMoneyInfo, TableView<TeamInfo> tableTeam) {
int pageIndex = DataConstans.Index_Table_Id_Map.size();
if (pageIndex < 0) {
return new HashMap<>();
}
// 获取实时金额数据
Map<String, String> map = DataConstans.All_Locked_Data_Map.get(pageIndex + "");
List<CurrentMoneyInfo> CurrentMoneyInfoList = null;
List<TeamInfo> teamInfoList = null;
// 情况1:从最新的表中获取数据
if (tableTeam != null && tableTeam.getItems() != null) {
CurrentMoneyInfoList = new ArrayList<>();
for (CurrentMoneyInfo infos : tableCurrentMoneyInfo.getItems()) {
CurrentMoneyInfoList.add(infos);
}
teamInfoList = new ArrayList<>();
for (TeamInfo infos : tableTeam.getItems()) {
teamInfoList.add(infos);
}
} else // 情况2:从最新的锁定表中获取数据
{
CurrentMoneyInfoList = JSON.parseObject(MoneyService.getJsonString(map, "实时金额"), new TypeReference<List<CurrentMoneyInfo>>() {
});
teamInfoList = JSON.parseObject(MoneyService.getJsonString(map, "团队回水"), new TypeReference<List<TeamInfo>>() {
});
}
List<CurrentMoneyInfo> SSJE_obList = new LinkedList<>();
for (CurrentMoneyInfo infos : CurrentMoneyInfoList) {
if (!StringUtil.isBlank(infos.getWanjiaId()) && !StringUtil.isBlank(infos.getMingzi())) {
SSJE_obList.add(infos);
}
}
// 获取每个股东的实时金额数据
List<String> gudongList = DataConstans.gudongList;
int gudongSize = gudongList.size();
List<CurrentMoneyInfo> eachGudongList = null;
Map<String, List<CurrentMoneyInfo>> gudongMap = new HashMap<>();
String playerId;
Player player;
// 步骤1:添加玩家
for (CurrentMoneyInfo infos : SSJE_obList) {
boolean isSuperId = DataConstans.Combine_Super_Id_Map.containsKey(infos.getWanjiaId());
if (!isSuperId) {
// 为解决联合ID的问题,在这里把父节点信息加了进来,后面会把父节点的联合额度为0或空的清除掉,问题:能否在此处就过滤过??
if (StringUtil.isBlank(infos.getShishiJine()) || "0".equals(infos.getShishiJine()) || !infos.getShishiJine().contains("-")) {
continue;
}
}
// if(StringUtil.isBlank(infos.getShishiJine())
// || "0".equals(infos.getShishiJine())
// || !infos.getShishiJine().contains("-")) {
// continue;
// }
playerId = infos.getWanjiaId();
if (!StringUtil.isBlank(playerId)) {
player = DataConstans.membersMap.get(playerId);
if (player == null) {
ShowUtil.show("名单列表中匹配不到该玩家!玩家名称:" + infos.getMingzi() + " ID是" + infos.getWanjiaId());
continue;
}
if (gudongList.contains(player.getGudong())) {
for (String gudong : gudongList) {
if (gudong.equals(player.getGudong())) {
if (gudongMap.get(gudong) == null) {
eachGudongList = new ArrayList<>();
// eachGudongList.add(infos);
} else {
eachGudongList = gudongMap.get(gudong);
// eachGudongList.add(infos);
}
/**
***2018-01-01 add***
*/
CurrentMoneyInfo tempInfo = copyCurrentMoneyInfo(infos);
eachGudongList.add(tempInfo);
/**
******
*/
gudongMap.put(gudong, eachGudongList);
break;
}
}
} else {
ShowUtil.show("玩家的股东不存在于股东表中!玩家名称:" + infos.getMingzi() + " ID是" + infos.getWanjiaId());
break;
}
} else {
ShowUtil.show("玩家ID为空!玩家名称:" + infos.getMingzi() + " ID是" + infos.getWanjiaId());
}
}
// 步骤2:处理个人外债和有联合额度的外债
Map<String, CurrentMoneyInfo> ssje_map = get_SSJE_Map(SSJE_obList);
handlePersonWaizhai(gudongMap, ssje_map);
System.out.println("===============================================以上外债信息为:处理个人外债和有联合额度的外债finishes");
// 步骤3:添加团队
for (TeamInfo infos : teamInfoList) {
String teamId = infos.getTeamID();
Huishui hsInfo = DataConstans.huishuiMap.get(teamId);
if (hsInfo == null) {
ErrorUtil.err("外债信息:添加负数团队时检测到缓存中没有该团队信息,团队ID:" + teamId);
continue;
}
String isManaged = hsInfo.getZjManaged();
String gudong = hsInfo.getGudong();
String hasJiesuan = infos.getHasJiesuaned();
String zhanji = infos.getTeamZJ();
if (// 战绩非管理的团队
!"是".equals(isManaged) && // 未结算的团队
!"1".equals(hasJiesuan) && zhanji.contains("-")) {
// 战绩为负数的团队
CurrentMoneyInfo cmi = new CurrentMoneyInfo();
cmi.setMingzi("团队" + teamId);
cmi.setShishiJine(infos.getTeamZJ());
if (gudongMap.get(gudong) == null) {
eachGudongList = new ArrayList<>();
eachGudongList.add(cmi);
} else {
eachGudongList = gudongMap.get(gudong);
eachGudongList.add(cmi);
}
gudongMap.put(gudong, eachGudongList);
}
}
/*
* A、负数个人(若其父节点的联合额度为正则不显示 )
* B、公司(不显示团队;若其父节点的联合额度为正则不显示,否则不显示子ID,只显示联合额度;其他节点不变
* C、非公司团队(全部累加到相应团队;若其父节点的联合额度为正则只累加联合额度;其他节点累加实时金额)
*/
if (MapUtil.isHavaValue(gudongMap)) {
// LMController.allClubMap.keySet().forEach(clubID -> log.info(LMController.allClubMap.keySet()));
Iterator<Map.Entry<String, List<CurrentMoneyInfo>>> it = gudongMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, List<CurrentMoneyInfo>> entry = it.next();
String gudongName = entry.getKey();
// if(!"B".equals(gudongName)) continue;//只测试股东B
List<CurrentMoneyInfo> eachList = entry.getValue();
// 深层复制
List<CurrentMoneyInfo> tempEachList = copyListCurrentMoneyInfo(eachList);
List<CurrentMoneyInfo> tempSuperList = new ArrayList<>();
// 过滤掉没有负数团队的股东,过滤掉没有联合ID的股东
if (CollectUtil.isNullOrEmpty(eachList))
continue;
// if(eachList.stream().filter(cmi->cmi.getMingzi().startsWith("团队")).count() == 0) continue;
if (eachList.stream().filter(cmi -> DataConstans.Combine_Super_Id_Map.containsKey(cmi.getWanjiaId())).count() == 0)
continue;
// 处理包含有负数团队的股东(既有联合ID,又有负数团队)
ListIterator<CurrentMoneyInfo> ite = eachList.listIterator();
while (ite.hasNext()) {
CurrentMoneyInfo cmi = ite.next();
String pId = cmi.getWanjiaId();
// TODO 对下面的特殊情况进行分析
if (pId == null && cmi.getMingzi() != null && cmi.getMingzi().startsWith("团队")) {
continue;
}
boolean isSuperId = DataConstans.Combine_Super_Id_Map.containsKey(pId);
// 1528833636
Player _player = DataConstans.membersMap.get(pId);
// 如ST,公司
String teamID = _player.getTeamName();
// 将联合ID的金额设置到对应的团队里
if (isSuperId) {
String playerName = DataConstans.membersMap.get(pId).getPlayerName();
if ("公司".equals(teamID)) {
final String _cmSuperIdSum = cmi.getCmSuperIdSum();
cmi.setShishiJine(_cmSuperIdSum);
log.info(String.format("外债:股东%s--属于公司的父节点%s(%s)设置联合额度%s为实时金额", gudongName, playerName, pId, _cmSuperIdSum));
continue;
}
final String _teamId = "团队" + DataConstans.membersMap.get(pId).getTeamName();
Optional<CurrentMoneyInfo> teamInfoOpt = eachList.stream().filter(info -> info.getMingzi().equals(_teamId)).findFirst();
if (teamInfoOpt.isPresent()) {
CurrentMoneyInfo teamInfo = teamInfoOpt.get();
teamInfo.setShishiJine(NumUtil.getSum(teamInfo.getShishiJine(), cmi.getShishiJine()));
ite.remove();
log.info(String.format("外债:股东%s--有联合ID的父节点%s(%s)将%s转移到%s,并删除父节点", gudongName, playerName, pId, cmi.getShishiJine(), teamInfo.getMingzi()));
} else {
// 新增一个所属团队信息
ite.remove();
CurrentMoneyInfo cmiInfo = new CurrentMoneyInfo(_teamId, cmi.getCmSuperIdSum(), "", "");
ite.add(cmiInfo);
log.info(String.format("外债:股东%s--根据父点(%s)新建团队外债信息(%s),联合额度(团队的实时金额)为%s,并删除父节点", gudongName, playerName, _teamId, cmi.getCmSuperIdSum()));
}
} else // 非公司团队,非父节点,累加进其所属的团队中
if (!"公司".equals(teamID)) {
String playerName = DataConstans.membersMap.get(pId).getPlayerName();
final String _teamId = "团队" + DataConstans.membersMap.get(pId).getTeamName();
Optional<CurrentMoneyInfo> teamInfoOpt = eachList.stream().filter(info -> info.getMingzi().equals(_teamId)).findFirst();
if (teamInfoOpt.isPresent()) {
CurrentMoneyInfo teamInfo = teamInfoOpt.get();
teamInfo.setShishiJine(NumUtil.getSum(teamInfo.getShishiJine(), cmi.getShishiJine()));
ite.remove();
log.info(String.format("外债:股东%s--非父节点%s(%s)将%s转移到%s,并删除非父节点", gudongName, playerName, pId, cmi.getShishiJine(), teamInfo.getMingzi()));
} else {
// 新增一个所属团队信息
ite.remove();
CurrentMoneyInfo cmiInfo = new CurrentMoneyInfo(_teamId, cmi.getShishiJine(), "", "");
ite.add(cmiInfo);
log.info(String.format("外债:股东%s--根据非父点(%s)新建团队外债信息(%s),联合额度(团队的实时金额)为%s,并删除非父节点", gudongName, playerName, _teamId, cmi.getShishiJine()));
}
}
}
}
}
return gudongMap;
}
use of javafx.scene.control.TableView in project blue by kunstmusik.
the class BlueJFXControlsApplication method setTablesTest.
private void setTablesTest(TabPane root) {
TableView<Person> jfxTable = new TableView<>();
ObservableList<Person> people = FXCollections.observableArrayList();
for (int i = 0; i < 20; i++) {
Person p = new Person();
p.setFirstName("test");
p.setLastName(Integer.toString(i));
people.add(p);
}
TableColumn<Person, String> firstNameCol = new TableColumn<Person, String>("First Name");
firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
TableColumn<Person, String> lastNameCol = new TableColumn<Person, String>("Last Name");
lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
jfxTable.getColumns().addAll(firstNameCol, lastNameCol);
jfxTable.setItems(people);
SwingNode swingNode = new SwingNode();
Vector v = new Vector();
for (int i = 0; i < 20; i++) {
Vector t = new Vector();
t.add("test");
t.add(Integer.toString(i));
v.add(t);
}
Vector labels = new Vector();
labels.add("First Name");
labels.add("Last Name");
SwingUtilities.invokeLater(() -> {
DefaultTableModel tm = new DefaultTableModel(v, labels);
JTable table = new JTable(tm);
table.updateUI();
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
swingNode.setContent(scrollPane);
});
root.getTabs().add(new Tab("Tables", new SplitPane(jfxTable, swingNode)));
}
use of javafx.scene.control.TableView in project blue by kunstmusik.
the class ParameterLineView method editPoints.
private void editPoints() {
TableView<LinePoint> table = new TableView<>();
TableColumn<LinePoint, Double> xCol = new TableColumn<>("x");
TableColumn<LinePoint, Double> yCol = new TableColumn<>("y");
table.getColumns().setAll(xCol, yCol);
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
table.setItems(getSelectedLine().getObservableList());
table.setEditable(true);
xCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<LinePoint, Double>, ObservableValue<Double>>() {
@Override
public ObservableValue<Double> call(TableColumn.CellDataFeatures<LinePoint, Double> param) {
return new ReadOnlyObjectWrapper<>(param.getValue().getX() * getDuration() + getStartTime());
}
});
xCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
xCol.setOnEditCommit(te -> {
LinePoint lp = te.getRowValue();
ObservableList<LinePoint> lpList = getSelectedLine().getObservableList();
if (getSelectedLine().getLinePoint(0) == lp || getSelectedLine().getLinePoint(getSelectedLine().size() - 1) == lp) {
return;
}
int index = lpList.indexOf(lp);
double v = (te.getNewValue() - getStartTime()) / getDuration();
lp.setX(Utils.clamp(lpList.get(index - 1).getX(), v, lpList.get(index + 1).getX()));
});
xCol.setEditable(true);
yCol.setCellValueFactory(new PropertyValueFactory<>("y"));
yCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
yCol.setOnEditCommit(te -> {
te.getRowValue().setY(Utils.clamp(getSelectedLine().getMin(), te.getNewValue(), getSelectedLine().getMax()));
});
yCol.setEditable(true);
Dialog<ButtonType> d = new Dialog<>();
d.initOwner(getScene().getWindow());
d.initModality(Modality.APPLICATION_MODAL);
d.getDialogPane().setContent(new ScrollPane(table));
d.getDialogPane().getStylesheets().add(BlueFX.getBlueFxCss());
d.getDialogPane().getButtonTypes().setAll(ButtonType.OK);
d.setTitle("Edit Points");
TableModelListener tml = tme -> {
repaint();
};
getSelectedLine().addTableModelListener(tml);
Optional<ButtonType> res = d.showAndWait();
getSelectedLine().removeTableModelListener(tml);
}
use of javafx.scene.control.TableView in project jvarkit by lindenb.
the class IgvReview method start.
@Override
public void start(final Stage stage) throws Exception {
stage.setTitle(getClass().getSimpleName());
Predicate<VariantContext> ctxFilter;
Map<String, String> params = super.getParameters().getNamed();
if (params.containsKey("--filter")) {
ctxFilter = JexlVariantPredicate.create(params.get("--filter"));
} else {
ctxFilter = V -> true;
}
final List<String> args = super.getParameters().getUnnamed();
final File configFile;
if (args.isEmpty()) {
final FileChooser fc = new FileChooser();
final String lastDirStr = preferences.get(LAST_USED_DIR_KEY, null);
if (lastDirStr != null && !lastDirStr.isEmpty()) {
fc.setInitialDirectory(new File(lastDirStr));
}
fc.getExtensionFilters().addAll(Collections.singletonList(new FileChooser.ExtensionFilter("Config file", "*.config", "*.cfg", "*.list")));
configFile = fc.showOpenDialog(stage);
} else if (args.size() == 1) {
configFile = new File(args.get(0));
} else {
configFile = null;
}
if (configFile == null || !configFile.exists()) {
JfxUtils.dialog().cause("Illegal number of arguments or file doesn't exists.").show(stage);
Platform.exit();
return;
}
if (configFile.isFile() && configFile.getParentFile() != null) {
this.preferences.put(LAST_USED_DIR_KEY, configFile.getParentFile().getPath());
}
final List<String> configLines = Files.readAllLines(configFile.toPath());
final Predicate<String> ignoreComment = (S) -> !S.startsWith("#");
final Predicate<String> predVcf = S -> S.endsWith(".vcf") || S.endsWith(".vcf.gz");
if (configLines.stream().filter(ignoreComment).filter(predVcf).count() != 1) {
JfxUtils.dialog().cause("Found more than one vcf file in " + configFile).show(stage);
Platform.exit();
return;
}
final File vcfFile = configLines.stream().filter(ignoreComment).filter(predVcf).map(S -> new File(S)).findFirst().get();
LOG.info("Opening vcf file and loading in memory");
VCFFileReader vfr = null;
CloseableIterator<VariantContext> iter = null;
final Set<String> sampleNames;
try {
this.variants.clear();
vfr = new VCFFileReader(vcfFile, false);
this.vcfHeader = vfr.getFileHeader();
sampleNames = new HashSet<>(this.vcfHeader.getSampleNamesInOrder());
if (sampleNames.isEmpty()) {
JfxUtils.dialog().cause("No Genotypes in " + vcfFile).show(stage);
Platform.exit();
return;
}
iter = vfr.iterator();
this.variants.addAll(iter.stream().filter(ctxFilter).filter(CTX -> CTX.isVariant()).collect(Collectors.toList()));
} catch (final Exception err) {
JfxUtils.dialog().cause(err).show(stage);
Platform.exit();
return;
} finally {
CloserUtil.close(iter);
CloserUtil.close(vfr);
}
if (this.variants.isEmpty()) {
JfxUtils.dialog().cause("No Variants").show(stage);
Platform.exit();
return;
}
final SAMSequenceDictionary dict = this.vcfHeader.getSequenceDictionary();
if (dict == null || dict.isEmpty()) {
JfxUtils.dialog().cause(JvarkitException.VcfDictionaryMissing.getMessage(vcfFile.getPath())).show(stage);
Platform.exit();
return;
}
final SamReaderFactory srf = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.LENIENT);
configLines.stream().filter(ignoreComment).filter(S -> S.endsWith(".bam")).map(S -> new File(S)).forEach(F -> {
final SamReader samIn = srf.open(F);
final SAMFileHeader header = samIn.getFileHeader();
CloserUtil.close(samIn);
String sample = null;
for (final SAMReadGroupRecord rg : header.getReadGroups()) {
String s = rg.getSample();
if (s == null)
continue;
if (sample == null) {
sample = s;
} else if (!sample.equals(s)) {
JfxUtils.dialog().cause("Two samples in " + F).show(stage);
Platform.exit();
return;
}
}
if (sample == null) {
JfxUtils.dialog().cause("No sample in " + F + ". Ignoring").show(stage);
return;
}
if (!sampleNames.contains(sample)) {
JfxUtils.dialog().cause("Not in VCF header " + sample + " / " + F + ". Ignoring").show(stage);
return;
}
this.sample2bamFile.put(sample, F);
});
if (this.sample2bamFile.isEmpty()) {
JfxUtils.dialog().cause("No valid bam file in " + configFile).show(stage);
return;
}
sampleNames.retainAll(this.sample2bamFile.keySet());
if (sampleNames.isEmpty()) {
JfxUtils.dialog().cause("No Sample associated to bam").show(stage);
return;
}
ObservableList<VariantAndGenotype> genotypes = FXCollections.observableArrayList(this.variants.stream().flatMap(CTX -> CTX.getGenotypes().stream().filter(G -> sampleNames.contains(G.getSampleName())).map(G -> new VariantAndGenotype(CTX, G))).collect(Collectors.toList()));
if (genotypes.isEmpty()) {
JfxUtils.dialog().cause("No Genotype to show").show(stage);
return;
}
Menu menu = new Menu("File");
MenuItem menuItem = new MenuItem("Save as...");
menuItem.setOnAction(AE -> {
saveVariantsAs(stage);
});
menu.getItems().add(menuItem);
menuItem = new MenuItem("Save");
menuItem.setOnAction(AE -> {
if (this.saveAsFile != null) {
saveVariants(stage, this.saveAsFile);
} else {
saveVariantsAs(stage);
}
});
menu.getItems().add(menuItem);
menu.getItems().add(new SeparatorMenuItem());
menuItem = new MenuItem("Quit");
menuItem.setOnAction(AE -> {
Platform.exit();
});
menu.getItems().add(menuItem);
MenuBar bar = new MenuBar(menu);
this.genotypeTable = new TableView<>(genotypes);
this.genotypeTable.getColumns().add(makeColumn("CHROM", G -> G.ctx.getContig()));
this.genotypeTable.getColumns().add(makeColumn("POS", G -> G.ctx.getStart()));
this.genotypeTable.getColumns().add(makeColumn("ID", G -> G.ctx.getID()));
this.genotypeTable.getColumns().add(makeColumn("REF", G -> G.ctx.getReference().getDisplayString()));
this.genotypeTable.getColumns().add(makeColumn("ALT", G -> G.ctx.getAlternateAlleles().stream().map(A -> A.getDisplayString()).collect(Collectors.joining(","))));
this.genotypeTable.getColumns().add(makeColumn("Sample", G -> G.g.getSampleName()));
this.genotypeTable.getColumns().add(makeColumn("Type", G -> G.g.getType().name()));
this.genotypeTable.getColumns().add(makeColumn("Alleles", G -> G.g.getAlleles().stream().map(A -> A.getDisplayString()).collect(Collectors.joining(","))));
TableColumn<VariantAndGenotype, String> reviewCol = new TableColumn<>("Review");
reviewCol.setCellValueFactory(C -> C.getValue().getReviewProperty());
reviewCol.setCellFactory(TextFieldTableCell.forTableColumn());
reviewCol.setOnEditCommit((E) -> {
int y = E.getTablePosition().getRow();
this.genotypeTable.getItems().get(y).setReview(E.getNewValue());
});
reviewCol.setEditable(true);
this.genotypeTable.getColumns().add(reviewCol);
this.genotypeTable.getSelectionModel().cellSelectionEnabledProperty().set(true);
this.genotypeTable.setEditable(true);
final ContextMenu cm = new ContextMenu();
MenuItem mi1 = new MenuItem("Menu 1");
cm.getItems().add(mi1);
MenuItem mi2 = new MenuItem("Menu 2");
cm.getItems().add(mi2);
this.genotypeTable.setOnMousePressed(event -> {
if (event.isPrimaryButtonDown() && (event.getClickCount() == 3 || event.isShiftDown())) {
moveIgvTo(stage, genotypeTable.getSelectionModel().getSelectedItem());
} else if (event.isSecondaryButtonDown()) {
cm.show(genotypeTable, event.getScreenX(), event.getScreenY());
}
});
final BorderPane pane2 = new BorderPane(this.genotypeTable);
pane2.setPadding(new Insets(10, 10, 10, 10));
VBox vbox1 = new VBox(bar, pane2);
final Scene scene = new Scene(vbox1, 500, 300);
stage.setScene(scene);
stage.show();
}
Aggregations