Improve solution panel.
This commit is contained in:
		| @@ -16,8 +16,6 @@ import javax.swing.JButton; | |||||||
| import javax.swing.JComboBox; | import javax.swing.JComboBox; | ||||||
| import javax.swing.JLabel; | import javax.swing.JLabel; | ||||||
| import javax.swing.JPanel; | import javax.swing.JPanel; | ||||||
| import javax.swing.JTextArea; |  | ||||||
| import javax.swing.UIManager; |  | ||||||
| import javax.swing.border.CompoundBorder; | import javax.swing.border.CompoundBorder; | ||||||
| import javax.swing.border.EmptyBorder; | import javax.swing.border.EmptyBorder; | ||||||
|  |  | ||||||
| @@ -105,12 +103,14 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap | |||||||
|             if (solution.isFeasible()) { |             if (solution.isFeasible()) { | ||||||
|                 Method[] methods = this.solution.getClass().getDeclaredMethods(); |                 Method[] methods = this.solution.getClass().getDeclaredMethods(); | ||||||
|                 for (Method method: methods) { |                 for (Method method: methods) { | ||||||
|                     if (method.getReturnType().equals(Path.class) && method.getParameterCount() == 0) { |                     if (method.getReturnType().equals(Path.class) | ||||||
|  |                             && method.getParameterCount() == 0) { | ||||||
|                         try { |                         try { | ||||||
|                             Path path = (Path) method.invoke(this.solution); |                             Path path = (Path) method.invoke(this.solution); | ||||||
|                             overlays.add(drawing.drawPath(path)); |                             overlays.add(drawing.drawPath(path)); | ||||||
|                         } |                         } | ||||||
|                         catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { |                         catch (IllegalAccessException | IllegalArgumentException | ||||||
|  |                                 | InvocationTargetException e) { | ||||||
|                             // This has been check before, so should never happen... |                             // This has been check before, so should never happen... | ||||||
|                             e.printStackTrace(); |                             e.printStackTrace(); | ||||||
|                         } |                         } | ||||||
| @@ -137,8 +137,7 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap | |||||||
|     // Solution selector |     // Solution selector | ||||||
|     private final JComboBox<SolutionBundle> solutionSelect; |     private final JComboBox<SolutionBundle> solutionSelect; | ||||||
|  |  | ||||||
|     // Map solution -> panel |     private final JLabel informationPanel; | ||||||
|     private final JTextArea informationPanel; |  | ||||||
|  |  | ||||||
|     // Current bundle |     // Current bundle | ||||||
|     private SolutionBundle currentBundle = null; |     private SolutionBundle currentBundle = null; | ||||||
| @@ -154,16 +153,11 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap | |||||||
|         solutionSelect.setAlignmentX(Component.LEFT_ALIGNMENT); |         solutionSelect.setAlignmentX(Component.LEFT_ALIGNMENT); | ||||||
|         add(solutionSelect); |         add(solutionSelect); | ||||||
|  |  | ||||||
|         informationPanel = new JTextArea(); |         informationPanel = new JLabel(); | ||||||
|         informationPanel.setWrapStyleWord(true); |  | ||||||
|         informationPanel.setLineWrap(true); |  | ||||||
|         informationPanel.setOpaque(true); |         informationPanel.setOpaque(true); | ||||||
|         informationPanel.setFocusable(false); |         informationPanel.setFocusable(false); | ||||||
|         informationPanel.setEditable(false); |         // informationPanel.setAlignmentX(JLabel.LEFT_ALIGNMENT); | ||||||
|         informationPanel.setBackground(UIManager.getColor("Label.background")); |         informationPanel.setHorizontalAlignment(JLabel.LEFT); | ||||||
|         informationPanel.setFont(UIManager.getFont("Label.font")); |  | ||||||
|         informationPanel.setBorder(UIManager.getBorder("Label.border")); |  | ||||||
|         informationPanel.setAlignmentX(JLabel.LEFT_ALIGNMENT); |  | ||||||
|  |  | ||||||
|         add(Box.createVerticalStrut(8)); |         add(Box.createVerticalStrut(8)); | ||||||
|         add(informationPanel); |         add(informationPanel); | ||||||
| @@ -244,6 +238,8 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap | |||||||
|  |  | ||||||
|     protected void updateInformationLabel(SolutionBundle bundle) { |     protected void updateInformationLabel(SolutionBundle bundle) { | ||||||
|         informationPanel.setText(bundle.getSolution().toString()); |         informationPanel.setText(bundle.getSolution().toString()); | ||||||
|  |         revalidate(); | ||||||
|  |         repaint(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user