瀏覽代碼

Fixes an ArrayOutOfBoundsException and removes Panel from ElementPopUp

Andreas T. Meyer-Berg 6 年之前
父節點
當前提交
3f1ef8830b
共有 2 個文件被更改,包括 3 次插入10 次删除
  1. 1 8
      src/ui/view/AddElementPopUp.java
  2. 2 2
      src/ui/view/UnitGraph.java

+ 1 - 8
src/ui/view/AddElementPopUp.java

@@ -45,8 +45,6 @@ public class AddElementPopUp extends JDialog {
 	private JTextField flexibleEnergy;
 	/** Flexible if checkbox is checked */
 	JCheckBox checkboxFlexible;
-	/** Panel for the Graph */
-	JPanel panelGraph;
 	/** Model which is used */
 	private Model model;
 
@@ -58,7 +56,7 @@ public class AddElementPopUp extends JDialog {
 		super((java.awt.Frame) null, true);
 		this.setIconImage(Util.loadImage(this, "/Images/Dummy_House.png", 30, 30));
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
-		setBounds(100, 100, 400, 515);
+		setBounds(100, 100, 400, 245);
 		setLocationRelativeTo(parentFrame);
 		getContentPane().setLayout(new BorderLayout());
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
@@ -133,11 +131,6 @@ public class AddElementPopUp extends JDialog {
 		amount.setColumns(10);
 		amount.setText("1");
 
-		/* Add Graph Panel */
-		panelGraph = new JPanel();
-		panelGraph.setBounds(12, 157, 358, 263);
-		contentPanel.add(panelGraph);
-
 		/* Add Buttons and Actions */
 		JPanel buttonPane = new JPanel();
 		buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));

+ 2 - 2
src/ui/view/UnitGraph.java

@@ -138,8 +138,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
                                     + 2 + border,
                             this.getHeight() - 10);
                 } else {
-                    g2.drawString("" + arrayOfFloats[model.getCurIteration()],
-                            (model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
+                    g2.drawString("" + arrayOfFloats[model.getCurIteration()%model.getGraphIterations()],
+                            (model.getCurIteration()%model.getGraphIterations()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
                                     + border - textWidth,
                             this.getHeight() - 10);
                 }