/// <summary> /// Sets up the GUI. /// </summary> private void setupGUI() { addWindowListener(this); __descriptionTextField = new JTextField(25); __origDesc = __nodes[__nodeNum].getDescription(); __descriptionTextField.setText(__origDesc); __idTextField = new JTextField(10); __origID = __nodes[__nodeNum].getCommonID(); __idTextField.setText(__origID); __idTextField.addKeyListener(this); __xTextField = new JTextField(10); __origX = StringUtil.formatString(__nodes[__nodeNum].getX(), "%13.6f").Trim(); __xTextField.setText(__origX); __xTextField.addKeyListener(this); __yTextField = new JTextField(10); __origY = StringUtil.formatString(__nodes[__nodeNum].getY(), "%13.6f").Trim(); __yTextField.setText(__origY); __yTextField.addKeyListener(this); __areaTextField = new JTextField(10); __origArea = StringUtil.formatString(__nodes[__nodeNum].getArea(), "%13.6f").Trim(); __areaTextField.setText(__origArea); __areaTextField.addKeyListener(this); __precipitationTextField = new JTextField(10); __origPrecipitation = StringUtil.formatString(__nodes[__nodeNum].getPrecip(), "%13.6f").Trim(); __precipitationTextField.setText(__origPrecipitation); __precipitationTextField.addKeyListener(this); __typeComboBox = new SimpleJComboBox(false); __typeComboBox.add(__NODE_DIVERSION); __typeComboBox.add(__NODE_DIVERSION_AND_WELL); __typeComboBox.add(__NODE_INSTREAM_FLOW); __typeComboBox.add(__NODE_OTHER); __typeComboBox.add(__NODE_PLAN); __typeComboBox.add(__NODE_RESERVOIR); __typeComboBox.add(__NODE_STREAMFLOW); __typeComboBox.add(__NODE_WELL); int type = __nodes[__nodeNum].getType(); if (type == HydrologyNode.NODE_TYPE_CONFLUENCE) { __typeComboBox.select(__NODE_CONFLUENCE); } else if (type == HydrologyNode.NODE_TYPE_DIV) { __typeComboBox.select(__NODE_DIVERSION); } else if (type == HydrologyNode.NODE_TYPE_DIV_AND_WELL) { __typeComboBox.select(__NODE_DIVERSION_AND_WELL); } else if (type == HydrologyNode.NODE_TYPE_END) { __typeComboBox.removeAll(); __typeComboBox.add(__NODE_END); } else if (type == HydrologyNode.NODE_TYPE_ISF) { __typeComboBox.select(__NODE_INSTREAM_FLOW); } else if (type == HydrologyNode.NODE_TYPE_OTHER) { __typeComboBox.select(__NODE_OTHER); } else if (type == HydrologyNode.NODE_TYPE_PLAN) { __typeComboBox.select(__NODE_PLAN); } else if (type == HydrologyNode.NODE_TYPE_RES) { __typeComboBox.select(__NODE_RESERVOIR); } else if (type == HydrologyNode.NODE_TYPE_FLOW) { __typeComboBox.select(__NODE_STREAMFLOW); } else if (type == HydrologyNode.NODE_TYPE_WELL) { __typeComboBox.select(__NODE_WELL); } else if (type == HydrologyNode.NODE_TYPE_XCONFLUENCE) { __typeComboBox.select(__NODE_XCONFLUENCE); } else { __typeComboBox.removeAll(); __typeComboBox.add("Unknown Type: " + type); } __typeComboBox.setMaximumRowCount(__typeComboBox.getItemCount()); __origIType = type; __origType = __typeComboBox.getSelected(); __labelPositionComboBox = new SimpleJComboBox(false); __labelPositionComboBox.add(__ABOVE_CENTER); __labelPositionComboBox.add(__UPPER_RIGHT); __labelPositionComboBox.add(__RIGHT); __labelPositionComboBox.add(__LOWER_RIGHT); __labelPositionComboBox.add(__BELOW_CENTER); __labelPositionComboBox.add(__LOWER_LEFT); __labelPositionComboBox.add(__LEFT); __labelPositionComboBox.add(__UPPER_LEFT); __labelPositionComboBox.add(__CENTER); __labelPositionComboBox.setMaximumRowCount(__labelPositionComboBox.getItemCount()); int dir = __nodes[__nodeNum].getLabelDirection() % 10; if (dir == 2) { __labelPositionComboBox.select(__BELOW_CENTER); } else if (dir == 1) { __labelPositionComboBox.select(__ABOVE_CENTER); } else if (dir == 4) { __labelPositionComboBox.select(__RIGHT); } else if (dir == 3) { __labelPositionComboBox.select(__LEFT); } else if (dir == 7) { __labelPositionComboBox.select(__UPPER_RIGHT); } else if (dir == 8) { __labelPositionComboBox.select(__LOWER_RIGHT); } else if (dir == 5) { __labelPositionComboBox.select(__LOWER_LEFT); } else if (dir == 6) { __labelPositionComboBox.select(__UPPER_LEFT); } else if (dir == 9) { __labelPositionComboBox.select(__CENTER); } else { __labelPositionComboBox.removeAll(); __labelPositionComboBox.add("Unknown Position: " + dir); } __origIDir = dir; __origDir = __labelPositionComboBox.getSelected(); __isNaturalFlowCheckBox = new JCheckBox(); __isImportCheckBox = new JCheckBox(); __origDirty = __nodes[__nodeNum].isDirty(); __reservoirDirectionLabel = new JLabel("Reservoir Direction: "); __reservoirDirectionComboBox = new SimpleJComboBox(false); __reservoirDirectionComboBox.setToolTipText("Reservoir body is to the indicated direction " + "(downstream follows the arrow)."); __reservoirDirectionComboBox.add(__TOP); __reservoirDirectionComboBox.add(__BOTTOM); __reservoirDirectionComboBox.add(__LEFT); __reservoirDirectionComboBox.add(__RIGHT); int resDir = __nodes[__nodeNum].getLabelDirection() / 10; if (resDir == 1) { __reservoirDirectionComboBox.select(__BOTTOM); } else if (resDir == 2) { __reservoirDirectionComboBox.select(__TOP); } else if (resDir == 3) { __reservoirDirectionComboBox.select(__RIGHT); } else if (resDir == 4) { __reservoirDirectionComboBox.select(__LEFT); } else if (resDir == 0) { } else { __reservoirDirectionComboBox.removeAll(); __reservoirDirectionComboBox.add("Unknown direction: " + resDir); } __origResIDir = resDir; __origResDir = __reservoirDirectionComboBox.getSelected(); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); int y = 0; JGUIUtil.addComponent(panel, new JLabel("ID: "), 0, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, __idTextField, 1, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(panel, new JLabel("Type: "), 0, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, __typeComboBox, 1, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(panel, new JLabel("Description: "), 0, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, __descriptionTextField, 1, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(panel, new JLabel("X: "), 0, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, __xTextField, 1, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(panel, new JLabel("Y: "), 0, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, __yTextField, 1, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(panel, new JLabel("Is natural flow?: "), 0, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, __isNaturalFlowCheckBox, 1, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(panel, new JLabel("Is import?: "), 0, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, __isImportCheckBox, 1, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(panel, new JLabel("Area: "), 0, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, __areaTextField, 1, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(panel, new JLabel("Precipitation: "), 0, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, __precipitationTextField, 1, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); if (__nodes[__nodeNum].getIsNaturalFlow()) { __isNaturalFlowCheckBox.setSelected(true); } else { __isNaturalFlowCheckBox.setSelected(false); __areaTextField.setEnabled(false); __precipitationTextField.setEnabled(false); } __isNaturalFlowCheckBox.addActionListener(this); if (__nodes[__nodeNum].getIsImport()) { __isImportCheckBox.setSelected(true); } else { __isImportCheckBox.setSelected(false); } __isImportCheckBox.addActionListener(this); __origNaturalFlow = __isNaturalFlowCheckBox.isSelected(); __origImport = __isImportCheckBox.isSelected(); y++; JGUIUtil.addComponent(panel, new JLabel("Label Position: "), 0, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, __labelPositionComboBox, 1, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(panel, __reservoirDirectionLabel, 0, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, __reservoirDirectionComboBox, 1, y, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; y = addUpstreamNodesToPanel(panel, y); addDownstreamNodeToPanel(panel, y); getContentPane().add(panel); JPanel southPanel = new JPanel(); southPanel.setLayout(new GridBagLayout()); __applyButton = new JButton(__BUTTON_APPLY); __applyButton.addActionListener(this); __okButton = new JButton(__BUTTON_OK); __okButton.addActionListener(this); JButton cancelButton = new JButton(__BUTTON_CANCEL); cancelButton.addActionListener(this); JGUIUtil.addComponent(southPanel, __applyButton, 0, 0, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(southPanel, __okButton, 2, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(southPanel, cancelButton, 3, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); getContentPane().add(southPanel, "South"); pack(); if (__origIType != HydrologyNode.NODE_TYPE_RES) { __reservoirDirectionLabel.setVisible(false); __reservoirDirectionComboBox.setVisible(false); } __typeComboBox.addActionListener(this); if (__parent.inStateModGUI()) { __typeComboBox.setEnabled(false); __precipitationTextField.setEditable(false); __precipitationTextField.removeKeyListener(this); __descriptionTextField.setEditable(false); __descriptionTextField.removeKeyListener(this); __areaTextField.removeKeyListener(this); __areaTextField.setEditable(false); __idTextField.removeKeyListener(this); __idTextField.setEditable(false); __isNaturalFlowCheckBox.setEnabled(false); __isImportCheckBox.setEnabled(false); } JGUIUtil.center(this); setVisible(true); }
/// <summary> /// Sets up the GUI. /// </summary> private void setupGUI() { addWindowListener(this); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); int y = 0; JGUIUtil.addComponent(panel, new JLabel("Text:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, new JLabel("X:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, new JLabel("Y:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, new JLabel("Text Position:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, new JLabel("Font Name:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, new JLabel("Font Size:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(panel, new JLabel("Font Style:"), 0, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); __textTextField = new JTextField(30); __textFieldBackground = __textTextField.getBackground(); __xTextField = new JTextField(15); __yTextField = new JTextField(15); __textPositionComboBox = new SimpleJComboBox(false); string[] positions = GRText.getTextPositions(); __textPositionComboBox.setMaximumRowCount(positions.Length); IList <string> positionsChoices = new List <string>(); for (int i = 0; i < positions.Length; i++) { positionsChoices.Add(positions[i]); } __textPositionComboBox.setData(positionsChoices); __fontNameComboBox = JGUIUtil.newFontNameJComboBox(); __fontSizeTextField = new JTextField(7); __fontStyleComboBox = JGUIUtil.newFontStyleJComboBox(); displayPropListValues(); __textTextField.addKeyListener(this); __xTextField.addKeyListener(this); __yTextField.addKeyListener(this); __fontSizeTextField.addKeyListener(this); __textPositionComboBox.addActionListener(this); __fontNameComboBox.addActionListener(this); __fontStyleComboBox.addActionListener(this); y = 0; JGUIUtil.addComponent(panel, __textTextField, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(panel, __xTextField, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(panel, __yTextField, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(panel, __textPositionComboBox, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(panel, __fontNameComboBox, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(panel, __fontSizeTextField, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(panel, __fontStyleComboBox, 1, y++, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); if (!__editable) { __textTextField.setEditable(false); __xTextField.setEditable(false); __yTextField.setEditable(false); __textPositionComboBox.setEnabled(false); __fontNameComboBox.setEnabled(false); __fontSizeTextField.setEditable(false); __fontStyleComboBox.setEnabled(false); } __applyButton = new JButton(__BUTTON_APPLY); if (__editable) { __applyButton.setToolTipText("Apply changes."); __applyButton.addActionListener(this); } __applyButton.setEnabled(false); JButton cancelButton = new JButton(__BUTTON_CANCEL); cancelButton.setToolTipText("Discard changes and return."); cancelButton.addActionListener(this); __okButton = new JButton(__BUTTON_OK); __okButton.setToolTipText("Accept changes and return."); __okButton.setEnabled(false); __okButton.addActionListener(this); JPanel southPanel = new JPanel(); southPanel.setLayout(new GridBagLayout()); if (__editable) { JGUIUtil.addComponent(southPanel, __applyButton, 0, 0, 1, 1, 1, 1, 0, 10, 0, 10, GridBagConstraints.NONE, GridBagConstraints.EAST); } int space = 0; if (!__editable) { space = 1; } JGUIUtil.addComponent(southPanel, __okButton, 1, 0, 1, 1, space, space, 0, 10, 0, 10, GridBagConstraints.NONE, GridBagConstraints.EAST); if (__editable) { JGUIUtil.addComponent(southPanel, cancelButton, 2, 0, 1, 1, 0, 0, 0, 10, 0, 10, GridBagConstraints.NONE, GridBagConstraints.EAST); } else { __okButton.setEnabled(true); } getContentPane().add("Center", panel); getContentPane().add("South", southPanel); string app = JGUIUtil.getAppNameForWindows(); if (string.ReferenceEquals(app, null) || app.Trim().Equals("")) { app = ""; } else { app += " - "; } setTitle(app + "Node Properties"); pack(); setSize(getWidth() + 100, getHeight()); JGUIUtil.center(this); setVisible(true); }
/// <summary> /// Sets up the GUI. /// </summary> private void setupGUI() { addWindowListener(__parent); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); int y = 0; IList <string> nodeIds = new List <object>(__nodes.Length); for (int i = 0; i < __nodes.Length; i++) { nodeIds.Add(__nodes[i].getCommonID()); } nodeIds.Sort(); JPanel top = new JPanel(); top.setLayout(new GridBagLayout()); JGUIUtil.addComponent(panel, top, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.WEST); y = 0; __node1ComboBox = new SimpleJComboBox(nodeIds); __node1ComboBox.addItemListener(this); __node1ComboBox.addActionListener(this); JGUIUtil.addComponent(top, new JLabel("From node: "), 0, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(top, __node1ComboBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); __node2ComboBox = new SimpleJComboBox(nodeIds); __node2ComboBox.addItemListener(this); __node2ComboBox.addActionListener(this); JGUIUtil.addComponent(top, new JLabel("To node: "), 0, ++y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(top, __node2ComboBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); __linkId_JTextField = new JTextField(10); JGUIUtil.addComponent(top, new JLabel("Link ID: "), 0, ++y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(top, __linkId_JTextField, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); IList <string> lineStyleChoices = new List <object>(); lineStyleChoices.Add("" + GRLineStyleType.DASHED); lineStyleChoices.Add("" + GRLineStyleType.SOLID); __lineStyleComboBox = new SimpleJComboBox(lineStyleChoices); __lineStyleComboBox.addItemListener(this); __lineStyleComboBox.addActionListener(this); JGUIUtil.addComponent(top, new JLabel("Line style: "), 0, ++y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(top, __lineStyleComboBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); IList <string> arrowEndChoices = new List <object>(); arrowEndChoices.Add("" + GRArrowStyleType.NONE); arrowEndChoices.Add("" + GRArrowStyleType.SOLID); __fromArrowStyleComboBox = new SimpleJComboBox(arrowEndChoices); __fromArrowStyleComboBox.addItemListener(this); __fromArrowStyleComboBox.addActionListener(this); JGUIUtil.addComponent(top, new JLabel("Arrow (from) style: "), 0, ++y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(top, __fromArrowStyleComboBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); __toArrowStyleComboBox = new SimpleJComboBox(arrowEndChoices); __toArrowStyleComboBox.addItemListener(this); __toArrowStyleComboBox.addActionListener(this); JGUIUtil.addComponent(top, new JLabel("Arrow (to) style: "), 0, ++y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(top, __toArrowStyleComboBox, 1, y, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JPanel southPanel = new JPanel(); southPanel.setLayout(new GridBagLayout()); __okJButton = new JButton(__BUTTON_OK); __okJButton.addActionListener(this); __okJButton.setEnabled(false); JButton cancelButton = new JButton(__BUTTON_CANCEL); cancelButton.addActionListener(this); JGUIUtil.addComponent(southPanel, __okJButton, 0, 0, 1, 1, 1, 1, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(southPanel, cancelButton, 1, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); getContentPane().add(panel); getContentPane().add(southPanel, "South"); pack(); JGUIUtil.center(this); setVisible(true); }