From: <de...@us...> - 2013-01-10 14:14:30
|
Revision: 8195 http://fudaa.svn.sourceforge.net/fudaa/?rev=8195&view=rev Author: deniger Date: 2013-01-10 14:14:23 +0000 (Thu, 10 Jan 2013) Log Message: ----------- Modified Paths: -------------- trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueGeometry.java Added Paths: ----------- trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueGeometryLabelConfigure.java Modified: trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java =================================================================== --- trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java 2013-01-10 14:12:46 UTC (rev 8194) +++ trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java 2013-01-10 14:14:23 UTC (rev 8195) @@ -407,12 +407,15 @@ setSurfaceModel(i, (TraceSurfaceModel) _p.get(prop)); } } - + if (_p.isDefined("calque.paletteCouleurUsed")) { + isPaletteCouleurUsed_ = _p.getBoolean("calque.paletteCouleurUsed"); + } if (_p.isDefined("calque.paletteCouleur")) { final BPalettePlageInterface newPalette = createPaletteCouleur(); newPalette.load((BPalettePlageProperties) _p.get("calque.paletteCouleur")); - setPaletteCouleurPlages(newPalette); + setPaletteCouleurPlages(newPalette, false); } + } } @@ -634,6 +637,7 @@ if (isAntialiasSupported()) { res.put("calque.antialias", Boolean.valueOf(antialiasing_)); } + res.put("calque.paletteCouleurUsed", isPaletteCouleurUsed_); return res; } @@ -693,6 +697,10 @@ @Override public void setPaletteCouleurPlages(final BPalettePlageInterface _newPlage) { + setPaletteCouleurPlages(_newPlage, true); + } + + private void setPaletteCouleurPlages(final BPalettePlageInterface _newPlage, boolean updatePaletteCouleurProp) { if (_newPlage == null) { paletteCouleur_ = null; } else { @@ -708,7 +716,9 @@ paletteCouleur_.initFrom(_newPlage); } } - isPaletteCouleurUsed_ = (paletteCouleur_ != null) && paletteCouleur_.getNbPlages() > 0; + if (updatePaletteCouleurProp) { + isPaletteCouleurUsed_ = (paletteCouleur_ != null) && paletteCouleur_.getNbPlages() > 0; + } construitLegende(); firePropertyChange("paletteCouleur", null, paletteCouleur_); repaint(); 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 2013-01-10 14:12:46 UTC (rev 8194) +++ trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueGeometry.java 2013-01-10 14:14:23 UTC (rev 8195) @@ -7,6 +7,7 @@ */ package org.fudaa.ebli.calque; +import com.memoire.bu.BuLib; import com.memoire.fu.FuLog; import com.vividsolutions.jts.algorithm.SIRtreePointInRing; import com.vividsolutions.jts.geom.Coordinate; @@ -18,10 +19,13 @@ import gnu.trove.TIntArrayList; import gnu.trove.TIntObjectIterator; import java.awt.Color; +import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; +import org.apache.commons.lang.ObjectUtils; +import org.apache.commons.lang.StringUtils; import org.fudaa.ctulu.CtuluListSelection; import org.fudaa.ctulu.CtuluListSelectionInterface; import org.fudaa.ctulu.CtuluRange; @@ -42,6 +46,8 @@ import org.fudaa.ebli.commun.EbliSelectionMode; import org.fudaa.ebli.commun.EbliSelectionState; import org.fudaa.ebli.commun.EbliUIProperties; +import org.fudaa.ebli.controle.BConfigurableComposite; +import org.fudaa.ebli.controle.BConfigurableInterface; import org.fudaa.ebli.find.EbliFindActionInterface; import org.fudaa.ebli.find.EbliFindExpressionContainerInterface; import org.fudaa.ebli.geometrie.GrBoite; @@ -87,6 +93,66 @@ clearCacheAndRepaint(); } + public void paintLines(final GrBoite _clipReel, final GrMorphisme _versEcran, final Graphics2D _g) { + 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(); + } + + final GrBoite bPoly = new GrBoite(); + bPoly.o_ = new GrPoint(); + bPoly.e_ = new GrPoint(); + + // on part de la fin : comme ca la premiere ligne apparait au-dessus + for (int i = nombre - 1; i >= 0; i--) { + if (!isPainted(i, _versEcran)//dans certains cas, ne pas dessiner l'objet + || !modele_.isGeometryReliee(i)) { + continue; + } + + // il n'y a pas de points pour cette g\xE9om\xE9trie + final int nbPoints = modele_.getNbPointForGeometry(i); + if (nbPoints <= 0) { + 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) { + continue; + } + + final GrPoint ptOri = new GrPoint(); + modele_.point(ptOri, i, nbPoints - 1); + ptOri.autoApplique(versEcran); + + if (!isRapide()) { + initTrace(ligneModel_, i); + } + final GrPoint ptDest = new GrPoint(); + for (int j = nbPoints - 2; j >= 0; j--) { + // le point de dest est initialise + modele_.point(ptDest, i, j); + ptDest.autoApplique(versEcran); + tl.dessineTrait(_g, ptOri.x_, ptOri.y_, ptDest.x_, ptDest.y_); + ptOri.initialiseAvec(ptDest); + } + if (modele_.isGeometryFermee(i)) { + modele_.point(ptOri, i, nbPoints - 1); + ptOri.autoApplique(versEcran); + tl.dessineTrait(_g, ptOri.x_, ptOri.y_, ptDest.x_, ptDest.y_); + } + modele_.point(ptOri, i, nbPoints - 1); + ptOri.autoApplique(versEcran); + } + } + /** * Une enumearion pour le mode de selection */ @@ -117,11 +183,39 @@ * L'attribut utilis\xE9 pour afficher les labels */ protected GISAttributeInterface attrLabels_ = null; + private Color labelsForegroundColor = Color.BLACK; + private Color labelsBackgroundColor = Color.WHITE; /** * Le finder pour une recherche sur le calque */ protected CalqueFindActionAtomic finder_; + public void setLabelsForegroundColor(Color labelsForegroundColor) { + if (!ObjectUtils.equals(this.labelsForegroundColor, labelsForegroundColor)) { + Color old = this.labelsForegroundColor; + this.labelsForegroundColor = labelsForegroundColor; + repaint(); + firePropertyChange(ZCalqueGeometryLabelConfigure.PROPERTY_LABELS_FOREGROUND, old, labelsForegroundColor); + } + } + + public void setLabelsBackgroundColor(Color labelsBackgroundColor) { + if (!ObjectUtils.equals(this.labelsBackgroundColor, labelsBackgroundColor)) { + Color old = this.labelsBackgroundColor; + this.labelsBackgroundColor = labelsBackgroundColor; + repaint(); + firePropertyChange(ZCalqueGeometryLabelConfigure.PROPERTY_LABELS_FOREGROUND, old, labelsBackgroundColor); + } + } + + public Color getLabelsBackgroundColor() { + return labelsBackgroundColor; + } + + public Color getLabelsForegroundColor() { + return labelsForegroundColor; + } + /** * Le seul constructeur, avec le mod\xE8le. * @@ -137,6 +231,7 @@ } iconModel_ = new TraceIconModel(TraceIcon.CARRE_PLEIN, 2, Color.BLACK); mode = SelectionMode.NORMAL; + setFont(BuLib.DEFAULT_FONT); } protected EbliListeSelectionMulti creeSelectionMulti() { @@ -453,12 +548,28 @@ } @Override + public EbliUIProperties saveUIProperties() { + EbliUIProperties properties = super.saveUIProperties(); + properties.put(ZCalqueGeometryLabelConfigure.PROPERTY_LABELS_BACKGROUND, labelsBackgroundColor); + properties.put(ZCalqueGeometryLabelConfigure.PROPERTY_LABELS_FOREGROUND, labelsForegroundColor); + return properties; + } + + @Override public void initFrom(final EbliUIProperties _p) { if (_p != null) { super.initFrom(_p); if (_p.isDefined("calqueGIS.ligneModel")) { setLineModel(0, (TraceLigneModel) _p.get("calqueGIS.ligneModel")); } + if (_p.isDefined(ZCalqueGeometryLabelConfigure.PROPERTY_LABELS_BACKGROUND)) { + setLabelsBackgroundColor((Color) _p.get(ZCalqueGeometryLabelConfigure.PROPERTY_LABELS_BACKGROUND)); + } + if (_p.isDefined(ZCalqueGeometryLabelConfigure.PROPERTY_LABELS_FOREGROUND)) { + setLabelsForegroundColor((Color) _p.get(ZCalqueGeometryLabelConfigure.PROPERTY_LABELS_FOREGROUND)); + } + + } } @@ -542,6 +653,17 @@ clearCacheAndRepaint(); } + @Override + protected BConfigurableInterface getAffichageConf() { + final BConfigurableInterface[] sect = new BConfigurableInterface[3 + getNbSet()]; + sect[0] = new ZCalqueAffichageDonneesConfigure(this); + sect[1] = new ZCalqueGeometryLabelConfigure(this); + for (int i = 2; i < sect.length; i++) { + sect[i] = new ZCalqueAffichageDonneesTraceConfigure(this, i - 2); + } + return new BConfigurableComposite(sect, EbliLib.getS("Affichage")); + } + /** * Indique si la s\xE9lection est vide. * @@ -595,65 +717,8 @@ // Trac\xE9 des surfaces paintSurfaces(_g, _versEcran, _versReel, _clipReel); + paintLines(_clipReel, _versEcran, _g); - 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(); - } - - final GrBoite bPoly = new GrBoite(); - bPoly.o_ = new GrPoint(); - bPoly.e_ = new GrPoint(); - - // on part de la fin : comme ca la premiere ligne apparait au-dessus - for (int i = nombre - 1; i >= 0; i--) { - if (!isPainted(i, _versEcran)//dans certains cas, ne pas dessiner l'objet - || !modele_.isGeometryReliee(i)) { - continue; - } - - // il n'y a pas de points pour cette g\xE9om\xE9trie - final int nbPoints = modele_.getNbPointForGeometry(i); - if (nbPoints <= 0) { - 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) { - continue; - } - - final GrPoint ptOri = new GrPoint(); - modele_.point(ptOri, i, nbPoints - 1); - ptOri.autoApplique(versEcran); - - if (!isRapide()) { - initTrace(ligneModel_, i); - } - final GrPoint ptDest = new GrPoint(); - for (int j = nbPoints - 2; j >= 0; j--) { - // le point de dest est initialise - modele_.point(ptDest, i, j); - ptDest.autoApplique(versEcran); - tl.dessineTrait(_g, ptOri.x_, ptOri.y_, ptDest.x_, ptDest.y_); - ptOri.initialiseAvec(ptDest); - } - if (modele_.isGeometryFermee(i)) { - modele_.point(ptOri, i, nbPoints - 1); - ptOri.autoApplique(versEcran); - tl.dessineTrait(_g, ptOri.x_, ptOri.y_, ptDest.x_, ptDest.y_); - } - modele_.point(ptOri, i, nbPoints - 1); - ptOri.autoApplique(versEcran); - } - // Les icones sur les atomiques paintIconsOnAtomics(_g, _versEcran, _versReel, _clipReel); // Enfin les labels sur les atomiques. @@ -800,20 +865,20 @@ protected void paintLabelsOnAtomics(final Graphics2D _g, final GrMorphisme _versEcran, final GrMorphisme _versReel, final GrBoite _clipReel) { - final GrBoite clip = _clipReel; - final GrMorphisme versEcran = _versEcran; - final int nombre = modele_.getNombre(); - final GrBoite bPoly = new GrBoite(); - if (attrLabels_ != null && !isRapide()) { GISZoneCollection geomData = modeleDonnees().getGeomData(); int idxLabels = geomData.getIndiceOf(attrLabels_); if (idxLabels != -1) { + final Color fgColor = labelsForegroundColor; + final Color bgColor = labelsBackgroundColor; + Font old = _g.getFont(); + _g.setFont(getFont()); final FontMetrics fm = _g.getFontMetrics(); - final Color fgColor = _g.getColor(); - final Color bgColor = getBackground(); - + final GrMorphisme versEcran = _versEcran; + final int nombre = modele_.getNombre(); + int w = getWidth() + 1; + CtuluListSelection memory = new CtuluListSelection(w * getHeight()); for (int i = nombre - 1; i >= 0; i--) { // il n'y a pas de points pour cette ligne if (modele_.getNbPointForGeometry(i) <= 0) { @@ -824,12 +889,7 @@ 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) { - continue; - } + final int nbPoints = modele_.getNbPointForGeometry(i); if (nbPoints <= 0) { continue; @@ -843,27 +903,35 @@ if (!_clipReel.contientXY(ptDest)) { continue; } + int idxOnScreen = (int) ptDest.x_ + (int) ptDest.y_ * w; + //pour \xE9viter de redessiner le texte au m\xEAme endroit: + if (idxOnScreen >= 0 && !memory.isSelected(idxOnScreen)) { + memory.add(idxOnScreen); + Object o = mdl.getObjectValueAt(j); + if (o == null) { + continue; + } + String s = o.toString().trim(); + if (StringUtils.isBlank(s)) { + continue; + } - Object o = mdl.getObjectValueAt(j); - if (o == null) { - continue; + ptDest.autoApplique2D(versEcran); + final Rectangle2D rec = fm.getStringBounds(s, _g); + double x = ptDest.x_ - rec.getWidth() / 2; + double y = ptDest.y_ - 5; + rec.setFrame(x, y - fm.getAscent(), rec.getWidth(), fm.getAscent() + 2); + if (bgColor != null) { + _g.setColor(bgColor); + _g.fill(rec); + } + _g.setColor(fgColor); + _g.drawString(s, (int) x, (int) y); } - String s = o.toString().trim(); - if (s.equals("")) { - continue; - } - - ptDest.autoApplique2D(versEcran); - final Rectangle2D rec = fm.getStringBounds(s, _g); - double x = ptDest.x_ - rec.getWidth() / 2; - double y = ptDest.y_ - 5; - rec.setFrame(x, y - fm.getAscent(), rec.getWidth(), fm.getAscent() + 2); - _g.setColor(bgColor); - _g.fill(rec); - _g.setColor(fgColor); - _g.drawString(s, (int) x, (int) y); } } + _g.setFont(old); + } } } @@ -1481,18 +1549,10 @@ return null; } - /* - * (non-Javadoc) @see org.fudaa.ctulu.gis.AttributeListener#attributeAction(java.lang.Object, int, - * org.fudaa.ctulu.gis.GISAttributeInterface, int) - */ @Override public void attributeAction(Object _source, int _indexAtt, GISAttributeInterface _att, int _action) { } - /* - * (non-Javadoc) @see org.fudaa.ctulu.gis.AttributeListener#attributeValueChangeAction(java.lang.Object, int, - * org.fudaa.ctulu.gis.GISAttributeInterface, int, java.lang.Object) - */ @Override public void attributeValueChangeAction(Object _source, int _indexAtt, GISAttributeInterface _att, int _indexGeom, Object _newValue) { Copied: trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueGeometryLabelConfigure.java (from rev 7853, trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueAffichageDonneesConfigure.java) =================================================================== --- trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueGeometryLabelConfigure.java (rev 0) +++ trunk/framework/ebli-2d/src/main/java/org/fudaa/ebli/calque/ZCalqueGeometryLabelConfigure.java 2013-01-10 14:14:23 UTC (rev 8195) @@ -0,0 +1,81 @@ +/* + * @creation 9 nov. 06 + * @modification $Date: 2007-05-04 13:49:43 $ + * @license GNU General Public License 2 + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail de...@fu... + */ +package org.fudaa.ebli.calque; + +import java.awt.Color; +import java.awt.Font; +import java.util.ArrayList; +import java.util.List; +import org.fudaa.ebli.commun.EbliLib; +import org.fudaa.ebli.controle.BSelecteurColorChooserBt; +import org.fudaa.ebli.controle.BSelecteurFont; +import org.fudaa.ebli.controle.BSelecteurInterface; +import org.fudaa.ebli.controle.BSelecteurReduitFonteNewVersion; + +/** + * @author fred deniger + * @version $Id: ZCalqueAffichageDonneesConfigure.java,v 1.4 2007-05-04 13:49:43 deniger Exp $ + */ +public class ZCalqueGeometryLabelConfigure extends BCalqueConfigureSectionAbstract { + + public static final String PROPERTY_LABELS_FOREGROUND = "labelsForegroundColor"; + public static final String PROPERTY_LABELS_BACKGROUND = "labelsBackgroundColor"; + + public ZCalqueGeometryLabelConfigure(final ZCalqueGeometry _target, final boolean _addVisible) { + super(_target, EbliLib.getS("Labels")); + } + + public ZCalqueGeometryLabelConfigure(final ZCalqueGeometry _target) { + this(_target, false); + } + + @Override + public boolean setProperty(final String _key, final Object _newProp) { + if (BSelecteurReduitFonteNewVersion.PROPERTY.equals(_key)) { + ((ZCalqueAffichageDonneesAbstract) target_).setFont(((Font) _newProp)); + return true; + } + if (PROPERTY_LABELS_FOREGROUND.equals(_key)) { + ((ZCalqueGeometry) target_).setLabelsForegroundColor(((Color) _newProp)); + return true; + } + if (PROPERTY_LABELS_BACKGROUND.equals(_key)) { + ((ZCalqueGeometry) target_).setLabelsBackgroundColor(((Color) _newProp)); + return true; + } + return false; + } + + @Override + public Object getProperty(final String _key) { + if (BSelecteurReduitFonteNewVersion.PROPERTY.equals(_key)) { + return ((ZCalqueAffichageDonneesAbstract) target_).getFont(); + } + if (PROPERTY_LABELS_FOREGROUND.equals(_key)) { + return ((ZCalqueGeometry) target_).getLabelsForegroundColor(); + } + if (PROPERTY_LABELS_BACKGROUND.equals(_key)) { + return ((ZCalqueGeometry) target_).getLabelsBackgroundColor(); + } + return null; + } + + @Override + public BSelecteurInterface[] createSelecteurs() { + final List dest = new ArrayList(); + + BSelecteurColorChooserBt foregroundColor = new BSelecteurColorChooserBt(false, PROPERTY_LABELS_FOREGROUND); + foregroundColor.setTitle(EbliLib.getS("Couleur texte")); + dest.add(foregroundColor); + BSelecteurColorChooserBt backgroundColor = new BSelecteurColorChooserBt(true, PROPERTY_LABELS_BACKGROUND); + backgroundColor.setTitle(EbliLib.getS("Couleur fond")); + dest.add(backgroundColor); + dest.add(new BSelecteurFont()); + return (BSelecteurInterface[]) dest.toArray(new BSelecteurInterface[dest.size()]); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |