Search in sources :

Example 1 with FreightAnalyser

use of net.parostroj.timetable.model.freight.FreightAnalyser in project grafikon by jub77.

the class FreightDestinationPanel method addFreightTrainsFromNode.

private void addFreightTrainsFromNode(DataModel model, Node node, FreightAnalyser analyser) {
    Locale locale = Locale.getDefault();
    List<TimeInterval> intervalsFrom = analyser.getFreightIntervalsFrom(node);
    List<Tuple<String>> trains = intervalsFrom.stream().map(i -> new Tuple<>(util.intervalToString(diagram, i, locale), util.freightListToString(analyser.getConnectionStrategy().getFreightToNodes(i), locale).stream().collect(Collectors.joining(", ")))).collect(Collectors.toList());
    model.addLinesWithEmpty(trains);
}
Also used : Locale(java.util.Locale) TableColumnModel(javax.swing.table.TableColumnModel) OutputFreightUtil(net.parostroj.timetable.output2.util.OutputFreightUtil) TableCellRenderer(javax.swing.table.TableCellRenderer) Node(net.parostroj.timetable.model.Node) ArrayList(java.util.ArrayList) TimeInterval(net.parostroj.timetable.model.TimeInterval) ResourceLoader(net.parostroj.timetable.gui.utils.ResourceLoader) Locale(java.util.Locale) AbstractTableModel(javax.swing.table.AbstractTableModel) NodeFreight(net.parostroj.timetable.model.freight.NodeFreight) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) Wrapper(net.parostroj.timetable.gui.wrappers.Wrapper) Collator(java.text.Collator) FlowLayout(java.awt.FlowLayout) ItemEvent(java.awt.event.ItemEvent) JButton(javax.swing.JButton) WrapperListModel(net.parostroj.timetable.gui.wrappers.WrapperListModel) Collection(java.util.Collection) GuiComponentUtils(net.parostroj.timetable.gui.utils.GuiComponentUtils) BorderFactory(javax.swing.BorderFactory) Component(java.awt.Component) Collectors(java.util.stream.Collectors) JScrollPane(javax.swing.JScrollPane) List(java.util.List) GuiIcon(net.parostroj.timetable.gui.utils.GuiIcon) Tuple(net.parostroj.timetable.utils.Tuple) JTable(javax.swing.JTable) RxActionHandler(net.parostroj.timetable.gui.actions.execution.RxActionHandler) Comparator(java.util.Comparator) FreightAnalyser(net.parostroj.timetable.model.freight.FreightAnalyser) TrainDiagram(net.parostroj.timetable.model.TrainDiagram) JPanel(javax.swing.JPanel) TimeInterval(net.parostroj.timetable.model.TimeInterval) Tuple(net.parostroj.timetable.utils.Tuple)

Example 2 with FreightAnalyser

use of net.parostroj.timetable.model.freight.FreightAnalyser in project grafikon by jub77.

the class FreightDestinationPanel method addFreightTrainUnitsFromNode.

private void addFreightTrainUnitsFromNode(DataModel model, Node node, FreightAnalyser analyser) {
    Locale locale = Locale.getDefault();
    List<TimeInterval> intervals = analyser.getFreightTrainUnitIntervals(node);
    List<Tuple<String>> trains = intervals.stream().map(i -> new Tuple<>(util.intervalToString(diagram, i, locale), util.intervalFreightTrainUnitToString(diagram, i).stream().collect(Collectors.joining(", ")))).collect(Collectors.toList());
    model.addLinesWithEmpty(trains);
}
Also used : Locale(java.util.Locale) TableColumnModel(javax.swing.table.TableColumnModel) OutputFreightUtil(net.parostroj.timetable.output2.util.OutputFreightUtil) TableCellRenderer(javax.swing.table.TableCellRenderer) Node(net.parostroj.timetable.model.Node) ArrayList(java.util.ArrayList) TimeInterval(net.parostroj.timetable.model.TimeInterval) ResourceLoader(net.parostroj.timetable.gui.utils.ResourceLoader) Locale(java.util.Locale) AbstractTableModel(javax.swing.table.AbstractTableModel) NodeFreight(net.parostroj.timetable.model.freight.NodeFreight) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) Wrapper(net.parostroj.timetable.gui.wrappers.Wrapper) Collator(java.text.Collator) FlowLayout(java.awt.FlowLayout) ItemEvent(java.awt.event.ItemEvent) JButton(javax.swing.JButton) WrapperListModel(net.parostroj.timetable.gui.wrappers.WrapperListModel) Collection(java.util.Collection) GuiComponentUtils(net.parostroj.timetable.gui.utils.GuiComponentUtils) BorderFactory(javax.swing.BorderFactory) Component(java.awt.Component) Collectors(java.util.stream.Collectors) JScrollPane(javax.swing.JScrollPane) List(java.util.List) GuiIcon(net.parostroj.timetable.gui.utils.GuiIcon) Tuple(net.parostroj.timetable.utils.Tuple) JTable(javax.swing.JTable) RxActionHandler(net.parostroj.timetable.gui.actions.execution.RxActionHandler) Comparator(java.util.Comparator) FreightAnalyser(net.parostroj.timetable.model.freight.FreightAnalyser) TrainDiagram(net.parostroj.timetable.model.TrainDiagram) JPanel(javax.swing.JPanel) TimeInterval(net.parostroj.timetable.model.TimeInterval) Tuple(net.parostroj.timetable.utils.Tuple)

Example 3 with FreightAnalyser

use of net.parostroj.timetable.model.freight.FreightAnalyser in project grafikon by jub77.

the class FreightDestinationPanel method updateView.

public void updateView(Node node) {
    // update selection
    if (nodesModel.getSelectedObject() != node) {
        nodesModel.setSelectedObject(node);
    }
    tableModel.clear();
    if (node != null) {
        DataModel model = new DataModel();
        RxActionHandler.createInstance().newExecution("freight_dest", GuiComponentUtils.getTopLevelComponent(this), diagram).addConsumer((c, diagram) -> {
            c.setWaitMessage(ResourceLoader.getString("wait.message.processing"));
            c.setWaitDialogVisible(true);
        }).onBackground().addConsumer((c, diagram) -> {
            FreightAnalyser analyser = new FreightAnalyser(diagram.getFreightNet().getConnectionStrategy());
            NodeFreight freight = analyser.getNodeFreightFrom(node);
            addFreightToNodes(model, freight);
            addFreightToRegions(model, freight);
            addFreightToColors(model, freight);
            addFreightTrainsFromNode(model, node, analyser);
            addFreightTrainUnitsFromNode(model, node, analyser);
        }).addConsumer((c, diagram) -> {
            tableModel.addLines(model);
            adjustColumnWidth.run();
        }).execute();
    }
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel) OutputFreightUtil(net.parostroj.timetable.output2.util.OutputFreightUtil) TableCellRenderer(javax.swing.table.TableCellRenderer) Node(net.parostroj.timetable.model.Node) ArrayList(java.util.ArrayList) TimeInterval(net.parostroj.timetable.model.TimeInterval) ResourceLoader(net.parostroj.timetable.gui.utils.ResourceLoader) Locale(java.util.Locale) AbstractTableModel(javax.swing.table.AbstractTableModel) NodeFreight(net.parostroj.timetable.model.freight.NodeFreight) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) Wrapper(net.parostroj.timetable.gui.wrappers.Wrapper) Collator(java.text.Collator) FlowLayout(java.awt.FlowLayout) ItemEvent(java.awt.event.ItemEvent) JButton(javax.swing.JButton) WrapperListModel(net.parostroj.timetable.gui.wrappers.WrapperListModel) Collection(java.util.Collection) GuiComponentUtils(net.parostroj.timetable.gui.utils.GuiComponentUtils) BorderFactory(javax.swing.BorderFactory) Component(java.awt.Component) Collectors(java.util.stream.Collectors) JScrollPane(javax.swing.JScrollPane) List(java.util.List) GuiIcon(net.parostroj.timetable.gui.utils.GuiIcon) Tuple(net.parostroj.timetable.utils.Tuple) JTable(javax.swing.JTable) RxActionHandler(net.parostroj.timetable.gui.actions.execution.RxActionHandler) Comparator(java.util.Comparator) FreightAnalyser(net.parostroj.timetable.model.freight.FreightAnalyser) TrainDiagram(net.parostroj.timetable.model.TrainDiagram) JPanel(javax.swing.JPanel) NodeFreight(net.parostroj.timetable.model.freight.NodeFreight) FreightAnalyser(net.parostroj.timetable.model.freight.FreightAnalyser)

Aggregations

BorderLayout (java.awt.BorderLayout)3 Component (java.awt.Component)3 FlowLayout (java.awt.FlowLayout)3 ItemEvent (java.awt.event.ItemEvent)3 Collator (java.text.Collator)3 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 Comparator (java.util.Comparator)3 List (java.util.List)3 Locale (java.util.Locale)3 Collectors (java.util.stream.Collectors)3 BorderFactory (javax.swing.BorderFactory)3 JButton (javax.swing.JButton)3 JComboBox (javax.swing.JComboBox)3 JPanel (javax.swing.JPanel)3 JScrollPane (javax.swing.JScrollPane)3 JTable (javax.swing.JTable)3 AbstractTableModel (javax.swing.table.AbstractTableModel)3 TableCellRenderer (javax.swing.table.TableCellRenderer)3 TableColumnModel (javax.swing.table.TableColumnModel)3