|
From: <de...@us...> - 2012-05-29 13:20:30
|
Revision: 7244
http://fudaa.svn.sourceforge.net/fudaa/?rev=7244&view=rev
Author: deniger
Date: 2012-05-29 13:20:18 +0000 (Tue, 29 May 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueGeometry.java
trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java
trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalquePoint.java
trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/edition/ZModelePointEditable.java
Modified: trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueGeometry.java
===================================================================
--- trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueGeometry.java 2012-05-29 09:55:46 UTC (rev 7243)
+++ trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueGeometry.java 2012-05-29 13:20:18 UTC (rev 7244)
@@ -114,7 +114,6 @@
protected EbliListeSelectionMulti creeSelectionMulti() {
return new EbliListeSelectionMulti(modeleDonnees().getNombre() / 2);
}
-
protected void initTrace(final TraceIconModel _icon, final int _idxPoly) {
_icon.updateData(getIconModel(0));
@@ -504,6 +503,10 @@
return modele_;
}
+ protected boolean isPainted(int idx, GrMorphisme _versEcran) {
+ return modele_.isGeometryVisible(idx);
+ }
+
/**
* @param _g
*/
@@ -533,7 +536,8 @@
// on part de la fin : comme ca la premiere ligne apparait au-dessus
for (int i = nombre - 1; i >= 0; i--) {
- if (!modele_.isGeometryReliee(i)) {
+ if (!isPainted(i, _versEcran)//dans certains cas, ne pas dessiner l'objet
+ || !modele_.isGeometryReliee(i)) {
continue;
}
@@ -542,10 +546,6 @@
if (nbPoints <= 0) {
continue;
}
- // La g\xE9ometrie n'est pas visible
- if (!modele_.isGeometryVisible(i)) {
- continue;
- }
modele_.getDomaineForGeometry(i, bPoly);
// Si la boite du polygone n'est pas dans la boite d'affichage on passe
@@ -582,8 +582,6 @@
// Enfin les labels sur les atomiques.
paintLabelsOnAtomics(_g, _versEcran, _versReel, _clipReel);
}
-
-
protected void paintSurfaces(final Graphics2D _g, final GrMorphisme _versEcran, final GrMorphisme _versReel,
final GrBoite _clipReel) {
@@ -617,7 +615,7 @@
continue;
}
// La g\xE9ometrie n'est pas visible
- if (!modele_.isGeometryVisible(i)) {
+ if (!isPainted(i,_versEcran)) {
continue;
}
@@ -663,11 +661,11 @@
if (icone != null) {
for (int i = nombre - 1; i >= 0; i--) {
// il n'y a pas de points pour cette ligne
- if (modele_.getNbPointForGeometry(i) <= 0) {
+ if (modele_.getNbPointForGeometry(i) <= 0 || !isPainted(i, _versEcran)) {
continue;
}
// La g\xE9ometrie n'est pas visible
- if (!modele_.isGeometryVisible(i)) {
+ if (!isPainted(i,_versEcran)) {
continue;
}
@@ -721,7 +719,7 @@
continue;
}
// La g\xE9ometrie n'est pas visible
- if (!modele_.isGeometryVisible(i)) {
+ if (!isPainted(i,_versEcran)) {
continue;
}
@@ -1183,8 +1181,6 @@
return false;
}
-
-
@Override
public boolean setSelection(final int[] _idx) {
if (!isSelectable()) {
Modified: trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java
===================================================================
--- trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java 2012-05-29 09:55:46 UTC (rev 7243)
+++ trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java 2012-05-29 13:20:18 UTC (rev 7244)
@@ -9,6 +9,7 @@
import java.awt.Color;
import java.awt.Graphics2D;
+import java.awt.Shape;
import org.fudaa.ebli.commun.EbliLib;
import org.fudaa.ebli.commun.EbliUIProperties;
@@ -23,20 +24,26 @@
import org.fudaa.ebli.trace.TraceLigneModel;
/**
- * Un calque g\xE9rant des lignes bris\xE9es, ouvertes ou ferm\xE9es \xE0 un niveau global ou atomique.<p>
- * Le niveau atomique des lignes bris\xE9es est le niveau points. Le calque s'appuie sur un mod\xE8le
+ * Un calque g\xE9rant des lignes bris\xE9es, ouvertes ou ferm\xE9es \xE0 un niveau global ou atomique.<p> Le niveau atomique des lignes
+ * bris\xE9es est le niveau points. Le calque s'appuie sur un mod\xE8le
* {@link ZModeleLigneBrisee}.
- *
+ *
* @author Fred Deniger
* @version $Id$
*/
public class ZCalqueLigneBrisee extends ZCalqueGeometry {
- /** Le modele d'icone pour les lignes ouvertes */
+ /**
+ * Le modele d'icone pour les lignes ouvertes
+ */
protected TraceIconModel iconeModelOuvert_;
- /** Le modele de lignes pour les lignes ouvertes */
+ /**
+ * Le modele de lignes pour les lignes ouvertes
+ */
protected TraceLigneModel ligneModelOuvert_;
- /** On dessine une fl\xE8che sur chaque ligne pour indiquer le sens de celle-ci. */
+ /**
+ * On dessine une fl\xE8che sur chaque ligne pour indiquer le sens de celle-ci.
+ */
protected boolean showLineOrientation_;
/**
@@ -52,25 +59,26 @@
public ZCalqueLigneBrisee(final ZModeleLigneBrisee _modele) {
super(_modele);
modele_ = _modele;
- if(modele_!=null)
+ if (modele_ != null) {
modele_.addModelListener(this);
+ }
iconModel_ = new TraceIconModel(TraceIcon.CARRE_PLEIN, 2, Color.BLACK);
ligneModelOuvert_ = new TraceLigneModel(ligneModel_);
iconeModelOuvert_ = new TraceIconModel(iconModel_);
- showLineOrientation_=false;
+ showLineOrientation_ = false;
}
- public boolean getShowLineOrientation(){
+ public boolean getShowLineOrientation() {
return showLineOrientation_;
}
-
- public void setShowLineOrientation(boolean _value){
- if(showLineOrientation_!=_value){
- showLineOrientation_=_value;
+
+ public void setShowLineOrientation(boolean _value) {
+ if (showLineOrientation_ != _value) {
+ showLineOrientation_ = _value;
repaint();
}
}
-
+
protected void initTrace(final TraceLigneModel _ligne, final int _idxPoly) {
final int idx = modele_.isGeometryFermee(_idxPoly) ? 0 : 1;
_ligne.updateData(getLineModel(idx));
@@ -79,9 +87,23 @@
} else if (EbliLib.isAlphaChanged(alpha_)) {
_ligne.setCouleur(EbliLib.getAlphaColor(_ligne.getCouleur(), alpha_));
}
+ }
+ public static void initTraceWithAlpha(TraceIconModel model, int alpha) {
+ if (model.getCouleur() != null && model.getCouleur().getAlpha() != alpha) {
+ model.setCouleur(EbliLib.getAlphaColor(model.getCouleur(), alpha));
+ }
+ if (model.getBackgroundColor() != null && model.getBackgroundColor().getAlpha() != alpha) {
+ model.setBackgroundColor(EbliLib.getAlphaColor(model.getBackgroundColor(), alpha));
+ }
}
+ protected static void initTraceWithAlpha(TraceLigneModel model, int alpha) {
+ if (model.getCouleur() != null && model.getCouleur().getAlpha() != alpha) {
+ model.setCouleur(EbliLib.getAlphaColor(model.getCouleur(), alpha));
+ }
+ }
+
protected void initTrace(final TraceIconModel _icon, final int _idxPoly) {
final int idx = modele_.isGeometryFermee(_idxPoly) ? 0 : 1;
_icon.updateData(getIconModel(idx));
@@ -135,21 +157,23 @@
*/
public void modele(final ZModeleLigneBrisee _modele) {
if (modele_ != _modele) {
- if(modele_!=null)
+ if (modele_ != null) {
modele_.removeModelListener(this);
+ }
final ZModeleGeometry vp = modele_;
modele_ = _modele;
- if(modele_!=null)
+ if (modele_ != null) {
modele_.addModelListener(this);
+ }
firePropertyChange("modele", vp, modele_);
}
}
public ZModeleLigneBrisee modeleDonnees() {
- return (ZModeleLigneBrisee)modele_;
+ return (ZModeleLigneBrisee) modele_;
}
-
- protected boolean showOrientation(int idxPoly){
+
+ protected boolean showOrientation(int idxPoly) {
return showLineOrientation_;
}
@@ -157,27 +181,29 @@
* @param _g
*/
public void paintDonnees(final Graphics2D _g, final GrMorphisme _versEcran, final GrMorphisme _versReel,
- final GrBoite _clipReel) {
+ final GrBoite _clipReel) {
if ((modele_ == null) || (modele_.getNombre() <= 0)) {
return;
}
-
+
paintSurfaces(_g, _versEcran, _versReel, _clipReel);
-
+
final GrBoite clip = _clipReel;
final GrMorphisme versEcran = _versEcran;
final int nombre = modele_.getNombre();
final TraceLigne tl;
- if (isRapide())
- tl=new TraceLigne(TraceLigne.LISSE,1,ligneModel_.getCouleur());
- else
- tl= ligneModel_.buildCopy();
-
+ if (isRapide()) {
+ tl = new TraceLigne(TraceLigne.LISSE, 1, ligneModel_.getCouleur());
+ } else {
+ tl = ligneModel_.buildCopy();
+ }
+
final TraceLigneModel ligneModel = tl.getModel();
final GrBoite bPoly = new GrBoite();
bPoly.o_ = new GrPoint();
bPoly.e_ = new GrPoint();
+ Shape oldClip = _g.getClip();
// on part de la fin : comme ca la premiere ligne apparait au-dessus
for (int i = nombre - 1; i >= 0; i--) {
@@ -186,9 +212,10 @@
continue;
}
// La g\xE9ometrie n'est pas visible
- if (!modele_.isGeometryVisible(i))
+ if (!modele_.isGeometryVisible(i)) {
continue;
-
+ }
+
modele_.getDomaineForGeometry(i, bPoly);
// Si la boite du polygone n'est pas dans la boite d'affichage on passe
if (bPoly.intersectionXY(clip) == null) {
@@ -198,70 +225,76 @@
if (nbPoints <= 0) {
continue;
}
-
- if (!isRapide()) initTrace(ligneModel, i);
-
- if(nbPoints <2)
+ updateClip(_g, oldClip, _versEcran, i);
+
+ if (!isRapide()) {
+ initTrace(ligneModel, i);
+ }
+
+ if (nbPoints < 2) {
continue;
-
+ }
+
// Affichage de la polyligne ou polygone \\
/*
- * On part de la fin pour commencer \xE0 afficher la fleche si l'option est
- * activ\xE9e. Pour \xEAtre sur que la fleche s'affiche correctement, on
- * recherche deux points non confondus.
+ * On part de la fin pour commencer \xE0 afficher la fleche si l'option est activ\xE9e. Pour \xEAtre sur que la fleche s'affiche
+ * correctement, on recherche deux points non confondus.
*/
- GrPoint ptDest=new GrPoint();
- GrPoint ptOrig=new GrPoint();
+ GrPoint ptDest = new GrPoint();
+ GrPoint ptOrig = new GrPoint();
int j;
// Si c'est une polyligne on prend le dernier point si c'est un polygone,
// on prend le premier (le permier et le dernier doivent \xEAtre confondus).
- if(modele_.isGeometryFermee(i)){
+ if (modele_.isGeometryFermee(i)) {
modele_.point(ptDest, i, 0);
- modele_.point(ptOrig, i, nbPoints-1);
- j=nbPoints-1;
+ modele_.point(ptOrig, i, nbPoints - 1);
+ j = nbPoints - 1;
+ } else {
+ modele_.point(ptDest, i, nbPoints - 1);
+ modele_.point(ptOrig, i, nbPoints - 2);
+ j = nbPoints - 2;
}
- else {
- modele_.point(ptDest, i, nbPoints-1);
- modele_.point(ptOrig, i, nbPoints-2);
- j=nbPoints-2;
- }
// Recherche du point pr\xE9c\xE9dent non identique
- while(ptOrig.x_==ptDest.x_&&ptOrig.y_==ptDest.y_&&j>0)
+ while (ptOrig.x_ == ptDest.x_ && ptOrig.y_ == ptDest.y_ && j > 0) {
modele_.point(ptOrig, i, --j);
- if(j==0&&(ptOrig.x_==ptDest.x_&&ptOrig.y_==ptDest.y_))
+ }
+ if (j == 0 && (ptOrig.x_ == ptDest.x_ && ptOrig.y_ == ptDest.y_)) {
continue;
+ }
ptOrig.autoApplique(versEcran);
ptDest.autoApplique(versEcran);
-
+
// Dessin de la fleche
- if(showOrientation(i)){
- GrVecteur vct=ptDest.soustraction(ptOrig);
+ if (showOrientation(i)) {
+ GrVecteur vct = ptDest.soustraction(ptOrig);
vct.autoNormaliseXY();
vct.autoMultiplication(20);
// Cr\xE9ation d'un point interm\xE9diare
- double xorig=ptDest.x_-vct.x_;
- double yorig=ptDest.y_-vct.y_;
+ double xorig = ptDest.x_ - vct.x_;
+ double yorig = ptDest.y_ - vct.y_;
// La point est lisse
- int typeTrait=tl.getTypeTrait();
+ int typeTrait = tl.getTypeTrait();
tl.setTypeTrait(TraceLigne.LISSE);
- tl.dessinePointe(_g, (int)xorig, (int)yorig, (int)ptDest.x_, (int)ptDest.y_, 11, 5);
+ tl.dessinePointe(_g, (int) xorig, (int) yorig, (int) ptDest.x_, (int) ptDest.y_, 11, 5);
tl.setTypeTrait(typeTrait);
}
// Dessin des segments
- for(;j>=0;j--){
+ for (; j >= 0; j--) {
modele_.point(ptOrig, i, j);
ptOrig.autoApplique(versEcran);
tl.dessineTrait(_g, ptOrig.x_, ptOrig.y_, ptDest.x_, ptDest.y_);
ptDest.initialiseAvec(ptOrig);
}
}
-
+ _g.setClip(oldClip);
+
// Les icones sur les atomiques
- if (!isRapide())
+ if (!isRapide()) {
paintIconsOnAtomics(_g, _versEcran, _versReel, _clipReel);
+ }
// Enfin les labels sur les atomiques.
paintLabelsOnAtomics(_g, _versEcran, _versReel, _clipReel);
}
@@ -278,4 +311,11 @@
firePropertyChange(BSelecteurLineModel.PROPERTY + "open", null, ligneModelOuvert_);
}
+ /**
+ * To be used to update clip before painting a line
+ * @param _g
+ * @param oldClip clip at the beginning of paintDonnees.
+ */
+ protected void updateClip(Graphics2D _g, Shape oldClip, GrMorphisme _versEcran, int idx) {
+ }
}
Modified: trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalquePoint.java
===================================================================
--- trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalquePoint.java 2012-05-29 09:55:46 UTC (rev 7243)
+++ trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalquePoint.java 2012-05-29 13:20:18 UTC (rev 7244)
@@ -248,6 +248,10 @@
}
}
+ protected boolean isPainted(int idx) {
+ return true;
+ }
+
public void paintDonnees(final Graphics2D _g, final int _nbPt, final GrMorphisme _versEcran, final GrBoite _clipReel) {
if ((modele_ == null) || (_nbPt <= 0)) {
return;
@@ -268,6 +272,9 @@
icone.setCouleur(EbliLib.getAlphaColor(icone.getCouleur(), alpha_));
}
for (int i = _nbPt - 1; i >= 0; i--) {
+ if (!isPainted(i)) {
+ continue;
+ }
// si le point est filtre on passe. On ne force pas l'affectation.
if (!modele_.point(p_, i, false)) {
continue;
@@ -351,6 +358,9 @@
p_ = new GrPoint();
}
for (int i = selection_.getMinIndex(); i <= nb; i++) {
+ if (!isPainted(i)) {
+ continue;
+ }
if (selection_.isSelected(i)) {
modele_.point(p_, i, true);
if (clip.contientXY(p_)) {
@@ -384,6 +394,9 @@
// un testeur optimis\xE9e
final SIRtreePointInRing tester = new SIRtreePointInRing(_poly);
for (int i = nb; i >= 0; i--) {
+ if (!isPainted(i)) {
+ continue;
+ }
modele().point(p, i, true);
c.x = p.x_;
c.y = p.y_;
@@ -431,7 +444,7 @@
return null;
}
final int i = getSelectedPoint(modele_, _pt, _tolerance, getVersReel(), getClipReel(getGraphics()));
- if (i >= 0) {
+ if (i >= 0 && isPainted(i)) {
final CtuluListSelection r = creeSelection();
r.add(i);
return r;
Modified: trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/edition/ZModelePointEditable.java
===================================================================
--- trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/edition/ZModelePointEditable.java 2012-05-29 09:55:46 UTC (rev 7243)
+++ trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/edition/ZModelePointEditable.java 2012-05-29 13:20:18 UTC (rev 7244)
@@ -127,6 +127,7 @@
pts_.prepareExport();
}
+ @Override
public void setGeometries(GISZoneCollectionGeometry geometries) {
super.setGeometries(geometries);
pts_ = (GISZoneCollectionPoint) geometries;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|