|
From: <de...@us...> - 2010-01-09 00:55:14
|
Revision: 5608
http://fudaa.svn.sourceforge.net/fudaa/?rev=5608&view=rev
Author: deniger
Date: 2010-01-09 00:55:01 +0000 (Sat, 09 Jan 2010)
Log Message:
-----------
Modified Paths:
--------------
trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/impl/MvInternalFrame.java
trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/layer/MvVisuPanel.java
trunk/soft/fudaa-prepro/pom.xml
trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/data/TrSiProfilLayer.java
trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/data/TrSiProfilModel.java
trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/post/profile/MvProfileGridPalette.java
trunk/soft/fudaa-prepro/ui/src/test/java/org/fudaa/fudaa/tr/TestJSave.java
Added Paths:
-----------
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/common/
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/AltimetryLayersBuilder.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/ContextGeometricLayersImpl.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/ContextGeometryModule.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/EnumLayerDataType.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/GeometricLayerBuilder.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/GridVisuPanelController.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/GridVisulPanel.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/LayerHelper.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/RepereContainerImpl.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/AttributeConstants.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/ContextGeometricLayers.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricDefaultIndexer.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricLigneBriseeModel.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricLineFromPointUpdater.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricLineModelIndexer.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricPointFromLineUpdater.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricPointModel.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricPointModelIndexer.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/LineFindResult.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/NodeFindResult.java
trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/RepereContainer.java
trunk/soft/fudaa-prepro/grid/src/main/resources/org/fudaa/fudaa/fgrid/
trunk/soft/fudaa-prepro/grid/src/main/resources/org/fudaa/fudaa/fgrid/layer/
trunk/soft/fudaa-prepro/grid/src/main/resources/org/fudaa/fudaa/fgrid/layer/package.html
trunk/soft/fudaa-prepro/grid/src/site/vue-ensemble-calque.xmind
trunk/soft/fudaa-prepro/grid/src/test/java/org/fudaa/fudaa/fgrid/
trunk/soft/fudaa-prepro/grid/src/test/java/org/fudaa/fudaa/fgrid/layer/
trunk/soft/fudaa-prepro/grid/src/test/java/org/fudaa/fudaa/fgrid/layer/ExampleGridVisuPanel.java
trunk/soft/fudaa-prepro/src/config/
trunk/soft/fudaa-prepro/src/config/eclipse/
trunk/soft/fudaa-prepro/src/config/eclipse/org.eclipse.core.resources.prefs
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/AltimetryLayersBuilder.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/AltimetryLayersBuilder.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/AltimetryLayersBuilder.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,56 @@
+package org.fudaa.fudaa.fgrid.layer;
+
+import org.fudaa.ctulu.gis.GISAttribute;
+import org.fudaa.ctulu.gis.GISAttributeConstants;
+import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee;
+import org.fudaa.ctulu.gis.GISZoneCollectionPoint;
+import org.fudaa.ebli.calque.ZCalqueLigneBrisee;
+import org.fudaa.fudaa.sig.layer.FSigLayerGroup;
+import org.fudaa.fudaa.sig.layer.FSigLayerPointEditable;
+
+/**
+ * Builder for altimetry layers.
+ *
+ * @author deniger
+ */
+public class AltimetryLayersBuilder {
+
+ protected static FSigLayerGroup buildGroup(final GridVisulPanel visuPanel) {
+ final FSigLayerGroup grAltimetry = new FSigLayerGroup(visuPanel, AltimetryLayersBuilder.buildAttributes());
+ grAltimetry.setTitle("Donn\xE9es altim\xE9triques");
+ grAltimetry.setName("grAlti");
+ return grAltimetry;
+ }
+
+ /**
+ * @param parent the parent group layer to complete with default layer
+ */
+ protected static void buildDefault(final FSigLayerGroup parent) {
+ addLevelLayerLine(parent);
+ addPointsLayer(parent);
+ addProfileLayerLine(parent);
+
+ }
+
+ private static ZCalqueLigneBrisee addLevelLayerLine(final FSigLayerGroup parent) {
+ final GISZoneCollectionLigneBrisee ligne = GeometricLayerBuilder.createZoneCollectionLigne(parent.getAttributes(),
+ parent.getGisEditor());
+ return parent.addLigneBriseeLayerAct("Lignes de niveau", ligne);
+ }
+
+ private static ZCalqueLigneBrisee addProfileLayerLine(final FSigLayerGroup parent) {
+ final GISZoneCollectionLigneBrisee ligne = GeometricLayerBuilder.createZoneCollectionLigne(parent.getAttributes(),
+ parent.getGisEditor());
+ return parent.addLigneBriseeLayerAct("Profils", ligne);
+ }
+
+ private static FSigLayerPointEditable addPointsLayer(final FSigLayerGroup parent) {
+ final GISZoneCollectionPoint pointModele = GeometricLayerBuilder.createZoneCollectionPoint(parent.getAttributes(),
+ parent.getGisEditor());
+ return (FSigLayerPointEditable) parent.addPointLayerAct("Semis de points", pointModele);
+ }
+
+ static GISAttribute[] buildAttributes() {
+ return new GISAttribute[] { GISAttributeConstants.BATHY };
+ }
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/ContextGeometricLayersImpl.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/ContextGeometricLayersImpl.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/ContextGeometricLayersImpl.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,223 @@
+package org.fudaa.fudaa.fgrid.layer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import org.fudaa.ctulu.CtuluUI;
+import org.fudaa.ctulu.gis.GISAttributeModelLongInterface;
+import org.fudaa.ctulu.gis.GISZoneCollection;
+import org.fudaa.ebli.calque.edition.ZCalqueLigneBriseeEditable;
+import org.fudaa.fudaa.fgrid.model.AttributeConstants;
+import org.fudaa.fudaa.fgrid.model.ContextGeometricLayers;
+import org.fudaa.fudaa.fgrid.model.GeometricLigneBriseeModel;
+import org.fudaa.fudaa.fgrid.model.GeometricLineModelIndexer;
+import org.fudaa.fudaa.fgrid.model.GeometricPointModel;
+import org.fudaa.fudaa.fgrid.model.GeometricPointModelIndexer;
+import org.fudaa.fudaa.fgrid.model.LineFindResult;
+import org.fudaa.fudaa.fgrid.model.NodeFindResult;
+import org.fudaa.fudaa.fgrid.model.RepereContainer;
+import org.fudaa.fudaa.sig.layer.FSigLayerLineEditable;
+import org.fudaa.fudaa.sig.layer.FSigLayerPointEditable;
+
+/**
+ * Context for geometric layers. <br>
+ * Permet de retrouver facilement les calques geometriques et de faire des recherches sur les ID des points, lignes et
+ * surfaces. Ce sont les indexer {@linkplain GeometricLineModelIndexer} et {@linkplain GeometricPointModelIndexer} qui
+ * permettent de recuperer facilement les ID des points/lignes.
+ *
+ * @author deniger
+ */
+public class ContextGeometricLayersImpl implements ContextGeometricLayers {
+
+ /**
+ * @param nodeId l'identifiant du noeud a chercher
+ * @param pt le calque a parcourir
+ * @return toujours non null
+ */
+ public static NodeFindResult findNode(long nodeId, FSigLayerPointEditable pt) {
+ NodeFindResult res = NodeFindResult.EMPTY;
+ GISZoneCollection geomData = pt.getModelEditable().getGeomData();
+ int indiceOf = geomData.getIndiceOf(AttributeConstants.ID);
+ GISAttributeModelLongInterface dataModel = (GISAttributeModelLongInterface) geomData.getDataModel(indiceOf);
+ for (int i = dataModel.getSize() - 1; i >= 0; i--) {
+ if (dataModel.getValue(i) == nodeId) {
+ res = new NodeFindResult();
+ res.idx = i;
+ res.layer = pt;
+ return res;
+ }
+ }
+ return res;
+
+ }
+
+ public static boolean isDefinedID(Long id) {
+ return id != null && id.longValue() >= 0;
+ }
+
+ public static boolean isNotDefinedID(Long id) {
+ return !isDefinedID(id);
+ }
+
+ long currentFreeNodeId;
+ long currentFreeLineId;
+
+ long currentFreeSurfaceId;
+
+ final CtuluUI ui;
+
+ Collection<FSigLayerPointEditable> layerPoints = new HashSet<FSigLayerPointEditable>();
+
+ Collection<ZCalqueLigneBriseeEditable> layerLines = new HashSet<ZCalqueLigneBriseeEditable>();
+
+ /**
+ * The support layer in which the node will be created if needed.
+ */
+ FSigLayerPointEditable nodeLayerSupport;
+
+ private final RepereContainer repere;
+
+ /**
+ * @param ui
+ */
+ public ContextGeometricLayersImpl(CtuluUI ui, RepereContainer repere) {
+ super();
+ this.ui = ui;
+ this.repere = repere;
+ }
+
+ /**
+ * @return the next id for a new line
+ */
+ public long createLineId() {
+ return currentFreeLineId++;
+ }
+
+ /**
+ * @return the next id for a new node
+ */
+ public long createNodeId() {
+ return currentFreeNodeId++;
+ }
+
+ /**
+ * @return the next id for a new surface
+ */
+ protected long createSurfaceId() {
+ return currentFreeSurfaceId++;
+ }
+
+ /**
+ * @param dataType
+ * @return the first (created) line layer of type dataType
+ */
+ public ZCalqueLigneBriseeEditable findFirstLineLayerOfType(EnumLayerDataType dataType) {
+ return LayerHelper.findLayerOfType(layerLines, dataType);
+ }
+
+ /**
+ * @param dataType
+ * @return the first (created) point layer of type dataType
+ */
+ public FSigLayerPointEditable findFirstPointLayerOfType(EnumLayerDataType dataType) {
+ return LayerHelper.findLayerOfType(layerPoints, dataType);
+ }
+
+ /**
+ * @param nodeId l'identifiant du noeud
+ * @return toujours non null.
+ */
+ public NodeFindResult findNode(long nodeId) {
+ for (FSigLayerPointEditable layerPt : layerPoints) {
+ NodeFindResult res = findNode(nodeId, layerPt);
+ if (res.isNotEmpty()) return res;
+
+ }
+ return NodeFindResult.EMPTY;
+ }
+
+ /**
+ * @return the layerLines
+ */
+ public Collection<ZCalqueLigneBriseeEditable> getLayerLines() {
+ return layerLines;
+ }
+
+ /**
+ * @return the layerPoints
+ */
+ public Collection<FSigLayerPointEditable> getLayerPoints() {
+ return layerPoints;
+ }
+
+ public Collection<LineFindResult> getLineUsingPoint(long pointID) {
+ List<LineFindResult> res = new ArrayList<LineFindResult>();
+ for (ZCalqueLigneBriseeEditable layer : layerLines) {
+ GeometricLigneBriseeModel model = (GeometricLigneBriseeModel) layer.getModele();
+ model.getIndexer().collectLineUsingPointId(pointID, res, (FSigLayerLineEditable) layer);
+ }
+ return res;
+ }
+
+ public NodeFindResult locateNode(long pointId) {
+ for (FSigLayerPointEditable layer : layerPoints) {
+ NodeFindResult findPoint = ((GeometricPointModel)layer.getModelEditable()).getIndexer().findPoint(pointId);
+ if(findPoint.idx>=0) {
+ findPoint.layer=layer;
+ return findPoint;
+ }
+ }
+
+ return NodeFindResult.EMPTY;
+ }
+
+ /**
+ * @return the nodeLayerSupport
+ */
+ public FSigLayerPointEditable getNodeLayerSupport() {
+ return nodeLayerSupport;
+ }
+
+ public RepereContainer getRepere() {
+ return repere;
+ }
+
+ public GeometricPointModel getSupportModelPoint() {
+ return (GeometricPointModel) getNodeLayerSupport().getModelEditable();
+ }
+
+ /**
+ * @return the ui
+ */
+ public CtuluUI getUi() {
+ return ui;
+ }
+
+ public boolean isNodeUsedByALine(long pointID) {
+ for (ZCalqueLigneBriseeEditable layer : layerLines) {
+ GeometricLigneBriseeModel model = (GeometricLigneBriseeModel) layer.getModele();
+ if (model.getIndexer().isNodeUsedByALine(pointID)) return true;
+ }
+ return false;
+
+ }
+
+ /**
+ * @param layerPt layer to register in the geometric context.
+ */
+ protected void register(FSigLayerPointEditable layerPt) {
+ this.register(layerPt, false);
+ }
+
+ protected void register(FSigLayerPointEditable layerPt, boolean isSupportLayer) {
+ layerPoints.add(layerPt);
+ if (isSupportLayer) nodeLayerSupport = layerPt;
+ }
+
+ protected void register(ZCalqueLigneBriseeEditable layerLine) {
+ layerLines.add(layerLine);
+ }
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/ContextGeometryModule.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/ContextGeometryModule.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/ContextGeometryModule.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,79 @@
+package org.fudaa.fudaa.fgrid.layer;
+
+import org.fudaa.ctulu.CtuluUI;
+import org.fudaa.ebli.calque.BGroupeCalque;
+import org.fudaa.fudaa.fgrid.model.RepereContainer;
+import org.fudaa.fudaa.sig.layer.FSigLayerGroup;
+import org.fudaa.fudaa.sig.layer.FSigVisuPanelController;
+
+/**
+ * GeometryModule Contexte. Contexte du module geometrique. Permet de recuperer les groupe altimetrie et geometrie.
+ * Permet egalement de r\xE9cup\xE9rer le contexte geometrique: ce dernier facilite les recherches dans les indices.
+ *
+ * @author deniger
+ */
+public class ContextGeometryModule {
+
+ private FSigLayerGroup grAltimetry;
+ private FSigLayerGroup grGeometric;
+ private BGroupeCalque cqMain;
+ private GridVisuPanelController visuController;
+ private GridVisulPanel visuPanel;
+
+ private final ContextGeometricLayersImpl geometricContext;
+ private final RepereContainerImpl repere;
+
+ public RepereContainer getRepere() {
+ return repere;
+ }
+
+ /**
+ * @return the geometricContext
+ */
+ public ContextGeometricLayersImpl getGeometricContext() {
+ return geometricContext;
+ }
+
+ public ContextGeometryModule(CtuluUI ui) {
+ visuController = new GridVisuPanelController(ui);
+ // par la suite ce repere devra etre fourni pour le projet.
+ repere = new RepereContainerImpl();
+ geometricContext = new ContextGeometricLayersImpl(ui, repere);
+
+ cqMain = new BGroupeCalque();
+ cqMain.setName("grMain");
+ }
+
+ public FSigLayerGroup getGroupAltimetry() {
+ return grAltimetry;
+ }
+
+ public BGroupeCalque getMainGroup() {
+ return cqMain;
+ }
+
+ public FSigVisuPanelController getVisuController() {
+ return visuController;
+ }
+
+ /**
+ * A utiliser \xE0 l'initialisation de GridVisuPanel: ne doit etre appele qu'une fois.
+ *
+ * @param gridVisulPanel
+ */
+ void install(GridVisulPanel gridVisulPanel) {
+ assert visuPanel == null;
+ visuPanel = gridVisulPanel;
+ // we can select several objects in several layers.
+ visuPanel.getScene().setRestrictedToCalqueActif(false);
+ // install altimetry group
+ grAltimetry = AltimetryLayersBuilder.buildGroup(gridVisulPanel);
+ AltimetryLayersBuilder.buildDefault(grAltimetry);
+ gridVisulPanel.getDonneesCalque().add(grAltimetry);
+ // install geometric group
+ grGeometric = GeometricLayerBuilder.createGeomtricGroupLayer(gridVisulPanel);
+ gridVisulPanel.getDonneesCalque().add(grGeometric);
+ GeometricLayerBuilder.buildDefault(grGeometric, this);
+ }
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/EnumLayerDataType.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/EnumLayerDataType.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/EnumLayerDataType.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,12 @@
+package org.fudaa.fudaa.fgrid.layer;
+
+/**
+ * Type des diff\xE9rents calques utilis\xE9es. A completer par la suite.
+ * @author deniger
+ *
+ */
+public enum EnumLayerDataType {
+
+ GEOMETRIC_POINT, GEOMETRIC_POINT_DUR, GEOMETRIC_LINE, GEOMETRIC_LINE_DUR
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/GeometricLayerBuilder.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/GeometricLayerBuilder.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/GeometricLayerBuilder.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,126 @@
+package org.fudaa.fudaa.fgrid.layer;
+
+import org.fudaa.ctulu.gis.GISAttribute;
+import org.fudaa.ctulu.gis.GISAttributeConstants;
+import org.fudaa.ctulu.gis.GISAttributeInterface;
+import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee;
+import org.fudaa.ctulu.gis.GISZoneCollectionPoint;
+import org.fudaa.ctulu.gis.GISZoneListenerDispatcher;
+import org.fudaa.ebli.calque.ZCalqueAffichageDonnees;
+import org.fudaa.ebli.calque.edition.ZCalqueLigneBriseeEditable;
+import org.fudaa.ebli.calque.edition.ZCalquePointEditable;
+import org.fudaa.ebli.commun.EbliActionInterface;
+import org.fudaa.fudaa.fgrid.model.AttributeConstants;
+import org.fudaa.fudaa.fgrid.model.GeometricLigneBriseeModel;
+import org.fudaa.fudaa.fgrid.model.GeometricPointModel;
+import org.fudaa.fudaa.sig.layer.FSigEditor;
+import org.fudaa.fudaa.sig.layer.FSigLayerGroup;
+import org.fudaa.fudaa.sig.layer.FSigLayerPointEditable;
+import org.fudaa.fudaa.sig.layer.FSigVisuPanel;
+
+/**
+ * Builder for geometric layer.
+ *
+ * @author deniger
+ */
+public class GeometricLayerBuilder {
+
+ private static String TYPE = "GRID_DATA_TYPE";
+
+ /**
+ * @param pn the parent visu panel
+ * @return created group layer for geometric data.
+ */
+ protected static FSigLayerGroup createGeomtricGroupLayer(FSigVisuPanel pn) {
+ FSigLayerGroup res = new FSigLayerGroup(pn);
+ res.setTitle("Donn\xE9es g\xE9ometriques");
+ res.setName("grGeometric");
+ res.setActions(new EbliActionInterface[] { pn.getGisEditor().getExportAction() });
+ return res;
+ }
+
+ /**
+ * Build default geometric layers.
+ *
+ * @param parent
+ * @param ctx
+ */
+ protected static void buildDefault(FSigLayerGroup parent, ContextGeometryModule ctx) {
+ GISAttribute[] createPointAttributes = createPointAttributes();
+ createNodeLayer(parent, ctx, createPointAttributes);
+ // TODO traduction of Dure
+ createNodeDurLayer(parent, ctx, createPointAttributes);
+ GISAttribute[] createLineAttributes = createLineAttributes();
+ createLineLayer(parent, ctx, createLineAttributes);
+ createLineDurLayer(parent, ctx, createLineAttributes);
+ // il reste a traiter les surfaces.
+ }
+
+ /**
+ * @param cq
+ * @return le type du calque et null si non trouv\xE9.
+ */
+ public static EnumLayerDataType getType(ZCalqueAffichageDonnees cq) {
+ return (EnumLayerDataType) cq.getClientProperty(TYPE);
+ }
+
+ private static void createLineDurLayer(FSigLayerGroup parent, ContextGeometryModule ctx,
+ GISAttribute[] createLineAttributes) {
+ ZCalqueLigneBriseeEditable ligneDurLayer = (ZCalqueLigneBriseeEditable) parent.addLigneBriseeLayerAct(
+ "Lignes dures", new GeometricLigneBriseeModel(ctx.getGeometricContext(), createZoneCollectionLigne(
+ createLineAttributes, parent.getGisEditor())), null);
+ ligneDurLayer.putClientProperty(TYPE, EnumLayerDataType.GEOMETRIC_LINE_DUR);
+ ctx.getGeometricContext().register(ligneDurLayer);
+ }
+
+ private static void createLineLayer(FSigLayerGroup parent, ContextGeometryModule ctx, GISAttribute[] createLineAttributes) {
+ ZCalqueLigneBriseeEditable ligneLayer = (ZCalqueLigneBriseeEditable) parent.addLigneBriseeLayerAct("Lignes",
+ new GeometricLigneBriseeModel(ctx.getGeometricContext(), createZoneCollectionLigne(createLineAttributes, parent
+ .getGisEditor())), null);
+ ligneLayer.putClientProperty(TYPE, EnumLayerDataType.GEOMETRIC_LINE);
+ ctx.getGeometricContext().register(ligneLayer);
+ }
+
+ private static void createNodeDurLayer(FSigLayerGroup parent, ContextGeometryModule ctx,
+ GISAttribute[] createPointAttributes) {
+ ZCalquePointEditable pointDurLayer = parent.addPointLayerAct("Points dur", new GeometricPointModel(
+ createZoneCollectionPoint(createPointAttributes, parent.getGisEditor()), ctx.getGeometricContext()), null);
+ pointDurLayer.putClientProperty(TYPE, EnumLayerDataType.GEOMETRIC_POINT_DUR);
+ ctx.getGeometricContext().register((FSigLayerPointEditable) pointDurLayer);
+ }
+
+ private static void createNodeLayer(FSigLayerGroup parent, ContextGeometryModule ctx,
+ GISAttribute[] createPointAttributes) {
+ ZCalquePointEditable pointLayer = parent.addPointLayerAct("Points", new GeometricPointModel(
+ createZoneCollectionPoint(createPointAttributes, parent.getGisEditor()), ctx.getGeometricContext()), null);
+ // calque support.
+ ctx.getGeometricContext().register((FSigLayerPointEditable) pointLayer, true);
+ pointLayer.putClientProperty(TYPE, EnumLayerDataType.GEOMETRIC_POINT);
+ }
+
+ protected static GISZoneCollectionPoint createZoneCollectionPoint(GISAttributeInterface[] createPointAttributes,
+ FSigEditor editor) {
+ GISZoneListenerDispatcher l = new GISZoneListenerDispatcher();
+ l.addListener(editor);
+ GISZoneCollectionPoint pt = new GISZoneCollectionPoint(l);
+ pt.setAttributes(createPointAttributes, null);
+ return pt;
+ }
+
+ protected static GISZoneCollectionLigneBrisee createZoneCollectionLigne(
+ GISAttributeInterface[] createPointAttributes, FSigEditor editor) {
+ GISZoneListenerDispatcher l = new GISZoneListenerDispatcher();
+ l.addListener(editor);
+ GISZoneCollectionLigneBrisee pt = new GISZoneCollectionLigneBrisee(l);
+ pt.setAttributes(createPointAttributes, null);
+ return pt;
+ }
+
+ private static GISAttribute[] createPointAttributes() {
+ return new GISAttribute[] { AttributeConstants.ID, GISAttributeConstants.BATHY, AttributeConstants.GRID_PRECISION };
+ }
+
+ private static GISAttribute[] createLineAttributes() {
+ return new GISAttribute[] { AttributeConstants.ID, AttributeConstants.NODE_ID, AttributeConstants.GRID_PRECISION };
+ }
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/GridVisuPanelController.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/GridVisuPanelController.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/GridVisuPanelController.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,107 @@
+package org.fudaa.fudaa.fgrid.layer;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.Action;
+import javax.swing.JComponent;
+
+import org.fudaa.ctulu.CtuluUI;
+import org.fudaa.ebli.commun.EbliActionInterface;
+import org.fudaa.ebli.commun.EbliActionPaletteAbstract;
+import org.fudaa.fudaa.sig.layer.FSigVisuPanelController;
+
+public class GridVisuPanelController extends FSigVisuPanelController {
+
+ Collection<String> useAsTab = Arrays.asList("INFOS", "PALETTE_EDTION", "NAVIGATE");
+ /**
+ * Contient chaque palette enlevee sous la forme l'actionCommand-> l'action
+ */
+ Map<String, EbliActionPaletteAbstract> mapTabPalettes_ = new HashMap<String, EbliActionPaletteAbstract>(2);
+
+ /**
+ * Les palettes utisees dans des composants normaux.
+ */
+ Collection<EbliActionPaletteAbstract> tabPalettes_ = null;
+
+ /**
+ * @param ui
+ */
+ public GridVisuPanelController(CtuluUI ui) {
+ super(ui);
+ }
+
+ @Override
+ protected EbliActionInterface[] getApplicationActions() {
+ return removePalettes(pn_.getApplicationActions());
+ }
+
+ @Override
+ protected void buildButtonGroupNavigation() {
+ if (navigationActionGroup_ != null) { return; }
+ super.buildButtonGroupNavigation();
+ final EbliActionInterface[] actions = navigationActionGroup_;
+ navigationActionGroup_ = removePalettes(actions);
+ }
+
+ @Override
+ protected void buildButtonGroupStandard() {
+ if (standardActionGroup_ != null) return;
+ super.buildButtonGroupStandard();
+ standardActionGroup_ = removePalettes(standardActionGroup_);
+ }
+
+ protected void buildButtonGroupSpecifiques() {
+ if (standardActionGroup_ != null) return;
+ super.buildButtonGroupStandard();
+ standardActionGroup_ = removePalettes(standardActionGroup_);
+
+ }
+
+ /**
+ * recupere les palettes et initialise les actions
+ */
+ @Override
+ public Collection<EbliActionPaletteAbstract> getTabPaletteAction() {
+ // si deja fait on retourne de suite
+ if (tabPalettes_ != null) return tabPalettes_;
+ initSpecificActions();
+ tabPalettes_ = new ArrayList<EbliActionPaletteAbstract>(3);
+ for (final String str : useAsTab) {
+ final EbliActionPaletteAbstract o = mapTabPalettes_.get(str);
+ if (o != null) tabPalettes_.add(o);
+ }
+ return tabPalettes_;
+ }
+
+ /**
+ * @param actions les actions a trier
+ * @return la listes des actions a ajouter dans les menus et autres. Les autres ( les palettes) seront visible tout le
+ * temps dans des dock.
+ */
+ private EbliActionInterface[] removePalettes(final EbliActionInterface[] actions) {
+
+ final List<EbliActionInterface> acts = new ArrayList<EbliActionInterface>(actions.length);
+
+ for (int i = 0; i < actions.length; i++) {
+ final EbliActionInterface action = actions[i];
+ if (action == null) continue;
+ final String value = (String) action.getValue(Action.ACTION_COMMAND_KEY);
+ final boolean isPalette = action instanceof EbliActionPaletteAbstract;
+ if (isPalette && useAsTab.contains(value)) {
+ mapTabPalettes_.put(value, (EbliActionPaletteAbstract) action);
+ } else {
+ acts.add(action);
+ }
+ }
+ return acts.toArray(new EbliActionInterface[acts.size()]);
+ }
+
+ public JComponent getPaletteInfoModel() {
+ return mapTabPalettes_.get("PALETTE_EDTION").buildContentPane();
+ }
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/GridVisulPanel.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/GridVisulPanel.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/GridVisulPanel.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,38 @@
+package org.fudaa.fudaa.fgrid.layer;
+
+import org.fudaa.fudaa.sig.layer.FSigLayerGroup;
+import org.fudaa.fudaa.sig.layer.FSigVisuPanel;
+
+/**
+ * Le visupanel contenant toutes les donn\xE9es. Le contexte {@link #getGeometryContext()} permet de recuperer le context
+ * et de naviguer entre les diff\xE9rents calques.
+ *
+ * @author deniger
+ */
+@SuppressWarnings("serial")
+public class GridVisulPanel extends FSigVisuPanel {
+
+ final ContextGeometryModule ctx;
+
+ /**
+ * @return the ctx used for the geometry module
+ */
+ public ContextGeometryModule getGeometryContext() {
+ return ctx;
+ }
+
+ /**
+ * @param ctx le context contenant le tout et utilis\xE9e pour construire les calques.
+ */
+ public GridVisulPanel(ContextGeometryModule ctx) {
+ super(ctx.getMainGroup(), ctx.getVisuController());
+ this.ctx = ctx;
+ ctx.install(this);
+ }
+
+ @Override
+ public FSigLayerGroup getGroupGIS() {
+ return ctx.getGroupAltimetry();
+ }
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/LayerHelper.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/LayerHelper.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/LayerHelper.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,54 @@
+package org.fudaa.fudaa.fgrid.layer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Predicate;
+import org.fudaa.ebli.calque.ZCalqueAffichageDonnees;
+
+public class LayerHelper {
+
+ public static class TypePredicate implements Predicate {
+
+ final EnumLayerDataType searchType;
+
+ /**
+ * @param searchType
+ */
+ public TypePredicate(EnumLayerDataType searchType) {
+ super();
+ this.searchType = searchType;
+ }
+
+ public boolean evaluate(Object object) {
+ return GeometricLayerBuilder.getType((ZCalqueAffichageDonnees) object) == searchType;
+ }
+ }
+
+ /**
+ * @param <T>
+ * @param collection
+ * @param dataToSearch
+ * @return the first layer found with the type <code>dataToSearch</code>
+ */
+ @SuppressWarnings("unchecked")
+ public static <T extends ZCalqueAffichageDonnees> T findLayerOfType(Collection<T> collection,
+ EnumLayerDataType dataToSearch) {
+ return (T) CollectionUtils.find(collection, new TypePredicate(dataToSearch));
+ }
+
+ /**
+ * @param <T>
+ * @param collection
+ * @param dataToSearch
+ * @return the first layer found
+ */
+ public static <T extends ZCalqueAffichageDonnees> Collection<T> selectLayersOfType(Collection<T> collection,
+ EnumLayerDataType dataToSearch) {
+ Collection<T> res = new ArrayList<T>();
+ CollectionUtils.select(collection, new TypePredicate(dataToSearch), res);
+ return res;
+ }
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/RepereContainerImpl.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/RepereContainerImpl.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/layer/RepereContainerImpl.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,23 @@
+package org.fudaa.fudaa.fgrid.layer;
+
+import org.fudaa.ctulu.CtuluLib;
+import org.fudaa.fudaa.fgrid.model.RepereContainer;
+
+/**
+ * A renommmer en anglais et a completer
+ *
+ * @author deniger
+ */
+public class RepereContainerImpl implements RepereContainer {
+
+ double epsXY = 1;
+
+ public boolean isSamePoint(double x, double y, double x1, double y1) {
+ return CtuluLib.isEquals(x, x1, epsXY) && CtuluLib.isEquals(y, y1, epsXY);
+ }
+
+ public boolean isDifferentPoint(double x, double y, double x1, double y1) {
+ return !isSamePoint(x, y, x1, y1);
+ }
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/AttributeConstants.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/AttributeConstants.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/AttributeConstants.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,37 @@
+package org.fudaa.fudaa.fgrid.model;
+
+import org.fudaa.ctulu.gis.GISAttributeDouble;
+import org.fudaa.ctulu.gis.GISAttributeLong;
+
+/**
+ * The default attributes.
+ *
+ * @author deniger
+ */
+public final class AttributeConstants {
+
+ /**
+ * A voir :sera la donn\xE9e a utiliser par le mailleur.
+ */
+ public static GISAttributeDouble GRID_PRECISION = new GISAttributeDouble("PREC", true);
+ public static GISAttributeLong ID = new GISAttributeLong("ID", false);
+ /**
+ * Contenu par les lignes pour indique le point support
+ */
+ public static GISAttributeLong NODE_ID = new GISAttributeLong("NODE_ID", true);
+ /**
+ * Contenu par les surface pour indiquer l'id de la ligne.
+ */
+ public static GISAttributeLong LINE_ID = new GISAttributeLong("LINE_ID", true);
+
+ static {
+ AttributeConstants.ID.setUserVisible(false);
+ AttributeConstants.NODE_ID.setUserVisible(false);
+ AttributeConstants.LINE_ID.setUserVisible(false);
+ Long def = Long.valueOf(-1);
+ AttributeConstants.ID.setDefaultValue(def);
+ AttributeConstants.NODE_ID.setDefaultValue(def);
+ AttributeConstants.LINE_ID.setDefaultValue(def);
+ }
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/ContextGeometricLayers.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/ContextGeometricLayers.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/ContextGeometricLayers.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,38 @@
+package org.fudaa.fudaa.fgrid.model;
+
+import java.util.Collection;
+
+import org.fudaa.ctulu.CtuluUI;
+
+/**
+ * Context of Geometric layers
+ *
+ * @author deniger
+ */
+public interface ContextGeometricLayers {
+
+ long createLineId();
+
+ GeometricPointModel getSupportModelPoint();
+
+ long createNodeId();
+
+ boolean isNodeUsedByALine(long nodeId);
+
+ CtuluUI getUi();
+
+ /**
+ * @param pointId ID of point to look for
+ * @return list of layer/line containing this point ID.
+ */
+ Collection<LineFindResult> getLineUsingPoint(long pointId);
+
+ /**
+ * @param pointId ID of point to look for
+ * @return the point layer and the position of the point
+ */
+ NodeFindResult locateNode(long pointId);
+
+ public RepereContainer getRepere();
+
+}
\ No newline at end of file
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricDefaultIndexer.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricDefaultIndexer.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricDefaultIndexer.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,83 @@
+package org.fudaa.fudaa.fgrid.model;
+
+import gnu.trove.TLongIntHashMap;
+
+import org.fudaa.ctulu.gis.GISAttributeInterface;
+import org.fudaa.ctulu.gis.GISAttributeModelLongInterface;
+import org.fudaa.ctulu.gis.GISCollection;
+import org.fudaa.ctulu.gis.GISCollectionData;
+import org.fudaa.ctulu.gis.GISZoneCollection;
+import org.fudaa.ctulu.gis.GISZoneListener;
+import org.fudaa.ctulu.gis.GISZoneListenerDispatcher;
+
+public class GeometricDefaultIndexer implements GISZoneListener {
+
+ /**
+ * Mapping between node id and its positions in the collection.
+ */
+ final TLongIntHashMap idForPosition = new TLongIntHashMap();
+
+ boolean mustUpdate = true;
+ final GISZoneCollection collection;
+
+ /**
+ * @param collection
+ */
+ public GeometricDefaultIndexer(GISZoneCollection collection) {
+ super();
+ this.collection = collection;
+ ((GISZoneListenerDispatcher) collection.getListener()).addListener(this);
+ }
+
+ public void attributeChanged(GISCollection src, GISAttributeInterface att) {
+ if (att == AttributeConstants.ID) {
+ mustUpdate = true;
+ }
+ }
+
+ public void dataChanged(GISAttributeInterface attribute, GISCollectionData data) {}
+
+ public void geometryChanged(GISCollection src, int[] idxs, Class class1, int action) {
+ if (action == GISZoneListener.DELETE || action == GISZoneListener.INSERT) {
+ mustUpdate = true;
+ }
+
+ }
+
+ /**
+ * Empty method that can be overload: called by the index method.
+ */
+ protected void postIndex() {
+
+ }
+
+ public void index() {
+ if (mustUpdate) {
+ mustUpdate = false;
+ idForPosition.clear();
+ int nbGeom = collection.getNbGeometries();
+ GISAttributeModelLongInterface ids = (GISAttributeModelLongInterface) collection.getDataModel(collection
+ .getIndiceOf(AttributeConstants.ID));
+ for (int i = 0; i < nbGeom; i++) {
+ idForPosition.put(ids.getValue(i), i);
+ }
+ postIndex();
+ }
+ }
+
+ public int getPositionOfId(long id) {
+ index();
+ if (idForPosition.contains(id)) { return idForPosition.get(id); }
+ return -1;
+ }
+
+ /**
+ * @param nodeId l'ID of the point
+ * @return if contains by this collection.
+ */
+ public boolean isIdUsed(long nodeId) {
+ index();
+ return idForPosition.contains(nodeId);
+ }
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricLigneBriseeModel.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricLigneBriseeModel.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricLigneBriseeModel.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,128 @@
+package org.fudaa.fudaa.fgrid.model;
+
+import com.vividsolutions.jts.geom.LineString;
+
+import org.fudaa.ctulu.CtuluCommandComposite;
+import org.fudaa.ctulu.CtuluCommandContainer;
+import org.fudaa.ctulu.CtuluListSelectionInterface;
+import org.fudaa.ctulu.CtuluUI;
+import org.fudaa.ctulu.gis.GISAttributeModelLongInterface;
+import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee;
+import org.fudaa.ctulu.gis.GISZoneListenerDispatcher;
+import org.fudaa.ebli.calque.edition.ZEditionAttibutesContainer;
+import org.fudaa.ebli.calque.edition.ZEditionAttributesDataI;
+import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable;
+import org.fudaa.ebli.commun.EbliListeSelectionMultiInterface;
+import org.fudaa.ebli.geometrie.GrPoint;
+import org.fudaa.fudaa.fgrid.layer.ContextGeometricLayersImpl;
+
+/**
+ * Model to be used to create or delete nodes and lines.
+ *
+ * @author deniger
+ */
+public class GeometricLigneBriseeModel extends ZModeleLigneBriseeEditable {
+
+ final ContextGeometricLayers geoContext;
+
+ GeometricLineModelIndexer indexer;
+
+ public GeometricLigneBriseeModel(ContextGeometricLayers geoContext) {
+ this(geoContext, null);
+ }
+
+ public GeometricLigneBriseeModel(ContextGeometricLayers geoContext, GISZoneCollectionLigneBrisee zone) {
+ super(zone);
+ this.geoContext = geoContext;
+ ((GISZoneListenerDispatcher) zone.getListener()).addListener(new GeometricPointFromLineUpdater(geoContext, this));
+ }
+
+ @Override
+ public void addPoint(int ligneIdx, int idxBefore, double x, double y, CtuluCommandContainer cmd) {
+ // TODO a continuer pour ajouter automatiquement le point
+ super.addPoint(ligneIdx, idxBefore, x, y, cmd);
+ }
+
+ @Override
+ protected Object[] createData(LineString s, ZEditionAttributesDataI initData, CtuluCommandComposite cmp) {
+ ZEditionAttributesDataI d = initData;
+ // on ne cree rien si on sur que cela va planter par la suite.
+ if (d == null && needData()) return null;
+ if (d == null) {
+ d = new ZEditionAttibutesContainer(getGeomData().getAttributes()).createLigneBriseeDataFor(s);
+ }
+ // l'id de la ligne ajoutee:
+ final Long id = (Long) d.getValue(AttributeConstants.ID, 0);
+ // serait inutile surtout si c'est une nouvelle ligne
+ if (ContextGeometricLayersImpl.isNotDefinedID(id)) {
+ d.setValue(AttributeConstants.ID, 0, geoContext.createLineId());
+ }
+ createNodeIfNeedForLine(s, d, cmp);
+ return super.createData(s, d, cmp);
+ }
+
+ /**
+ * pour tous les points ajout\xE9s et contenu par la ligne on v\xE9rifie si un point est pr\xE9sent dans le calque noeud
+ * support<br>
+ * for each vertex of the lines we test if the point exist and if not we create a new one and we add the id.
+ *
+ * @param s
+ * @param d
+ * @param cmp
+ */
+ private void createNodeIfNeedForLine(LineString s, ZEditionAttributesDataI d, CtuluCommandComposite cmp) {
+ int nbGeom = d.getNumGeometry();
+ GrPoint pt = new GrPoint();
+
+ for (int i = 0; i < nbGeom; i++) {
+ Long value = (Long) d.getValue(AttributeConstants.NODE_ID, i);
+ if (value == null || value.longValue() < 0) {
+ GeometricPointModel modelEditable = (GeometricPointModel) geoContext.getSupportModelPoint();
+ pt.x_ = s.getCoordinateSequence().getX(i);
+ pt.y_ = s.getCoordinateSequence().getY(i);
+ value = modelEditable.addPointAndReturnId(pt, null, cmp);
+ d.setValue(AttributeConstants.NODE_ID, i, value);
+ }
+
+ }
+ }
+
+ /**
+ * @return the indexer
+ */
+ public GeometricLineModelIndexer getIndexer() {
+ if (indexer == null) {
+ indexer = new GeometricLineModelIndexer(getGeomData());
+ }
+ return indexer;
+ }
+
+ /**
+ * @param idxLineInThisLayer index in this model
+ * @return the global unique ID
+ */
+ public long getLineId(int idxLineInThisLayer) {
+ return ((GISAttributeModelLongInterface) getGeomData().getDataModel(
+ getGeomData().getIndiceOf(AttributeConstants.ID))).getValue(idxLineInThisLayer);
+ }
+
+ @Override
+ public boolean moveAtomic(EbliListeSelectionMultiInterface selection, double dx, double dy, double dz,
+ CtuluCommandContainer cmd, CtuluUI ui) {
+ return super.moveAtomic(selection, dx, dy, dz, cmd, ui);
+ }
+
+ @Override
+ public boolean moveGlobal(CtuluListSelectionInterface selection, double dx, double dy, double dz,
+ CtuluCommandContainer cmd) {
+ return super.moveGlobal(selection, dx, dy, dz, cmd);
+ }
+
+ /**
+ * @param indexer the indexer to set
+ */
+ public void setIndexer(GeometricLineModelIndexer indexer) {
+ this.indexer = indexer;
+ }
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricLineFromPointUpdater.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricLineFromPointUpdater.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricLineFromPointUpdater.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,65 @@
+package org.fudaa.fudaa.fgrid.model;
+
+import java.util.Collection;
+
+import com.vividsolutions.jts.geom.CoordinateSequence;
+
+import org.fudaa.ctulu.gis.GISAttributeInterface;
+import org.fudaa.ctulu.gis.GISCollection;
+import org.fudaa.ctulu.gis.GISCollectionData;
+import org.fudaa.ctulu.gis.GISZoneListener;
+import org.fudaa.ebli.calque.edition.ZEditorDefault;
+
+/**
+ * Update line Layer when point has been changed
+ *
+ * @author deniger
+ */
+public class GeometricLineFromPointUpdater implements GISZoneListener {
+ final ContextGeometricLayers context;
+ final GeometricPointModel model;
+
+ /**
+ * @param context
+ * @param model
+ */
+ public GeometricLineFromPointUpdater(ContextGeometricLayers context, GeometricPointModel model) {
+ super();
+ this.context = context;
+ this.model = model;
+ }
+
+ public void attributeChanged(GISCollection src, GISAttributeInterface att) {}
+
+ public void dataChanged(GISAttributeInterface attribute, GISCollectionData data) {}
+
+ public void geometryChanged(GISCollection src, int[] idxs, Class class1, int action) {
+ if (action == GISZoneListener.UPDATE) {
+ for (int i = idxs.length - 1; i >= 0; i--) {
+ int pos = idxs[i];
+ long nodeId = model.getNodeId(pos);
+ Collection<LineFindResult> lineUsingPoint = context.getLineUsingPoint(nodeId);
+ updateVertex(lineUsingPoint, model.getX(pos), model.getY(pos));
+ }
+ }
+ }
+
+ private void updateVertex(Collection<LineFindResult> toUpdate, double x, double y) {
+ ZEditorDefault editorToRepaint = null;
+ for (LineFindResult lineFindResult : toUpdate) {
+ GeometricLigneBriseeModel modele = (GeometricLigneBriseeModel) lineFindResult.layer.getModele();
+ CoordinateSequence coords = modele.getGeomData().getCoordinateSequence(lineFindResult.idxOfLine);
+ int vertexPos = lineFindResult.idxOfSommet;
+ if (context.getRepere().isDifferentPoint(x, y, coords.getX(vertexPos), coords.getY(vertexPos))) {
+ coords.setOrdinate(vertexPos, 0, x);
+ coords.setOrdinate(vertexPos, 1, y);
+ //il y en a qu'un
+ editorToRepaint = (ZEditorDefault) lineFindResult.layer.getEditor();
+ }
+ }
+ if (editorToRepaint != null) {
+ editorToRepaint.repaintPanel();
+ }
+
+ }
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricLineModelIndexer.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricLineModelIndexer.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricLineModelIndexer.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,127 @@
+package org.fudaa.fudaa.fgrid.model;
+
+import gnu.trove.TLongObjectHashMap;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.fudaa.ctulu.collection.CtuluCollectionEmpty;
+import org.fudaa.ctulu.collection.CtuluCollectionInteger;
+import org.fudaa.ctulu.collection.CtuluListInteger;
+import org.fudaa.ctulu.gis.GISAttributeModel;
+import org.fudaa.ctulu.gis.GISAttributeModelLongInterface;
+import org.fudaa.ctulu.gis.GISZoneCollection;
+import org.fudaa.ebli.calque.ZCalqueLigneBrisee;
+import org.fudaa.fudaa.sig.layer.FSigLayerLineEditable;
+
+/**
+ * An indexer for line. Used to fine id of used line and of used points.
+ *
+ * @author deniger
+ */
+public class GeometricLineModelIndexer extends GeometricDefaultIndexer {
+
+ /**
+ * Use to give the position of the lines using a node with a given id.
+ */
+ TLongObjectHashMap<CtuluListInteger> idNodeForLinePosition = new TLongObjectHashMap<CtuluListInteger>();
+
+ /**
+ * @param collection
+ */
+ public GeometricLineModelIndexer(GISZoneCollection collection) {
+ super(collection);
+ }
+
+ @Override
+ protected void postIndex() {
+ // fill the idNodeForLinePosition map
+ idNodeForLinePosition.clear();
+ GISAttributeModel dataModel = getNodeIdLongModel();
+ int nbLine = dataModel.getSize();
+ for (int i = 0; i < nbLine; i++) {
+ fillMap(i, (GISAttributeModelLongInterface) dataModel.getObjectValueAt(i));
+ }
+ }
+
+ protected GISAttributeModel getNodeIdLongModel() {
+ int idxOfNodeId = collection.getIndiceOf(AttributeConstants.NODE_ID);
+ GISAttributeModel dataModel = collection.getDataModel(idxOfNodeId);
+ return dataModel;
+ }
+
+ public boolean isNodeUsedByALine(long nodeId) {
+ index();
+ return idNodeForLinePosition.contains(nodeId);
+ }
+
+ public CtuluCollectionInteger getLinePositionUsingThisNode(long nodeId) {
+ index();
+ return idNodeForLinePosition.contains(nodeId) ? idNodeForLinePosition.get(nodeId) : CtuluCollectionEmpty.INTEGER;
+ }
+
+ /**
+ * @param id l'id du point
+ * @return une collection de LineFindResult pour chaque somment utilisant l'id du point.Attention le calque n'est pas
+ * renseigne dans les LineFindResult.
+ */
+ public Collection<LineFindResult> getLineUsingPointId(long id) {
+ Collection<LineFindResult> res = new ArrayList<LineFindResult>();
+ collectLineUsingPointId(id, res, null);
+ return res;
+ }
+
+ /**
+ * @param pointID id searched
+ * @param out the list that will be completed
+ * @param containerLayer the containing layer used to fill LineFindResult.
+ */
+ public void collectLineUsingPointId(long pointID, Collection<LineFindResult> out, FSigLayerLineEditable containerLayer) {
+ CtuluCollectionInteger lines = getLinePositionUsingThisNode(pointID);
+ if (lines == null) return;
+ int nb = lines.getSize();
+ GISAttributeModel dataModel = getNodeIdLongModel();
+ for (int i = 0; i < nb; i++) {
+ int lineIdx = lines.getValue(i);
+ GISAttributeModelLongInterface ids = ((GISAttributeModelLongInterface) dataModel.getObjectValueAt(lineIdx));
+ int nbVertex = ids.getSize();
+ for (int j = 0; j < nbVertex; j++) {
+ if (ids.getValue(j) == pointID) {
+ LineFindResult findRes = new LineFindResult();
+ findRes.idxOfLine = lineIdx;
+ findRes.idxOfSommet = j;
+ findRes.layer = containerLayer;
+ out.add(findRes);
+ }
+ }
+ }
+ }
+
+ /**
+ * @param linePos the position of the line in this zone
+ * @param nodesId list of nodes id used by the line
+ */
+ private void fillMap(int linePos, GISAttributeModelLongInterface nodesId) {
+ int nbPt = nodesId.getSize();
+ for (int i = 0; i < nbPt; i++) {
+ long nodeId = nodesId.getValue(i);
+ CtuluListInteger lines = idNodeForLinePosition.get(nodeId);
+ if (lines == null) {
+ lines = new CtuluListInteger();
+ idNodeForLinePosition.put(nodeId, lines);
+ }
+ lines.add(linePos);
+ }
+
+ }
+
+ /**
+ * @param lineId l'ID of the point
+ * @return if contains by this collection.
+ */
+ public boolean isLineUsed(long lineId) {
+ index();
+ return idForPosition.contains(lineId);
+ }
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricPointFromLineUpdater.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricPointFromLineUpdater.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricPointFromLineUpdater.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,75 @@
+package org.fudaa.fudaa.fgrid.model;
+
+import java.util.Collection;
+
+import com.vividsolutions.jts.geom.CoordinateSequence;
+
+import org.fudaa.ctulu.gis.GISAttributeInterface;
+import org.fudaa.ctulu.gis.GISAttributeModel;
+import org.fudaa.ctulu.gis.GISAttributeModelLongInterface;
+import org.fudaa.ctulu.gis.GISCollection;
+import org.fudaa.ctulu.gis.GISCollectionData;
+import org.fudaa.ctulu.gis.GISZoneCollectionPoint;
+import org.fudaa.ctulu.gis.GISZoneListener;
+import org.fudaa.ebli.calque.edition.ZEditorDefault;
+
+/**
+ * Update point Layers when a line has been changed
+ *
+ * @author deniger
+ */
+public class GeometricPointFromLineUpdater implements GISZoneListener {
+ final ContextGeometricLayers context;
+ final GeometricLigneBriseeModel model;
+
+ /**
+ * @param context
+ * @param model
+ */
+ public GeometricPointFromLineUpdater(ContextGeometricLayers context, GeometricLigneBriseeModel model) {
+ super();
+ this.context = context;
+ this.model = model;
+ }
+
+ public void attributeChanged(GISCollection src, GISAttributeInterface att) {}
+
+ public void dataChanged(GISAttributeInterface attribute, GISCollectionData data) {}
+
+ public void geometryChanged(GISCollection src, int[] idxs, Class class1, int action) {
+ ZEditorDefault editorToRepaint = null;
+ if (action == GISZoneListener.UPDATE) {
+ GISAttributeModel nodeIdLongModel = model.getIndexer().getNodeIdLongModel();
+ for (int i = idxs.length - 1; i >= 0; i--) {
+ int posOfLine = idxs[i];
+ editorToRepaint = lineChanged(posOfLine, nodeIdLongModel, editorToRepaint);
+
+ }
+ }
+ if (editorToRepaint != null) {
+ editorToRepaint.repaintPanel();
+ }
+ }
+
+ private ZEditorDefault lineChanged(int posOfLine, GISAttributeModel nodeIdLongModel, ZEditorDefault editorToRepaint) {
+ GISAttributeModelLongInterface pointIds = (GISAttributeModelLongInterface) nodeIdLongModel
+ .getObjectValueAt(posOfLine);
+ int nbPoints = pointIds.getSize();
+ CoordinateSequence pointXYInLine = model.getGeomData().getCoordinateSequence(posOfLine);
+ for (int j = 0; j < nbPoints; j++) {
+ NodeFindResult nodeUsingPoint = context.locateNode(pointIds.getValue(j));
+ GeometricPointModel model = (GeometricPointModel) nodeUsingPoint.layer.modele();
+ GISZoneCollectionPoint pt = (GISZoneCollectionPoint) model.getGeomData();
+ double x = pointXYInLine.getX(j);
+ double y = pointXYInLine.getY(j);
+ int idxInPointModel = nodeUsingPoint.idx;
+ if (context.getRepere().isDifferentPoint(x, y, pt.getX(idxInPointModel), pt.getY(idxInPointModel))) {
+ pt.set(idxInPointModel, x, y, null);
+ editorToRepaint = (ZEditorDefault) nodeUsingPoint.layer.getEditor();
+ }
+
+ }
+ return editorToRepaint;
+ }
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricPointModel.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricPointModel.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricPointModel.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,137 @@
+package org.fudaa.fudaa.fgrid.model;
+
+import gnu.trove.TIntArrayList;
+
+import org.fudaa.ctulu.CtuluCommandContainer;
+import org.fudaa.ctulu.CtuluListSelectionInterface;
+import org.fudaa.ctulu.gis.GISAttributeModelLongInterface;
+import org.fudaa.ctulu.gis.GISZoneCollectionPoint;
+import org.fudaa.ctulu.gis.GISZoneListenerDispatcher;
+import org.fudaa.ebli.calque.edition.ZEditionAttibutesContainer;
+import org.fudaa.ebli.calque.edition.ZEditionAttributesDataI;
+import org.fudaa.ebli.calque.edition.ZModelePointEditable;
+import org.fudaa.ebli.geometrie.GrPoint;
+import org.fudaa.fudaa.fgrid.layer.ContextGeometricLayersImpl;
+
+/**
+ * Index for a node model: used to quick find the modele containing a node with a given id.
+ *
+ * @author deniger
+ */
+public class GeometricPointModel extends ZModelePointEditable {
+
+ final ContextGeometricLayers geoContext;
+
+ GeometricPointModelIndexer indexer;
+
+ /**
+ * @param zone
+ */
+ public GeometricPointModel(final GISZoneCollectionPoint zone, final ContextGeometricLayers geoContext) {
+ super(zone);
+ this.geoContext = geoContext;
+ ((GISZoneListenerDispatcher) zone.getListener()).addListener(new GeometricLineFromPointUpdater(geoContext, this));
+ }
+
+ @Override
+ public void addPoint(final GrPoint p, final ZEditionAttributesDataI initData, final CtuluCommandContainer cmd) {
+ ZEditionAttributesDataI data = initData;
+ if (data == null) {
+ data = new ZEditionAttibutesContainer(getGeomData().getAttributes()).createPointData();
+ }
+ final Long id = (Long) data.getValue(AttributeConstants.ID, 0);
+ // serait inutile surtout si c'est un nouveau point
+ if (ContextGeometricLayersImpl.isNotDefinedID(id)) {
+ data.setValue(AttributeConstants.ID, 0, geoContext.createNodeId());
+ }
+ super.addPoint(p, data, cmd);
+ }
+
+ /**
+ * @param p
+ * @param data
+ * @param cmd
+ * @return l'id du point ajoute
+ */
+ public long addPointAndReturnId(final GrPoint p, final ZEditionAttributesDataI initData,
+ final CtuluCommandContainer cmd) {
+ ZEditionAttributesDataI data = initData;
+ if (data == null) {
+ data = new ZEditionAttibutesContainer(getGeomData().getAttributes()).createPointData();
+ }
+ final Long id = (Long) data.getValue(AttributeConstants.ID, 0);
+ long res = -1l;
+ if (ContextGeometricLayersImpl.isNotDefinedID(id)) {
+ res = geoContext.createNodeId();
+ data.setValue(AttributeConstants.ID, 0, res);
+ } else {
+ res = id.longValue();
+ }
+ super.addPoint(p, data, cmd);
+ return res;
+ }
+
+ @Override
+ public boolean copyGlobal(final CtuluListSelectionInterface selection, final double dx, final double dy,
+ final CtuluCommandContainer cmd) {
+ // TODO a continuer pour les lignes utilisant ces points
+ return super.copyGlobal(selection, dx, dy, cmd);
+ }
+
+ /**
+ * @return the indexer
+ */
+ public GeometricPointModelIndexer getIndexer() {
+ if (indexer == null) indexer = new GeometricPointModelIndexer(getGeomData());
+ return indexer;
+ }
+
+ /**
+ * @param idxNodeInThisLayer index of the node in this model
+ * @return the global unique ID
+ */
+ public long getNodeId(int idxNodeInThisLayer) {
+ return ((GISAttributeModelLongInterface) getGeomData().getDataModel(
+ getGeomData().getIndiceOf(AttributeConstants.ID))).getValue(idxNodeInThisLayer);
+ }
+
+ /**
+ * @param nodeId ID of the searched point
+ * @return the position in this model and -1 if not found
+ */
+ public int getPositionOfNodeId(long nodeId) {
+ return getIndexer().getPositionOfId(nodeId);
+ }
+
+ @Override
+ public boolean removePoint(final int[] idx, final CtuluCommandContainer cmd) {
+ TIntArrayList removableNodes = new TIntArrayList();
+ boolean isANodeUsed = false;
+ for (int i = 0; i < idx.length; i++) {
+ long nodeId = getNodeId(idx[i]);
+
+ if (geoContext.isNodeUsedByALine(nodeId)) {
+ isANodeUsed = true;
+ } else {
+ removableNodes.add(idx[i]);
+ }
+ }
+ if (isANodeUsed) {
+ if (removableNodes.isEmpty()) {
+ geoContext.getUi().error("Op\xE9ration annul\xE9e: tous les noeuds sont utilis\xE9s");
+ return false;
+ } else {
+ geoContext.getUi().warn("Noeuds utilis\xE9s",
+ "Op\xE9ration partiellement effectu\xE9e: des noeuds sont utilis\xE9 par des lignes", false);
+ }
+ }
+ return super.removePoint(removableNodes.toNativeArray(), cmd);
+ }
+
+ @Override
+ public boolean setPoint(final int idx, final double newX, final double newY, final CtuluCommandContainer cmd) {
+ //le correspondance est gerer par les listener.
+ return super.setPoint(idx, newX, newY, cmd);
+ }
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricPointModelIndexer.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricPointModelIndexer.java (rev 0)
+++ trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/GeometricPointModelIndexer.java 2010-01-09 00:55:01 UTC (rev 5608)
@@ -0,0 +1,37 @@
+package org.fudaa.fudaa.fgrid.model;
+
+import org.fudaa.ctulu.gis.GISZoneCollection;
+
+public class GeometricPointModelIndexer extends GeometricDefaultIndexer {
+
+ /**
+ * @param collection
+ */
+ public GeometricPointModelIndexer(GISZoneCollection collection) {
+ super(collection);
+ }
+
+ /**
+ * @param pointID l'ID of the point
+ * @return if contains by this collection.
+ */
+ public boolean isPointUsed(long pointID) {
+ index();
+ return idForPosition.contains(pointID);
+ }
+
+ /**
+ * @param pointID the id to look for
+ * @return le FindResult without le layer set
+ */
+ public NodeFindResult findPoint(long pointID) {
+ NodeFindResult res = NodeFindResult.EMPTY;
+ int positionOfId = super.getPositionOfId(pointID);
+ if (positionOfId >= 0) {
+ res = new NodeFindResult();
+ res.idx = positionOfId;
+ }
+ return res;
+ }
+
+}
Added: trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/LineFindResult.java
===================================================================
--- trunk/soft/fudaa-prepro/grid/src/main/java/org/fudaa/fudaa/fgrid/model/LineFindResult.java (rev 0)
+++ trunk/soft/fudaa-...
[truncated message content] |