Search in sources :

Example 51 with TableColumn

use of javafx.scene.control.TableColumn in project jvarkit by lindenb.

the class BamStage method reloadData.

@Override
void reloadData() {
    updateStatusBar(AlertType.NONE, "");
    final int max_items = super.maxItemsLimitSpinner.getValue();
    final List<SAMRecord> L = new ArrayList<SAMRecord>(max_items);
    final String location = this.gotoField.getText().trim();
    final CloseableIterator<SAMRecord> iter;
    final java.util.function.Predicate<SAMRecord> recFilter = makeFlagPredicate();
    Long canvasFirstRecordGenomicIndex = null;
    Long canvasLastRecordGenomicIndex = null;
    try {
        if (location.isEmpty()) {
            iter = this.getBamFile().iterator();
        } else if (location.equalsIgnoreCase("unmapped")) {
            iter = this.getBamFile().queryUnmapped();
        } else {
            final Interval interval = parseInterval(location);
            if (interval == null) {
                iter = null;
            } else {
                iter = this.getBamFile().iterator(interval.getContig(), interval.getStart(), interval.getEnd());
            }
        }
    } catch (final IOException err) {
        err.printStackTrace();
        JfxNgs.showExceptionDialog(this, err);
        return;
    }
    Optional<BamJavascripFilter> bamjsfilter = Optional.empty();
    if (this.owner.javascriptCompiler.isPresent() && !this.javascriptArea.getText().trim().isEmpty()) {
        try {
            bamjsfilter = Optional.of(new BamJavascripFilter(this.getBamFile().getHeader(), Optional.of(this.owner.javascriptCompiler.get().compile(this.javascriptArea.getText()))));
        } catch (final Exception err) {
            LOG.warning(err.getMessage());
            updateStatusBar(AlertType.ERROR, err);
            bamjsfilter = Optional.empty();
        }
    }
    final Map<ContigPos, Pileup> pos2pileup = new TreeMap<>();
    final Function<ContigPos, Pileup> getpileup = new Function<ContigPos, Pileup>() {

        @Override
        public Pileup apply(ContigPos t) {
            Pileup p = pos2pileup.get(t);
            if (p == null) {
                p = new Pileup(t.contig, t.position);
                pos2pileup.put(t, p);
            }
            return p;
        }
    };
    int count_items = 0;
    while (iter != null && iter.hasNext() && count_items < max_items) {
        final SAMRecord rec = iter.next();
        ++count_items;
        if (bamjsfilter.isPresent()) {
            if (bamjsfilter.get().eval(rec) == null)
                continue;
        }
        if (!recFilter.test(rec))
            continue;
        L.add(rec);
        /* get bounds for canvas genmic browser */
        if (!rec.getReadUnmappedFlag() && rec.getCigar() != null) {
            final long endIndex = convertContigPosToGenomicIndex(rec.getContig(), rec.getUnclippedEnd());
            if (canvasFirstRecordGenomicIndex == null) {
                canvasFirstRecordGenomicIndex = convertContigPosToGenomicIndex(rec.getContig(), rec.getUnclippedStart());
                canvasLastRecordGenomicIndex = endIndex;
            } else if (canvasLastRecordGenomicIndex < endIndex) {
                canvasLastRecordGenomicIndex = endIndex;
            }
        }
        /* FILL pileup */
        if (!rec.getReadUnmappedFlag() && rec.getCigar() != null) {
            int refpos = rec.getUnclippedStart();
            int readpos = 0;
            final byte[] bases = rec.getReadBases();
            final byte[] quals = rec.getOriginalBaseQualities();
            /**
             * function getting the ith base
             */
            final Function<Integer, Character> getBaseAt = new Function<Integer, Character>() {

                @Override
                public Character apply(Integer readPos) {
                    char c;
                    if (bases == null || bases.length <= readPos) {
                        return '?';
                    } else {
                        c = (char) bases[readPos];
                    }
                    c = (rec.getReadNegativeStrandFlag() ? Character.toLowerCase(c) : Character.toUpperCase(c));
                    return c;
                }
            };
            /**
             * function getting the ith base quality
             */
            final Function<Integer, Character> getQualAt = new Function<Integer, Character>() {

                @Override
                public Character apply(Integer readPos) {
                    char c;
                    if (quals == null || quals.length <= readPos) {
                        return '#';
                    } else {
                        c = (char) quals[readPos];
                    }
                    return c;
                }
            };
            for (final CigarElement ce : rec.getCigar()) {
                switch(ce.getOperator()) {
                    case P:
                        break;
                    case N:
                    case D:
                        {
                            refpos += ce.getLength();
                            break;
                        }
                    case H:
                        {
                            for (int i = 0; i < ce.getLength(); ++i) {
                                final Pileup p = getpileup.apply(new ContigPos(rec.getContig(), refpos));
                                p.watch('-', '#', ce.getOperator());
                                ++refpos;
                            }
                            break;
                        }
                    case I:
                        {
                            for (int i = 0; i < ce.getLength(); ++i) {
                                final Pileup p = getpileup.apply(new ContigPos(rec.getContig(), refpos));
                                p.watch('<', getQualAt.apply(readpos), ce.getOperator());
                                readpos++;
                            }
                            break;
                        }
                    case S:
                        for (int i = 0; i < ce.getLength(); ++i) {
                            final Pileup p = getpileup.apply(new ContigPos(rec.getContig(), refpos));
                            p.watch('-', getQualAt.apply(readpos), ce.getOperator());
                            ++readpos;
                            ++refpos;
                        }
                        break;
                    case EQ:
                    case X:
                    case M:
                        for (int i = 0; i < ce.getLength(); ++i) {
                            final Pileup p = getpileup.apply(new ContigPos(rec.getContig(), refpos));
                            p.watch(getBaseAt.apply(readpos), getQualAt.apply(readpos), ce.getOperator());
                            ++readpos;
                            ++refpos;
                        }
                        break;
                }
            }
        }
    }
    if (iter != null)
        iter.close();
    this.canvasScrolVInCoverage.setMin(0);
    final int max_depth = pos2pileup.values().stream().map(P -> P.depth()).max((A, B) -> (A.compareTo(B))).orElse(0);
    this.canvasScrolVInCoverage.setMax(max_depth + 1);
    this.canvasScrolVInCoverage.setValue(0);
    this.recordTable.getItems().setAll(L);
    this.pileupTable.getItems().setAll(pos2pileup.values());
    if (canvasFirstRecordGenomicIndex != null && canvasLastRecordGenomicIndex != null && canvasFirstRecordGenomicIndex.longValue() < canvasLastRecordGenomicIndex.longValue()) {
        this.canvasScrollHGenomicLoc.setMin(canvasFirstRecordGenomicIndex);
        this.canvasScrollHGenomicLoc.setMax(canvasLastRecordGenomicIndex);
        // this.canvasScrollHGenomicLoc.setUnitIncrement(1);
        // this.canvasScrollHGenomicLoc.setBlockIncrement(Math.max(1.0,Math.min( canvasLastRecordGenomicIndex-canvasFirstRecordGenomicIndex, this.canvas.getWidth())));
        this.canvasScrollHGenomicLoc.setValue(canvasFirstRecordGenomicIndex);
    } else {
        this.canvasScrollHGenomicLoc.setMin(0);
        this.canvasScrollHGenomicLoc.setMax(0);
        this.canvasScrollHGenomicLoc.setValue(0);
        this.canvasScrollHGenomicLoc.setBlockIncrement(0);
        this.canvasScrollHGenomicLoc.setUnitIncrement(1);
    }
    if (!this.recordTable.getItems().isEmpty()) {
        final int last_index = this.recordTable.getItems().size() - 1;
        if (!this.recordTable.getItems().get(0).getReadUnmappedFlag() && !this.recordTable.getItems().get(last_index).getReadUnmappedFlag()) {
            super.seqDictionaryCanvas.setItemsInterval(new ContigPos(this.recordTable.getItems().get(0).getContig(), this.recordTable.getItems().get(0).getStart()), new ContigPos(this.recordTable.getItems().get(last_index).getContig(), this.recordTable.getItems().get(last_index).getEnd()));
            if (this.recordTable.getItems().get(0).getContig().equals(this.recordTable.getItems().get(last_index).getContig())) {
                this.gotoField.setText(this.recordTable.getItems().get(0).getContig() + ":" + this.recordTable.getItems().get(0).getStart() + "-" + this.recordTable.getItems().get(last_index).getEnd());
            }
        } else {
            super.seqDictionaryCanvas.setItemsInterval(null, null);
        }
    } else {
        super.seqDictionaryCanvas.setItemsInterval(null, null);
    }
    /* show hide columns for paired end data if no paired data found */
    {
        final boolean contains_paired = this.recordTable.getItems().stream().anyMatch(S -> S.getReadPairedFlag());
        for (final TableColumn<SAMRecord, ?> tc : this.pairedEndColumns) tc.setVisible(contains_paired);
    }
    repaintCanvas();
}
Also used : Arrays(java.util.Arrays) VCFHeader(htsjdk.variant.vcf.VCFHeader) CigarOperator(htsjdk.samtools.CigarOperator) ChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.ChartFactory) VariantContextChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantContextChartFactory) ScrollPane(javafx.scene.control.ScrollPane) TabPane(javafx.scene.control.TabPane) Map(java.util.Map) Hershey(com.github.lindenb.jvarkit.util.Hershey) CigarOpPerPositionChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.CigarOpPerPositionChartFactory) ScriptException(javax.script.ScriptException) CloserUtil(htsjdk.samtools.util.CloserUtil) Rectangle2D(javafx.geometry.Rectangle2D) SplitPane(javafx.scene.control.SplitPane) SAMTagUtil(htsjdk.samtools.SAMTagUtil) GraphicsContext(javafx.scene.canvas.GraphicsContext) SAMRecordIterator(htsjdk.samtools.SAMRecordIterator) Event(javafx.event.Event) Set(java.util.Set) SAMFileWriter(htsjdk.samtools.SAMFileWriter) Screen(javafx.stage.Screen) SAMTagAndValue(htsjdk.samtools.SAMRecord.SAMTagAndValue) FastqRecord(htsjdk.samtools.fastq.FastqRecord) Platform(javafx.application.Platform) Separator(javafx.scene.control.Separator) Stream(java.util.stream.Stream) SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) FlowPane(javafx.scene.layout.FlowPane) SAMFlag(htsjdk.samtools.SAMFlag) BorderPane(javafx.scene.layout.BorderPane) SamFlagsChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.SamFlagsChartFactory) CloseableIterator(htsjdk.samtools.util.CloseableIterator) FXCollections(javafx.collections.FXCollections) LogCloseableIterator(com.github.lindenb.jvarkit.tools.vcfviewgui.NgsStage.LogCloseableIterator) TextFlow(javafx.scene.text.TextFlow) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) Color(javafx.scene.paint.Color) SAMFileWriterFactory(htsjdk.samtools.SAMFileWriterFactory) StringWriter(java.io.StringWriter) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) File(java.io.File) Menu(javafx.scene.control.Menu) FileChooser(javafx.stage.FileChooser) SamInputResource(htsjdk.samtools.SamInputResource) TreeMap(java.util.TreeMap) Tab(javafx.scene.control.Tab) CompiledScript(javax.script.CompiledScript) ObservableValue(javafx.beans.value.ObservableValue) EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) CigarElement(htsjdk.samtools.CigarElement) CheckMenuItem(javafx.scene.control.CheckMenuItem) OverrunStyle(javafx.scene.control.OverrunStyle) VBox(javafx.scene.layout.VBox) SAMFileHeader(htsjdk.samtools.SAMFileHeader) BasesPerPositionChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.BasesPerPositionChartFactory) ComboBox(javafx.scene.control.ComboBox) AlertType(javafx.scene.control.Alert.AlertType) ContextMenu(javafx.scene.control.ContextMenu) WindowEvent(javafx.stage.WindowEvent) TableView(javafx.scene.control.TableView) ReadLengthChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.ReadLengthChartFactory) Orientation(javafx.geometry.Orientation) Alert(javafx.scene.control.Alert) MenuItem(javafx.scene.control.MenuItem) Predicate(java.util.function.Predicate) Logger(com.github.lindenb.jvarkit.util.log.Logger) Font(javafx.scene.text.Font) Chart(javafx.scene.chart.Chart) Collectors(java.util.stream.Collectors) SAMRecord(htsjdk.samtools.SAMRecord) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Text(javafx.scene.text.Text) SimpleBindings(javax.script.SimpleBindings) QualityPerPositionChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.QualityPerPositionChartFactory) List(java.util.List) SAMProgramRecord(htsjdk.samtools.SAMProgramRecord) Optional(java.util.Optional) VariantContext(htsjdk.variant.variantcontext.VariantContext) Pattern(java.util.regex.Pattern) SamReaderFactory(htsjdk.samtools.SamReaderFactory) FastqReader(htsjdk.samtools.fastq.FastqReader) ReadQualityChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.ReadQualityChartFactory) Cigar(htsjdk.samtools.Cigar) Scene(javafx.scene.Scene) SequenceUtil(htsjdk.samtools.util.SequenceUtil) SAMUtils(htsjdk.samtools.SAMUtils) TextArea(javafx.scene.control.TextArea) ButtonType(javafx.scene.control.ButtonType) HashMap(java.util.HashMap) GCPercentChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.GCPercentChartFactory) MapqChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.MapqChartFactory) Function(java.util.function.Function) ValidationStringency(htsjdk.samtools.ValidationStringency) SAMTextHeaderCodec(htsjdk.samtools.SAMTextHeaderCodec) TableColumn(javafx.scene.control.TableColumn) HashSet(java.util.HashSet) Interval(htsjdk.samtools.util.Interval) TableCell(javafx.scene.control.TableCell) Insets(javafx.geometry.Insets) Tooltip(javafx.scene.control.Tooltip) Locatable(htsjdk.samtools.util.Locatable) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) ReadChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.ReadChartFactory) SamReader(htsjdk.samtools.SamReader) ScrollEvent(javafx.scene.input.ScrollEvent) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) ChangeListener(javafx.beans.value.ChangeListener) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) Collections(java.util.Collections) ScrollBar(javafx.scene.control.ScrollBar) ArrayList(java.util.ArrayList) Function(java.util.function.Function) IOException(java.io.IOException) TreeMap(java.util.TreeMap) CigarElement(htsjdk.samtools.CigarElement) TableColumn(javafx.scene.control.TableColumn) ScriptException(javax.script.ScriptException) IOException(java.io.IOException) SAMRecord(htsjdk.samtools.SAMRecord) Interval(htsjdk.samtools.util.Interval)

Example 52 with TableColumn

use of javafx.scene.control.TableColumn in project jvarkit by lindenb.

the class VcfStage method buildSampleTab.

/**
 * build table of Sample
 */
private Tab buildSampleTab() {
    final boolean editable = this.name2sampledef.size() > 1;
    final BorderPane pane = new BorderPane(this.sampleTable);
    pane.setPadding(new Insets(10));
    this.sampleTable.setEditable(editable);
    if (!getVcfFile().getPedigree().isEmpty()) {
        this.sampleTable.getColumns().add(makeColumn("Family", R -> {
            if (R.getPedSample().isPresent()) {
                return R.getPedSample().get().getFamily();
            }
            return null;
        }));
    }
    this.sampleTable.getColumns().add(makeColumn("Name", R -> R.getName()));
    final TableColumn<SampleDef, Boolean> selectCol = new TableColumn<>("Display");
    selectCol.setCellValueFactory(new PropertyValueFactory<>("displayed"));
    selectCol.setCellFactory(col -> {
        CheckBoxTableCell<SampleDef, Boolean> cell = new CheckBoxTableCell<>(index -> {
            return sampleTable.getItems().get(index).displayedProperty();
        });
        return cell;
    });
    selectCol.setEditable(editable);
    this.sampleTable.getColumns().add(selectCol);
    this.sampleTable.getColumns().add(makeColumn("Description", R -> R.getDescription()));
    this.sampleTable.setPlaceholder(new Label("No Sample."));
    this.sampleTable.getItems().addAll(this.name2sampledef.values());
    if (!getVcfFile().getPedigree().isEmpty()) {
        this.sampleTable.getColumns().add(makeColumn("Father", R -> {
            if (R.getPedSample().isPresent()) {
                final PedFile.Sample parent = R.getPedSample().get().getFather();
                return parent == null ? null : parent.getName();
            }
            return (String) null;
        }));
        this.sampleTable.getColumns().add(makeColumn("Mother", R -> {
            if (R.getPedSample().isPresent()) {
                final PedFile.Sample parent = R.getPedSample().get().getMother();
                return parent == null ? null : parent.getName();
            }
            return (String) null;
        }));
        this.sampleTable.getColumns().add(makeColumn("Sex", R -> {
            if (R.getPedSample().isPresent()) {
                return R.getPedSample().get().getSex().name();
            }
            return (String) null;
        }));
        this.sampleTable.getColumns().add(makeColumn("Status", R -> {
            if (R.getPedSample().isPresent()) {
                return R.getPedSample().get().getStatus().name();
            }
            return (String) null;
        }));
    }
    final HBox top = new HBox();
    top.setPadding(new Insets(10));
    Button but = new Button("Select all");
    but.setOnAction(AE -> {
        for (final SampleDef def : name2sampledef.values()) {
            def.setDisplayed(true);
        }
        if (getCurrentSelectedItem().isPresent()) {
            refreshGenotypeTable(getCurrentSelectedItem().get());
        }
    });
    top.getChildren().add(but);
    but = new Button("Unselect all");
    but.setOnAction(AE -> {
        for (final SampleDef def : name2sampledef.values()) {
            def.setDisplayed(false);
        }
        if (getCurrentSelectedItem().isPresent()) {
            refreshGenotypeTable(getCurrentSelectedItem().get());
        }
    });
    top.getChildren().add(but);
    pane.setTop(top);
    final Tab tab = new Tab("Samples", pane);
    tab.setClosable(false);
    return tab;
}
Also used : Arrays(java.util.Arrays) VCFHeader(htsjdk.variant.vcf.VCFHeader) ChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.ChartFactory) VariantContextChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantContextChartFactory) ScrollPane(javafx.scene.control.ScrollPane) TabPane(javafx.scene.control.TabPane) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) VariantDepthChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantDepthChartFactory) Map(java.util.Map) AlleleFrequencyChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.AlleleFrequencyChartFactory) CloserUtil(htsjdk.samtools.util.CloserUtil) Rectangle2D(javafx.geometry.Rectangle2D) SplitPane(javafx.scene.control.SplitPane) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) GenotypeBuilder(htsjdk.variant.variantcontext.GenotypeBuilder) GraphicsContext(javafx.scene.canvas.GraphicsContext) AFByPopulationChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.AFByPopulationChartFactory) TiTvChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.TiTvChartFactory) Set(java.util.Set) Screen(javafx.stage.Screen) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) ArcType(javafx.scene.shape.ArcType) Separator(javafx.scene.control.Separator) PieChart(javafx.scene.chart.PieChart) BooleanProperty(javafx.beans.property.BooleanProperty) FlowPane(javafx.scene.layout.FlowPane) VariantContextWriter(htsjdk.variant.variantcontext.writer.VariantContextWriter) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) Genotype(htsjdk.variant.variantcontext.Genotype) CloseableIterator(htsjdk.samtools.util.CloseableIterator) OutputType(htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder.OutputType) FXCollections(javafx.collections.FXCollections) TextFlow(javafx.scene.text.TextFlow) Supplier(java.util.function.Supplier) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) TabClosingPolicy(javafx.scene.control.TabPane.TabClosingPolicy) SequenceOntologyTree(com.github.lindenb.jvarkit.util.so.SequenceOntologyTree) VCFConstants(htsjdk.variant.vcf.VCFConstants) Counter(com.github.lindenb.jvarkit.util.Counter) Color(javafx.scene.paint.Color) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) AFBySexChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.AFBySexChartFactory) File(java.io.File) Menu(javafx.scene.control.Menu) FileChooser(javafx.stage.FileChooser) Tab(javafx.scene.control.Tab) CompiledScript(javax.script.CompiledScript) AnnPredictionParserFactory(com.github.lindenb.jvarkit.util.vcf.predictions.AnnPredictionParserFactory) VCFFormatHeaderLine(htsjdk.variant.vcf.VCFFormatHeaderLine) ObservableValue(javafx.beans.value.ObservableValue) VariantTypeChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantTypeChartFactory) EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) Allele(htsjdk.variant.variantcontext.Allele) VariantContextWriterBuilder(htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder) VBox(javafx.scene.layout.VBox) AlertType(javafx.scene.control.Alert.AlertType) ContextMenu(javafx.scene.control.ContextMenu) WindowEvent(javafx.stage.WindowEvent) TableView(javafx.scene.control.TableView) Orientation(javafx.geometry.Orientation) Alert(javafx.scene.control.Alert) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) PatternSyntaxException(java.util.regex.PatternSyntaxException) MenuItem(javafx.scene.control.MenuItem) Predicate(java.util.function.Predicate) VariantQualChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantQualChartFactory) GenotypeType(htsjdk.variant.variantcontext.GenotypeType) Font(javafx.scene.text.Font) Collectors(java.util.stream.Collectors) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Text(javafx.scene.text.Text) List(java.util.List) Paint(javafx.scene.paint.Paint) Term(com.github.lindenb.jvarkit.util.so.SequenceOntologyTree.Term) VCFInfoHeaderLine(htsjdk.variant.vcf.VCFInfoHeaderLine) Optional(java.util.Optional) VariantContext(htsjdk.variant.variantcontext.VariantContext) Pattern(java.util.regex.Pattern) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VCFHeaderLine(htsjdk.variant.vcf.VCFHeaderLine) Scene(javafx.scene.Scene) AnnPredictionParser(com.github.lindenb.jvarkit.util.vcf.predictions.AnnPredictionParser) ButtonType(javafx.scene.control.ButtonType) Function(java.util.function.Function) TableColumn(javafx.scene.control.TableColumn) Interval(htsjdk.samtools.util.Interval) Insets(javafx.geometry.Insets) VepPredictionParser(com.github.lindenb.jvarkit.util.vcf.predictions.VepPredictionParser) VepPredictionParserFactory(com.github.lindenb.jvarkit.util.vcf.predictions.VepPredictionParserFactory) Callback(javafx.util.Callback) GenotypeTypeChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.GenotypeTypeChartFactory) VCFFilterHeaderLine(htsjdk.variant.vcf.VCFFilterHeaderLine) Label(javafx.scene.control.Label) ActionEvent(javafx.event.ActionEvent) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) Collections(java.util.Collections) BorderPane(javafx.scene.layout.BorderPane) HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) TableColumn(javafx.scene.control.TableColumn) Tab(javafx.scene.control.Tab) Button(javafx.scene.control.Button) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell)

Example 53 with TableColumn

use of javafx.scene.control.TableColumn in project jvarkit by lindenb.

the class JvarkitCentral method start.

@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Jvarkit-Central");
    StackPane root = new StackPane();
    root.setPadding(new Insets(2));
    final TableView<Class<?>> tableView = new TableView<>();
    final TableColumn<Class<?>, String> nameCol = new TableColumn<>("Name");
    nameCol.setCellValueFactory(CB -> {
        final String value;
        Class<?> clazz = CB.getValue();
        final Program program = clazz.getAnnotation(Program.class);
        if (!Launcher.class.isAssignableFrom(clazz) || program == null) {
            value = null;
        } else {
            value = program.name();
        }
        return new SimpleStringProperty(value);
    });
    final TableColumn<Class<?>, String> descCol = new TableColumn<>("Description");
    descCol.setCellValueFactory(CB -> {
        final String value;
        Class<?> clazz = CB.getValue();
        final Program program = clazz.getAnnotation(Program.class);
        if (!Launcher.class.isAssignableFrom(clazz) || program == null) {
            value = null;
        } else {
            value = program.description();
        }
        return new SimpleStringProperty(value);
    });
    tableView.getColumns().addAll(nameCol, descCol);
    final BorderPane borderPane1 = new BorderPane(tableView);
    borderPane1.setPadding(new Insets(10));
    final Button but = new Button("New Instance...");
    but.setOnAction(AE -> {
        final Class<?> clazz = tableView.getSelectionModel().getSelectedItem();
        if (clazz == null)
            return;
        final Program program = clazz.getAnnotation(Program.class);
        if (!Launcher.class.isAssignableFrom(clazz) || program == null)
            return;
        createNewInstanceOf(clazz);
    });
    FlowPane bottom = new FlowPane(but);
    borderPane1.setBottom(bottom);
    tableView.getItems().addAll(String.class, Integer.class, VCFFilterJS.class, BioAlcidae.class);
    root.getChildren().add(borderPane1);
    // root.getChildren().add(btn);
    primaryStage.setScene(new Scene(root, 300, 250));
    primaryStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) Insets(javafx.geometry.Insets) Program(com.github.lindenb.jvarkit.util.jcommander.Program) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) Button(javafx.scene.control.Button) FlowPane(javafx.scene.layout.FlowPane) StackPane(javafx.scene.layout.StackPane) TableView(javafx.scene.control.TableView)

Example 54 with TableColumn

use of javafx.scene.control.TableColumn in project latexdraw by arnobl.

the class BadaboomController method initialize.

@SuppressWarnings("unchecked")
@Override
public void initialize(final URL location, final ResourceBundle resources) {
    final ObservableList<TableColumn<Throwable, ?>> cols = table.getColumns();
    ((TableColumn<Throwable, String>) cols.get(0)).setCellValueFactory(cell -> new ReadOnlyStringWrapper(cell.getValue().toString()));
    ((TableColumn<Throwable, String>) cols.get(1)).setCellValueFactory(cell -> new ReadOnlyStringWrapper(cell.getValue().getMessage()));
    ((TableColumn<Throwable, String>) cols.get(2)).setCellValueFactory(cell -> {
        final StackTraceElement[] stackTrace = cell.getValue().getStackTrace();
        final String msg = stackTrace != null && stackTrace.length > 0 ? stackTrace[0].toString() : "";
        return new ReadOnlyStringWrapper(msg);
    });
    cols.forEach(col -> col.prefWidthProperty().bind(table.widthProperty().divide(3)));
    table.setItems(FXCollections.observableArrayList(BadaboomCollector.INSTANCE));
    table.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    final Callable<String> converter = () -> {
        final Throwable ex = table.getSelectionModel().getSelectedItem();
        if (ex == null)
            return "";
        // NON-NLS
        return Arrays.stream(ex.getStackTrace()).map(Object::toString).collect(Collectors.joining("\n\tat ", ex.toString() + "\n\tat ", ""));
    };
    stack.textProperty().bind(Bindings.createStringBinding(converter, table.getSelectionModel().selectedItemProperty()));
}
Also used : ReadOnlyStringWrapper(javafx.beans.property.ReadOnlyStringWrapper) TableColumn(javafx.scene.control.TableColumn)

Example 55 with TableColumn

use of javafx.scene.control.TableColumn in project CST-135 by psradke.

the class FinalSale method start.

@Override
public void start(Stage primaryStage) throws Exception {
    // Background image
    BackgroundImage backImg = new BackgroundImage(new Image("file:src/DispenserDesign/Background&ButtonImages/FinalSalePage/FinalSaleBackground.png", 810, 720, false, true), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT);
    // PANE CREATION
    // Home and Back Buttons Pane
    GridPane buttons = new GridPane();
    buttons.setHgap(10);
    buttons.setVgap(10);
    buttons.setPadding(new Insets(0, 10, 0, 10));
    // TableView Cart Pane
    GridPane cartView = new GridPane();
    cartView.setHgap(9);
    cartView.setVgap(9);
    cartView.setOpacity(0.9);
    cartView.setPadding(new Insets(0, 10, 0, 10));
    // Delete and Purchase Buttons Pane
    GridPane buttons2 = new GridPane();
    buttons2.setHgap(10);
    buttons2.setVgap(10);
    buttons2.setPadding(new Insets(0, 10, 0, 10));
    // Main Pane for arrangement
    VBox vBox = new VBox();
    vBox.setPadding(new Insets(10, 10, 10, 10));
    vBox.getChildren().addAll(buttons, cartView, buttons2);
    // Background Pane
    StackPane root = new StackPane();
    root.setMaxSize(800, 610);
    root.setMinSize(800, 610);
    root.setBackground(new Background(backImg));
    root.setPadding(new Insets(0, 10, 0, 10));
    root.getChildren().add(vBox);
    // BUTTON CREATION
    // Home Button
    Button home = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/NavigationButtons/HomeButton.png")));
    home.setBackground(Background.EMPTY);
    home.setMaxSize(5, 10);
    home.setMinSize(5, 10);
    buttons.add(home, 9, 2);
    // home.setOnAction(e -> {
    // homePage.setScene(scene);
    // });
    // Back Button
    Button back = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/NavigationButtons/BackButton.png")));
    back.setBackground(Background.EMPTY);
    back.setMaxSize(5, 10);
    back.setMinSize(5, 10);
    buttons.add(back, 64, 2);
    back.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            System.out.println("Back");
        }
    });
    // Purchase Button
    Button purchase = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/FinalSalePage/Purchase.png")));
    purchase.setBackground(Background.EMPTY);
    purchase.setMaxSize(5, 10);
    purchase.setMinSize(5, 10);
    buttons2.add(purchase, 36, 11);
    purchase.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            System.out.println("Purcahse");
        }
    });
    // Delete Button
    // Button delete = new Button("Delete Product");
    // delete.setOnAction(e -> deleteClicked());
    // CREATE TABLE FOR DISPLAYING CART
    TableView<Product> table;
    // Name column
    TableColumn<Product, String> nameCol = new TableColumn<>("Name");
    nameCol.setMinWidth(150);
    nameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
    // Price column
    TableColumn<Product, Double> priceCol = new TableColumn<>("Price");
    priceCol.setMinWidth(20);
    priceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
    // Weight column
    TableColumn<Product, Double> weightCol = new TableColumn<>("Weight");
    weightCol.setMinWidth(50);
    weightCol.setCellValueFactory(new PropertyValueFactory<>("weight"));
    // Quantity column
    TableColumn<Product, Double> quantityCol = new TableColumn<>("Quantity");
    quantityCol.setMinWidth(20);
    quantityCol.setCellValueFactory(new PropertyValueFactory<>("quantity"));
    table = new TableView<>();
    table.setItems(getProduct());
    table.setBackground(Background.EMPTY);
    table.setMaxSize(620, 313);
    table.setMinSize(620, 313);
    table.getColumns().addAll(nameCol, priceCol, weightCol, quantityCol);
    cartView.add(table, 7, 18);
    Scene scene = new Scene(root, 800, 710);
    primaryStage.setTitle("Checkout");
    primaryStage.setScene(scene);
    primaryStage.setResizable(false);
    primaryStage.show();
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) ActionEvent(javafx.event.ActionEvent) BackgroundImage(javafx.scene.layout.BackgroundImage) Image(javafx.scene.image.Image) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) BackgroundImage(javafx.scene.layout.BackgroundImage) Button(javafx.scene.control.Button) ImageView(javafx.scene.image.ImageView) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane)

Aggregations

TableColumn (javafx.scene.control.TableColumn)132 TableView (javafx.scene.control.TableView)68 TableCell (javafx.scene.control.TableCell)66 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)46 Button (javafx.scene.control.Button)44 VBox (javafx.scene.layout.VBox)41 Tooltip (javafx.scene.control.Tooltip)40 Callback (javafx.util.Callback)40 ObservableList (javafx.collections.ObservableList)39 Insets (javafx.geometry.Insets)37 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)36 Label (javafx.scene.control.Label)35 ArrayList (java.util.ArrayList)33 List (java.util.List)33 Scene (javafx.scene.Scene)32 Res (bisq.core.locale.Res)31 FxmlView (bisq.desktop.common.view.FxmlView)31 Inject (javax.inject.Inject)31 HyperlinkWithIcon (bisq.desktop.components.HyperlinkWithIcon)30 SortedList (javafx.collections.transformation.SortedList)27