|
From: <chr...@us...> - 2010-05-26 16:30:39
|
Revision: 5755
http://fudaa.svn.sourceforge.net/fudaa/?rev=5755&view=rev
Author: chrisc83
Date: 2010-05-26 16:30:32 +0000 (Wed, 26 May 2010)
Log Message:
-----------
Version de tests!!!
Modified Paths:
--------------
trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/layer/MvElementLayer.java
trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/post/TrIsoLayerDefault.java
Added Paths:
-----------
trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/layer/MvElementLayerOriginal.java
trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/post/TrIsoLayerDefaultOriginal.java
Modified: trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/layer/MvElementLayer.java
===================================================================
--- trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/layer/MvElementLayer.java 2010-05-25 21:55:58 UTC (rev 5754)
+++ trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/layer/MvElementLayer.java 2010-05-26 16:30:32 UTC (rev 5755)
@@ -14,6 +14,9 @@
import java.awt.Graphics2D;
import java.util.Arrays;
+import javax.print.attribute.standard.JobMessageFromOperator;
+import javax.swing.JOptionPane;
+
import com.vividsolutions.jts.algorithm.SIRtreePointInRing;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
@@ -132,6 +135,8 @@
@Override
public void paintDonnees(final Graphics2D _g, final GrMorphisme _versEcran, final GrMorphisme _versReel,
final GrBoite _clipReel) {
+ System.out.println("Start MvElementLayer.paintDonnees");
+
if ((modele_ == null) || (modele_.getNombre() <= 0)) { return; }
final GrBoite clip = _clipReel;
final GrMorphisme versEcran = _versEcran;
@@ -223,6 +228,7 @@
}
}
+ System.out.println("Stop MvElementLayer.paintDonnees");
}
public int[] getSelectedElementIdx() {
Added: trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/layer/MvElementLayerOriginal.java
===================================================================
--- trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/layer/MvElementLayerOriginal.java (rev 0)
+++ trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/layer/MvElementLayerOriginal.java 2010-05-26 16:30:32 UTC (rev 5755)
@@ -0,0 +1,370 @@
+/*
+ * @creation 13 nov. 2003
+ * @modification $Date: 2008-02-20 10:11:50 $
+ * @license GNU General Public License 2
+ * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne
+ * @mail de...@fu...
+ */
+package org.fudaa.fudaa.meshviewer.layer;
+
+import gnu.trove.TIntHashSet;
+
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.util.Arrays;
+
+import com.vividsolutions.jts.algorithm.SIRtreePointInRing;
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.Envelope;
+import com.vividsolutions.jts.geom.LinearRing;
+
+import com.memoire.fu.Fu;
+import com.memoire.fu.FuLog;
+
+import org.fudaa.ctulu.CtuluListSelection;
+import org.fudaa.ctulu.CtuluListSelectionInterface;
+
+import org.fudaa.dodico.ef.EfElementVolume;
+import org.fudaa.dodico.ef.EfGridInterface;
+import org.fudaa.dodico.ef.EfGridVolumeInterface;
+import org.fudaa.dodico.ef.operation.EfIndexHelper;
+import org.fudaa.dodico.ef.operation.EfIndexVisitorHashSet;
+import org.fudaa.dodico.ef.operation.EfIndexVisitorNearestElt;
+import org.fudaa.dodico.ef.operation.EfIndexVisitorNearestNode;
+
+import org.fudaa.ebli.calque.ZCalquePolygone;
+import org.fudaa.ebli.commun.EbliLib;
+import org.fudaa.ebli.find.EbliFindActionInterface;
+import org.fudaa.ebli.find.EbliFindExpressionContainerInterface;
+import org.fudaa.ebli.geometrie.GrBoite;
+import org.fudaa.ebli.geometrie.GrMorphisme;
+import org.fudaa.ebli.geometrie.GrPoint;
+import org.fudaa.ebli.geometrie.GrPolygone;
+import org.fudaa.ebli.geometrie.VecteurGrPoint;
+import org.fudaa.ebli.trace.TraceIcon;
+import org.fudaa.ebli.trace.TraceIconModel;
+import org.fudaa.ebli.trace.TraceLigne;
+import org.fudaa.ebli.trace.TraceLigneModel;
+
+import org.fudaa.fudaa.meshviewer.MvLayerGrid;
+import org.fudaa.fudaa.meshviewer.model.MvElementModel;
+import org.fudaa.fudaa.meshviewer.model.MvExpressionSupplierElement;
+
+
+/**
+ * @author deniger
+ * @version $Id: MvElementLayer.java,v 1.31.6.1 2008-02-20 10:11:50 bmarchan Exp $
+ */
+public class MvElementLayerOriginal extends ZCalquePolygone implements MvLayerGrid {
+
+ public MvElementLayerOriginal() {
+ super();
+ iconModel_ = null;
+ }
+
+ public final static int[] getSelectedEdgeIdx(final EfGridVolumeInterface _grid,
+ final CtuluListSelectionInterface _select) {
+ if (_grid == null || _select == null) {
+ return null;
+ }
+ final TIntHashSet set = new TIntHashSet();
+ final int max = _select.getMaxIndex();
+ for (int i = _select.getMinIndex(); i <= max; i++) {
+ if (_select.isSelected(i)) {
+ final EfElementVolume elt = _grid.getEltVolume(i);
+ elt.fillWithAreteIdx(set);
+ }
+ }
+ final int[] res = set.toArray();
+ Arrays.sort(res);
+ return res;
+ }
+
+ public final static int[] getSelectedEdgeIdx(final EfGridVolumeInterface _grid, final int[] _select) {
+ if (_grid == null || _select == null) {
+ return null;
+ }
+ final TIntHashSet set = new TIntHashSet();
+ for (int i = _select.length - 1; i >= 0; i--) {
+ final EfElementVolume elt = _grid.getEltVolume(_select[i]);
+ elt.fillWithAreteIdx(set);
+ }
+ final int[] res = set.toArray();
+ Arrays.sort(res);
+ return res;
+ }
+
+ public int[] getSelectedEdgeIdx() {
+ if (((MvElementModel) modele_).getGrid() instanceof EfGridVolumeInterface) {
+ return getSelectedEdgeIdx((EfGridVolumeInterface) ((MvElementModel) modele_).getGrid(), getLayerSelection());
+ }
+ return null;
+ }
+
+ public boolean isSelectionEdgeEmpty() {
+ return isSelectionEmpty();
+ }
+
+ /**
+ * @param _modele
+ */
+ public MvElementLayerOriginal(final MvElementModel _modele) {
+ super(_modele);
+ }
+
+ @Override
+ public EbliFindActionInterface getFinder() {
+ return new MvFindActionNodeElt(this);
+ }
+
+ @Override
+ public EbliFindExpressionContainerInterface getExpressionContainer() {
+ final EbliFindExpressionContainerInterface i = ((MvElementModel) modele_).getExpressionContainer();
+ return i == null ? new MvExpressionSupplierElement((MvElementModel) modele_) : i;
+ }
+
+ /**
+ * Ne dessine que les donn\xE9es.
+ *
+ * @param _g le graphics cible
+ */
+ @Override
+ public void paintDonnees(final Graphics2D _g, final GrMorphisme _versEcran, final GrMorphisme _versReel,
+ final GrBoite _clipReel) {
+ if ((modele_ == null) || (modele_.getNombre() <= 0)) { return; }
+ final GrBoite clip = _clipReel;
+ final GrMorphisme versEcran = _versEcran;
+ final boolean rapide = isRapide();
+ // BPaletteCouleur paletteCouleur = getPaletteCouleur();
+ // BPaletteIcone paletteIcone = getPaletteIcone();
+ final int nombre = modele_.getNombre();
+ // pour ne pas modifier le model par defaut
+ final TraceIcon icone = iconModel_ == null ? null : new TraceIcon(new TraceIconModel(iconModel_));
+ final GrBoite bPoly = new GrBoite();
+ int incrementPt = 1;
+ final TraceLigne tl = new TraceLigne(new TraceLigneModel(ligneModel_));
+ if (isAttenue()) {
+ tl.setCouleur(attenueCouleur(tl.getCouleur()));
+ if (icone != null) {
+ icone.setCouleur(attenueCouleur(icone.getCouleur()));
+ }
+ }
+ if (EbliLib.isAlphaChanged(alpha_)) {
+ tl.setCouleur(EbliLib.getAlphaColor(tl.getCouleur(), alpha_));
+ if (icone != null) {
+ icone.setCouleur(EbliLib.getAlphaColor(icone.getCouleur(), alpha_));
+ }
+
+ }
+ GrPoint ptOri = null;
+ GrPoint ptDest = null;
+ final MvElementModel model = (MvElementModel) modele_;
+ final boolean containsFr = model.getFrNbFrontier() > 0;
+ for (int i = 0; i < nombre; i++) {
+ // si le polygone i est filtre on passe.
+ if (!modele_.polygone(poly_, i, false)) {
+ continue;
+ }
+ poly_.boite(bPoly);
+ // Si la boite du polygone n'est pas dans la boite d'affichage on passe
+ if (!bPoly.intersectXY(clip)) {
+ continue;
+ }
+ final int nbPoints = poly_.sommets_.nombre();
+ if (nbPoints <= 0) {
+ continue;
+ }
+ if (rapide && (nbPoints > 15)) {
+ incrementPt = 3;
+ } else {
+ incrementPt = 1;
+ }
+ poly_.autoApplique(versEcran);
+ updateTrace(icone == null ? null : icone.getModel(), tl.getModel(), i);
+ ptOri = poly_.sommets_.renvoie(0);
+ ptDest = null;
+ int idxFrom = model.getIndice(i, 0);
+ int idxTo = -1;
+ for (int j = poly_.nombre() - 1; j >= 0; j -= incrementPt) {
+ // le point de dest est initialise
+ idxTo = model.getIndice(i, j);
+ ptDest = poly_.sommets_.renvoie(j);
+ if (!containsFr || idxTo > idxFrom) {
+ if (icone != null) {
+ // icone.paintIconCentre(this, _g, ptDest.x, ptDest.y);
+ icone.paintIconCentre(this, _g, ptOri.x_, ptOri.y_);
+ }
+ tl.dessineTrait(_g, ptOri.x_, ptOri.y_, ptDest.x_, ptDest.y_);
+ }
+ ptOri = ptDest;
+ idxFrom = idxTo;
+ }
+ }
+ ptOri = new GrPoint();
+ ptDest = new GrPoint();
+ for (int i = model.getFrNbFrontier() - 1; i >= 0; i--) {
+ int idxFrom = model.getFrGlobalIdx(i, 0);
+ int idxTo = -1;
+ for (int j = model.getFrNbPointInFrontier(i) - 1; j >= 0; j--) {
+ idxTo = model.getFrGlobalIdx(i, j);
+ if (idxFrom > idxTo) {
+ model.point(idxFrom, ptOri);
+ model.point(idxTo, ptDest);
+ ptDest.autoApplique(versEcran);
+ ptOri.autoApplique(versEcran);
+ if (icone != null) {
+ // icone.paintIconCentre(this, _g, ptDest.x, ptDest.y);
+ icone.paintIconCentre(this, _g, ptOri.x_, ptOri.y_);
+ }
+ tl.dessineTrait(_g, ptOri.x_, ptOri.y_, ptDest.x_, ptDest.y_);
+ }
+ idxFrom = idxTo;
+ }
+
+ }
+ }
+
+ public int[] getSelectedElementIdx() {
+ return selection_ == null ? null : selection_.getSelectedIndex();
+ }
+
+ @Override
+ public int[] getSelectedObjectInTable() {
+ return getSelectedElementIdx();
+ }
+
+ protected EfGridInterface getGrid() {
+ return ((MvElementModel) modele_).getGrid();
+ }
+
+ @Override
+ public CtuluListSelection selection(final GrPoint _pt, final int _tolerance) {
+ return getGrid().getIndex() == null ? super.selection(_pt, _tolerance) : selectionFromIndex(_pt, _tolerance);
+ }
+
+ public CtuluListSelection selectionFromIndex(final LinearRing _poly, final int _mode) {
+ if (Fu.DEBUG && FuLog.isDebug()) {
+ FuLog.debug("FMV: layer select from index");
+ }
+ final EfIndexVisitorHashSet list = new EfIndexVisitorHashSet();
+ final Envelope envelopeInternal = _poly.getEnvelopeInternal();
+ getGrid().getIndex().query(envelopeInternal, list);
+ final SIRtreePointInRing tester = new SIRtreePointInRing(_poly);
+ final int[] nds = list.getResult();
+ final CtuluListSelection r = creeSelection();
+ final Coordinate c = new Coordinate();
+ final GrPolygone poly = new GrPolygone();
+ final GrBoite b = new GrBoite();
+ for (int i = nds.length - 1; i >= 0; i--) {
+ final int idx = nds[i];
+ modele().polygone(poly, idx, true);
+ poly.boite(b);
+ if (VecteurGrPoint.estSelectionneEnv(c, envelopeInternal, _poly, tester, poly.sommets_, _mode)) {
+ r.add(idx);
+ }
+ }
+
+ return r;
+ }
+
+ private CtuluListSelection selectionFromIndex(final GrPoint _pt, final int _tolerance) {
+ if (Fu.DEBUG && FuLog.isDebug()) {
+ FuLog.debug("FMV: layer select from index");
+ }
+ return EfIndexHelper.getNearestElement(getGrid(), _pt.x_, _pt.y_, GrMorphisme.convertDistanceXY(getVersReel(),
+ _tolerance), null);
+// final EfIndexVisitorNearestElt visitor = new EfIndexVisitorNearestElt(grid, _pt.x_, _pt.y_, toleranceReel);
+// grid.getIndex().query(EfIndexVisitorNearestNode.getEnvelope(_pt.x_, _pt.y_, toleranceReel), visitor);
+// return visitor.getSelection();
+ }
+
+ @Override
+ public CtuluListSelection selection(final LinearRing _polySelection, final int _mode) {
+ return getGrid().getIndex() == null ? super.selection(_polySelection, _mode) : selectionFromIndex(_polySelection,
+ _mode);
+ }
+
+ public int[] getSelectedPtIdx() {
+ if (!isSelectionEmpty()) {
+ final TIntHashSet res = new TIntHashSet();
+ final int max = selection_.getMaxIndex();
+ final MvElementModel m = (MvElementModel) modele_;
+ for (int i = selection_.getMinIndex(); i <= max; i++) {
+ if (selection_.isSelected(i)) {
+ m.fillWithPtIdx(i, res);
+ }
+ }
+ return res.toArray();
+ }
+ return null;
+ }
+
+ public GrBoite getDomaineOnSelected() {
+ if (isSelectionEmpty()) {
+ return null;
+ }
+ int m = selection_.getMaxIndex();
+ if (m > modele_.getNombre()) {
+ m = modele_.getNombre() - 1;
+ }
+ final GrBoite r = new GrBoite();
+ final GrBoite temp = new GrBoite();
+ final GrPolygone poly = new GrPolygone();
+ for (int i = selection_.getMinIndex(); i <= m; i++) {
+ if (selection_.isSelected(i)) {
+ modele_.polygone(poly, i, true);
+ poly.boite(temp);
+ r.ajuste(temp);
+ }
+ }
+// ajusteZoomOnSelected(r);
+ return r;
+ }
+
+ public boolean isConfigurable() {
+ return true;
+ }
+
+ public boolean isFontModifiable() {
+ return false;
+ }
+
+ @Override
+ public boolean isPaletteModifiable() {
+ return false;
+ }
+
+ public boolean isSelectionElementEmpty() {
+ return isSelectionEmpty();
+ }
+
+ public boolean isSelectionPointEmpty() {
+ return isSelectionEmpty();
+ }
+
+ @Override
+ public void paintIcon(final Component _c, final Graphics _g, final int _x, final int _y) {
+ super.paintIcon(_c, _g, _x, _y);
+ _g.setColor(getForeground());
+ final int w = getIconWidth();
+ final int h = getIconHeight();
+ int x1 = _x + 3;
+ int y1 = _y + h / 2;
+ final int x2 = _x + w / 2;
+ final int y2 = _y + 3;
+ final int x3 = _x + w / 4;
+ final int y3 = _y + h - 3;
+ final int x4 = x2;
+ final int y4 = _y + h / 2 + 4;
+ _g.drawLine(x1, y1, x2, y2);
+ _g.drawLine(x1, y1, x3, y3);
+ _g.drawLine(x1, y1, x4, y4);
+ _g.drawLine(x2, y2, x4, y4);
+ _g.drawLine(x3, y3, x4, y4);
+ x1 = _x + w - 3;
+ y1 = _y + h / 2 + 3;
+ _g.drawLine(x1, y1, x3, y3);
+ _g.drawLine(x1, y1, x4, y4);
+ }
+}
\ No newline at end of file
Modified: trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/post/TrIsoLayerDefault.java
===================================================================
--- trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/post/TrIsoLayerDefault.java 2010-05-25 21:55:58 UTC (rev 5754)
+++ trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/post/TrIsoLayerDefault.java 2010-05-26 16:30:32 UTC (rev 5755)
@@ -15,6 +15,7 @@
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -24,17 +25,12 @@
import javax.swing.DefaultListSelectionModel;
import javax.swing.JComponent;
import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
-import com.memoire.bu.BuMenuItem;
-import com.memoire.bu.BuResource;
-import com.memoire.fu.FuLog;
-import com.vividsolutions.jts.geom.LineString;
-import com.vividsolutions.jts.geom.LinearRing;
-
import org.fudaa.ctulu.CtuluAnalyze;
import org.fudaa.ctulu.CtuluLib;
import org.fudaa.ctulu.CtuluLibArray;
@@ -46,7 +42,13 @@
import org.fudaa.dodico.ef.operation.EfIsoRestructuredGridActivity;
import org.fudaa.dodico.ef.operation.EfIsoRestructuredGridResult;
import org.fudaa.dodico.h2d.type.H2dVariableType;
-import org.fudaa.ebli.calque.*;
+import org.fudaa.ebli.calque.BCalque;
+import org.fudaa.ebli.calque.BCalquePersistenceInterface;
+import org.fudaa.ebli.calque.ZCalqueAffichageDonnees;
+import org.fudaa.ebli.calque.ZCalqueAffichageDonneesConfigure;
+import org.fudaa.ebli.calque.ZCalquePolygone;
+import org.fudaa.ebli.calque.ZCalqueSondeInterface;
+import org.fudaa.ebli.calque.ZSelectionTrace;
import org.fudaa.ebli.commun.EbliLib;
import org.fudaa.ebli.commun.EbliUIProperties;
import org.fudaa.ebli.controle.BConfigurableComposite;
@@ -72,6 +74,12 @@
import org.fudaa.fudaa.tr.persistence.TrPostIsoLayerPersistence;
import org.fudaa.fudaa.tr.post.data.TrPostDataListener;
+import com.memoire.bu.BuMenuItem;
+import com.memoire.bu.BuResource;
+import com.memoire.fu.FuLog;
+import com.vividsolutions.jts.geom.LineString;
+import com.vividsolutions.jts.geom.LinearRing;
+
/**
* Un calque de trace de cartes avec un nouvel algorithme de trace.
*
@@ -718,6 +726,8 @@
@Override
public void paintDonnees(final Graphics2D _g, final GrMorphisme _versEcran, final GrMorphisme _versReel,
final GrBoite _clipReel) {
+ System.out.println("Start TrIsoLayerDefault.paintDonnees");
+ long currentTime = System.currentTimeMillis();
if (namePalette_ == null) {
updateLegende();
}
@@ -791,6 +801,9 @@
}
}
paintSonde(_g, _versEcran);
+ currentTime = System.currentTimeMillis() - currentTime;
+ System.out.println("Stop TrIsoLayerDefault.paintDonnees");
+ System.out.println("Dur\xE9e : " + currentTime);
}
protected void updateEltAdapter() {
Added: trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/post/TrIsoLayerDefaultOriginal.java
===================================================================
--- trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/post/TrIsoLayerDefaultOriginal.java (rev 0)
+++ trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/post/TrIsoLayerDefaultOriginal.java 2010-05-26 16:30:32 UTC (rev 5755)
@@ -0,0 +1,1005 @@
+/**
+ * @creation 1999-08-10
+ * @modification $Date: 2007-06-05 09:01:14 $
+ * @license GNU General Public License 2
+ * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne
+ * @mail de...@fu...
+ */
+package org.fudaa.fudaa.tr.post;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Polygon;
+import java.awt.RenderingHints;
+import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.JComponent;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.ListModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import org.fudaa.ctulu.CtuluAnalyze;
+import org.fudaa.ctulu.CtuluLib;
+import org.fudaa.ctulu.CtuluLibArray;
+import org.fudaa.ctulu.CtuluLibString;
+import org.fudaa.ctulu.CtuluListSelection;
+import org.fudaa.ctulu.CtuluRange;
+import org.fudaa.dodico.ef.EfGridInterface;
+import org.fudaa.dodico.ef.operation.EfIndexHelper;
+import org.fudaa.dodico.ef.operation.EfIsoRestructuredGridActivity;
+import org.fudaa.dodico.ef.operation.EfIsoRestructuredGridResult;
+import org.fudaa.dodico.h2d.type.H2dVariableType;
+import org.fudaa.ebli.calque.BCalque;
+import org.fudaa.ebli.calque.BCalquePersistenceInterface;
+import org.fudaa.ebli.calque.ZCalqueAffichageDonnees;
+import org.fudaa.ebli.calque.ZCalqueAffichageDonneesConfigure;
+import org.fudaa.ebli.calque.ZCalquePolygone;
+import org.fudaa.ebli.calque.ZCalqueSondeInterface;
+import org.fudaa.ebli.calque.ZSelectionTrace;
+import org.fudaa.ebli.commun.EbliLib;
+import org.fudaa.ebli.commun.EbliUIProperties;
+import org.fudaa.ebli.controle.BConfigurableComposite;
+import org.fudaa.ebli.controle.BConfigurableInterface;
+import org.fudaa.ebli.controle.BSelecteurListTarget;
+import org.fudaa.ebli.find.EbliFindExpressionContainerInterface;
+import org.fudaa.ebli.geometrie.GrBoite;
+import org.fudaa.ebli.geometrie.GrMorphisme;
+import org.fudaa.ebli.geometrie.GrPoint;
+import org.fudaa.ebli.geometrie.GrPolygone;
+import org.fudaa.ebli.palette.BPalettePlage;
+import org.fudaa.ebli.palette.BPalettePlageInterface;
+import org.fudaa.ebli.palette.BPalettePlageProperties;
+import org.fudaa.ebli.palette.PaletteManager;
+import org.fudaa.ebli.palette.BPaletteInfo.InfoData;
+import org.fudaa.ebli.trace.TraceIcon;
+import org.fudaa.ebli.trace.TraceIsoInterface;
+import org.fudaa.ebli.trace.TraceIsoLignesAvecPlages;
+import org.fudaa.ebli.trace.TraceIsoSurfacesAvecPlages;
+import org.fudaa.ebli.trace.TraceLigne;
+import org.fudaa.ebli.trace.TraceLigneModel;
+import org.fudaa.fudaa.meshviewer.layer.MvNodeLayer;
+import org.fudaa.fudaa.tr.persistence.TrPostIsoLayerPersistence;
+import org.fudaa.fudaa.tr.post.data.TrPostDataListener;
+
+import com.memoire.bu.BuMenuItem;
+import com.memoire.bu.BuResource;
+import com.memoire.fu.FuLog;
+import com.vividsolutions.jts.geom.LineString;
+import com.vividsolutions.jts.geom.LinearRing;
+
+/**
+ * Un calque de trace de cartes avec un nouvel algorithme de trace.
+ *
+ * @version $Id: TrIsoLayerDefault.java,v 1.48 2007-06-05 09:01:14 deniger Exp $
+ * @author Bertrand Marchand
+ */
+public class TrIsoLayerDefaultOriginal extends MvNodeLayer implements ListSelectionListener, BSelecteurListTarget,
+ ZCalqueSondeInterface, TrPostDataListener {
+
+ static int nameIdx;
+
+ public static TraceIcon getSondeIcone() {
+ final TraceIcon r = new TraceIcon(TraceIcon.RIEN, 6) {
+
+ @Override
+ public void paintIconCentre(final Component _c, final Graphics _g, final int _x, final int _y) {
+ if (_g == null) return;
+ Color old = null;
+ if (getCouleur() != null) {
+ old = _g.getColor();
+ _g.setColor(getCouleur());
+ }
+ final int taille = super.getTaille();
+ final int demiTaille = taille / 2;
+ _g.drawLine(_x - demiTaille, _y, _x - taille, _y + 1);
+ _g.drawLine(_x - demiTaille, _y, _x - taille, _y - 1);
+ _g.drawLine(_x + demiTaille, _y, _x + taille, _y + 1);
+ _g.drawLine(_x + demiTaille, _y, _x + taille, _y - 1);
+ _g.drawLine(_x, _y - demiTaille, _x + 1, _y - taille);
+ _g.drawLine(_x, _y - demiTaille, _x - 1, _y - taille);
+ _g.drawLine(_x, _y + demiTaille, _x + 1, _y + taille);
+ _g.drawLine(_x, _y + demiTaille, _x - 1, _y + taille);
+ _g.drawLine(_x, _y - taille, _x, _y + taille);
+ _g.drawLine(_x - taille, _y, _x + taille, _y);
+ if (super.getCouleur() != null) {
+ _g.setColor(old);
+ }
+ }
+ };
+ r.setCouleur(Color.BLACK);
+ return r;
+ }
+
+ public static boolean restorePalette(final EbliUIProperties _p, final Map _dest) {
+ final String[] names = (String[]) _p.get("post.paletteNames");
+ if (names != null && names.length > 0) {
+ final BPalettePlageProperties[] props = (BPalettePlageProperties[]) _p.get("post.paletteProps");
+ if (_dest.size() > 0) {
+ _dest.clear();
+ }
+ for (int i = 0; i < names.length; i++) {
+ if (props[i] != null && names[i] != null) {
+ _dest.put(names[i], new BPalettePlage(props[i]));
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public static void restoreVar(final EbliUIProperties _p, final BSelecteurListTarget _target, final String _defaultId) {
+ if (_p == null || _target == null) { return; }
+ final int size = _target.getListModel().getSize();
+ if (size == 0) { return; }
+ String varId = _p.getString("post.varId");
+ if (varId == null) {
+ varId = _defaultId;
+ }
+ if (varId != null) {
+ int idx = TrIsoModelAbstract.getVarIdx(varId, _target.getListModel());
+
+ if (idx < 0 || idx >= size) {
+ idx = size - 1;
+ }
+ if (idx >= 0) {
+ _target.getListSelectionModel().setSelectionInterval(idx, idx);
+ }
+ }
+ }
+
+ public static EbliUIProperties savePalettes(final Map _nameBPalette, final EbliUIProperties _prop) {
+ if (_prop == null) { return null; }
+ if (_nameBPalette == null || _nameBPalette.size() == 0) { return _prop; }
+ final List paletteNames = new ArrayList(_nameBPalette.size());
+ final List palettes = new ArrayList(_nameBPalette.size());
+ for (final Iterator it = _nameBPalette.entrySet().iterator(); it.hasNext();) {
+ final Map.Entry e = (Map.Entry) it.next();
+ final String key = (String) e.getKey();
+ if (!CtuluLibString.isEmpty(key)) {
+
+ paletteNames.add(key);
+ palettes.add(((BPalettePlage) e.getValue()).save());
+ }
+ }
+ _prop.put("post.paletteNames", paletteNames.toArray(new String[paletteNames.size()]));
+ _prop.put("post.paletteProps", palettes.toArray(new BPalettePlageProperties[palettes.size()]));
+ return _prop;
+ }
+
+ public static EbliUIProperties saveVar(final EbliUIProperties _prop, final BSelecteurListTarget _list) {
+ if (_prop == null) { return null; }
+ if (_list == null || _list.getListSelectionModel().isSelectionEmpty()) { return _prop; }
+ final Object oi = _list.getListModel().getElementAt(_list.getListSelectionModel().getMaxSelectionIndex());
+
+ H2dVariableType variableSelected = null;
+ if (oi instanceof H2dVariableType) {
+ variableSelected = (H2dVariableType) oi;
+ } else if (oi instanceof TrPostFlecheContent) {
+ variableSelected = ((TrPostFlecheContent) oi).getVar();
+ }
+ if (variableSelected != null) {
+ final String varName = variableSelected.getID();
+ if (varName != null) {
+ _prop.put("post.varId", varName);
+ }
+ }
+ return _prop;
+ }
+
+ public static int selectionElement(final GrPoint _pt, final int _tolerance, final GrMorphisme _versReel,
+ final TrPostModelInterface _model, final GrBoite _clipReel) {
+ GrBoite bClip = _model.getDomaine();
+ final double distanceReel = GrMorphisme.convertDistanceXY(_versReel, _tolerance);
+ if ((!bClip.contientXY(_pt)) && (bClip.distanceXY(_pt) > distanceReel)) { return -1; }
+ bClip = _clipReel;
+ final GrPolygone poly = new GrPolygone();
+ int r = -1;
+ for (int i = _model.getNbElt() - 1; i >= 0; i--) {
+ _model.polygone(poly, i, true);
+ if (bClip.intersectXY(poly.boite())) {
+ if (poly.contientXY(_pt)) {
+ return i;
+ } else if (poly.distanceXY(_pt) <= distanceReel) {
+ r = i;
+ }
+ }
+ }
+ return r;
+
+ }
+
+ /**
+ * Methode qui permet de savoir si le point appartient a la sonde
+ *
+ * @param _prReel
+ * @param _model
+ * @return
+ */
+ public static int sondeSelection(final GrPoint _prReel, final TrPostModelInterface _model) {
+ final EfGridInterface grid = _model.getGrid();
+ if (grid.getIndex() != null) { return EfIndexHelper.getElementEnglobant(grid, _prReel.x_, _prReel.y_, null); }
+ return sondeSelectionLong(_prReel, _model);
+ }
+
+ /**
+ * Recherche l'\xE9l\xE9ment qui peut contenir la sonde pour bien initialiser la var.
+ *
+ * @param _prReel
+ * @param grid
+ * @return
+ */
+ public static int sondeSelection(final GrPoint _prReel, final EfGridInterface grid) {
+ if (grid.getIndex() != null) { return EfIndexHelper.getElementEnglobant(grid, _prReel.x_, _prReel.y_, null); }
+ return -1;
+ }
+
+ private static int sondeSelectionLong(final GrPoint _prReel, final TrPostModelInterface _model) {
+ final GrPolygone poly = new GrPolygone();
+ for (int i = _model.getNbElt() - 1; i >= 0; i--) {
+ _model.polygone(poly, i, true);
+ if (poly.contientXY(_prReel)) { return i; }
+ }
+ return -1;
+
+ }
+
+ private boolean sonde_;
+
+ ListSelectionModel mainVariableSelectionModel_;
+
+ Map namePalette_;
+
+ boolean oldDataTypeIsElement_;
+
+ TraceIcon sondeIcone_;
+
+ List<GrPoint> sondePt_;
+
+ int sondeSelectedElement_ = -1;
+
+ JMenuItem[] spec_;
+
+ double[] v_;
+
+ /**
+ * Contructeur du calque.
+ *
+ * @param _m le modele de donnees
+ */
+ public TrIsoLayerDefaultOriginal(final TrIsoModelAbstract _m) {
+ super(_m);
+ // setTitle(TrResource.getS("r\xE9sultats"));
+ paletteCouleur_ = new BPalettePlage();
+ // on choisit la hauteur d'eau
+ int i = _m.getIndexOf(H2dVariableType.HAUTEUR_EAU);
+ if (i < 0) {
+ i = 0;
+ }
+ setV(i);
+ sondePt_=new ArrayList<GrPoint>();
+ }
+
+ void initPaletteMap() {
+ if (namePalette_ == null) {
+ namePalette_ = new HashMap(getIsoModelAbstract().getVariableNb() + 1);
+ }
+ }
+
+ protected TrIsoLayerDefaultOriginal buildLayer() {
+ return new TrIsoLayerDefaultOriginal(getIsoModelAbstract());
+ }
+
+ @Override
+ protected void buildSpecificMenuItemsForAction(final List _l) {
+ _l.add(createDuplicateItem());
+
+ }
+
+ protected BPalettePlage createPlageForSelectedVar(final H2dVariableType _t) {
+ if (_t == null) { return null; }
+ BPalettePlage s = new BPalettePlage();
+ final TrIsoModelAbstract model = getIsoModelAbstract();
+ if (_t.getParentVariable() == H2dVariableType.TEMPS) {
+ s = new TrPostPaletteTime(model.s_);
+ }
+ s.setTitre(model.getVarDescriptionForPalette(_t));
+ final CtuluRange r = getRangeForPalette();
+ if (r.max_ - r.min_ < 0.01) {
+ s.initPlages(1, r.min_, r.max_);
+ } else {
+ s.initPlages(10, r.min_, r.max_);
+ }
+ s.initCouleurs(PaletteManager.INSTANCE);
+ updateSavedPalBeforeSet(s);
+ return s;
+ }
+
+ public final TrIsoModelAbstract getIsoModelAbstract() {
+ return (TrIsoModelAbstract) modele_;
+ }
+
+ protected CtuluRange getRangeForPalette() {
+ return getIsoModelAbstract().getPaletteExtremaForSelectedValue();
+ }
+
+ protected final void paintSonde(final Graphics2D _g2d, final GrMorphisme _versEcran) {
+ if (sondeSelectedElement_ >= 0) {
+ GrPoint oldPoint=null;
+ for(GrPoint point:sondePt_) {
+
+ final GrPoint p = point.applique(_versEcran);
+ if (sondeIcone_ == null) {
+ sondeIcone_ = getSondeIcone();
+ }
+ // _g2d.setXORMode(Color.WHITE);
+ sondeIcone_.paintIconCentre(this, _g2d, p.x_, p.y_);
+
+ //-- on trace la ligne entre les sondes --//
+ if(oldPoint!=null){
+ _g2d.drawLine((int)oldPoint.x_,(int) oldPoint.y_, (int) p.x_,(int) p.y_);
+
+ }
+ oldPoint=p ;
+ }
+ }
+ }
+
+ protected void timeStepFormatChanged() {
+ if (getIsoModelAbstract().getVariableSelected() != null
+ && getIsoModelAbstract().getVariableSelected().getParentVariable() == H2dVariableType.TEMPS) {
+ updateTimeLegende();
+ updateLegende();
+ } else {
+ firePropertyChange("paletteCouleur", null, paletteCouleur_);
+ }
+ }
+
+ protected void updateCalqueInfo() {
+ final String var = getIsoModelAbstract().getVariableNameSelected();
+ putCalqueInfo(var);
+ }
+
+ protected void updateLegende() {
+ updateLegende(false);
+ }
+
+ protected void updateTimeLegende() {
+ for (final Iterator it = namePalette_.values().iterator(); it.hasNext();) {
+ final BPalettePlage p = (BPalettePlage) it.next();
+ if (p instanceof TrPostPaletteTime) {
+ p.updatePlageLegendes();
+ }
+ }
+ }
+
+ protected void updateLegende(final boolean _forceUpdate) {
+ if (getIsoModelAbstract().getVariableNb() == 0 || getListSelectionModel().isSelectionEmpty()) { return; }
+ initPaletteMap();
+ final String v = getIsoModelAbstract().getCompleteVariableNameId();
+ BPalettePlage s = (BPalettePlage) namePalette_.get(v);
+ if (s == null || _forceUpdate) {
+ final H2dVariableType t = getIsoModelAbstract().getVariableSelected();
+ s = createPlageForSelectedVar(t);
+ namePalette_.put(v, s);
+ } else {
+ updateSavedPalBeforeSet(s);
+ }
+ setPaletteCouleur(s);
+ construitLegende();
+ }
+
+ protected void updateSavedPalBeforeSet(final BPalettePlage _p) {}
+
+ public final boolean changeSonde(final GrPoint _ptReel, final boolean _add) {
+ if (!isSondeEnable()) { return false; }
+ if (sondePt_ == null) {
+ //sondePt_ = new GrPoint();
+ sondePt_=new ArrayList<GrPoint>();
+ }
+
+ GrPoint point=new GrPoint();
+
+ point.initialiseAvec(_ptReel);
+
+ if(!_add)
+ sondePt_.clear();
+ sondePt_.add(point);
+
+ final int i = sondeSelection(point, getIsoModelAbstract());
+ final boolean oldIsDraw = sondeSelectedElement_ >= 0;
+ sondeSelectedElement_ = i;
+ if (sondeSelectedElement_ >= 0) {
+ paintSonde((Graphics2D) getGraphics(), getVersEcran());
+ } else if (oldIsDraw) {
+ repaint();
+ }
+ // pour le panel d'info
+ fireSelectionEvent();
+ return sondeSelectedElement_ >= 0;
+ }
+
+ public JMenuItem createDuplicateItem() {
+ final BuMenuItem it = new BuMenuItem(BuResource.BU.getIcon("dupliquer"), BuResource.BU.getString("dupliquer")) {
+
+ @Override
+ protected void fireActionPerformed(final ActionEvent _event) {
+ super.fireActionPerformed(_event);
+ final BCalque c = (BCalque) TrIsoLayerDefaultOriginal.this.getParent();
+ final Component[] cs = c.getCalques();
+ int i = -1;
+ for (i = 0; i < cs.length; i++) {
+ if (TrIsoLayerDefaultOriginal.this.equals(cs[i])) {
+ break;
+ }
+ }
+ if (i < 0 || i == (cs.length - 1)) {
+ c.enDernier(duplicate());
+ } else if (i == 0) {
+ c.enPremier(duplicate());
+ } else {
+ c.add(duplicate(), i + 1);
+ }
+ }
+ };
+ return it;
+ }
+
+ @Override
+ public BPalettePlageInterface createPaletteCouleur() {
+ if (getIsoModelAbstract().getVariableSelected() != null
+ && getIsoModelAbstract().getVariableSelected().getParentVariable() == H2dVariableType.TEMPS) { return new TrPostPaletteTime(
+ getIsoModelAbstract().s_); }
+ return super.createPaletteCouleur();
+ }
+
+ public void dataAdded(final boolean _isFleche) {}
+
+ public void dataChanged(final H2dVariableType _old, final H2dVariableType _new, final boolean _contentChanged,
+ final boolean _isFleche, final Set _varDepending) {
+ if (_isFleche) { return; }
+ if (_old == getIsoModelAbstract().var_ || _varDepending.contains(getIsoModelAbstract().var_)) {
+ // la variable en cours d'affichage est modifi\xE9e
+ if (_old != _new && _old == getIsoModelAbstract().var_) {
+ getListSelectionModel().clearSelection();
+ setV(getIsoModelAbstract().getIndexOf(_new));
+ }
+ // si le contenu de la variable en cours d'affichage est concern\xE9, on met a jour le cache
+ else {
+ getIsoModelAbstract().updateCurrentValueCache();
+ fireSelectionEvent();
+ repaint();
+ }
+ }
+
+ }
+
+ public void dataRemoved(final H2dVariableType[] _vars, final boolean _isFleche) {
+ // si la variable en cours a ete supprimee, on deselectionne l'affichage....
+ if (FuLog.isDebug()) {
+ FuLog.debug("TRP: " + getClass().getName() + " var removed");
+ }
+ if (getIsoModelAbstract().var_ == null) { return; }
+ if (_vars != null && CtuluLibArray.findObject(_vars, getIsoModelAbstract().var_) >= 0) {
+ if (FuLog.isDebug()) {
+ FuLog.debug("TRP: " + getClass().getName() + " var was used ...");
+ }
+ mainVariableSelectionModel_.clearSelection();
+ }
+ }
+
+ public final ZCalqueAffichageDonnees duplicate() {
+ final TrIsoLayerDefaultOriginal r = buildLayer();
+ r.setName(getName() + "-" + nameIdx++);
+ r.initFrom(saveUIProperties());
+ r.setTitle(r.getTitle() + CtuluLibString.ESPACE + CtuluLib.getS("copie"));
+ r.setLegende(getLegende());
+ r.setActions(getActions());
+ r.setDestructible(true);
+ return r;
+ }
+
+ @Override
+ public void fillWithInfo(final InfoData _m) {
+ _m.setTitle(getTitle());
+ if (isSondeActive()) {
+ fillWithInterpolateInfo(_m);
+ } else {
+ modele_.fillWithInfo(_m, this);
+ }
+ }
+
+ @Override
+ public void fillWithInterpolateInfo(final InfoData _m) {
+ getIsoModelAbstract().fillInterpolateInfo(_m, sondeSelectedElement_, sondePt_.get(0).x_, sondePt_.get(0).y_, getTitle());
+ }
+
+ @Override
+ public final String getDataDescription() {
+ return getTitle();
+ }
+
+ public final int getElementSonde() {
+ return sondeSelectedElement_;
+ }
+
+ @Override
+ public EbliFindExpressionContainerInterface getExpressionContainer() {
+ return getIsoModelAbstract().getExpressionContainer();
+ }
+
+ public final ListModel getListModel() {
+ return getIsoModelAbstract().getVariableList();
+ }
+
+ public final ListSelectionModel getListSelectionModel() {
+ if (mainVariableSelectionModel_ == null) {
+ mainVariableSelectionModel_ = new DefaultListSelectionModel();
+ mainVariableSelectionModel_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ final H2dVariableType t = getIsoModelAbstract().getVariableSelected();
+ if (t != null) {
+ for (int i = getListModel().getSize() - 1; i >= 0; i--) {
+ if (getListModel().getElementAt(i) == t) {
+ mainVariableSelectionModel_.setSelectionInterval(i, i);
+ break;
+ }
+ }
+ }
+ mainVariableSelectionModel_.addListSelectionListener(this);
+ }
+ return mainVariableSelectionModel_;
+ }
+
+ @Override
+ public int getNbSet() {
+ return 1;
+ }
+
+ @Override
+ public BCalquePersistenceInterface getPersistenceMng() {
+ return new TrPostIsoLayerPersistence();
+ }
+
+ @Override
+ public int[] getSelectedElementIdx() {
+ if (getIsoModelAbstract().isRubar()) { return getSelectedIndex(); }
+ return null;
+ }
+
+ @Override
+ public LineString getSelectedLine() {
+ if (getIsoModelAbstract().isCurrentDataElementType()) { return ZCalquePolygone.getSelectedLine(this,
+ getIsoModelAbstract()); }
+ return super.getSelectedLine();
+ }
+
+ @Override
+ public int[] getSelectedObjectInTable() {
+ return getSelectedIndex();
+ }
+
+ @Override
+ public int[] getSelectedPtIdx() {
+ if (getIsoModelAbstract().isRubar()) { return null; }
+ return super.getSelectedPtIdx();
+ }
+
+ @Override
+ protected BConfigurableInterface getAffichageConf() {
+ final BConfigurableInterface[] sect = new BConfigurableInterface[2];
+ final ZCalqueAffichageDonneesConfigure calqueAffichageDonneesConfigure = new ZCalqueAffichageDonneesConfigure(this);
+ calqueAffichageDonneesConfigure.setAddColor(false);
+ sect[0] = calqueAffichageDonneesConfigure;
+ sect[1] = new TrIsoLayerConfigure(this);
+
+ return new BConfigurableComposite(sect, EbliLib.getS("Affichage"));
+ }
+
+ @Override
+ public BConfigurableInterface getSingleConfigureInterface() {
+ return new BConfigurableComposite(new BConfigurableInterface[] { getAffichageConf(),
+ new TrPostFilterConfigure(getIsoModelAbstract().s_, this, getIsoModelAbstract().getCond()) }, null);
+ }
+
+ public final double getSondeX() {
+ return sondePt_ == null ? 0 : sondePt_.get(0).x_;
+ }
+
+ public final double getSondeY() {
+ return sondePt_ == null ? 0 : sondePt_.get(0).y_;
+ }
+
+ public final JComponent getTargetComponent() {
+ return this;
+ }
+
+ public GrBoite getDomaineOnSelected() {
+ if (isSelectionEmpty()) { return null; }
+ int m = selection_.getMaxIndex();
+ if (m > modele_.getNombre()) {
+ m = modele_.getNombre() - 1;
+ }
+ final GrBoite r = new GrBoite();
+ if (getIsoModelAbstract().isCurrentDataElementType()) {
+ final GrPolygone p = new GrPolygone();
+ final GrBoite b = new GrBoite();
+ for (int i = selection_.getMinIndex(); i <= m; i++) {
+ if (selection_.isSelected(i)) {
+ getIsoModelAbstract().polygone(p, i, true);
+ p.boite(b);
+ r.ajuste(b);
+ }
+ }
+ } else {
+ final GrPoint p = new GrPoint();
+ for (int i = selection_.getMinIndex(); i <= m; i++) {
+ if (selection_.isSelected(i)) {
+ modele_.point(p, i, true);
+ r.ajuste(p);
+ }
+ }
+ }
+ ajusteZoomOnSelected(r);
+ return r;
+ }
+
+ @Override
+ public void initFrom(final EbliUIProperties _p) {
+ if (_p != null) {
+ getListSelectionModel().clearSelection();
+ super.initFrom(_p);
+ initPaletteMap();
+ if (restorePalette(_p, namePalette_)) {
+ updateLegende();
+ }
+ restoreVar(_p, this, H2dVariableType.BATHYMETRIE.getID());
+ getIsoModelAbstract().restoreFilter(_p);
+ traceIsoLine_ = _p.getBoolean("calque.draw.iso");
+ }
+ }
+
+ @Override
+ public boolean isAntialiasSupported() {
+ return true;
+ }
+
+ public boolean isBase() {
+ return !isDestructible();
+ }
+
+ @Override
+ public boolean isConfigurable() {
+ return true;
+ }
+
+ @Override
+ public final boolean isDonneesBoiteAvailable() {
+ return true;
+ }
+
+ public boolean isPointSondable(final GrPoint _reel) {
+ return sondeSelection(_reel, getIsoModelAbstract()) >= 0;
+ }
+
+ @Override
+ public boolean isSelectionElementEmpty() {
+ if (getIsoModelAbstract().isRubar()) { return isSelectionEmpty(); }
+ return true;
+ }
+
+ @Override
+ public boolean isSelectionPointEmpty() {
+ return getIsoModelAbstract().isRubar() ? true : super.isSelectionPointEmpty();
+ }
+
+ public final boolean isSondeActive() {
+ return isSondeEnable() && sondeSelectedElement_ >= 0;
+ }
+
+ /**
+ * @return true si la sonde est active
+ */
+ public final boolean isSondeEnable() {
+ return sonde_;
+ }
+
+ @Override
+ public boolean isTitleModifiable() {
+ return true;
+ }
+
+ boolean traceIsoLine_;
+ TrIsoModelEltDataAdapter eltAdapter_;
+
+ @Override
+ public void paintDonnees(final Graphics2D _g, final GrMorphisme _versEcran, final GrMorphisme _versReel,
+ final GrBoite _clipReel) {
+ if (namePalette_ == null) {
+ updateLegende();
+ }
+ final boolean rapide = isRapide();
+ if (rapide) {
+ super.paintDonnees(_g, getIsoModelAbstract().getNbPoint(), _versEcran, _clipReel);
+ return;
+ }
+ int i;
+ TraceIsoInterface isos = null;
+ // TrIsoTraceSurface isos = null;
+ final boolean isElement = getIsoModelAbstract().isCurrentDataElementType();
+ boolean keepAntialias = false;
+ TrPostModelInterface modelToUse = getIsoModelAbstract();
+ if (traceIsoLine_) {
+ isos = new TraceIsoLignesAvecPlages(paletteCouleur_, alpha_, ligneModel_);
+ keepAntialias = true;
+ if (isElement) {
+ // TODO:a modifier null?
+ if (eltAdapter_ == null) {
+ final EfIsoRestructuredGridResult res = new EfIsoRestructuredGridActivity().restructure(getIsoModelAbstract()
+ .getGrid(), null, new CtuluAnalyze());
+ eltAdapter_ = new TrIsoModelEltDataAdapter(res, getIsoModelAbstract());
+ }
+ updateEltAdapter();
+ modelToUse = eltAdapter_;
+ }
+ } else if (!isElement) {
+ isos = new TraceIsoSurfacesAvecPlages(paletteCouleur_, alpha_);
+ }
+ // pour les surfaces, on voudrait eviter d'utiliser l'anticrenelage
+ if (!keepAntialias && isAntialiasing()) {
+ final RenderingHints renderingHints = _g.getRenderingHints();
+ renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+ renderingHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
+ _g.setRenderingHints(renderingHints);
+ }
+
+ final int n = modelToUse.getNbElt();
+ final GrPolygone poly = new GrPolygone();
+ final GrBoite b = new GrBoite();
+ for (i = 0; i < n; i++) {
+ // le test sur la condition se fait dans le modele
+ if (!modelToUse.polygone(poly, i, false)) {
+ continue;
+ }
+ poly.boite(b);
+ if (!_clipReel.intersectXY(b)) {
+ continue;
+ }
+ // Trace des isosurfaces / Isolignes (dans la couleur du fond si les isocouleurs sont
+ // tracees).
+ if (isElement && !traceIsoLine_) {
+ poly.autoApplique(_versEcran);
+ final Polygon p = poly.polygon();
+ final Color c = paletteCouleur_ == null ? null : ((BPalettePlage) paletteCouleur_)
+ // on utilise getIsoModelAbstract car on est bien dans le cas ou il n'y a pas d'adapteur
+ .getColorFor(getIsoModelAbstract().getValue(i));
+ if (c != null) {
+ _g.setColor(EbliLib.getAlphaColor(c, alpha_));
+ _g.fillPolygon(p);
+ }
+
+ } else {
+ v_ = modelToUse.fillWithData(i, v_);
+ if (v_ != null && isos != null) {
+ poly.autoApplique(_versEcran);
+ final Polygon p = poly.polygon();
+ isos.draw(_g, p, v_);
+ }
+ }
+ }
+ paintSonde(_g, _versEcran);
+ }
+
+ protected void updateEltAdapter() {
+ eltAdapter_.setCurrentEltData(getIsoModelAbstract().var_, 0, getIsoModelAbstract().oldData_);
+ }
+
+ /**
+ * Ne dessine que la selection.
+ *
+ * @param _g le graphics cible
+ */
+ public final void paintElementSelection(final Graphics2D _g, final ZSelectionTrace _trace,
+ final GrMorphisme _versEcran, final GrBoite _clipReel) {
+ if (isSelectionEmpty()) { return; }
+ final GrBoite domaine = modele_.getDomaine();
+ if (!domaine.intersectXY(_clipReel)) { return; }
+ Color cs = _trace.getColor();
+ if (isAttenue()) {
+ cs = attenueCouleur(cs);
+ }
+ final TraceLigne tlSelection = _trace.getLigne();
+ final TraceIcon ic = _trace.getIcone();
+ if (isAttenue()) {
+ cs = attenueCouleur(cs);
+ }
+ _g.setColor(cs);
+ // tlSelection_.setEpaisseur(2f);
+ final int nb = selection_.getMaxIndex();
+ final int min = selection_.getMinIndex();
+ final GrPolygone poly = new GrPolygone();
+ for (int i = nb; i >= min; i--) {
+ if (!selection_.isSelected(i)) {
+ continue;
+ }
+ getIsoModelAbstract().polygone(poly, i, true);
+ if (_clipReel.intersectXY(poly.boite())) {
+ poly.autoApplique(_versEcran);
+ final int nbPoints = poly.nombre();
+ GrPoint ptOri = poly.sommets_.renvoie(0);
+ GrPoint ptDest;
+ for (int j = nbPoints - 1; j >= 0; j--) {
+ // le point de dest est initialise
+ ptDest = poly.sommets_.renvoie(j);
+ ic.paintIconCentre(this, _g, ptDest.x_, ptDest.y_);
+ tlSelection.dessineTrait(_g, ptOri.x_, ptOri.y_, ptDest.x_, ptDest.y_);
+ ptOri = ptDest;
+ }
+ }
+ }
+ }
+
+ @Override
+ public void paintIcon(final Component _c, final Graphics _g, final int _x, final int _y) {
+ // super.paintIcon(_c,_g,_x,_y);
+ _g.translate(_x, _y);
+ final boolean attenue = isAttenue();
+ final int w = getIconWidth();
+ final int h = getIconHeight();
+ Color c;
+ c = Color.blue;
+ if (attenue) {
+ c = attenueCouleur(c);
+ }
+ _g.setColor(c);
+ _g.fillRect(1, 1, w - 1, h - 1);
+ c = Color.red;
+ if (attenue) {
+ c = attenueCouleur(c);
+ }
+ _g.setColor(c);
+ _g.fillOval(3, 3, w - 5, h - 5);
+ c = Color.yellow;
+ if (attenue) {
+ c = attenueCouleur(c);
+ }
+ _g.setColor(c);
+ _g.fillOval(7, 7, w - 14, h - 14);
+ _g.translate(-_x, -_y);
+ }
+
+ @Override
+ public final void paintSelection(final Graphics2D _g, final ZSelectionTrace _trace, final GrMorphisme _versEcran,
+ final GrBoite _clipReel) {
+ if (getIsoModelAbstract().isRubar()) {
+ paintElementSelection(_g, _trace, _versEcran, _clipReel);
+ } else {
+ super.paintSelection(_g, _trace, _versEcran, _clipReel);
+ }
+ }
+
+ @Override
+ public EbliUIProperties saveUIProperties() {
+ // c'est pour que la variable en cours soit enregistr\xE9e
+ updateLegende(false);
+ final EbliUIProperties res = super.saveUIProperties();
+ savePalettes(namePalette_, res);
+ saveVar(res, this);
+ getIsoModelAbstract().saveFilter(res);
+ res.put("calque.draw.iso", this.traceIsoLine_);
+ return res;
+ }
+
+ @Override
+ public final CtuluListSelection selection(final GrPoint _pt, final int _tolerance) {
+ if (getIsoModelAbstract().isRubar()) { return selectionElement(_pt, _tolerance); }
+ return super.selection(_pt, _tolerance);
+ }
+
+ @Override
+ public final CtuluListSelection selection(final LinearRing _poly, final int _mode) {
+ if (getIsoModelAbstract().isRubar()) { return selectionElement(_poly, _mode); }
+ return super.selection(_poly, _mode);
+ }
+
+ public final CtuluListSelection selectionElement(final GrPoint _pt, final int _tolerance) {
+ if (!isVisible()) { return null; }
+ final int i = selectionElement(_pt, _tolerance, getVersReel(), getIsoModelAbstract(), getClipReel(getGraphics()));
+ if (i >= 0) {
+ final CtuluListSelection r = creeSelection();
+ r.add(i);
+ return r;
+ }
+ return null;
+ }
+
+ public final CtuluListSelection selectionElement(final LinearRing _poly, final int _mode) {
+ if (!isVisible()) { return null; }
+ return ZCalquePolygone.selection(_poly, _mode, getIsoModelAbstract());
+ }
+
+ @Override
+ public void setForeground(final Color _v) {
+ // super.setForeground(_v);
+ }
+
+ @Override
+ public void setPaletteCouleurPlages(final BPalettePlageInterface _newPlage) {
+ if (getListSelectionModel().isSelectionEmpty()) { return; }
+ super.setPaletteCouleurPlages(_newPlage);
+ }
+
+ /**
+ * @param _enable nouvel etat de l'outil sonde
+ */
+ public void setSondeEnable(final boolean _enable) {
+ if (_enable != sonde_) {
+ sonde_ = _enable;
+ if (sonde_) {
+ clearSelection();
+ } else {
+ sondeSelectedElement_ = -1;
+ }
+ // pour mettre a jour le panel d'info
+ fireSelectionEvent();
+ }
+ }
+
+ public final void setV(final int _i) {
+ if (getIsoModelAbstract().getVariableNb() == 0) { return; }
+ getListSelectionModel().setSelectionInterval(_i, _i);
+ }
+
+ public void valueChanged(final ListSelectionEvent _e) {
+ if (_e.getValueIsAdjusting()) { return; }
+ if (_e.getSource() == mainVariableSelectionModel_) {
+ getIsoModelAbstract().setVar(this.mainVariableSelectionModel_.getMinSelectionIndex());
+ varUpdated();
+ }
+ }
+
+ public final void varUpdated() {
+ updateLegende();
+ // si on passe de donn\xE9es sur des elements a des donn\xE9es sur des points ou inve
+ if (oldDataTypeIsElement_ != getIsoModelAbstract().isCurrentDataElementType()) {
+ clearSelection();
+ oldDataTypeIsElement_ = getIsoModelAbstract().isCurrentDataElementType();
+ }
+ updateCalqueInfo();
+ fireSelectionEvent();
+ repaint();
+ }
+
+ public boolean isTraceIsoLine() {
+ return traceIsoLine_;
+ }
+
+ public void setTraceIsoLine(final boolean _traceIsoLine) {
+ if (_traceIsoLine != traceIsoLine_) {
+ traceIsoLine_ = _traceIsoLine;
+ if (traceIsoLine_ && ligneModel_ == null) {
+ ligneModel_ = new TraceLigneModel();
+ }
+ if (!traceIsoLine_) {
+ eltAdapter_ = null;
+ }
+ repaint();
+ }
+ }
+
+ public List<GrPoint> getLigneBriseeFromSondes(){
+ return this.sondePt_;
+ }
+
+
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|