|
From: Johannes Z. <jza...@us...> - 2006-02-23 18:34:51
|
Update of /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4028/src/net/sf/magicmap/client/gui Modified Files: MainGUI.java MapPanel.java Log Message: implemented routines for geo positions Index: MainGUI.java =================================================================== RCS file: /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/gui/MainGUI.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** MainGUI.java 20 Feb 2006 08:49:27 -0000 1.13 --- MainGUI.java 23 Feb 2006 18:34:39 -0000 1.14 *************** *** 160,165 **** toolBar = new JToolBar(); toolBar.setRollover(true); ! toolBar.putClientProperty(com.jgoodies.plaf.plastic.PlasticLookAndFeel.IS_3D_KEY, Boolean.TRUE); ! menuBar.putClientProperty(com.jgoodies.plaf.plastic.PlasticLookAndFeel.IS_3D_KEY, Boolean.TRUE); addMainToolBarButtons(toolBar); --- 160,165 ---- toolBar = new JToolBar(); toolBar.setRollover(true); ! // toolBar.putClientProperty(com.jgoodies.plaf.plastic.PlasticLookAndFeel.IS_3D_KEY, Boolean.TRUE); ! // menuBar.putClientProperty(com.jgoodies.plaf.plastic.PlasticLookAndFeel.IS_3D_KEY, Boolean.TRUE); addMainToolBarButtons(toolBar); Index: MapPanel.java =================================================================== RCS file: /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/gui/MapPanel.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** MapPanel.java 8 Nov 2005 11:24:19 -0000 1.13 --- MapPanel.java 23 Feb 2006 18:34:39 -0000 1.14 *************** *** 18,21 **** --- 18,22 ---- import net.sf.magicmap.client.controller.Controller; + import net.sf.magicmap.client.gui.dialogs.GeoPosDialog; import net.sf.magicmap.client.gui.utils.GUIBuilder; import net.sf.magicmap.client.gui.utils.GUIConstants; *************** *** 29,32 **** --- 30,34 ---- import net.sf.magicmap.client.model.node.AccessPointNode; import net.sf.magicmap.client.model.node.ClientNode; + import net.sf.magicmap.client.model.node.GeoPos; import net.sf.magicmap.client.model.node.LocationNode; import net.sf.magicmap.client.model.node.Node; *************** *** 37,228 **** /** * Komponente des Programmes, welches die Karte verwaltet und ! *auf das NodeModel gesteuert durch Benutzeraktionen zugreift. * * @author thuebner */ ! public class MapPanel extends JPanel ! implements ! MapViewListener, ! CreatePositionCallback, ! DeletePositionCallback, ! PositionCallback, ! MovePositionCallback { ! private MapView mapView; ! private JPopupMenu mapMenu; ! private int lastX; ! private int lastY; ! Node selectedNode; ! private AbstractAction createLocationAction; ! private AbstractAction fetchLocationsAction; ! private MagicAction fixAction; ! private AbstractAction deleteAction; ! private AbstractAction renameAction; ! private AbstractAction propertiesAction; ! private AbstractAction measureLocationAction; ! public Node getSelectedNode(){ ! return selectedNode; ! } ! public MapPanel() { ! super(); ! buildActions(); ! this.setLayout(new BorderLayout()); ! this.setPreferredSize(new Dimension(-1, 450)); ! this.mapView = null; ! this.mapMenu = buildMapMenu(); ! } ! private void buildActions(){ ! createLocationAction = new AbstractAction(GUIUtils.i18n("createlocation")) { ! public void actionPerformed(ActionEvent e){ ! createLocation(); ! } ! }; ! measureLocationAction = new AbstractAction(GUIUtils.i18n("measurelocation")) { ! public void actionPerformed(ActionEvent e){ ! measureLocation(); ! } ! }; ! fetchLocationsAction = new AbstractAction(GUIUtils.i18n("fetchlocations")) { ! public void actionPerformed(ActionEvent e){ ! fetchLocations(); ! } ! }; ! fixAction = new MagicAction("fixated") { ! public void actionPerformed(ActionEvent e){ ! //selectedNode.setFix(!selectedNode.isFix()); ! setFix(!selectedNode.isFix()); ! } ! }; ! deleteAction = new AbstractAction(GUIUtils.i18n("delete"), GUIBuilder.getToolIcon(GUIConstants.ICON_DELETE)) { ! public void actionPerformed(ActionEvent e){ ! //assert (selectedNode != null); ! deleteNode(); ! } ! }; ! renameAction = new AbstractAction(GUIUtils.i18n("rename"), GUIBuilder.getToolIcon(GUIConstants.ICON_RENAME)) { ! public void actionPerformed(ActionEvent e){ ! renameNode(); ! } ! }; ! propertiesAction = new AbstractAction(GUIUtils.i18n("properties"), GUIBuilder ! .getToolIcon(GUIConstants.ICON_PROPERTIES)) { ! public void actionPerformed(ActionEvent e){ ! // TODO Auto-generated method stub ! } ! }; ! } ! private JMenu buildTestMenu(){ ! JMenu menu = new JMenu(GUIUtils.i18n("test")); ! return menu; ! } ! private JPopupMenu buildMapMenu(){ ! JPopupMenu menu = new JPopupMenu(); ! menu.add(buildTestMenu()); ! menu.addSeparator(); ! menu.add(GUIBuilder.createMenuItem(createLocationAction)); ! menu.addSeparator(); ! menu.add(GUIBuilder.createMenuItem(fetchLocationsAction)); ! return menu; ! } ! private JPopupMenu buildNodeMenu(Node node){ ! JPopupMenu menu = new JPopupMenu(); ! // +++++++ TEST +++++++++ ! //menu.add(buildNodeNeighborMenu(node)); ! //menu.add(buildNodeNonNeighborMenu(node)); ! if (node.getType() == NodeModel.NODETYPE_LOCATION) menu.add(GUIBuilder.createMenuItem(measureLocationAction)); ! menu.add(GUIBuilder.createCheckBoxMenuItem(fixAction, node.isFix())); ! menu.addSeparator(); ! // ------- TEST --------- ! menu.add(GUIBuilder.createMenuItem(renameAction)); ! menu.add(GUIBuilder.createMenuItem(deleteAction)); ! menu.addSeparator(); ! menu.add(GUIBuilder.createMenuItem(propertiesAction)); ! deleteAction.setEnabled(node.getType() == NodeModel.NODETYPE_LOCATION); ! renameAction.setEnabled(false); ! propertiesAction.setEnabled(false); ! return menu; ! } ! /* (non-Javadoc) ! * @see net.sf.magicmap.client.interfaces.MapListener#vertexRightClicked(edu.uci.ics.jung.graph.Vertex, int, int) ! */ ! public void nodeRightClicked(Node node, int x, int y){ ! lastX = x; ! lastY = y; ! selectedNode = node; ! selectedNode.setPositionSilent(x, y); ! int ox = mapView.getGraphOffsetX(); ! int oy = mapView.getGraphOffsetY(); ! buildNodeMenu(node).show(this, x + ox, y + oy); ! } ! /* (non-Javadoc) ! * @see net.sf.magicmap.client.interfaces.MapListener#rightClicked(int, int) ! */ ! public void rightClicked(int x, int y){ ! lastX = x; ! lastY = y; ! selectedNode = null; ! int ox = mapView.getGraphOffsetX(); ! int oy = mapView.getGraphOffsetY(); ! mapMenu.show(this, x + ox, y + oy); ! } ! public int getLastX(){ ! return lastX; ! } ! public int getLastY(){ ! return lastY; ! } ! /** ! * Referenzpunkt mit aktuell gemessenen Werten anlegen. Dies ! * geschieht über den Controller, so dass dieser am Server ! * gespeichert werden kann. ! * ! */ ! void createLocation(){ ! String r = JOptionPane.showInputDialog(this, GUIUtils.i18n("locationname")); ! if (r != null){ ! Date date = new Date(); ! String timeAsString = new SimpleDateFormat(Settings.TIME_DATE_FORMAT).format(date); ! /*TODO: WORKAROUND, die Position hat alle nötigen Informationen (Client, der sie angelegt/verändert hat), Zeitpunkt der letzten Änderung, ! * daher sollte die Information über den Client und der Zeitpunkt des Anlegens einer Position !!!NICHT!!! in ihrem Namen gespeichert werden!!!! ! * ! * todo: Hier den Client und den Zeitpunkt aus dem Namen entfernen, Information nur beim Darstellen auf der Karte aus dem PositionDTO nehmen! ! */ ! Controller.getInstance().createLocation(getLastX(), getLastY(), ! (r + " (" + Controller.getInstance().getClient().getName() + ") <" + timeAsString + ">"), true, this); ! } ! } /** --- 39,384 ---- /** * Komponente des Programmes, welches die Karte verwaltet und ! * auf das NodeModel gesteuert durch Benutzeraktionen zugreift. * * @author thuebner */ ! public class MapPanel extends JPanel implements ! MapViewListener, ! CreatePositionCallback, ! DeletePositionCallback, ! PositionCallback, ! MovePositionCallback { ! /** ! * serial version id ! */ ! private static final long serialVersionUID = -2121613388654392917L; ! ! private MapView mapView; ! private JPopupMenu mapMenu; ! private int lastX; ! private int lastY; ! Node selectedNode; ! private AbstractAction createLocationAction; ! private AbstractAction createGeoPosAction; ! private AbstractAction createInfoObjectAction; ! private AbstractAction createRFIDAntennaAction; ! private AbstractAction fetchLocationsAction; ! private MagicAction fixAction; ! private AbstractAction deleteAction; ! private AbstractAction renameAction; ! private AbstractAction propertiesAction; ! private AbstractAction measureLocationAction; ! ! /** ! * Getter for selected node ! * @return the selected node ! */ ! public Node getSelectedNode(){ ! return selectedNode; ! } ! /** ! * Constructor ! */ ! public MapPanel() { ! super(); ! buildActions(); ! this.setLayout(new BorderLayout()); ! this.setPreferredSize(new Dimension(-1, 450)); ! this.mapView = null; ! this.mapMenu = buildMapMenu(); ! } ! ! /** ! * The action building method ! */ ! private void buildActions() { ! ! createLocationAction = new AbstractAction(GUIUtils.i18n("createlocation")) { ! /** ! * serial version id ! */ ! private static final long serialVersionUID = -5950182498648593271L; ! public void actionPerformed(ActionEvent e){ ! createLocation(); ! } ! }; ! ! createGeoPosAction = new AbstractAction(GUIUtils.i18n("creategeopos")) { ! /** ! * serial version id ! */ ! private static final long serialVersionUID = 1L; ! public void actionPerformed(ActionEvent e){ ! createGeoPos(); ! } ! }; ! ! createInfoObjectAction = new AbstractAction(GUIUtils.i18n("createinfoobject")) { ! /** ! * serial version id ! */ ! private static final long serialVersionUID = 1L; ! public void actionPerformed(ActionEvent e){ ! createInfoObject(); ! } ! }; ! ! createRFIDAntennaAction = new AbstractAction(GUIUtils.i18n("createrfidantenna")) { ! /** ! * serial version id ! */ ! private static final long serialVersionUID = 1L; ! public void actionPerformed(ActionEvent e){ ! createRFIDAntenna(); ! } ! }; ! measureLocationAction = new AbstractAction(GUIUtils.i18n("measurelocation")) { ! /** ! * serial version id ! */ ! private static final long serialVersionUID = 7431846299555207166L; ! public void actionPerformed(ActionEvent e){ ! measureLocation(); ! } ! }; ! fetchLocationsAction = new AbstractAction(GUIUtils.i18n("fetchlocations")) { ! /** ! * serial version id ! */ ! private static final long serialVersionUID = -3428721448067681186L; ! public void actionPerformed(ActionEvent e){ ! fetchLocations(); ! } ! }; ! fixAction = new MagicAction("fixated") { ! /** ! * serial version id ! */ ! private static final long serialVersionUID = 2039840191048447633L; ! public void actionPerformed(ActionEvent e){ ! //selectedNode.setFix(!selectedNode.isFix()); ! setFix(!selectedNode.isFix()); ! } ! }; ! deleteAction = new AbstractAction(GUIUtils.i18n("delete"), GUIBuilder.getToolIcon(GUIConstants.ICON_DELETE)) { ! /** ! * serial version ! */ ! private static final long serialVersionUID = 6412040207867763736L; ! public void actionPerformed(ActionEvent e){ ! //assert (selectedNode != null); ! deleteNode(); ! } ! }; ! renameAction = new AbstractAction(GUIUtils.i18n("rename"), GUIBuilder.getToolIcon(GUIConstants.ICON_RENAME)) { ! /** ! * serial version id ! */ ! private static final long serialVersionUID = 8740256818963533442L; ! public void actionPerformed(ActionEvent e){ ! renameNode(); ! } ! }; ! propertiesAction = new AbstractAction(GUIUtils.i18n("properties"), GUIBuilder.getToolIcon(GUIConstants.ICON_PROPERTIES)) { ! /** ! * serial version id ! */ ! private static final long serialVersionUID = -8194784366560052071L; ! public void actionPerformed(ActionEvent e){ ! // TODO Auto-generated method stub ! } ! }; ! } ! /** ! * @deprecated ! * @return ! */ ! private JMenu buildTestMenu() { ! JMenu menu = new JMenu(GUIUtils.i18n("test")); ! return menu; ! } ! ! /** ! * ! * @return ! */ ! private JPopupMenu buildMapMenu() { ! JPopupMenu menu = new JPopupMenu(); ! menu.add(buildTestMenu()); ! menu.addSeparator(); ! menu.add(GUIBuilder.createMenuItem(createLocationAction)); ! menu.add(GUIBuilder.createMenuItem(createGeoPosAction)); ! // menu.add(GUIBuilder.createMenuItem(createInfoObjectAction)); ! // menu.add(GUIBuilder.createMenuItem(createRFIDAntennaAction)); ! menu.addSeparator(); ! menu.add(GUIBuilder.createMenuItem(fetchLocationsAction)); ! return menu; ! } ! /** ! * ! * @param node ! * @return ! */ ! private JPopupMenu buildNodeMenu(Node node) { ! JPopupMenu menu = new JPopupMenu(); ! // +++++++ TEST +++++++++ ! //menu.add(buildNodeNeighborMenu(node)); ! //menu.add(buildNodeNonNeighborMenu(node)); ! if (node.getType() == NodeModel.NODETYPE_LOCATION) menu.add(GUIBuilder.createMenuItem(measureLocationAction)); ! menu.add(GUIBuilder.createCheckBoxMenuItem(fixAction, node.isFix())); ! menu.addSeparator(); ! // ------- TEST --------- ! menu.add(GUIBuilder.createMenuItem(renameAction)); ! menu.add(GUIBuilder.createMenuItem(deleteAction)); ! menu.addSeparator(); ! menu.add(GUIBuilder.createMenuItem(propertiesAction)); ! deleteAction.setEnabled(node.getType() == NodeModel.NODETYPE_LOCATION); ! renameAction.setEnabled(false); ! propertiesAction.setEnabled(false); ! return menu; ! } ! /* (non-Javadoc) ! * @see net.sf.magicmap.client.interfaces.MapListener#vertexRightClicked(edu.uci.ics.jung.graph.Vertex, int, int) ! */ ! public void nodeRightClicked(Node node, int x, int y){ ! lastX = x; ! lastY = y; ! selectedNode = node; ! selectedNode.setPositionSilent(x, y); ! int ox = mapView.getGraphOffsetX(); ! int oy = mapView.getGraphOffsetY(); ! buildNodeMenu(node).show(this, x + ox, y + oy); ! } ! /* (non-Javadoc) ! * @see net.sf.magicmap.client.interfaces.MapListener#rightClicked(int, int) ! */ ! public void rightClicked(int x, int y){ ! lastX = x; ! lastY = y; ! selectedNode = null; ! int ox = mapView.getGraphOffsetX(); ! int oy = mapView.getGraphOffsetY(); ! mapMenu.show(this, x + ox, y + oy); ! } ! /** ! * ! * @return ! */ ! public int getLastX(){ ! return lastX; ! } ! /** ! * ! * @return ! */ ! public int getLastY(){ ! return lastY; ! } ! /** ! * Referenzpunkt mit aktuell gemessenen Werten anlegen. Dies ! * geschieht über den Controller, so dass dieser am Server ! * gespeichert werden kann. ! * ! */ ! void createLocation() { ! String r = JOptionPane.showInputDialog(this, GUIUtils.i18n("locationname")); ! if (r != null){ ! Date date = new Date(); ! String timeAsString = new SimpleDateFormat(Settings.TIME_DATE_FORMAT).format(date); ! /*TODO: WORKAROUND, die Position hat alle nötigen Informationen (Client, der sie angelegt/verändert hat), Zeitpunkt der letzten Änderung, ! * daher sollte die Information über den Client und der Zeitpunkt des Anlegens einer Position !!!NICHT!!! in ihrem Namen gespeichert werden!!!! ! * ! * todo: Hier den Client und den Zeitpunkt aus dem Namen entfernen, Information nur beim Darstellen auf der Karte aus dem PositionDTO nehmen! ! */ ! Controller.getInstance().createLocation(getLastX(), getLastY(), ! (r + " (" + Controller.getInstance().getClient().getName() + ") <" + timeAsString + ">"), true, this); ! } ! } ! /** ! * Create a geo pos for the current selected location ! * ! */ ! void createGeoPos() { ! GeoPos geoPos = GeoPosDialog.showDialog(MainGUI.getInstance()); ! if (geoPos != null) { ! Controller.getInstance().createGeoPos(getLastX(), getLastY(), geoPos, ! Controller.getInstance().getCurrentMap().name, true, this); ! } ! } ! ! /** ! * Create an info object for the current selected location ! * ! */ ! void createInfoObject() { ! String r = JOptionPane.showInputDialog(this, GUIUtils.i18n("locationname")); ! if (r != null){ ! Date date = new Date(); ! String timeAsString = new SimpleDateFormat(Settings.TIME_DATE_FORMAT).format(date); ! /*TODO: WORKAROUND, die Position hat alle nötigen Informationen (Client, der sie angelegt/verändert hat), Zeitpunkt der letzten Änderung, ! * daher sollte die Information über den Client und der Zeitpunkt des Anlegens einer Position !!!NICHT!!! in ihrem Namen gespeichert werden!!!! ! * ! * todo: Hier den Client und den Zeitpunkt aus dem Namen entfernen, Information nur beim Darstellen auf der Karte aus dem PositionDTO nehmen! ! */ ! Controller.getInstance().createLocation(getLastX(), getLastY(), ! (r + " (" + Controller.getInstance().getClient().getName() + ") <" + timeAsString + ">"), true, this); ! } ! } ! ! ! /** ! * Create an info object for the current selected location ! * ! */ ! void createRFIDAntenna() { ! String r = JOptionPane.showInputDialog(this, GUIUtils.i18n("locationname")); ! if (r != null){ ! Date date = new Date(); ! String timeAsString = new SimpleDateFormat(Settings.TIME_DATE_FORMAT).format(date); ! ! /*TODO: WORKAROUND, die Position hat alle nötigen Informationen (Client, der sie angelegt/verändert hat), Zeitpunkt der letzten Änderung, ! * daher sollte die Information über den Client und der Zeitpunkt des Anlegens einer Position !!!NICHT!!! in ihrem Namen gespeichert werden!!!! ! * ! * todo: Hier den Client und den Zeitpunkt aus dem Namen entfernen, Information nur beim Darstellen auf der Karte aus dem PositionDTO nehmen! ! */ ! Controller.getInstance().createLocation(getLastX(), getLastY(), ! (r + " (" + Controller.getInstance().getClient().getName() + ") <" + timeAsString + ">"), true, this); ! } ! } ! /** |