Search in sources :

Example 1 with NodeFreight

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

the class FreightDestinationPanel method addFreightToNodes.

private void addFreightToNodes(DataModel model, NodeFreight nodeFreight) {
    Locale locale = Locale.getDefault();
    Collator collator = Collator.getInstance();
    List<Tuple<String>> lines = nodeFreight.getNodeConnections().stream().filter(e -> e.getTo().isVisible()).map(e -> {
        String node = util.freightNodeToString(e.getTo(), locale, false);
        String trains = util.intervalsToString(diagram, e.getTransport().getTrains(), locale).stream().collect(Collectors.joining(", "));
        return new Tuple<>(node, trains);
    }).sorted(comparator(collator)).collect(Collectors.toList());
    model.addLinesWithEmpty(lines);
}
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) Tuple(net.parostroj.timetable.utils.Tuple) Collator(java.text.Collator)

Example 2 with NodeFreight

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

the class FreightDestinationPanel method addFreightToColors.

private void addFreightToColors(DataModel model, NodeFreight nodeFreight) {
    Locale locale = Locale.getDefault();
    List<Tuple<String>> lines = nodeFreight.getFreightColorConnections().stream().map(e -> {
        String color = util.freightColorsToString(e.getTo(), locale).stream().collect(Collectors.joining(", "));
        String transport = util.transportToString(diagram, e.getTransport(), locale).stream().collect(Collectors.joining(", "));
        return new Tuple<>(color, transport);
    }).collect(Collectors.toList());
    model.addLinesWithEmpty(lines);
}
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) Tuple(net.parostroj.timetable.utils.Tuple)

Example 3 with NodeFreight

use of net.parostroj.timetable.model.freight.NodeFreight 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