Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.17 KB | None | 0 0
  1. import javax.swing.*;
  2. import javax.swing.event.*;
  3. import javax.swing.filechooser.*;
  4. import java.awt.*;
  5. import java.awt.List;
  6. import java.awt.event.*;
  7. import java.io.*;
  8. import java.util.*;
  9. import java.io.*;
  10.  
  11. class MapArea extends JPanel {
  12.  
  13. private ImageIcon mapPicture;
  14.  
  15. public MapArea(String fileName) {
  16. mapPicture = new ImageIcon(fileName);
  17. setLayout(null);
  18. int mapPictureWidth = mapPicture.getIconWidth();
  19. int mapPictureHeight = mapPicture.getIconHeight();
  20. setPreferredSize(new Dimension(mapPictureWidth, mapPictureHeight));
  21. setMaximumSize(new Dimension(mapPictureWidth, mapPictureHeight));
  22. setMinimumSize(new Dimension(mapPictureWidth, mapPictureHeight));
  23. }
  24.  
  25. public void updateMap(String fileName) {
  26. mapPicture = new ImageIcon(fileName);
  27. int mapPictureWidth = mapPicture.getIconWidth();
  28. int mapPictureHeight = mapPicture.getIconHeight();
  29. setPreferredSize(new Dimension(mapPictureWidth, mapPictureHeight));
  30. setMaximumSize(new Dimension(mapPictureWidth, mapPictureHeight));
  31. setMinimumSize(new Dimension(mapPictureWidth, mapPictureHeight));
  32. }
  33.  
  34.  
  35.  
  36. protected void paintComponent(Graphics g) {
  37. super.paintComponent(g);
  38.  
  39. g.drawImage(mapPicture.getImage(), 0, 0, this);
  40.  
  41. }
  42.  
  43. }
  44.  
  45. public class MapProgram extends JFrame {
  46.  
  47. private ArrayList<Place> listOfSavePlaces = new ArrayList<Place>();
  48. private HashMap<Position, Place> listOfPlaces = new HashMap<Position, Place>();
  49. private Set<Place> listOfSelectedPlaces = new HashSet<Place>();
  50.  
  51. private HashMap<String, ArrayList<Place>> listOfNameSortedPlaces = new HashMap<String, ArrayList<Place>>();
  52. private HashMap<String, ArrayList<Place>> listOfCathegorySortedPlaces = new HashMap<String, ArrayList<Place>>();
  53.  
  54. private final String[] categories = { "Bus", "Underground", "Train" };
  55. private JMenuBar menuBar;
  56. private JRadioButton namedPlaceButton;
  57. private JRadioButton describedPlaceButton;
  58. private JTextField searchBox;
  59. private JButton searchButton;
  60. private JButton hideButton;
  61. private JButton removeButton;
  62. private JButton coordinatesButton;
  63. private JButton newPlaceButton;
  64. private JList<String> categoryList;
  65. private JButton hideCategoryButton;
  66. private String lastLoadedFile = null;
  67. private MapArea picArea;
  68. private boolean checkSave = false;
  69. public File fileChoser(Boolean save) {
  70. JFileChooser fileChooser = new JFileChooser();
  71. int answer;
  72. if (save == true) {
  73. answer = fileChooser.showSaveDialog(MapProgram.this);
  74. } else {
  75. answer = fileChooser.showOpenDialog(MapProgram.this);
  76. }
  77. if (answer == fileChooser.APPROVE_OPTION) {
  78. File f = fileChooser.getSelectedFile();
  79.  
  80. return f;
  81. }
  82. return null;
  83. }
  84.  
  85. public MapProgram() {
  86.  
  87. JPanel eastPanel = new JPanel();
  88. JPanel northPanel = new JPanel();
  89.  
  90. setLayout(new BorderLayout());
  91. menuBar = new JMenuBar();
  92. northPanel.add(menuBar);
  93.  
  94. JMenu archiveMenu = new JMenu("Archive");
  95. menuBar.add(archiveMenu);
  96.  
  97. JMenuItem newMapItem = new JMenuItem("New map");
  98. archiveMenu.add(newMapItem);
  99. newMapItem.addActionListener(new ArchiveChoice());
  100.  
  101. JMenuItem loadPlaceItem = new JMenuItem("Load places");
  102. archiveMenu.add(loadPlaceItem);
  103. loadPlaceItem.addActionListener(new ArchiveChoice());
  104.  
  105. JMenuItem saveItem = new JMenuItem("Save");
  106. archiveMenu.add(saveItem);
  107. saveItem.addActionListener(new ArchiveChoice());
  108.  
  109. JMenuItem exitItem = new JMenuItem("Exit");
  110. archiveMenu.add(exitItem);
  111. exitItem.addActionListener(new ArchiveChoice());
  112.  
  113. northPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
  114. add(northPanel, BorderLayout.NORTH);
  115.  
  116. newPlaceButton = new JButton("new");
  117. northPanel.add(newPlaceButton);
  118. newPlaceButton.addActionListener(new NewPlace());
  119.  
  120. namedPlaceButton = new JRadioButton("Name", true);
  121. northPanel.add(namedPlaceButton);
  122.  
  123. describedPlaceButton = new JRadioButton("Described");
  124. northPanel.add(describedPlaceButton);
  125.  
  126. ButtonGroup buttonGroup = new ButtonGroup();
  127.  
  128. buttonGroup.add(namedPlaceButton);
  129. buttonGroup.add(describedPlaceButton);
  130.  
  131. searchBox = new JTextField("Search");
  132. northPanel.add(searchBox);
  133.  
  134. searchButton = new JButton("search");
  135. searchButton.addActionListener(new SearchListener());
  136. northPanel.add(searchButton);
  137.  
  138. hideButton = new JButton("hide");
  139. hideButton.addActionListener(new HideListener());
  140. northPanel.add(hideButton);
  141.  
  142. removeButton = new JButton("remove");
  143. removeButton.addActionListener(new RemoveListener());
  144. northPanel.add(removeButton);
  145.  
  146. coordinatesButton = new JButton("coordinates");
  147. coordinatesButton.addActionListener(new CoordListener());
  148. northPanel.add(coordinatesButton);
  149.  
  150. eastPanel.setLayout(new BoxLayout(eastPanel, BoxLayout.Y_AXIS));
  151. add(eastPanel, BorderLayout.EAST);
  152.  
  153. categoryList = new JList<String>(categories);
  154. categoryList.addListSelectionListener(new ListListener());
  155. categoryList.addMouseListener(new MouseAdapter() {
  156. int lastInList;
  157. public void mouseClicked(MouseEvent e) {
  158. int i = categoryList.locationToIndex(e.getPoint());
  159.  
  160. if (i != -1 && i == lastInList) {
  161. categoryList.clearSelection();
  162. }
  163. lastInList = categoryList.getSelectedIndex();
  164.  
  165. }
  166. });
  167. eastPanel.add(new JLabel("Cathegories"));
  168. eastPanel.add(categoryList);
  169.  
  170. hideCategoryButton = new JButton("Hide Category");
  171. hideCategoryButton.addActionListener(new HideCathegoryListener());
  172. eastPanel.add(hideCategoryButton);
  173. setJMenuBar(menuBar);
  174. setSize(550, 400);
  175. setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  176. addWindowListener(new WindowAdapter() {
  177. public void windowClosing(WindowEvent e) {
  178. confirmClose();
  179. }
  180. });
  181.  
  182. setLocationRelativeTo(null);
  183. setVisible(true);
  184.  
  185. }
  186.  
  187. class ArchiveChoice implements ActionListener {
  188. public void actionPerformed(ActionEvent ave) {
  189.  
  190. System.out.println(ave.getActionCommand());
  191. String choice = ave.getActionCommand();
  192.  
  193. switch (choice) {
  194.  
  195. case "New map":
  196. newMap();
  197.  
  198. break;
  199.  
  200. case "Load places":
  201. loadPlacesToMap();
  202. break;
  203.  
  204. case "Save":
  205.  
  206. savePlaces();
  207.  
  208. break;
  209.  
  210. case "Exit":
  211.  
  212. confirmClose();
  213. break;
  214.  
  215. }
  216.  
  217. }
  218. }
  219.  
  220. private boolean saveWindow(boolean exit) {
  221. JPanel formPanel = new JPanel();
  222.  
  223. int formAnswer = JOptionPane.showConfirmDialog(MapProgram.this, formPanel, "Do you want to save? ",
  224. JOptionPane.YES_NO_CANCEL_OPTION);
  225.  
  226. if (formAnswer == JOptionPane.YES_OPTION) {
  227. if (savePlaces()) {
  228. return true;
  229. }
  230. return false;
  231.  
  232. } else if (formAnswer == JOptionPane.NO_OPTION) {
  233. if(exit==true){
  234. System.exit(0);
  235. }
  236. } else if (formAnswer == JOptionPane.CANCEL_OPTION) {
  237. return false;
  238. }
  239. return true;
  240. }
  241.  
  242. private void confirmClose() {
  243. if (lastLoadedFile == null && listOfPlaces.isEmpty()) {
  244. System.exit(0);
  245. } else if (lastLoadedFile == null && !listOfPlaces.isEmpty()) {
  246. if(saveWindow(true)) {
  247. System.exit(0);
  248. }
  249. }
  250.  
  251. else if (checkSave == true) {
  252. if(saveWindow(true)) {
  253. System.exit(0);
  254. }
  255.  
  256. } else {
  257. System.exit(0);
  258. }
  259. }
  260.  
  261. private boolean checkSave() {
  262. HashMap<Position, Place> saveListOfPlaces = new HashMap<Position, Place>();
  263. FileReader infile = null;
  264.  
  265. try {
  266. infile = new FileReader(lastLoadedFile);
  267.  
  268. BufferedReader in = new BufferedReader(infile);
  269. String line;
  270.  
  271. while ((line = in.readLine()) != null) {
  272. String[] data = line.split(",");
  273.  
  274. String sort = data[0];
  275. String cath = data[1];
  276. int X = Integer.parseInt(data[2]);
  277. int Y = Integer.parseInt(data[3]);
  278. String name = data[4];
  279. String desc = null;
  280. if (data.length == 6) {
  281. desc = data[5];
  282. }
  283. if (sort.equals("Named")) {
  284. Position p = new Position(X, Y);
  285. NamedPlace n = new NamedPlace(name, cath, p);
  286. saveListOfPlaces.put(p, n);
  287.  
  288. }
  289.  
  290. else if (sort.equals("Described")) {
  291. Position p = new Position(X, Y);
  292. DescribedPlace d = new DescribedPlace(name, cath, p, desc);
  293. saveListOfPlaces.put(p, d);
  294.  
  295. }
  296. }
  297. infile.close();
  298. in.close();
  299.  
  300. } catch (FileNotFoundException e) {
  301.  
  302. e.printStackTrace();
  303. errorMessage("File not found");
  304. } catch (IOException e) {
  305. e.printStackTrace();
  306. errorMessage("Error ");
  307.  
  308. }
  309. boolean b = false;
  310. return b;
  311. }
  312.  
  313. private void newMap() {
  314. boolean b = true;
  315. if (lastLoadedFile == null && listOfPlaces.isEmpty()) {
  316.  
  317. } else if (lastLoadedFile == null && !listOfPlaces.isEmpty()) {
  318. b = saveWindow(false);
  319. } else if (checkSave) {
  320. b = saveWindow(false);
  321. }
  322. if (b == true) {
  323. File f = fileChoser(false);
  324. if (f != null) {
  325. emptyMaps();
  326. if (picArea == null) {
  327. picArea = new MapArea(f.getAbsolutePath());
  328. add(picArea, BorderLayout.CENTER);
  329. JScrollPane scroll = new JScrollPane(picArea);
  330. add(scroll, BorderLayout.CENTER);
  331. pack();
  332. validate();
  333. } else {
  334. picArea.updateMap(f.getAbsolutePath());
  335. lastLoadedFile = null;
  336. repaint();
  337. pack();
  338. validate();
  339. }
  340. }
  341. }
  342.  
  343. }
  344.  
  345.  
  346. private void emptyMaps() {
  347. listOfSavePlaces.clear();
  348. listOfPlaces.clear();
  349. if (picArea != null) {
  350. picArea.removeAll();
  351. }
  352. listOfSelectedPlaces.clear();
  353. listOfNameSortedPlaces.clear();
  354. listOfCathegorySortedPlaces.clear();
  355. }
  356.  
  357. private void loadPlacesToMap() {
  358. boolean checkSave = true;
  359. boolean b = true;
  360. if (lastLoadedFile == null && listOfPlaces.isEmpty()) {
  361.  
  362. } else if (lastLoadedFile == null && !listOfPlaces.isEmpty()) {
  363. b = saveWindow(false);
  364. } else if (checkSave) {
  365. b = saveWindow(false);
  366. }
  367.  
  368. if (b == true) {
  369. File l = fileChoser(false);
  370. if (l != null) {
  371. lastLoadedFile = l.getAbsolutePath();
  372. FileReader infile = null;
  373.  
  374. try {
  375.  
  376. emptyMaps();
  377. infile = new FileReader(l.getAbsolutePath());
  378.  
  379. BufferedReader in = new BufferedReader(infile);
  380. String line;
  381.  
  382. while ((line = in.readLine()) != null) {
  383. String[] data = line.split(",");
  384.  
  385. String sort = data[0];
  386. String category = data[1];
  387. int x = Integer.parseInt(data[2]);
  388. int y = Integer.parseInt(data[3]);
  389. String name = data[4];
  390. String description = null;
  391. if (data.length == 6) {
  392. description = data[5];
  393. }
  394. if (sort.equals("Named")) {
  395. Position p = new Position(x, y);
  396. NamedPlace n = new NamedPlace(name, category, p);
  397.  
  398. addToLists(n);
  399.  
  400. }
  401.  
  402. else if (sort.equals("Described")) {
  403. Position p = new Position(x, y);
  404. DescribedPlace d = new DescribedPlace(name, category, p, description);
  405.  
  406. addToLists(d);
  407. }
  408. }
  409. infile.close();
  410. in.close();
  411. }
  412.  
  413. catch (FileNotFoundException e) {
  414. errorMessage("File not found ");
  415. e.printStackTrace();
  416.  
  417. } catch (IOException e) {
  418. errorMessage("Error ");
  419. e.printStackTrace();
  420.  
  421. }
  422. }
  423. }
  424. }
  425.  
  426. private boolean savePlaces() {
  427. File l = fileChoser(true);
  428. if (l != null) {
  429. lastLoadedFile = l.getAbsolutePath();
  430.  
  431. try {
  432.  
  433. FileWriter utfil = new FileWriter(l.getAbsolutePath());
  434. PrintWriter out = new PrintWriter(utfil);
  435.  
  436. for(int i = 0; i < listOfSavePlaces.size(); i++){
  437. String add = "";
  438. Place tmp = listOfSavePlaces.get(i);
  439. DescribedPlace d = null;
  440. if (tmp instanceof DescribedPlace) {
  441. d = (DescribedPlace) tmp;
  442. add += "Described";
  443. add += ",";
  444. add += d.returnCath();
  445. add += ",";
  446. add += d.returnX();
  447. add += ",";
  448. add += d.returnY();
  449. add += ",";
  450. add += d.returnName();
  451. add += ",";
  452. add += d.returnDesc();
  453. out.println(add);
  454. } else if (tmp instanceof NamedPlace) {
  455. add += "Named";
  456. add += ",";
  457. add += tmp.returnCath();
  458. add += ",";
  459. add += tmp.returnX();
  460. add += ",";
  461. add += tmp.returnY();
  462. add += ",";
  463. add += tmp.returnName();
  464. out.println(add);
  465. }
  466. }
  467.  
  468.  
  469. out.close();
  470. checkSave = false;
  471. return true;
  472.  
  473. } catch (FileNotFoundException e) {
  474.  
  475. e.printStackTrace();
  476. errorMessage("File not found ");
  477. } catch (IOException e) {
  478.  
  479. e.printStackTrace();
  480. errorMessage("Error ");
  481. }
  482. }
  483. return false;
  484. }
  485.  
  486.  
  487. class NewPlace implements ActionListener {
  488. public void actionPerformed(ActionEvent ave) {
  489. if (picArea != null) {
  490. MouseListener mouseListener = new MouseListener();
  491.  
  492. picArea.addMouseListener(mouseListener);
  493. picArea.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
  494. }
  495. }
  496.  
  497. }
  498.  
  499. class MouseListener extends MouseAdapter {
  500. @Override
  501. public void mouseClicked(MouseEvent mev) {
  502. picArea.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
  503. openPlaceForm(categoryList.getSelectedValue(), mev.getX(), mev.getY());
  504.  
  505. picArea.removeMouseListener(this);
  506.  
  507. }
  508. }
  509.  
  510. class GlobalListener extends MouseAdapter {
  511. @Override
  512. public void mouseClicked(MouseEvent mev) {
  513.  
  514. if(mev.getSource() instanceof Place){
  515. Place p = (Place)mev.getSource();
  516. if(mev.getButton() == 1){
  517. if (p.returnSelected()) {
  518. p.setSelected(false);
  519. } else if (p.returnSelected() == false) {
  520. p.setSelected(true);
  521. }
  522. }
  523. if(mev.getButton() == 3 && p.returnVisible()){
  524. if (p instanceof NamedPlace) {
  525. String displayMessage = "X: " + p.returnX() + "Y: " + p.returnY();
  526. JOptionPane.showMessageDialog(MapProgram.this, displayMessage);
  527. } else {
  528. String displayMessage = "X: " + p.returnX() + "Y: " + p.returnY() + "\n"
  529. + ((DescribedPlace) p).returnDesc();
  530. JOptionPane.showMessageDialog(MapProgram.this, displayMessage);
  531.  
  532. }
  533. }
  534. }
  535.  
  536. repaint();
  537. }
  538. }
  539. class ClickListner implements ActionListener{
  540. public void actionPerformed(ActionEvent ave){
  541.  
  542. }
  543. }
  544.  
  545. class HideListener implements ActionListener {
  546. public void actionPerformed(ActionEvent ave) {
  547. for(Place p: listOfSelectedPlaces){
  548. if (p.returnSelected()) {
  549. p.setVisible(false);
  550. p.setSelected(false);
  551. listOfPlaces.put(p.getPosition(), p);
  552. listOfSelectedPlaces.add(p);
  553. listOfSavePlaces.add(p);
  554. }
  555.  
  556.  
  557. }
  558.  
  559. repaint();
  560. }
  561.  
  562. }
  563.  
  564. class HideCathegoryListener implements ActionListener {
  565. public void actionPerformed(ActionEvent ave) {
  566. String choice = "";
  567.  
  568. if (listOfCathegorySortedPlaces.get(categoryList.getSelectedValue()) != null) {
  569. choice = categoryList.getSelectedValue();
  570. setVisible(choice);
  571. repaint();
  572. }
  573. }
  574.  
  575. }
  576.  
  577. public void setVisible(String nyckelNamn){
  578. listOfCathegorySortedPlaces.get(nyckelNamn).forEach(Place -> Place.setVisible(false));
  579. }
  580.  
  581.  
  582. class RemoveListener implements ActionListener {
  583. public void actionPerformed(ActionEvent ave) {
  584. checkSave = true;
  585. ArrayList<Place> tempList = new ArrayList<Place>();
  586. for(Place p: listOfSelectedPlaces){
  587. if(p.returnSelected()==true){
  588. listOfNameSortedPlaces.get(p.returnName()).remove(p);
  589. listOfCathegorySortedPlaces.get(p.returnCath()).remove(p);
  590. picArea.remove(p);
  591. tempList.add(p);
  592. }
  593. }
  594. listOfSelectedPlaces.removeAll(tempList);
  595. tempList.clear();
  596. repaint();
  597. }
  598. }
  599.  
  600. class CoordListener implements ActionListener {
  601. public void actionPerformed(ActionEvent ave) {
  602. openCoordForm();
  603. }
  604. }
  605.  
  606. class SearchListener implements ActionListener {
  607. public void actionPerformed(ActionEvent ave) {
  608.  
  609. if (listOfNameSortedPlaces.get(searchBox.getText()) != null) {
  610. for (Place p : listOfNameSortedPlaces.get(searchBox.getText())) {
  611. p.setVisible(true);
  612. p.setSelected(true);
  613. listOfPlaces.put(p.getPosition(), p);
  614. listOfSavePlaces.add(p);
  615.  
  616.  
  617. listOfSelectedPlaces.add(p);
  618. }
  619. }
  620. repaint();
  621. }
  622. }
  623.  
  624. class ListListener implements ListSelectionListener {
  625. public void valueChanged(ListSelectionEvent event) {
  626. if (!event.getValueIsAdjusting()) {
  627. if (picArea != null) {
  628.  
  629. String selected = "";
  630.  
  631. if (listOfCathegorySortedPlaces.get(categoryList.getSelectedValue()) != null) {
  632. selected = categoryList.getSelectedValue().toString();
  633.  
  634. for (Place p : listOfCathegorySortedPlaces.get(selected)) {
  635. p.setVisible(true);
  636. listOfPlaces.put(p.getPosition(), p);
  637. listOfSavePlaces.add(p);
  638. listOfSelectedPlaces.add(p);
  639.  
  640. }
  641. repaint();
  642. }
  643. }
  644. }
  645. }
  646. }
  647.  
  648. private void openCoordForm() {
  649. try {
  650. CoordForm form = new CoordForm();
  651. int formsAnswer = JOptionPane.showConfirmDialog(MapProgram.this, form, "Input",
  652. JOptionPane.OK_CANCEL_OPTION);
  653.  
  654. boolean notFound = true;
  655.  
  656. if (formsAnswer != JOptionPane.OK_OPTION) {
  657. return;
  658. } else {
  659. Position po = new Position(form.returnX(), form.returnY());
  660. if (listOfPlaces.containsKey(po)) {
  661. Place p = listOfPlaces.get(po);
  662. p.setSelected(true);
  663. p.setVisible(true);
  664. listOfPlaces.put(po, p);
  665. listOfSavePlaces.add(p);
  666. listOfSelectedPlaces.add(p);
  667. notFound = false;
  668. repaint();
  669. }
  670. }
  671. if (notFound) {
  672. JOptionPane.showMessageDialog(MapProgram.this, "There is nothing on the entered coordinates");
  673.  
  674. }
  675.  
  676. } catch (NumberFormatException e) {
  677. errorMessage("Error, wrong type of data entered ");
  678. }
  679. }
  680.  
  681. private void openPlaceForm(String category, int musX, int musY) {
  682. try {
  683. boolean descB = false;
  684. descB = describedPlaceButton.isSelected();
  685. PlaceForm form = new PlaceForm(descB);
  686. int formAnswer = JOptionPane.showConfirmDialog(MapProgram.this, form, "Input",
  687. JOptionPane.OK_CANCEL_OPTION);
  688. String placeName;
  689. String description;
  690.  
  691. if (formAnswer != JOptionPane.OK_OPTION) {
  692. return;
  693.  
  694. } else {
  695. placeName = form.getName();
  696.  
  697. }
  698. Position coord = new Position(musX, musY);
  699. if(category == null){
  700. category="None";
  701. }
  702. if (describedPlaceButton.isSelected()) {
  703. description = form.getDesc();
  704. DescribedPlace d = new DescribedPlace(placeName, category, coord, description);
  705. addToLists(d);
  706. }
  707.  
  708. else {
  709. NamedPlace n = new NamedPlace(placeName, category, coord);
  710. addToLists(n);
  711. }
  712. repaint();
  713. } catch (NumberFormatException e) {
  714. errorMessage("Error, wrong type of data entered ");
  715. }
  716. }
  717.  
  718. private void addToLists(Place p) {
  719. checkSave = true;
  720. GlobalListener g = new GlobalListener();
  721. picArea.add(p);
  722. p.addMouseListener(g);
  723. listOfPlaces.put(p.getPosition(), p);
  724. listOfSavePlaces.add(p);
  725. listOfSelectedPlaces.add(p);
  726.  
  727. if (listOfNameSortedPlaces.containsKey(p.returnName())) {
  728. listOfNameSortedPlaces.get(p.returnName()).add(p);
  729.  
  730. } else {
  731. ArrayList<Place> h = new ArrayList<Place>();
  732. h.add(p);
  733. listOfNameSortedPlaces.put(p.returnName(), h);
  734.  
  735. }
  736.  
  737. if (listOfCathegorySortedPlaces.containsKey(p.returnCath())) {
  738. listOfCathegorySortedPlaces.get(p.returnCath()).add(p);
  739.  
  740.  
  741. } else {
  742. ArrayList<Place> h = new ArrayList<Place>();
  743. h.add(p);
  744. listOfCathegorySortedPlaces.put(p.returnCath(), h);
  745.  
  746. }
  747. repaint();
  748. }
  749.  
  750. private void errorMessage(String msg) {
  751.  
  752. JOptionPane.showMessageDialog(MapProgram.this, msg);
  753.  
  754. }
  755.  
  756. public static void main(String[] args) {
  757.  
  758. MapProgram m = new MapProgram();
  759. m.pack();
  760.  
  761. }
  762. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement