Author: chatellier Date: 2009-11-23 15:03:22 +0000 (Mon, 23 Nov 2009) New Revision: 2771 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CellSelectionLayer.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Coordinate.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CopyMapToClipboardListener.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMap.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapInfo.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapList.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultDataMap.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultScale.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/IsisMapBean.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Motif.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ResultatLayer.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Scale.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties Log: Add new maps file formats management. Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CellSelectionLayer.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CellSelectionLayer.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CellSelectionLayer.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -219,9 +219,9 @@ * receiving events in "select" mode. * <code> * <pre> - * return new String[1] { + * return new String[1] { * SelectMouseMode.modeID - * }; + * }; * </pre> * <code> * @see NavMouseMode#modeID Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Coordinate.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Coordinate.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Coordinate.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -18,17 +18,22 @@ package fr.ifremer.isisfish.map; +import java.awt.geom.Point2D; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + /** - * Coordinate. + * Coordinate extends Float point to add serialisation implementation. * * Created: Mon Apr 22 16:49:52 2002 * * @author <a href="mailto:seb.regnier at free.fr"></a> * @version $Revision$ */ -public class Coordinate extends java.awt.geom.Point2D.Float implements java.io.Serializable { - - /** serialVersionUID */ +public class Coordinate extends Point2D.Float implements Serializable { + + /** serialVersionUID. */ private static final long serialVersionUID = 1L; public Coordinate() { @@ -39,15 +44,15 @@ super(latitude, longitude); } - private void writeObject(java.io.ObjectOutputStream stream) - throws java.io.IOException { + protected void writeObject(ObjectOutputStream stream) + throws java.io.IOException { stream.writeFloat(x); stream.writeFloat(y); } - private void readObject(java.io.ObjectInputStream stream) - throws java.io.IOException { + protected void readObject(ObjectInputStream stream) + throws java.io.IOException { x = stream.readFloat(); y = stream.readFloat(); } -}// Coordinate +} // Coordinate Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CopyMapToClipboardListener.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CopyMapToClipboardListener.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CopyMapToClipboardListener.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -43,7 +43,7 @@ import com.bbn.openmap.event.MapMouseListener; /** - * Listener for openmap map bean to display popop menu on rigth clic. + * Listener for openmap map bean to display popop menu on right click. * * Currently, this listener can : * - copy current map to system clip board Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMap.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMap.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMap.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -31,7 +31,7 @@ * @author <a href="mailto:seb.regnier at free.fr"></a> * @version $Revision$ */ -public interface DataMap extends Serializable{ +public interface DataMap extends Serializable { /** * Get the coordinates of the Cells position of the DataMap on the map. @@ -51,4 +51,4 @@ */ public DataMapInfo getInfo(); -}// DataMap +} // DataMap Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapInfo.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapInfo.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapInfo.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -20,7 +20,6 @@ import java.io.Serializable; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; /** @@ -33,7 +32,7 @@ */ public class DataMapInfo implements Serializable { - /** serialVersionUID */ + /** serialVersionUID. */ private static final long serialVersionUID = -8530276186766231164L; protected List<String> labels = new ArrayList<String>(); @@ -51,9 +50,9 @@ public String getLabels() { String str = ""; - for (Iterator i = labels.iterator(); i.hasNext();) { - str += (String) i.next(); + for (String label : labels) { + str += label; } return str; } -}// DataMapInfo +} // DataMapInfo Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapList.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapList.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapList.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -19,7 +19,9 @@ package fr.ifremer.isisfish.map; import java.io.Serializable; +import java.util.ArrayList; import java.util.Enumeration; +import java.util.List; import java.util.Vector; import org.apache.commons.logging.Log; @@ -78,7 +80,7 @@ * * @return Enumeration */ - public Enumeration getDataMaps() { + public Enumeration<DataMap> getDataMaps() { return dataMap.elements(); } @@ -87,8 +89,8 @@ * @param c ? * @return Get all the data map of this list */ - public Vector getDataMaps(Coordinate c) { - Vector<DataMap> v = new Vector<DataMap>(); + public List<DataMap> getDataMaps(Coordinate c) { + List<DataMap> v = new ArrayList<DataMap>(); DataMap dm; for (Object aDataMap : dataMap) { dm = (DataMap) aDataMap; @@ -171,8 +173,8 @@ */ public double getMaxDataMapValue() { double max = 0; - for (Enumeration enu = dataMap.elements(); enu.hasMoreElements();) { - max = Math.max(max, ((DataMap) enu.nextElement()).getValue()); + for (Enumeration<DataMap> enu = dataMap.elements(); enu.hasMoreElements();) { + max = Math.max(max, enu.nextElement().getValue()); } return max; } @@ -182,8 +184,8 @@ */ public double getMinDataMapValue() { double min = 0; - for (Enumeration enu = dataMap.elements(); enu.hasMoreElements();) { - min = Math.min(min, ((DataMap) enu.nextElement()).getValue()); + for (Enumeration<DataMap> enu = dataMap.elements(); enu.hasMoreElements();) { + min = Math.min(min, enu.nextElement().getValue()); } return min; } @@ -194,8 +196,8 @@ public double getPositiveMinDataMapValue() { double min = 0; double tmp; - for (Enumeration enu = dataMap.elements(); enu.hasMoreElements();) { - tmp = Math.min(min, ((DataMap) enu.nextElement()).getValue()); + for (Enumeration<DataMap> enu = dataMap.elements(); enu.hasMoreElements();) { + tmp = Math.min(min, enu.nextElement().getValue()); if (tmp > 0) { min = tmp; } @@ -223,11 +225,11 @@ scale = new DefaultScale(getMaxDataMapValue()); } DataMap datamap; - for (Enumeration enu = getDataMaps(); enu.hasMoreElements();) { - datamap = (DataMap) enu.nextElement(); + for (Enumeration<DataMap> enu = getDataMaps(); enu.hasMoreElements();) { + datamap = enu.nextElement(); motif.createOMDataMap(proj, omlist, scale, datamap); } } return omlist; } -}// DataMapList +} // DataMapList Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultDataMap.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultDataMap.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultDataMap.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -26,10 +26,9 @@ * @author <a href="mailto:seb.regnier at free.fr"></a> * @version $Revision$ */ - public class DefaultDataMap implements DataMap { - /** serialVersionUID */ + /** serialVersionUID. */ private static final long serialVersionUID = 3277576798583867731L; protected double value; @@ -86,9 +85,10 @@ String[] lat = latitudes.trim().split(" "); String[] lon = longitudes.trim().split(" "); coordinates = new Coordinate[lat.length]; - for (int i = 0; i < lat.length; i++) + for (int i = 0; i < lat.length; i++) { coordinates[i] = new Coordinate(Float.parseFloat(lat[i]), Float .parseFloat(lon[i])); + } } /** @@ -99,8 +99,9 @@ */ public void setCoordinates(float[] latitudes, float[] longitudes) { coordinates = new Coordinate[latitudes.length]; - for (int i = 0; i < latitudes.length; i++) + for (int i = 0; i < latitudes.length; i++) { coordinates[i] = new Coordinate(latitudes[i], longitudes[i]); + } } /** Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultScale.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultScale.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultScale.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -21,16 +21,14 @@ /** * DefaultScale.java * - * * Created: Mon Apr 22 16:52:17 2002 * * @author <a href="mailto:seb.regnier at free.fr"></a> * @version $Revision$ */ - public class DefaultScale implements Scale { - /** serialVersionUID */ + /** serialVersionUID. */ private static final long serialVersionUID = -3348731042237607596L; public double min; @@ -98,4 +96,4 @@ return Math.sqrt(scale); } -}// DefaultScale +} // DefaultScale Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/IsisMapBean.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/IsisMapBean.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/IsisMapBean.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -21,16 +21,17 @@ import static org.nuiton.i18n.I18n._; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Properties; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; -import org.nuiton.util.Resource; import com.bbn.openmap.BufferedMapBean; import com.bbn.openmap.LatLonPoint; @@ -41,7 +42,12 @@ import com.bbn.openmap.event.MapMouseMode; import com.bbn.openmap.event.NavMouseMode; import com.bbn.openmap.layer.GraticuleLayer; +import com.bbn.openmap.layer.dted.DTEDLayer; +import com.bbn.openmap.layer.e00.E00Layer; +import com.bbn.openmap.layer.mif.MIFLayer; +import com.bbn.openmap.layer.rpf.RpfLayer; import com.bbn.openmap.layer.shape.ShapeLayer; +import com.bbn.openmap.layer.vpf.VPFLayer; import com.bbn.openmap.omGraphics.DrawingAttributes; import fr.ifremer.isisfish.IsisFish; @@ -80,7 +86,7 @@ protected List<MapMouseListener> orderedListener = new ArrayList<MapMouseListener>(); protected LayerHandler layerHandler = new LayerHandler(); - protected MapMouseMode currentMouseMode;// = new SelectMouseMode(false); + protected MapMouseMode currentMouseMode; protected MouseDelegator md; protected CellSelectionLayer activeSelectionLayer = null; @@ -88,39 +94,39 @@ protected static final float SCALE = 9500000f; - public IsisMapBean (){ + public IsisMapBean() { init(); setActiveMouseMode(new NavMouseMode()); } - protected void init(){ + protected void init() { setScale(SCALE); // Let the LayerHandler know who is interested in Layers. //MapBean is just one component layerHandler.addLayerListener(this); md = new MouseDelegator(this); - // md.addMouseMode(selectMouseMode); + // md.addMouseMode(selectMouseMode); // Tell the delegator to use the default modes: Navigation // and Selection md.setDefaultMouseModes(); } - public void setActiveMouseMode(MapMouseMode mode){ + public void setActiveMouseMode(MapMouseMode mode) { md.setActiveMouseMode(mode); currentMouseMode = mode; // il faut remettre les listeners - for(MapMouseListener l: orderedListener){ + for (MapMouseListener l : orderedListener) { currentMouseMode.addMapMouseListener(l); } } - public void addMapMouseListener(MapMouseListener mml){ - if (mml instanceof CellSelectionLayer || mml instanceof ResultatLayer){ + public void addMapMouseListener(MapMouseListener mml) { + if (mml instanceof CellSelectionLayer || mml instanceof ResultatLayer) { // faut que certain listener soit toujours en premier orderedListener.add(0, mml); currentMouseMode.removeAllMapMouseListeners(); - for(MapMouseListener l: orderedListener){ + for (MapMouseListener l : orderedListener) { currentMouseMode.addMapMouseListener(l); } } else { @@ -129,21 +135,22 @@ } } - public void removeMapMouseListener(MapMouseListener mml){ + public void removeMapMouseListener(MapMouseListener mml) { currentMouseMode.removeMapMouseListener(mml); } /** - * Get the value of region. - * @return value of region. - */ + * Get the value of region. + * @return value of region. + */ public FisheryRegion getFisheryRegion() { return fisheryRegion; } public void setFisheryRegion(FisheryRegion fisheryRegion) { - if(log.isDebugEnabled()){ - log.debug("current fishery is now: " + fisheryRegion + " old was: " + this.fisheryRegion); + if (log.isDebugEnabled()) { + log.debug("current fishery is now: " + fisheryRegion + " old was: " + + this.fisheryRegion); } try { @@ -152,7 +159,7 @@ if (fisheryRegion == null) { layerHandler.removeAll(); } else { - if(!fisheryRegion.equals(oldFisheryRegion)){ + if (!fisheryRegion.equals(oldFisheryRegion)) { pasMailleLatitude = fisheryRegion.getCellLengthLatitude(); pasMailleLongitude = fisheryRegion.getCellLengthLongitude(); minLatitude = fisheryRegion.getMinLatitude(); @@ -162,17 +169,18 @@ initMap(); } } - } catch(Exception eee) { + } catch (Exception eee) { if (log.isErrorEnabled()) { log.error("Impossible d'initialiser la Region", eee); } } } - + protected TopiaContext getTopiaContext() { TopiaContext result = getFisheryRegion().getTopiaContext(); if (result == null) { - throw new IsisFishRuntimeException("Can't get topiaContext from FisheryRegion"); + throw new IsisFishRuntimeException( + "Can't get topiaContext from FisheryRegion"); } return result; } @@ -182,19 +190,20 @@ } /** - * Retourne la liste des mailles selectionnées + * Retourne la liste des mailles selectionnées. + * + * @return selected map list */ - public List<Cell> getSelectedCells(){ + public List<Cell> getSelectedCells() { try { List<Cell> result = new ArrayList<Cell>(); List<LatLonPoint> pts = activeSelectionLayer.getSelected(); - for(LatLonPoint llp: pts){ + for (LatLonPoint llp : pts) { List<Cell> cells = null; - try{ - cells = getCellDAO().findAllByProperties( - "latitude", llp.getLatitude(), - "longitude", llp.getLongitude()); - } catch (TopiaException eee){ + try { + cells = getCellDAO().findAllByProperties("latitude", + llp.getLatitude(), "longitude", llp.getLongitude()); + } catch (TopiaException eee) { log.warn("Can't find cell for this point: " + llp, eee); } if (cells != null && cells.size() > 0) { @@ -210,50 +219,52 @@ } } - public void setSelectedCells(List<Cell> cells){ - if (cells != null){ + public void setSelectedCells(List<Cell> cells) { + if (cells != null) { setSelectedCells(cells.toArray(new Cell[cells.size()])); } else { setSelectedCells(); } } - public void setSelectedCells(Cell ... cells) { - if(log.isDebugEnabled()){ + public void setSelectedCells(Cell... cells) { + if (log.isDebugEnabled()) { log.debug("Select cells: " + Arrays.toString(cells)); } activeSelectionLayer.unSelectAll(); addSelectedCells(cells); } - public void addSelectedCells(Cell ... cells) { - if(log.isDebugEnabled()){ + public void addSelectedCells(Cell... cells) { + if (log.isDebugEnabled()) { log.debug("add select cells: " + Arrays.toString(cells)); } - for(Cell cell: cells){ + for (Cell cell : cells) { if (cell != null) { - activeSelectionLayer.select( - (cell.getLatitude() + cell.getLatitude() + pasMailleLatitude) / 2f, - (cell.getLongitude() + cell.getLongitude() + pasMailleLongitude) / 2f); - } + activeSelectionLayer.select((cell.getLatitude() + + cell.getLatitude() + pasMailleLatitude) / 2f, (cell + .getLongitude() + + cell.getLongitude() + pasMailleLongitude) / 2f); + } } } - public void removeSelectedCells(Cell ... cells) { - if(log.isDebugEnabled()){ + public void removeSelectedCells(Cell... cells) { + if (log.isDebugEnabled()) { log.debug("remove select cells: " + Arrays.toString(cells)); } - for(Cell cell: cells){ - activeSelectionLayer.unSelect( - (cell.getLatitude() + cell.getLatitude() + pasMailleLatitude) / 2f, - (cell.getLongitude() + cell.getLongitude() + pasMailleLongitude) / 2f); + for (Cell cell : cells) { + activeSelectionLayer.unSelect((cell.getLatitude() + + cell.getLatitude() + pasMailleLatitude) / 2f, (cell + .getLongitude() + + cell.getLongitude() + pasMailleLongitude) / 2f); } } /** - * Get the value of layerHandler. - * @return value of layerHandler. - */ + * Get the value of layerHandler. + * @return value of layerHandler. + */ public LayerHandler getLayerHandler() { return layerHandler; } @@ -266,60 +277,284 @@ public void removeAllResultatLayer() { Layer[] layers = layerHandler.getLayers(); - for(int i = 0; i < layers.length; i++){ - if ( layers[i] instanceof ResultatLayer){ - removeMapMouseListener((MapMouseListener)layers[i]); + for (int i = 0; i < layers.length; i++) { + if (layers[i] instanceof ResultatLayer) { + removeMapMouseListener((MapMouseListener) layers[i]); layerHandler.removeLayer(layers[i]); } } } + /** + * Add a new layer to the map depending on mapFile extension. + * + * @param layerId layer id + * @param mapFile absolute map fail path + * @param lineColor line color + * @param fillColor fill color + */ + protected void addLayer(String layerId, String mapFile, String lineColor, + String fillColor) { + Layer layer = null; + // get layer depending on type + if (mapFile.endsWith(".shp")) { + layer = getShapeLayer(layerId, mapFile, lineColor, fillColor); + } + else if (mapFile.endsWith(".e00")) { + layer = getE00Layer(layerId, mapFile, lineColor, fillColor); + } + else if (mapFile.endsWith(".mif")) { + layer = getMIFLayer(layerId, mapFile, lineColor, fillColor); + } + else if (mapFile.endsWith(".rpf") || mapFile.endsWith(".cadrg") || mapFile.endsWith(".cib")) { + layer = getRPFLayer(layerId, mapFile, lineColor, fillColor); + } + else if (mapFile.endsWith(".vmap") || mapFile.endsWith(".dcw") || mapFile.endsWith(".vpf")) { + layer = getVPFLayer(layerId, mapFile, lineColor, fillColor); + } + /*else if (mapFile.endsWith(".dt0")) { + layer = getDTEDLayer(layerId, mapFile, lineColor, fillColor); + }*/ + else { + if (log.isErrorEnabled()) { + log.error("Can't find layer for " + mapFile + " (unknown type)"); + } + } + + // display layer + if (layer != null) { + if (log.isDebugEnabled()) { + log.debug("Add layer " + layer); + } + layerHandler.addLayer(layer); + } + } + /** - * Add a ShapeLayer to the Map. - */ - protected void addShapeLayer(String id, - String shapeFile, String spatialIndex, - String lineColor, String fillColor) { + * Manage shp layer display. + * + * @param layerId layer id + * @param mapFile absolute map fail path + * @param lineColor line color + * @param fillColor fill color + * + * @return shape layer + * @see ShapeLayer + */ + protected Layer getShapeLayer(String layerId, String mapFile, String lineColor, + String fillColor) { + + if (log.isDebugEnabled()) { + log.debug("Get ShapeLayer with filename : " + mapFile); + } + + ShapeLayer shapeLayer = new ShapeLayer(); Properties p = new Properties(); - p.setProperty(id+"."+ShapeLayer.shapeFileProperty, shapeFile); - // unneeded with openmap 4.6.5 - //p.setProperty(id+"."+ShapeLayer.spatialIndexProperty, spatialIndex); - p.setProperty(id+"."+DrawingAttributes.linePaintProperty, lineColor); - p.setProperty(id+"."+DrawingAttributes.fillPaintProperty, fillColor); - ShapeLayer slayer = new ShapeLayer(); - slayer.setProperties(id, p); - slayer.setName(id); - layerHandler.addLayer(slayer); + p.setProperty(layerId + "." + ShapeLayer.shapeFileProperty, mapFile); + p.setProperty(layerId + "." + DrawingAttributes.linePaintProperty, lineColor); + p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor); + shapeLayer.setProperties(layerId, p); + shapeLayer.setName(layerId); + + return shapeLayer; } + /** + * Manage E00 layer display. + * + * @param layerId layer id + * @param mapFile absolute map fail path + * @param lineColor line color + * @param fillColor fill color + * + * @return e00 layer + * @see E00Layer + */ + protected Layer getE00Layer(String layerId, String mapFile, String lineColor, + String fillColor) { + if (log.isDebugEnabled()) { + log.debug("Get E00Layer with filename : " + mapFile); + } + E00Layer e00Layer = new E00Layer(); + Properties p = new Properties(); + p.setProperty(layerId + ".FileName", mapFile); + p.setProperty(layerId + "." + DrawingAttributes.linePaintProperty, lineColor); + p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor); + e00Layer.setProperties(layerId, p); + e00Layer.setName(layerId); + + return e00Layer; + } + + /** + * Manage DTED layer display. + * + * @param layerId layer id + * @param mapFile absolute map fail path + * @param lineColor line color + * @param fillColor fill color + * + * @return dted layer + * @see DTEDLayer + */ + protected Layer getDTEDLayer(String layerId, String mapFile, String lineColor, + String fillColor) { + if (log.isDebugEnabled()) { + log.debug("Get DTEDLayer with filename : " + mapFile); + } + + // get current map parent file + File mapFileFile = new File(mapFile); + String parentFolder = mapFileFile.getParent(); + + DTEDLayer dtedLayer = new DTEDLayer(); + Properties p = new Properties(); + p.setProperty(layerId + ".dted.paths", parentFolder); + p.setProperty(layerId + "." + DrawingAttributes.linePaintProperty, lineColor); + p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor); + + dtedLayer.setProperties(layerId, p); + dtedLayer.setName(layerId); + + return dtedLayer; + } + + /** + * Manage MIF layer display. + * + * @param layerId layer id + * @param mapFile absolute map fail path + * @param lineColor line color + * @param fillColor fill color + * + * @return mif layer + * @see MIFLayer + */ + protected Layer getMIFLayer(String layerId, String mapFile, String lineColor, + String fillColor) { + + if (log.isDebugEnabled()) { + log.debug("Get MIFLayer with filename : " + mapFile); + } + + MIFLayer mifLayer = new MIFLayer(); + Properties p = new Properties(); + p.setProperty(layerId + "." + MIFLayer.MIF_FileProperty, mapFile); + p.setProperty(layerId + "." + MIFLayer.pointVisibleProperty, "true"); + p.setProperty(layerId + "." + DrawingAttributes.linePaintProperty, lineColor); + p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor); + + mifLayer.setProperties(layerId, p); + mifLayer.setName(layerId); + + return mifLayer; + + } + + /** + * Manage RPF layer display. + * + * Seams to handle cadrg and cib files too. + * + * @param layerId layer id + * @param mapFile absolute map fail path + * @param lineColor line color + * @param fillColor fill color + * + * @return rpf layer + * @see RpfLayer + */ + protected Layer getRPFLayer(String layerId, String mapFile, String lineColor, + String fillColor) { + + if (log.isDebugEnabled()) { + log.debug("Get RpfLayer with filename : " + mapFile); + } + + // get current map parent file + File mapFileFile = new File(mapFile); + String parentFolder = mapFileFile.getParent(); + + RpfLayer rpfLayer = new RpfLayer(); + Properties p = new Properties(); + // This property should reflect the paths to the RPF directories + p.setProperty(layerId + ".rpf.paths", parentFolder); + p.setProperty(layerId + "." + MIFLayer.pointVisibleProperty, "true"); + p.setProperty(layerId + "." + DrawingAttributes.linePaintProperty, lineColor); + p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor); + + rpfLayer.setProperties(layerId, p); + rpfLayer.setName(layerId); + + return rpfLayer; + + } + + /** + * Manage VPF layer display. + * + * Can manage .vmap, .dcw, .vpf files ? + * + * @param layerId layer id + * @param mapFile absolute map fail path + * @param lineColor line color + * @param fillColor fill color + * + * @return vpf layer + * @see vpfLayer + */ + protected Layer getVPFLayer(String layerId, String mapFile, String lineColor, + String fillColor) { + + // on presume que, dans le cas d'IsisFish, les cartes VMap ne + // sont pas politiques. + + if (log.isDebugEnabled()) { + log.debug("Get vpfLayer with filename : " + mapFile); + } + + VPFLayer vpfLayer = new VPFLayer(); + Properties p = new Properties(); + p.setProperty(layerId + "." + VPFLayer.pathProperty, mapFile); + p.setProperty(layerId + "." + VPFLayer.defaultLayerProperty, "vmapCoastline"); + p.setProperty(layerId + "." + DrawingAttributes.linePaintProperty, lineColor); + p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor); + + vpfLayer.setProperties(layerId, p); + vpfLayer.setName(layerId); + + return vpfLayer; + + } + protected void addGraticuleLayer() { GraticuleLayer layer = new GraticuleLayer(); Properties p = new Properties(); // Show lat / lon spacing labels - p.setProperty(".showRuler","true"); - p.setProperty(".show1And5Lines","true"); + p.setProperty("." + GraticuleLayer.ShowRulerProperty, "true"); + p.setProperty("." + GraticuleLayer.ShowOneAndFiveProperty, "true"); // Controls when the five degree lines and one degree lines kick in // - when there is less than the threshold of ten degree lat or lon // lines, five degree lines are drawn. The same relationship is there // for one to five degree lines. - p.setProperty(".threshold","5"); + p.setProperty("." + GraticuleLayer.ThresholdProperty, "5"); // the color of 10 degree spacing lines (Hex ARGB) - p.setProperty(".10DegreeColor","FF000000"); + p.setProperty("." + GraticuleLayer.TenDegreeColorProperty, "FF000000"); // the color of 5 degree spacing lines (Hex ARGB) - p.setProperty(".5DegreeColo","C7009900"); - // the color of 1 degree spaing lines (ARGB) - p.setProperty(".1DegreeColor","FF003300"); + p.setProperty("." + GraticuleLayer.FiveDegreeColorProperty, "C7009900"); + // the color of 1 degree spacing lines (ARGB) + p.setProperty("." + GraticuleLayer.OneDegreeColorProperty, "FF003300"); // the color of the equator (ARGB) - p.setProperty(".equatorColor","FFFF0000"); + p.setProperty("." + GraticuleLayer.EquatorColorProperty, "FFFF0000"); // the color of the international dateline (ARGB) - p.setProperty(".dateLineColor","FF000099"); + p.setProperty("." + GraticuleLayer.DateLineColorProperty, "FF000099"); // the color of the special lines (ARGB) (Tropic of Cancer, Capricorn) - p.setProperty(".specialLineColor","FF000000"); + p.setProperty("." + GraticuleLayer.SpecialLineColorProperty, "FF000000"); // the color of the labels (ARGB) - p.setProperty(".textColor","FF000000"); + p.setProperty("." + GraticuleLayer.TextColorProperty, "FF000000"); - layer.setProperties("",p); + layer.setProperties("", p); layerHandler.addLayer(layer); } @@ -328,12 +563,14 @@ layerHandler.addLayer(layer); } - protected void addSpecificLayer(){ - try{ + protected void addSpecificLayer() { + try { addSelectionLayer(); addZoneDelimiterLayer(); - }catch(TopiaException eee){ - log.warn("Can't add specific layer", eee); + } catch (TopiaException eee) { + if (log.isWarnEnabled()) { + log.warn("Can't add specific layer", eee); + } } } @@ -346,132 +583,72 @@ float centerLong = (maxLongitude + minLongitude) / 2f; layerHandler.removeAll(); //setProjection( new Mercator(new LatLonPoint(centerLat, centerLong), SCALE, 480, 540)); + + //FIXME requiered for DTED datas + //setProjection(new LLXY(new LatLonPoint(centerLat, centerLong), SCALE, 480, 540)); + // OR this one + //setProjection(new CADRG(new LatLonPoint(centerLat, centerLong), SCALE, 480, 540)); + setCenter(new LatLonPoint(centerLat, centerLong)); //setScale(SCALE); addSpecificLayer(); addGraticuleLayer(); - // ajout des shape + // ajout des shapes boolean shapeLoaded = false; - for(String filename:getFisheryRegion().getMapFilePath()){ - if(filename != null && !"".equals(filename)){ - String shp = filename + ".shp"; - String ssx = filename + ".ssx"; - try{ - //recherche l'url, si pas trouve leve une exception - Resource.getURL(shp); - log.info(_("isisfish.message.load.map", filename, shp, ssx)); - addShapeLayer(filename, shp, ssx, "ff000000", "ffbdde83"); - shapeLoaded = true; - }catch(Exception eee){ - log.error(_("isisfish.error.load.map", filename), eee); + for (String filename : getFisheryRegion().getMapFilePath()) { + if (!StringUtils.isEmpty(filename)) { + if (log.isDebugEnabled()) { + log.debug(_("isisfish.message.load.map", filename)); } + addLayer(filename, filename, "ff000000", "ffbdde83"); + shapeLoaded = true; } } - if(!shapeLoaded){ + if (!shapeLoaded) { + if (log.isDebugEnabled()) { + log.debug("Can't load custom map, load default one"); + } // a pas reussi a charger les fichiers demandés, on charge la // carte du monde String filename = IsisFish.config.getDefaultMapFilename(); - String shp = filename + ".shp"; - String ssx = filename + ".ssx"; - addShapeLayer(filename, shp, ssx, "ff000000", "ffbdde83"); + addLayer(filename, filename, "ff000000", "ffbdde83"); } - } catch(Exception eee) { - log.error(_("isisfish.error.init.map"), eee); + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error(_("isisfish.error.init.map"), eee); + } } } - /** - * Get the value of selectionMode. - * @return value of selectionMode. - */ + /** + * Get the value of selectionMode. + * @return value of selectionMode. + */ public int getSelectionMode() { return selectionMode; } /** - * Set the value of selectionMode. - * @param v Value to assign to selectionMode. - */ - public void setSelectionMode(int v) { + * Set the value of selectionMode. + * @param v value to assign to selectionMode. + */ + public void setSelectionMode(int v) { this.selectionMode = v; } - public void addSelectionLayer(){ - try{ - activeSelectionLayer = new CellSelectionLayer(fisheryRegion, - getSelectionMode()); + public void addSelectionLayer() { + try { + activeSelectionLayer = new CellSelectionLayer(fisheryRegion, getSelectionMode()); addMapMouseListener(activeSelectionLayer); layerHandler.addLayer(activeSelectionLayer); - }catch(TopiaException eee){ - log.warn("Can't add selection layer", eee); + } catch (TopiaException eee) { + if (log.isWarnEnabled()) { + log.warn("Can't add selection layer", eee); + } } } - // /** - // * Renvoie tous les carres selectionnes. - // * @return le vecteur contenant des LatLonPoint des carres selectionnes. - // * @deprecated - // */ - // public Vector getSelectedCells_(){ - // return activeSelectionLayer.getSelectedCells(); - // } - - // /** - // * Permet de selectionner le carre incluant le point donne. - // * @param pt le point pour lequel on cherche le carre correspondant - // * @return true si reussi sinon false. - // * @deprecated - // */ - // public boolean select(LatLonPoint pt){ - // return activeSelectionLayer.select(pt); - // } - - // /** - // * Permet de selectionner le carre incluant le point donne en latitude et longitude. - // * @param latitude la latitude du point - // * @param longitude la longitude du point - // * @return true si reussi sinon false. - // * @deprecated - // */ - // public boolean select(float latitude,float longitude){ - // return activeSelectionLayer.select(latitude,longitude); - // } - - // /** - // * Permet de deselectionner le carre incluant le point donne. - // * @param pt le point pour lequel on cherche le carre correspondant - // * @return true si reussi sinon false. - // * @deprecated - // */ - // public boolean unSelect(LatLonPoint pt){ - // if (activeSelectionLayer != null) - // return activeSelectionLayer.unSelect(pt); - // return false; - // } - - // /** - // * Permet de deselectionner le carre incluant le point donne en latitude et longitude. - // * @param latitude la latitude du point - // * @param longitude la longitude du point - // * @return true si reussi sinon false. - // * @deprecated - // */ - // public boolean unSelect(float latitude,float longitude){ - // if (activeSelectionLayer != null) - // return activeSelectionLayer.unSelect(latitude,longitude); - // return false; - // } - - // /** - // * Deselectionne tous les carres. - // * @deprecated - // */ - // public void unSelectAll(){ - // if (activeSelectionLayer != null) - // activeSelectionLayer.unSelectAll(); - // } - -}// IsisMapBean +} // IsisMapBean Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Motif.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Motif.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Motif.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -27,7 +27,7 @@ import com.bbn.openmap.proj.Projection; /** - * Motif.java A Motif that represents how to draw a DataMap on the map. A factor + * A Motif that represents how to draw a DataMap on the map. A factor * is applied to the graphic according to the DataMap value and the maximum * DataMap value. * @@ -38,7 +38,7 @@ */ public class Motif implements Serializable { - /** serialVersionUID */ + /** serialVersionUID. */ private static final long serialVersionUID = -2814583859271654759L; public static final Color defaultLineColor = new Color(0, true); @@ -208,4 +208,4 @@ } } } -}// Motif +} // Motif Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ResultatLayer.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ResultatLayer.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ResultatLayer.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -66,9 +66,6 @@ protected JPanel palette = null; - // FIXME dans l'ancien mais pas dans le nouveau, voir ce que ca change - // protected ResultatMapBean resultatMapBean = null; - protected Projection proj = null; /* Contient tous les carres possibles */ @@ -77,15 +74,6 @@ public ResultatLayer() { } - // FIXME to be continue - // public ResultatLayer(SimpleResultatMapBean aResultatMapBean){ - // resultatMapBean = null; - // } - - // public ResultatLayer(ResultatMapBean aResultatMapBean){ - // resultatMapBean = aResultatMapBean; - // } - /** * Add a DataMap to this layer. * @@ -121,8 +109,8 @@ int position = -1; // rechercher des zones dans la matrice - for (int i = 0; i < matInfo.getNbDim(); i++) { - List sem = matInfo.getSemantics(i); + for (int i = 0; i < matInfo.getDimCount(); i++) { + List sem = matInfo.getSemantic(i); if (sem.size() > 0 && sem.get(0) instanceof Zone) { position = i; vzone = sem; @@ -173,8 +161,8 @@ double elem = matInfo.getValue(i, j); DefaultDataMap data = new DefaultDataMap(); data.setValue(elem); - String itemx = matInfo.getSemantics(0).get(i).toString(); - String itemy = matInfo.getSemantics(1).get(j).toString(); + String itemx = matInfo.getSemantic(0).get(i).toString(); + String itemy = matInfo.getSemantic(1).get(j).toString(); if (position == 0) { data.setCoordinates(latitude.get(i), longitude.get(i)); @@ -345,48 +333,49 @@ /** * Invoked when the mouse has been clicked on a component. The listener will * receive this event if it successfully processed - * <code>mousePressed()</code>, or if no other listener processes the - * event. If the listener successfully processes mouseClicked(), then it - * will receive the next mouseClicked() notifications that have a click + * {@code mousePressed()}, or if no other listener processes the + * event. If the listener successfully processes {@code mouseClicked()}, then it + * will receive the next {@code mouseClicked()} notifications that have a click * count greater than one. * - * @param e MouseListener MouseEvent to handle. + * @param e MouseEvent to handle. * @return true if the listener was able to process the event. */ public boolean mouseClicked(MouseEvent e) { - // System.out.println("ResultatLayer - // mouseClicked-------------------------"+e.getID()); + // on recherche le datamap clique LatLonPoint llp = getProjection().inverse(e.getX(), e.getY()); - Vector datamaps = getDataMapList().getDataMaps( + List<DataMap> datamaps = getDataMapList().getDataMaps( new Coordinate(llp.getLatitude(), llp.getLongitude())); if (datamaps != null && datamaps.size() != 0) { String info = ""; for (Object datamap : datamaps) { DefaultDataMap dataMap = (DefaultDataMap) datamap; - if (dataMap.getInfo() != null) + if (dataMap.getInfo() != null) { info += _("Info") + ": " + dataMap.getInfo().getLabels() + " " + _("isisfish.common.value") + ":" + dataMap.getValue() + "\n"; - else + } + else { info += " " + _("isisfish.common.value") + ":" + dataMap.getValue() + "\n"; + } } - // System.out.println(info); + // InfoDisplayEvent infoevt = new InfoDisplayEvent(this,info); // fireRequestMessage(infoevt); JOptionPane.showMessageDialog(this, info, this.getName(), JOptionPane.INFORMATION_MESSAGE); - // System.out.println("ResultatLayer - // mouseClicked++++++++++++++++++++++++"); + // e.consume(); return true; - } else + } else { return false; + } } /** * Invoked when the mouse enters a component. * - * @param e MouseListener MouseEvent to handle. + * @param e MouseEvent to handle. */ public void mouseEntered(MouseEvent e) { } @@ -394,7 +383,7 @@ /** * Invoked when the mouse exits a component. * - * @param e MouseListener MouseEvent to handle. + * @param e MouseEvent to handle. */ public void mouseExited(MouseEvent e) { } @@ -404,7 +393,7 @@ * The listener will receive these events if it successfully processes * mousePressed(), or if no other listener processes the event. * - * @param e MouseMotionListener MouseEvent to handle. + * @param e MouseEvent to handle. * @return true if the listener was able to process the event. */ public boolean mouseDragged(MouseEvent e) { @@ -415,7 +404,7 @@ * Invoked when the mouse button has been moved on a component (with no * buttons no down). * - * @param e MouseListener MouseEvent to handle. + * @param e MouseEvent to handle. * @return true if the listener was able to process the event. */ public boolean mouseMoved(MouseEvent e) { @@ -449,4 +438,4 @@ public void mouseMoved() { } -}// ResultatLayer +} // ResultatLayer Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Scale.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Scale.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Scale.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -21,7 +21,6 @@ import java.io.Serializable; /** - * Scale. * This interface allows the user to define a graduation between 0.0 and 1.0 * whose movement are proportionnal to a bounded value. * @@ -32,12 +31,22 @@ */ public interface Scale extends Serializable{ - /** Get the corresponding value between 0.0 and 1.0 */ + /** + * Get the corresponding value between 0.0 and 1.0. + * + * @param value value to get scale + * @return scale value + */ public double getValueAsScale(double value); public int getValueAsRGB(double value); - /** Get the corresponding square root value between 0.0 and 1.0 */ + /** + * Get the corresponding square root value between 0.0 and 1.0. + * + * @param value value to get sqrt scale + * @return sqrt scale + */ public double getValueAsSqrtScale(double value); -}// Scale +} // Scale Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -51,7 +51,7 @@ public class ZoneDelimiterLayer extends Layer implements TopiaTransactionListener { //ZoneDelimiterLayer - /** serialVersionUID */ + /** serialVersionUID. */ private static final long serialVersionUID = 1127201121371123690L; /** to use log facility, just put in your code: log.info(\"...\"); */ @@ -59,10 +59,10 @@ protected Projection proj = null; - /* Contient tous les carres possibles */ + /** Contient tous les carres possibles. */ protected OMGraphicList graphics = new OMGraphicList(); - /* Caracteristiques du cadrillage */ + /** Caracteristiques du cadrillage. */ protected float pasMailleLatitude; protected float pasMailleLongitude; @@ -150,30 +150,6 @@ graphics.generate(getProjection()); } - // /** - // * Appelé lorsqu'une ou plusieurs entités ont été créées - // */ - // public void entityCreated(TopiaEntityEvent event){ - // refresh(); - // } - // /** - // * Appelé lorsqu'une ou plusieurs entités ont été chargées - // */ - // public void entityLoaded(TopiaEntityEvent event){ - // } - // /** - // * Appelé lorsqu'une ou plusieurs entités ont été modifiées - // */ - // public void entityUpdated(TopiaEntityEvent event){ - // refresh(); - // } - // /** - // * Appelé lorsqu'une ou plusieurs entités ont été supprimées - // */ - // public void entityDeleted(TopiaEntityEvent event){ - // refresh(); - // } - protected void refresh() { try { cells = fisheryRegion.getCell(); Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2009-11-23 15:03:22 UTC (rev 2771) @@ -39,6 +39,7 @@ import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.util.FileUtil; +import org.nuiton.widget.SwingUtil; import org.nuiton.widget.editor.Editor; import fr.ifremer.isisfish.IsisFishDAOHelper; @@ -1087,11 +1088,12 @@ return null; } - // FisheryRegion - /** * Add new map in region. * + * Since isis-fsih 3.3.0.0, this method supports a multiple file format : + * - http://openmap.bbn.com/cgi-bin/faqw.py?req=all#9.1 + * * @param fisheryRegion fishery region */ public void addMap(FisheryRegion fisheryRegion) { @@ -1099,42 +1101,50 @@ log.trace("AddMap called"); } - File shp = FileUtil.getFile(".*\\.shp", "shp file"); + // Openmap suported fileformat + String[] fileFormats = { + // ESRI (http://www.esri.com) Shapefiles + ".*\\.shp", "ESRI Shapefiles (.shp)", + + // NIMA (http://www.nima.mil) + ".*\\.dcw", "Digital Chart of the World (.dcw)", + ".*\\.vpf", "Vector Product Format (.vpf)", + ".*\\.vmap", "Vector Map (.vmap)", + ".*\\.cadrg", "Compressed ARC Digitized Raster Graphics (.cadrg)", + ".*\\.cib", "Controlled Image Base (.cib)", + ".*\\.rpf", "Raster Product Format (.rpf)", + // seams to be a special format with multiples files + //".*\\.dt[0-2]+", "Digital Terrain Elevation Data (levels 0, 1, 2) (.dt0, .dt0, .dt2)", + + // MapInfo (http://www.mapinfo.com) files (.mif) + ".*\\.mif", "MapInfo (.mif)", + + // ArcInfo (.e00) files. + ".*\\.e00", "ArcInfo (.e00)" + }; + + File inputMap = FileUtil.getFile(fileFormats); try { - if (shp != null) { - // copy shp and ssx to region map directory - String basename = FileUtil.basename(shp, ".shp"); + if (inputMap != null) { - String srcMap = shp.getPath(); - srcMap = srcMap.substring(0, srcMap.length() - ".shp".length()); - File ssx = new File(srcMap + ".ssx"); + // copy inputMapFormat to region map directory + // since isis-fsih-3.3.0.0, we store maps with extension + String filename = inputMap.getName(); - RegionStorage regionStorage = RegionStorage - .getRegion(fisheryRegion.getName()); + RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName()); File destDir = regionStorage.getMapRepository(); - // copy shp file - File destShp = new File(destDir, basename + ".shp"); - FileUtil.copy(shp, destShp); + // copy map file + File destMap = new File(destDir, filename); + FileUtil.copy(inputMap, destMap); - // copy ssx file (unneeded with openmap 4.6.5) - /*File destSsx = new File(destDir, basename + ".ssx"); - if (ssx.exists()) { - FileUtil.copy(ssx, destSsx); - } else { - if (log.isInfoEnabled()) { - log.info("Ssx file don't exist, try to generate it"); - } - SpatialIndex.createIndex(destShp.getPath(), destSsx.getPath()); - }*/ - List<String> maps = fisheryRegion.getMapFileList(); - maps.add(basename); + maps.add(filename); fisheryRegion.setMapFileList(maps); } } catch (Exception eee) { if (log.isErrorEnabled()) { - log.error("Can't copy .shp or .ssx file for: " + shp, eee); + log.error("Can't copy map file for : " + inputMap, eee); } ErrorHelper.showErrorDialog(_("isisfish.error.region.addmap"), eee); } @@ -1150,21 +1160,32 @@ if (log.isTraceEnabled()) { log.trace("removeMap called"); } + try { - List<String> maps = fisheryRegion.getMapFileList(); - RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion - .getName()); + RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName()); File mapDir = regionStorage.getMapRepository(); - for (Object map : selectedMaps) { - maps.remove(map); + for (Object selectedMap : selectedMaps) { + String mapName = (String)selectedMap; + maps.remove(mapName); // remove on disk too, if possible - File shp = new File(mapDir, map + ".shp"); - shp.delete(); - File ssx = new File(mapDir, map + ".ssx"); - ssx.delete(); + File mapFile = new File(mapDir, mapName); + mapFile.delete(); + if (log.isDebugEnabled()) { + log.debug("Removing map file : " + mapFile); + } + + // special case, for some format, an index is created + if (mapName.endsWith(".shp")) { + String indexName = mapName.replaceAll("\\.shp$", ".ssx"); + File indexFile = new File(mapDir, indexName); + indexFile.delete(); + if (log.isDebugEnabled()) { + log.debug("Removing index file : " + indexFile); + } + } } fisheryRegion.setMapFileList(maps); @@ -1282,6 +1303,7 @@ CheckRegion.check(fisheryRegion, result); CheckResultFrame dialog = new CheckResultFrame(); dialog.setCheckResult(result); + SwingUtil.center(dialog); dialog.setVisible(true); } catch (Exception eee) { if (log.isErrorEnabled()) { Modified: isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties =================================================================== --- isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties 2009-11-23 15:03:22 UTC (rev 2771) @@ -614,7 +614,7 @@ isisfish.message.import.zip=Import zip file isisfish.message.launchui.notlaunch= isisfish.message.load.finished=load finished -isisfish.message.load.map=Try to load map file\: %1$s (%2$s) +isisfish.message.load.map=Try to load map file\: %1$s isisfish.message.loading.old.simulation=Loading old simulation ... isisfish.message.loading.region=Loading region ... isisfish.message.name.imported.region=Enter name for imported region Modified: isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties =================================================================== --- isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties 2009-11-23 11:04:14 UTC (rev 2770) +++ isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties 2009-11-23 15:03:22 UTC (rev 2771) @@ -614,7 +614,7 @@ isisfish.message.import.zip=Import zip file isisfish.message.launchui.notlaunch=Interface utilisateur non lanc\u00E9e isisfish.message.load.finished=Chargement termin\u00E9 -isisfish.message.load.map=Chargement de la carte \: %1$s (%2$s) +isisfish.message.load.map=Chargement de la carte \: %1$s isisfish.message.loading.old.simulation=Chargement d'une ancienne simulation ... isisfish.message.loading.region=Chargement de la r\u00E9gion isisfish.message.name.imported.region=Entrez le nom de la r\u00E9gion \u00E0 importer
participants (1)
-
chatellier@users.labs.libre-entreprise.org