@Override public void actionPerformed(ActionEvent e) { try { boolean status = false; final String nombreCapa = e.getActionCommand(); for (Layer l : getAllLayers()) { if (l.name.indexOf(nombreCapa) == 0) { l.visible = !l.visible; status = l.visible; updateMarkers(); } } // vehiculos_visibles // personas_visibles // incidencias_visibles String capa_incidences = Internacionalization.getString("Incidences.incidences"); String capa_vehiculos = Internacionalization.getString("Resources.resources.vehicles"); String capa_people = Internacionalization.getString("Resources.resources.people"); Usuario u = UsuarioConsultas.find(Authentication.getUsuario().getNombreUsuario()); if (u != null) { if (nombreCapa.equalsIgnoreCase(capa_incidences)) u.setIncidenciasVisibles(status); else if (nombreCapa.equalsIgnoreCase(capa_vehiculos)) u.setVehiculosVisibles(status); else if (nombreCapa.equalsIgnoreCase(capa_people)) u.setPersonasVisibles(status); UsuarioAdmin.saveOrUpdate(u); } } catch (Throwable t) { log.error("Error actualizando el estado de la capa", t); } }
private void updateIncidences(final LatLon topleft, final LatLon bottomright) { MarkerLayer layer = null; // tomar las capas vehiculo y persona for (Layer l : getAllLayers()) { if (l.name.equals(Internacionalization.getString("Incidences.incidences"))) { layer = (MarkerLayer) l; break; } } if (layer == null) return; List<Incidencia> allres = IncidenciaConsultas.getOpened(); Collection<Marker> nuevoData = new LinkedList<Marker>(); for (Incidencia i : allres) { try { if (i.getGeometria() != null) { final com.vividsolutions.jts.geom.Point centroid = i.getGeometria().getCentroid(); if (centroid != null) { LatLon latlon = new LatLon(centroid.getCoordinate().y, centroid.getCoordinate().x); WayPoint w = new WayPoint(latlon); w.attr.put("name", i.getTitulo() + " (" + i.getPrioridad() + ")"); w.attr.put( "symbol", LogicConstants.get("DIRECTORIO_ICONOS_INCIDENCIAS", "incidencia/") + "incidencia_" + i.getEstado().toString() + "_" + i.getCategoria().toString() + "_" + i.getPrioridad().toString()); w.attr.put( "color", LogicConstants.get("COLOR_ESTADO_INC_" + i.getEstado().getId(), "#000000")); CustomMarker<Long, Incidencia> marker = new CustomMarker<Long, Incidencia>(w, layer, i.getId(), Type.INCIDENCE); marker.setObject(i); nuevoData.add(marker); } } } catch (Throwable t) { log.error("Error al intentar pintar una incidencia", t); } } layer.data = nuevoData; }
public CustomMapView() { super(); menu = new MainMenu(); contentPane.add(panel, BorderLayout.CENTER); // iniciar los controles mostrar/ocultar capas layerControls = new LinkedList<JToggleButton>(); JToggleButton botonMostrarOcultarBotones = new JToggleButton( Internacionalization.getString("map.layers.hideButtons"), LogicConstants.getIcon("capas_button_mostrar"), false); botonMostrarOcultarBotones.setSelected(true); botonMostrarOcultarBotones.setActionCommand("#hide"); // b.setVerticalTextPosition(SwingConstants.BOTTOM); // b.setHorizontalTextPosition(SwingConstants.CENTER); botonMostrarOcultarBotones.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JToggleButton b = (JToggleButton) e.getSource(); if (e.getActionCommand().equals("#hide")) { layerControlPanel.removeAll(); layerControlPanel.add(Box.createHorizontalStrut(10)); layerControlPanel.add(b); b.setActionCommand("#show"); b.setText(Internacionalization.getString("map.layers.showButtons")); } else { layerControlPanel.removeAll(); layerControlPanel.add(Box.createHorizontalStrut(10)); for (JToggleButton bt : layerControls) { layerControlPanel.add(bt); layerControlPanel.add(Box.createHorizontalGlue()); } b.setActionCommand("#hide"); b.setText(Internacionalization.getString("map.layers.hideButtons")); } layerControlPanel.updateUI(); } }); layerControls.add(botonMostrarOcultarBotones); final JToggleButton botonTodoasLasCapas = new JToggleButton( Internacionalization.getString("map.layers.allLayers"), LogicConstants.getIcon("capas_button_mostrar"), false); layerDialog = new LayerSelectionDialog(this); layerDialog.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { botonTodoasLasCapas.setSelected(false); } }); botonTodoasLasCapas.setSelected(false); botonTodoasLasCapas.setActionCommand("#all"); // all.setVerticalTextPosition(SwingConstants.BOTTOM); // all.setHorizontalTextPosition(SwingConstants.CENTER); botonTodoasLasCapas.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { layerDialog.setLocationRelativeTo((Component) e.getSource()); layerDialog.setVisible(!layerDialog.isShowing()); } }); layerControls.add(botonTodoasLasCapas); layerControlPanel = new JPanel(); layerControlPanel.setLayout(new BoxLayout(layerControlPanel, BoxLayout.X_AXIS)); Main.main.menu = this.menu; toolbar = new ToolbarPreferences(); toolbar.refreshToolbarControl(); // toolbar.control.updateUI(); // contentPane.add(toolbar.control, BorderLayout.NORTH); contentPane.updateUI(); panel.updateUI(); }
private void updateResources(final LatLon topleft, final LatLon bottomright) { MarkerLayer people = null, vehicles = null; // tomar las capas vehiculo y persona for (Layer l : getAllLayers()) { if (l.name.equalsIgnoreCase(Internacionalization.getString("Resources.resources.people"))) { people = (MarkerLayer) l; } if (l.name.equalsIgnoreCase(Internacionalization.getString("Resources.resources.vehicles"))) { vehicles = (MarkerLayer) l; } if (people != null && vehicles != null) { break; } } if (getParent() instanceof MapViewer) { // actualizar los recursos // disponibles ((MapViewer) getParent()).updateControls(); } List<Recurso> allres = RecursoConsultas.getAll(Authentication.getUsuario()); boolean peopleShowing = people != null && people.visible; boolean vehiclesShowing = vehicles != null && vehicles.visible; Collection<Marker> peop = new LinkedList<Marker>(); Collection<Marker> veh = new LinkedList<Marker>(); for (Recurso r : allres) { HistoricoGPS h = r.getHistoricoGps(); if (h == null) { continue; } WayPoint w = new WayPoint(new LatLon(h.getPosY(), h.getPosX())); String name = r.getNombre(); if (r.getPatrullas() != null) name += " (" + r.getPatrullas().getNombre() + ")"; w.attr.put("name", name); w.attr.put( "symbol", LogicConstants.get("DIRECTORIO_ICONOS_FLOTAS") + "/" + r.getFlotas().getJuegoIconos()); // w.attr.put("color", LogicConstants.get("COLOR_ESTADO_REC_" // + r.getEstadoEurocop().getId(), "#000000")); if (peopleShowing && r.getTipo().equalsIgnoreCase(Recurso.PERSONA)) { CustomMarker<String, Recurso> marker = new CustomMarker<String, Recurso>(w, people, r.getIdentificador(), Type.RESOURCE); marker.setObject(r); peop.add(marker); } else if (vehiclesShowing && r.getTipo().equalsIgnoreCase(Recurso.VEHICULO)) { CustomMarker<String, Recurso> marker = new CustomMarker<String, Recurso>(w, vehicles, r.getIdentificador(), Type.RESOURCE); marker.setObject(r); veh.add(marker); } } if (people != null) { people.data = peop; } if (vehicles != null) { vehicles.data = veh; } }