001package jmri.jmrit.timetable.swing;
002
003import java.awt.*;
004import javax.swing.*;
005
006/**
007 * Display a timetable graph.
008 * @author Dave Sand Copyright (c) 2019
009 */
010public class TimeTableDisplayGraph extends JPanel {
011
012    /**
013     * Initialize the data used by paint() and supporting methods when the
014     * panel is displayed.
015     * @param segmentId The segment to be displayed.  For multiple segment
016     * layouts separate graphs are required.
017     * @param scheduleId The schedule to be used for this graph.
018     * @param showTrainTimes When true, include the minutes portion of the
019     * train times at each station.
020     */
021    public TimeTableDisplayGraph(int segmentId, int scheduleId, boolean showTrainTimes) {
022        _segmentId = segmentId;
023        _scheduleId = scheduleId;
024        _showTrainTimes = showTrainTimes;
025    }
026
027    final int _segmentId;
028    final int _scheduleId;
029    final boolean _showTrainTimes;
030    Graphics2D _g2;
031
032    @Override
033    public void paint(Graphics g) {
034        if (g instanceof Graphics2D) {
035            _g2 = (Graphics2D) g;
036        } else {
037            throw new IllegalArgumentException();
038        }
039        Dimension dim = getSize();
040        double dimHeight = dim.getHeight();
041        double dimWidth = dim.getWidth();
042
043        TimeTableGraphCommon graph = new TimeTableGraphCommon();
044        graph.init(_segmentId, _scheduleId, _showTrainTimes, dimHeight, dimWidth, true);
045        graph.doPaint(_g2);
046
047    }
048
049//     private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TimeTableDisplayGraph.class);
050}