use of javafx.scene.control.TableColumn in project financial by greatkendy123.
the class WaizhaiService method generateWaizhaiTables.
/**
* 自动生成外债信息表
* @param tableWaizhai
* @param hbox
* @param tableCurrentMoneyInfo
* @param tableTeam
*/
@SuppressWarnings("unchecked")
public static void generateWaizhaiTables(TableView<WaizhaiInfo> tableWaizhai, HBox hbox, TableView<CurrentMoneyInfo> tableCurrentMoneyInfo, TableView<TeamInfo> tableTeam) {
// 清空数据
ObservableList<Node> allTables = hbox.getChildren();
if (allTables != null && allTables.size() > 0)
hbox.getChildren().remove(0, allTables.size());
if (DataConstans.Index_Table_Id_Map.size() == 0) {
ShowUtil.show("你当前还未锁定任意一局,查询没有数据!", 2);
return;
}
ObservableList<CurrentMoneyInfo> CurrentMoneyInfo_OB_List = FXCollections.observableArrayList();
Map<String, List<CurrentMoneyInfo>> gudongMap = get_SSJE_Gudong_Map(tableCurrentMoneyInfo, tableTeam);
Map<String, String> sumMap = getSum(gudongMap);
int gudongMapSize = gudongMap.size();
if (gudongMapSize == 0) {
ShowUtil.show("股东列表为空或实时金额为空!");
return;
}
TableView<CurrentMoneyInfo> table;
for (Map.Entry<String, List<CurrentMoneyInfo>> entry : gudongMap.entrySet()) {
String gudongName = entry.getKey();
List<CurrentMoneyInfo> list = entry.getValue();
table = new TableView<CurrentMoneyInfo>();
// 设置列
TableColumn firstNameCol = new TableColumn("股东" + gudongName);
firstNameCol.setPrefWidth(110);
firstNameCol.setCellValueFactory(new PropertyValueFactory<CurrentMoneyInfo, String>("mingzi"));
TableColumn lastNameCol = new TableColumn(sumMap.get(gudongName));
lastNameCol.setStyle("-fx-alignment: CENTER;");
lastNameCol.setPrefWidth(95);
lastNameCol.setCellValueFactory(new PropertyValueFactory<CurrentMoneyInfo, String>("shishiJine"));
lastNameCol.setCellFactory(MyController.getColorCellFactory(new CurrentMoneyInfo()));
table.setPrefWidth(210);
table.getColumns().addAll(firstNameCol, lastNameCol);
// 设置数据
CurrentMoneyInfo_OB_List = FXCollections.observableArrayList();
for (CurrentMoneyInfo info : list) {
CurrentMoneyInfo_OB_List.add(info);
}
table.setItems(CurrentMoneyInfo_OB_List);
hbox.setSpacing(5);
hbox.setPadding(new Insets(0, 0, 0, 0));
hbox.getChildren().addAll(table);
}
// 设置债务表
ObservableList<WaizhaiInfo> obList = FXCollections.observableArrayList();
for (Map.Entry<String, String> entry : sumMap.entrySet()) {
obList.add(new WaizhaiInfo(entry.getKey(), entry.getValue()));
}
tableWaizhai.setItems(obList);
setWaizhaiSum(tableWaizhai);
}
use of javafx.scene.control.TableColumn 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.TableColumn 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.TableColumn in project latexdraw by arnobl.
the class ShortcutsController method initialize.
@SuppressWarnings("unchecked")
@Override
public void initialize(final URL location, final ResourceBundle resources) {
final String ctrl = KeyEvent.getKeyModifiersText(InputEvent.CTRL_MASK);
final String shift = KeyEvent.getKeyModifiersText(InputEvent.SHIFT_MASK);
// $NON-NLS-1$
final String leftClick = LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.8");
// $NON-NLS-1$
final String catEdit = LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.89");
// $NON-NLS-1$
final String catNav = LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.4");
// $NON-NLS-1$
final String catTran = LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.5");
// $NON-NLS-1$
final String catDraw = LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.6");
// $NON-NLS-1$
final String catFile = LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.88");
for (int i = 0, size = table.getColumns().size(); i < size; i++) {
final int colIndex = i;
final TableColumn<ObservableList<String>, String> col = (TableColumn<ObservableList<String>, String>) table.getColumns().get(i);
col.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().get(colIndex)));
}
table.getColumns().forEach(col -> col.prefWidthProperty().bind(table.widthProperty().divide(3)));
// $NON-NLS-1$
table.getItems().addAll(// $NON-NLS-1$
FXCollections.observableArrayList(ctrl + "+C", LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.40"), catEdit), // $NON-NLS-1$
FXCollections.observableArrayList(ctrl + "+V", LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.43"), catEdit), // $NON-NLS-1$
FXCollections.observableArrayList(ctrl + "+X", LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.44"), catEdit), // $NON-NLS-1$ //$NON-NLS-2$
FXCollections.observableArrayList(ctrl + "+Z", LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.23"), catEdit), // $NON-NLS-1$ //$NON-NLS-2$
FXCollections.observableArrayList(ctrl + "+Y", LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.22"), catEdit), // $NON-NLS-1$
FXCollections.observableArrayList(ctrl + "+N", LangTool.INSTANCE.getBundle().getString("Res.2"), catFile), // $NON-NLS-1$
FXCollections.observableArrayList(ctrl + "+O", LangTool.INSTANCE.getBundle().getString("FileLoaderSaver.3"), catFile), // $NON-NLS-1$
FXCollections.observableArrayList(ctrl + "+S", LangTool.INSTANCE.getBundle().getString("FileLoaderSaver.1"), catFile), // $NON-NLS-1$ //$NON-NLS-2$
FXCollections.observableArrayList(ctrl + "+W", LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.18"), catFile), // $NON-NLS-1$
FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_ADD), LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.57"), catNav), // $NON-NLS-1$
FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_SUBTRACT), LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.58"), catNav), // $NON-NLS-1$
FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_DELETE), LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.17"), catDraw), // $NON-NLS-1$ //$NON-NLS-2$
FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_RIGHT), LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.9"), catNav), // $NON-NLS-1$ //$NON-NLS-2$
FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_LEFT), LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.10"), catNav), // $NON-NLS-1$ //$NON-NLS-2$
FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_UP), LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.11"), catNav), // $NON-NLS-1$ //$NON-NLS-2$
FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_DOWN), LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.12"), catNav), // $NON-NLS-1$ //$NON-NLS-2$
FXCollections.observableArrayList(ctrl + "+U", LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.23"), catTran), // $NON-NLS-1$ //$NON-NLS-2$
FXCollections.observableArrayList(ctrl + "+A", LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.25"), catDraw), // $NON-NLS-1$
FXCollections.observableArrayList(ctrl + '+' + leftClick, LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.26"), catDraw), // $NON-NLS-1$
FXCollections.observableArrayList(shift + '+' + leftClick, LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.27"), catDraw), // $NON-NLS-1$ //$NON-NLS-2$
FXCollections.observableArrayList(ctrl + '+' + LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.29"), LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.30"), catDraw));
}
use of javafx.scene.control.TableColumn 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