Browse Source

checkstyle

Kevin Trometer 7 years ago
parent
commit
d5ddfca829
2 changed files with 92 additions and 49 deletions
  1. 1 0
      src/ui/view/Console.java
  2. 91 49
      src/ui/view/EditEdgesPopUp.java

+ 1 - 0
src/ui/view/Console.java

@@ -79,6 +79,7 @@ public class Console extends JScrollPane {
 
 		// MouseListener
 		consoleText.addMouseListener(new MouseAdapter() {
+			@SuppressWarnings("static-access")
 			@Override
 			public void mouseReleased(MouseEvent e) {
 				if (e.getButton() == e.BUTTON3) {

+ 91 - 49
src/ui/view/EditEdgesPopUp.java

@@ -21,21 +21,29 @@ import ui.controller.Control;
 import java.awt.event.ActionListener;
 import java.awt.event.ActionEvent;
 
-public class EditEdgesPopUp extends JDialog{
+/**
+ * Popup for Editing Edges.
+ * 
+ * @author Gruppe14
+ */
+public class EditEdgesPopUp extends JDialog {
+
+	private static final long serialVersionUID = 1L;
 	private final JPanel contentPanel = new JPanel();
-	private JTextField textField;
-	private final JButton btnOk = new JButton("OK");
 	private JTextField capacityField;
 	private float capacity;
 	private JRadioButton rdbtnChangeForAll;
 	private JRadioButton rdbtnChangeForNew;
-	private JRadioButton rdbtnChangeForAll_1;
+	private JRadioButton rdbtnChangeForAll1;
 	private Control controller;
 	private MyCanvas canvas;
 	private JLabel lblenterinfiniteFor;
-	
+
 	/**
 	 * Launch the application.
+	 * 
+	 * @param args
+	 *            standard
 	 */
 	public static void main(String[] args) {
 		try {
@@ -47,7 +55,10 @@ public class EditEdgesPopUp extends JDialog{
 			e.printStackTrace();
 		}
 	}
-	
+
+	/**
+	 * Constructor.
+	 */
 	public EditEdgesPopUp() {
 		super((java.awt.Frame) null, true);
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
@@ -57,29 +68,29 @@ public class EditEdgesPopUp extends JDialog{
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
 		contentPanel.setLayout(null);
-		
+
 		JLabel lblMaximumCapacity = new JLabel("Maximum Capacity:");
 		lblMaximumCapacity.setFont(new Font("Tahoma", Font.PLAIN, 11));
 		lblMaximumCapacity.setBounds(10, 11, 98, 14);
 		contentPanel.add(lblMaximumCapacity);
-		
+
 		capacityField = new JTextField();
 		capacityField.setBounds(107, 8, 120, 20);
 		contentPanel.add(capacityField);
 		capacityField.setColumns(10);
-		
+
 		rdbtnChangeForAll = new JRadioButton("Change for all existing Edges only");
 		rdbtnChangeForAll.setBounds(10, 39, 265, 23);
 		contentPanel.add(rdbtnChangeForAll);
-		
+
 		rdbtnChangeForNew = new JRadioButton("Change for new created Edges only");
 		rdbtnChangeForNew.setBounds(10, 65, 265, 23);
 		contentPanel.add(rdbtnChangeForNew);
-		
-		rdbtnChangeForAll_1 = new JRadioButton("Change for all existing and new created Edges");
-		rdbtnChangeForAll_1.setBounds(10, 95, 296, 23);
-		contentPanel.add(rdbtnChangeForAll_1);
-		
+
+		rdbtnChangeForAll1 = new JRadioButton("Change for all existing and new created Edges");
+		rdbtnChangeForAll1.setBounds(10, 95, 296, 23);
+		contentPanel.add(rdbtnChangeForAll1);
+
 		JButton btnCancel = new JButton("Cancel");
 		btnCancel.setActionCommand("Cancel");
 		btnCancel.addActionListener(new ActionListener() {
@@ -89,82 +100,113 @@ public class EditEdgesPopUp extends JDialog{
 		});
 		btnCancel.setBounds(285, 147, 89, 23);
 		contentPanel.add(btnCancel);
-		
-		JButton btnOk_1 = new JButton("OK");
-		btnOk_1.addActionListener(new ActionListener() {
+
+		JButton btnOk1 = new JButton("OK");
+		btnOk1.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
-				if(capacityField.getText().equals("infinite")){
+				if (capacityField.getText().equals("infinite")) {
 					capacity = -1;
-					if(rdbtnChangeForAll.isSelected()){
+					if (rdbtnChangeForAll.isSelected()) {
 						changeForExisting(capacity);
 						dispose();
-					}else if (rdbtnChangeForNew.isSelected()){
+					} else if (rdbtnChangeForNew.isSelected()) {
 						changeForNew(capacity);
 						dispose();
-					}else if(rdbtnChangeForAll_1.isSelected()){
+					} else if (rdbtnChangeForAll1.isSelected()) {
 						changeForExAndNew(capacity);
 						dispose();
-					}else{
-						JOptionPane.showMessageDialog(new JFrame(),
-								"Please select one of the options");
+					} else {
+						JOptionPane.showMessageDialog(new JFrame(), "Please select one of the options");
 					}
-				}else{
+				} else {
 					try {
 						capacity = Float.parseFloat(capacityField.getText().toString());
-						if(capacity < 0){
+						if (capacity < 0) {
 							throw new NumberFormatException();
 						}
-						if(rdbtnChangeForAll.isSelected()){
+						if (rdbtnChangeForAll.isSelected()) {
 							changeForExisting(capacity);
 							dispose();
-						}else if (rdbtnChangeForNew.isSelected()){
+						} else if (rdbtnChangeForNew.isSelected()) {
 							changeForNew(capacity);
 							dispose();
-						}else if(rdbtnChangeForAll_1.isSelected()){
+						} else if (rdbtnChangeForAll1.isSelected()) {
 							changeForExAndNew(capacity);
 							dispose();
-						}else{
-							JOptionPane.showMessageDialog(new JFrame(),
-									"Please select one of the options");
+						} else {
+							JOptionPane.showMessageDialog(new JFrame(), "Please select one of the options");
 						}
-					} catch (NumberFormatException e1) {
+					} catch (NumberFormatException eex) {
 						JOptionPane.showMessageDialog(new JFrame(),
-							"Please enter a number greater or equal 0 in the Field for Maximum Capacity");
+								"Please enter a number greater or equal 0 in the Field for Maximum Capacity");
 					}
-				}			}
+				}
+			}
 		});
-		btnOk_1.setBounds(186, 147, 89, 23);
-		contentPanel.add(btnOk_1);
+		btnOk1.setBounds(186, 147, 89, 23);
+		contentPanel.add(btnOk1);
 		this.setTitle("Edit Edge Capacities");
 		ButtonGroup bG = new ButtonGroup();
-		bG.add(rdbtnChangeForAll_1);
+		bG.add(rdbtnChangeForAll1);
 		bG.add(rdbtnChangeForNew);
 		bG.add(rdbtnChangeForAll);
-		
+
 		lblenterinfiniteFor = new JLabel("(enter \"infinite\" for infinite Capacity)");
 		lblenterinfiniteFor.setBounds(237, 11, 175, 14);
 		contentPanel.add(lblenterinfiniteFor);
 	}
-	
-	public void setCanvas(MyCanvas can){
+
+	/**
+	 * Set the Canvas.
+	 * 
+	 * @param can
+	 *            the Canvas
+	 */
+	public void setCanvas(MyCanvas can) {
 		canvas = can;
 	}
-	
-	public void setController(Control cont){
+
+	/**
+	 * set the Controller.
+	 * 
+	 * @param cont
+	 *            the Controller
+	 */
+	public void setController(Control cont) {
 		controller = cont;
 	}
-	
-	public void changeForNew(float cap){
+
+	/**
+	 * set edge capacity for new edges.
+	 * 
+	 * @param cap
+	 *            the capacity
+	 */
+	public void changeForNew(float cap) {
 		canvas.setEdgeCapacity(cap);
 	}
-	public void changeForExisting(float cap){
-		for(CpsEdge edge : controller.getModel().getEdgesOnCanvas()){
+
+	/**
+	 * Set Capacity for all existing Edges.
+	 * 
+	 * @param cap
+	 *            the Capacity
+	 */
+	public void changeForExisting(float cap) {
+		for (CpsEdge edge : controller.getModel().getEdgesOnCanvas()) {
 			edge.setCapacity(cap);
 		}
 		controller.calculateStateForCurrentTimeStep();
 		canvas.repaint();
 	}
-	public void changeForExAndNew(float cap){
+
+	/**
+	 * Set the Capacity for all existing and new edges.
+	 * 
+	 * @param cap
+	 *            the capacity
+	 */
+	public void changeForExAndNew(float cap) {
 		changeForNew(cap);
 		changeForExisting(cap);
 	}