package nl.tudelft.simulation.dsol.swing.gui; import java.awt.Color; import java.awt.Toolkit; import javax.swing.JEditorPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ScrollPaneConstants; import nl.tudelft.simulation.dsol.model.DSOLModel; import nl.tudelft.simulation.dsol.model.inputparameters.InputParameter; import nl.tudelft.simulation.dsol.model.inputparameters.InputParameterMap; /** * InputParametersTab displays the input parameters in a ScrollPane. *

* Copyright (c) 2021-2021 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See * for project information DSOL Manual. The DSOL * project is distributed under a three-clause BSD-style license, which can be found at * DSOL License. *

* @author Alexander Verbraeck */ public class InputParametersTab extends JPanel { /** */ private static final long serialVersionUID = 1L; /** The parameter map. */ @SuppressWarnings("checkstyle:visibilitymodifier") protected final InputParameterMap inputParameterMap; /** * Create an InputParametersTab for the given simulation model. * @param model DSOLModel; the model. */ public InputParametersTab(final DSOLModel model) { this.inputParameterMap = model.getInputParameterMap(); JEditorPane textPane = new JEditorPane("text/html", ""); textPane.setOpaque(true); textPane.setBackground(Color.WHITE); textPane.setEditable(true); textPane.setPreferredSize(Toolkit.getDefaultToolkit().getScreenSize()); JScrollPane scrollPane = new JScrollPane(textPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); add(scrollPane); StringBuilder textBuilder = new StringBuilder(); textBuilder.append("\n"); textBuilder.append(makeHead()); textBuilder.append(makeBody()); textBuilder.append("\n"); textPane.setText(textBuilder.toString()); } /** * Return the head portion of the HTML page to display the parameter map. * @return String; the head portion of the HTML page to display the parameter map */ protected String makeHead() { StringBuilder textBuilder = new StringBuilder(); textBuilder.append(" \n"); textBuilder.append(" \n"); textBuilder.append(" \n"); return textBuilder.toString(); } /** * Return the body portion of the HTML page to display the parameter map. * @return String; the body portion of the HTML page to display the parameter map */ protected String makeBody() { StringBuilder textBuilder = new StringBuilder(); textBuilder.append(" \n

Parameters


\n"); for (InputParameter tab : this.inputParameterMap.getSortedSet()) { textBuilder.append("\n
\n

" + tab.getDescription() + "

\n"); InputParameterMap tabbedMap = (InputParameterMap) tab; for (InputParameter parameter : tabbedMap.getSortedSet()) { textBuilder.append(" " + parameter.toString() + "
\n"); } } textBuilder.append(" \n"); return textBuilder.toString(); } }