From: <de...@us...> - 2008-09-24 21:16:05
|
Revision: 3977 http://fudaa.svn.sourceforge.net/fudaa/?rev=3977&view=rev Author: deniger Date: 2008-09-24 21:15:55 +0000 (Wed, 24 Sep 2008) Log Message: ----------- Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/exemple.res.post.fzip branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/CalqueLegendeWidgetAdapter.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EbliWidgetCalqueLegende.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EbliWidgetCreatorLegende.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EbliWidgetPlage.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/WidgetLegendeManager.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/save/FudaaFilleVisuPersistence.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/save/FudaaSaveLib.java Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/CalqueLegendeWidgetAdapter.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/CalqueLegendeWidgetAdapter.java 2008-09-24 17:58:35 UTC (rev 3976) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/CalqueLegendeWidgetAdapter.java 2008-09-24 21:15:55 UTC (rev 3977) @@ -5,9 +5,6 @@ package org.fudaa.ebli.visuallibrary.calque; import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; import java.awt.Point; import javax.swing.JLabel; @@ -25,8 +22,10 @@ import org.fudaa.ebli.visuallibrary.EbliScene; import org.fudaa.ebli.visuallibrary.EbliWidget; import org.fudaa.ebli.visuallibrary.EbliWidgetWithBordure; +import org.netbeans.api.visual.border.BorderFactory; import org.netbeans.api.visual.layout.LayoutFactory.SerialAlignment; import org.netbeans.api.visual.widget.LabelWidget; +import org.netbeans.api.visual.widget.Widget; import org.netbeans.api.visual.widget.LabelWidget.Alignment; import org.netbeans.api.visual.widget.LabelWidget.VerticalAlignment; import org.netbeans.modules.visual.layout.FlowLayout; @@ -38,45 +37,17 @@ * * @author Adrien Hadoux */ +@SuppressWarnings("serial") public class CalqueLegendeWidgetAdapter extends BCalqueLegende { - static class MetricLegend extends FontMetrics { - - // protected MetricLegend(Font font) { - // super(font); - // } - public MetricLegend(Font font) { - super(font); - } - - } - /** - * Methode statique qui recree la widget associee au calque. Il faut que son parent la bordure ajoute et prenne en - * compte sa nouvelle fille pour bien gerer le dispatch des composants graphiques. - * - * @param widgetLegende_ - * @param _calqueLegende - * @param _scene - * @param model - */ - public static int cp = 1; - public static int LENGHT_PER_LEGENDE = 15; - public static int MAX_BORDURE = 12; - public static int WIDTH_LEGENDE = 200; - - public static int WIDTH_PER_LEGENDEICON = 10; - - public static int WIDTH_PER_LEGENDETEXT = 130; - - /** * Mananger statique qui se charge de creer \xE9a widget associee au calque. * * @param _calqueLegende le panel legende qui sera recopie version widget * @param _scene la scene * @return la widfget de la legende. */ - public static EbliWidget createLegendeWidget(EbliWidgetCalqueLegende _widgetLegende, + public static EbliWidgetCalqueLegende updateLegendeWidget(EbliWidgetCalqueLegende _widgetLegende, BCalqueLegendePanel _calqueLegende, EbliScene _scene) { // --creation de la widget conteneur --// @@ -84,6 +55,7 @@ // widgetLegende_ = new WidgetCalqueLegende(_scene, false, model, // _calqueLegende); _widgetLegende.setLayout(new FlowLayout(true, SerialAlignment.CENTER, 5)); + _widgetLegende.setBorder(BorderFactory.createEmptyBorder(10)); if (_calqueLegende != null) { Component[] listeC = _calqueLegende.getComponents(); @@ -102,6 +74,7 @@ } if (c instanceof BPalettePlageLegende) { + BPalettePlageLegende pal = (BPalettePlageLegende) c; // --recuperation de la liste des plages --// @@ -122,7 +95,8 @@ sstitre.setLabel(listeplages.getSousTitre()); sstitre.setEnabled(true); _widgetLegende.addChild(sstitre); - + Widget ws = new Widget(_scene); + ws.setLayout(new FlowLayout(true, SerialAlignment.LEFT_TOP, 5)); if (listeplages.getNbPlages() != 0) { for (int j = 0; j < listeplages.getNbPlages(); j++) { @@ -134,7 +108,7 @@ lw.setUseBorder(false); lw.setEnabled(true); - _widgetLegende.addChild(lw); + ws.addChild(lw); } } else { @@ -154,7 +128,7 @@ titre.setVerticalAlignment(VerticalAlignment.CENTER); titre.setLabel(((JLabel) panel.getComponents()[k]).getText()); titre.setEnabled(true); - _widgetLegende.addChild(titre); + ws.addChild(titre); } else if (panel.getComponents()[k] instanceof JList) { JList jlst = (JList) panel.getComponents()[k]; for (int g = 0; g < jlst.getModel().getSize(); g++) { @@ -163,7 +137,7 @@ titre.setVerticalAlignment(VerticalAlignment.CENTER); titre.setLabel((String) jlst.getModel().getElementAt(g)); titre.setEnabled(true); - _widgetLegende.addChild(titre); + ws.addChild(titre); } } @@ -173,7 +147,10 @@ } } + } + _widgetLegende.addChild(ws); + _widgetLegende.setLegendsWidget(ws); } } @@ -182,7 +159,7 @@ // -- prendre en compte le resize automatique --// _widgetLegende.getEbliScene().refresh(); - // _widgetLegende.setFormeFont(new Font("Helvetica", Font.PLAIN, 10)); + // _widgetLegende.setFormeFont(new Font("Helvetica", Font.PLAIN, 10)); return _widgetLegende; } else { @@ -191,16 +168,16 @@ } } - public static Dimension createSizeForWidget(int _nbLibelles) { - return new Dimension(WIDTH_LEGENDE + MAX_BORDURE, _nbLibelles * (LENGHT_PER_LEGENDE + MAX_BORDURE / 2)); - } + // public static Dimension createSizeForWidget(int _nbLibelles) { + // return new Dimension(WIDTH_LEGENDE + MAX_BORDURE, _nbLibelles * (LENGHT_PER_LEGENDE + MAX_BORDURE / 2)); + // } public static void reconstructWidget(EbliWidgetCalqueLegende widgetLegende_, BCalqueLegendePanel _calqueLegende, EbliScene _scene/* , BArbreCalqueModel model */) { EbliWidgetWithBordure parent = (EbliWidgetWithBordure) widgetLegende_.getParentWidget(); - widgetLegende_ = (EbliWidgetCalqueLegende) createLegendeWidget(widgetLegende_, _calqueLegende, _scene); + widgetLegende_ = (EbliWidgetCalqueLegende) updateLegendeWidget(widgetLegende_, _calqueLegende, _scene); parent.repaint(); Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EbliWidgetCalqueLegende.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EbliWidgetCalqueLegende.java 2008-09-24 17:58:35 UTC (rev 3976) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EbliWidgetCalqueLegende.java 2008-09-24 21:15:55 UTC (rev 3977) @@ -19,6 +19,7 @@ import org.fudaa.ebli.visuallibrary.EbliWidget; import org.netbeans.api.visual.action.ActionFactory; import org.netbeans.api.visual.action.InplaceEditorProvider; +import org.netbeans.api.visual.model.ObjectState; import org.netbeans.api.visual.widget.LabelWidget; import org.netbeans.api.visual.widget.Widget; import org.netbeans.modules.visual.action.InplaceEditorAction; @@ -31,15 +32,21 @@ public class EbliWidgetCalqueLegende extends EbliWidget implements InplaceEditorProvider<JComponent>, PropertyChangeListener { + Font boldFont_; + public InplaceEditorAction<JComponent> editorAction_; BCalqueLegendePanel legendePanel_; + + Widget legendsWidget_; + // BArbreCalqueModel modelTree_; boolean maj = true; - public InplaceEditorAction<JComponent> editorAction_; // Font oldFont_; - public EbliWidgetCalqueLegende(EbliScene _scene, boolean _controller/* , BArbreCalqueModel model */, - BCalqueLegendePanel _legendePanel) { + boolean mustUpdateFont_ = false; + + public EbliWidgetCalqueLegende(final EbliScene _scene, final boolean _controller/* , BArbreCalqueModel model */, + final BCalqueLegendePanel _legendePanel) { super(_scene, _controller); setCheckClipping(true); // oldFont_ = getFormeFont(); @@ -54,18 +61,48 @@ // -- creation de l action edition des labels --// editorAction_ = (InplaceEditorAction<JComponent>) ActionFactory.createInplaceEditorAction(this); - + // -- ajout de l action au label correspondant --// this.getActions().addAction(editorAction_); } + @Override + public boolean canColorBackground() { + return true; + } + + @Override + public void notifyStateChanged(ObjectState _previousState, ObjectState _newState) { + // super.notifyStateChanged(_previousState, _newState); + } + + @Override + public boolean canColorForeground() { + return false; + } + + @Override + public boolean canFont() { + return true; + } + + @Override + public boolean canRotate() { + return false; + } + + @Override + public boolean canTraceLigneModel() { + return false; + } + /** * Methode qui cree l editeur du calque. */ public JComponent createEditorComponent( - org.netbeans.api.visual.action.InplaceEditorProvider.EditorController _controller, Widget _widget) { + final org.netbeans.api.visual.action.InplaceEditorProvider.EditorController _controller, final Widget _widget) { if (PaletteSelecteurCouleurPlage.isTargetValid(legendePanel_.getCalque())) { - PaletteSelecteurCouleurPlage palette = new PaletteSelecteurCouleurPlage(); + final PaletteSelecteurCouleurPlage palette = new PaletteSelecteurCouleurPlage(); palette.setPalettePanelTarget(legendePanel_.getCalque()); palette.setSize(this.getBounds().width, this.getBounds().height); palette.setMaximumSize(new Dimension(this.getBounds().width, this.getBounds().height)); @@ -76,184 +113,84 @@ return null; } - @Override - public void setFormeFont(Font _newFont) { - super.setFormeFont(_newFont); - updateFont(_newFont); + public EnumSet<org.netbeans.api.visual.action.InplaceEditorProvider.ExpansionDirection> getExpansionDirections( + final org.netbeans.api.visual.action.InplaceEditorProvider.EditorController _controller, final Widget _widget, + final JComponent _editor) { + return null; } - @Override - public void setPropertyCmd(String _key, Object _prop, CtuluCommandContainer _cmd) { - super.setPropertyCmd(_key, _prop, _cmd); - if ("font".equals(_key)) { - Font ft = (Font) _prop; - updateFont(ft); - } - + public Rectangle getInitialEditorComponentBounds( + final org.netbeans.api.visual.action.InplaceEditorProvider.EditorController _controller, final Widget _widget, + final JComponent _editor, final Rectangle _viewBounds) { + return null; } - @Override - protected void paintWidget() { - if (mustUpdateFont_) { - updateFont(getFormeFont()); - } - super.paintWidget(); - } +// protected int getMaxTitle(final Font boldFt) { +// final FontMetrics ftmBold = this.getGraphics().getFontMetrics(boldFt); +// int maxWidth = 0; +// // -- mise a jour de la widget avec la nouvelle font +// final List<Widget> listePlage = getChildren(); +// for (final Iterator<Widget> it = listePlage.iterator(); it.hasNext();) { +// final Widget widget = it.next(); +// // -- test si il s agit d un widget plage --// +// if (widget instanceof LabelWidget && (((LabelWidget) widget).getLabel() != null)) { +// final LabelWidget lbWidget = (LabelWidget) widget; +// maxWidth = Math.max(maxWidth, ftmBold.stringWidth(lbWidget.getLabel()) + 5); +// // lbWidget.setPreferredBounds(boundsTitre); +// } +// } +// +// return maxWidth; +// +// } - boolean mustUpdateFont_ = false; +// protected int getMaxWidthLegende(final Font ft) { +// final FontMetrics ftm = this.getGraphics().getFontMetrics(ft); +// int maxWidth = 0; +// // -- mise a jour de la widget avec la nouvelle font +// final List<Widget> listePlage = getChildren(); +// for (final Iterator<Widget> it = listePlage.iterator(); it.hasNext();) { +// final Widget widget = it.next(); +// // -- test si il s agit d un widget plage --// +// if (widget instanceof EbliWidgetPlage) { +// final EbliWidgetPlage new_widget = (EbliWidgetPlage) widget; +// maxWidth = Math.max(maxWidth, ftm.stringWidth(new_widget.getInternWidget().getLabel())); +// } +// } +// +// return maxWidth; +// +// } - private void updateFont(Font ft) { - if (getGraphics() == null) { - mustUpdateFont_ = true; - return; - } - mustUpdateFont_ = false; - boldFont_ = BuLib.deriveFont(ft, Font.BOLD, 0); - // -- calcul des max height et width pour resize les composants --// - FontMetrics fmt = getGraphics().getFontMetrics(ft); - FontMetrics fmtBold = getGraphics().getFontMetrics(boldFont_); - int maxWidth = getMaxWidthLegende(ft); - int maxTitle = maxWidth; - Rectangle newBounds = new Rectangle(maxWidth, fmt.getHeight()); + public void notifyClosing(final EditorController _controller, final Widget _widget, final JComponent _editor, + final boolean _commit) { + editingStop(); - // -- mise a jour de la widget avec la nouvelle font - List<Widget> listePlage = getChildren(); - for (Iterator<Widget> it = listePlage.iterator(); it.hasNext();) { - Widget widget = it.next(); - // -- test si il s agit d un widget plage --// - if (widget instanceof EbliWidgetPlage) { - EbliWidgetPlage new_widget = (EbliWidgetPlage) widget; - new_widget.getInternWidget().setFont(ft); - new_widget.getInternWidget().majText(); - - // -- mise du nouveau bounds max --// - Rectangle boundsIntern = new_widget.getIntern().getBounds(); - if (boundsIntern != null) { - boundsIntern.width = newBounds.width; - boundsIntern.height = (int) (newBounds.height); - } - new_widget.getIntern().setPreferredBounds(boundsIntern); - - // resize pour le logo: forme carr\xE9 - Rectangle boundsLogo = new_widget.getLogo().getBounds(); - if (boundsLogo != null) { - - boundsLogo.height = (int) (newBounds.height); - boundsLogo.width = (int) (newBounds.height); - new_widget.getLogo().setPreferredBounds(boundsLogo); - } - new_widget.getLogo().repaint(); - - } else if (widget instanceof LabelWidget && (((LabelWidget) widget).getLabel() != null)) { - LabelWidget lbWidget = (LabelWidget) widget; - - lbWidget.setFont(boldFont_); - Rectangle boundsTitre = lbWidget.getBounds(); - if(boundsTitre!=null){ - boundsTitre.width = fmtBold.stringWidth(lbWidget.getLabel()) + 5; - maxTitle = Math.max(maxTitle, boundsTitre.width); - boundsTitre.height = (int) (fmtBold.getHeight() + 2); - } - // lbWidget.setPreferredBounds(boundsTitre); - } - - } - // getParentWidget().revalidate(); - // revalidate(); - // Resize de la widget - // getEbliScene().revalidate(); - Rectangle newBoundConteneurs = getParentWidget().getBounds(); - if (newBoundConteneurs != null) { - newBoundConteneurs.height = (int) ((fmtBold.getHeight() + 7) * 2 + (listePlage.size()) * (newBounds.height + 7));// ( - newBoundConteneurs.width = (int) (Math.max(maxWidth, maxTitle) * 1.5); - getParentWidget().setPreferredBounds(newBoundConteneurs); - } - getEbliScene().refresh(); } - public EnumSet<org.netbeans.api.visual.action.InplaceEditorProvider.ExpansionDirection> getExpansionDirections( - org.netbeans.api.visual.action.InplaceEditorProvider.EditorController _controller, Widget _widget, - JComponent _editor) { - return null; - } + public void notifyOpened(final EditorController _controller, final Widget _widget, final JComponent _editor) { + editingStart(); - public Rectangle getInitialEditorComponentBounds( - org.netbeans.api.visual.action.InplaceEditorProvider.EditorController _controller, Widget _widget, - JComponent _editor, Rectangle _viewBounds) { - return null; } + @Override protected void notifyRemoved() { legendePanel_.getCalque().removePropertyChangeListener("paletteCouleur", this); legendePanel_.getCalque().removePropertyChangeListener("paletteTitle", this); } - Font boldFont_; + @Override + protected void paintWidget() { + if (mustUpdateFont_) { + updateFont(getFormeFont()); + } + super.paintWidget(); + } - // protected void paintWidget() { - // - // // -- mise a jour de la fonte que si il y a eu une modification --// - // if (maj) { - // maj = false; - // boldFont_ = BuLib.deriveFont(getFormeFont(), Font.BOLD, 0); - // // -- calcul des max height et width pour resize les composants --// - // Rectangle newBounds = resizeMaxLegende(); - // - // // -- mise a jour de la widget avec la nouvelle font - // List<Widget> listePlage = getChildren(); - // for (Iterator<Widget> it = listePlage.iterator(); it.hasNext();) { - // Widget widget = it.next(); - // // -- test si il s agit d un widget plage --// - // if (widget instanceof EbliWidgetPlage) { - // EbliWidgetPlage new_widget = (EbliWidgetPlage) widget; - // new_widget.getIntern().setFont(getFormeFont()); - // new_widget.getIntern().majText(); - // FuLog.warning("MA plage: " + new_widget.plage_.getLegende()); - // - // // -- mise du nouveau bounds max --// - // Rectangle boundsIntern = new_widget.getIntern().getBounds(); - // boundsIntern.width = newBounds.width; - // boundsIntern.height = (int) (newBounds.height); - // - // new_widget.getIntern().setPreferredBounds(boundsIntern); - // - // // resize pour le logo: forme carr\xE9 - // Rectangle boundsLogo = new_widget.getLogo().getBounds(); - // boundsLogo.height = (int) (newBounds.height); - // boundsLogo.width = (int) (newBounds.height); - // new_widget.getLogo().setPreferredBounds(boundsLogo); - // new_widget.getLogo().repaint(); - // - // } else if (widget instanceof LabelWidget) { - // LabelWidget new_widget = (LabelWidget) widget; - // - // new_widget.setFont(boldFont_); - // Rectangle boundsTitre = new_widget.getBounds(); - // boundsTitre.width = newBounds.width; - // boundsTitre.height = (int) (newBounds.height); - // new_widget.setPreferredBounds(boundsTitre); - // } - // - // } - // // getParentWidget().revalidate(); - // // revalidate(); - // // Resize de la widget - // // getEbliScene().revalidate(); - // Rectangle newBoundConteneurs = getParentWidget().getBounds(); - // newBoundConteneurs.height = (int) ((listePlage.size() + 2) * (newBounds.height * 1.5));// ( - // newBoundConteneurs.width = (int) (newBounds.width * 1.5); - // getParentWidget().setPreferredBounds(newBoundConteneurs); - // getEbliScene().refresh(); - // // oldFont_ = getFormeFont(); - // - // } - // - // } - /** * Si la palette est modifiee on change la widget */ - public void propertyChange(PropertyChangeEvent _evt) { + public void propertyChange(final PropertyChangeEvent _evt) { rebuildWidget(); } @@ -266,53 +203,62 @@ this.getEbliScene().refresh(); } - public void notifyClosing(EditorController _controller, Widget _widget, JComponent _editor, boolean _commit) { - editingStop(); + @Override + public void setFormeFont(final Font _newFont) { + super.setFormeFont(_newFont); + updateFont(_newFont); + } + /** + * @param _legendsWidget the legendsWidget to set + */ + public void setLegendsWidget(Widget _legendsWidget) { + legendsWidget_ = _legendsWidget; } - public void notifyOpened(EditorController _controller, Widget _widget, JComponent _editor) { - editingStart(); + @Override + public void setPropertyCmd(final String _key, final Object _prop, final CtuluCommandContainer _cmd) { + super.setPropertyCmd(_key, _prop, _cmd); + if ("font".equals(_key)) { + final Font ft = (Font) _prop; + updateFont(ft); + } } - protected int getMaxWidthLegende(Font ft) { - FontMetrics ftm = this.getGraphics().getFontMetrics(ft); - int maxWidth = 0; - // -- mise a jour de la widget avec la nouvelle font - List<Widget> listePlage = getChildren(); - for (Iterator<Widget> it = listePlage.iterator(); it.hasNext();) { - Widget widget = it.next(); - // -- test si il s agit d un widget plage --// - if (widget instanceof EbliWidgetPlage) { - EbliWidgetPlage new_widget = (EbliWidgetPlage) widget; - maxWidth = Math.max(maxWidth, ftm.stringWidth(new_widget.getInternWidget().getLabel())); + protected void updateFont(final Font ft) { + if (getGraphics() == null) { + mustUpdateFont_ = true; + return; + } + mustUpdateFont_ = false; + boldFont_ = BuLib.deriveFont(ft, Font.BOLD, 1); + if (legendsWidget_ != null) { + final List<Widget> listePlage = legendsWidget_.getChildren(); + for (final Iterator<Widget> it = listePlage.iterator(); it.hasNext();) { + final Widget widget = it.next(); + // -- test si il s agit d un widget plage --// + if (widget instanceof EbliWidgetPlage) { + final EbliWidgetPlage widgetPlage = (EbliWidgetPlage) widget; + widgetPlage.getInternWidget().setFont(ft); + widgetPlage.getInternWidget().majText(); + } } } - return maxWidth; + // -- mise a jour de la widget avec la nouvelle font + final List<Widget> listePlage = getChildren(); + for (final Iterator<Widget> it = listePlage.iterator(); it.hasNext();) { + final Widget widget = it.next(); + if (widget instanceof LabelWidget && (((LabelWidget) widget).getLabel() != null)) { + final LabelWidget lbWidget = (LabelWidget) widget; + lbWidget.setFont(boldFont_); + } + } + getParentWidget().revalidate(); + revalidate(); + getEbliScene().refresh(); } - - - public boolean canRotate() { - return false; - } - public boolean canColorForeground() { - return false; - } - - public boolean canColorBackground() { - return true; - } - - public boolean canTraceLigneModel() { - return false; - } - - public boolean canFont() { - return true; - } - } \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EbliWidgetCreatorLegende.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EbliWidgetCreatorLegende.java 2008-09-24 17:58:35 UTC (rev 3976) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EbliWidgetCreatorLegende.java 2008-09-24 21:15:55 UTC (rev 3977) @@ -39,10 +39,11 @@ } public EbliWidget create(EbliScene _scene) { - EbliWidget widgetLegende_ = CalqueLegendeWidgetAdapter.createLegendeWidget( - new EbliWidgetCalqueLegende(_scene, false, g), g, _scene); - res = new EbliWidgetBordureSingle(widgetLegende_, true, true); - widgetLegende_.setFormeFont(new Font("Helvetica", Font.PLAIN, 10)); + EbliWidgetCalqueLegende widgetLegende = CalqueLegendeWidgetAdapter.updateLegendeWidget(new EbliWidgetCalqueLegende( + _scene, false, g), g, _scene); + res = new EbliWidgetBordureSingle(widgetLegende, true, true); + widgetLegende.setFormeFont(new Font("Helvetica", Font.PLAIN, 10)); + widgetLegende.updateFont(widgetLegende.getFormeFont()); return res; } Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EbliWidgetPlage.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EbliWidgetPlage.java 2008-09-24 17:58:35 UTC (rev 3976) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/calque/EbliWidgetPlage.java 2008-09-24 21:15:55 UTC (rev 3977) @@ -31,7 +31,7 @@ *Methode utilisee pour mettre a jour la plage. */ public void majText() { - this.setLabel(plage_.getLegende()); + this.setLabel(plage_.getLegende() + " "); setToolTipText(plage_.getLegende()); // setForeground(plage_.getCouleur()); } @@ -53,7 +53,7 @@ super(_scene); plage_ = _cb; - setLayout(new FlowLayout(false, SerialAlignment.CENTER, 5)); + setLayout(new FlowLayout(false, SerialAlignment.CENTER, 2)); // setEnabled(false); setEnabled(true); logo_ = new EbliWidget(_scene) { @@ -67,7 +67,13 @@ @Override protected Rectangle calculateClientArea() { Rectangle rec = new Rectangle(); - rec.width = (int) intern_.getPreferredBounds().getHeight(); + // rec.width = (int) intern_.getPreferredBounds().getHeight(); + Rectangle bounds = intern_.getBounds(); + if (bounds != null) { + rec.width = (int) bounds.getHeight(); + } else { + rec.width = (int) intern_.getPreferredBounds().getHeight(); + } rec.height = rec.width; return rec; } @@ -79,9 +85,8 @@ // -- creation de la legende --// intern_ = new InternWidget(_scene); + intern_.majText(); - intern_.setLabel(_cb.getLegende()); - // intern_.setForeground(_cb.getCouleur()); setToolTipText(_cb.getLegende()); addChild(intern_); @@ -115,7 +120,7 @@ public void majLabel() { // intern_.setForeground(plage_.getCouleur()); - intern_.setLabel(plage_.getLegende()); + intern_.majText(); } public void setInternLabel(InternWidget intern_) { Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/WidgetLegendeManager.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/WidgetLegendeManager.java 2008-09-24 17:58:35 UTC (rev 3976) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/WidgetLegendeManager.java 2008-09-24 21:15:55 UTC (rev 3977) @@ -24,28 +24,21 @@ * @author denf01a adrien hadoux * @creation 5 ao\xFBt 2008 * @version - * */ public class WidgetLegendeManager { - - public static int LENGHT_PER_LEGENDE = 15; - public static int WIDTH_PER_LEGENDEICON = 100; - public static int WIDTH_PER_LEGENDETEXT = 120; - public static int MAX_BORDURE = 12; - - public static Dimension createSizeForWidget(int _nbLibelles){ - return new Dimension(WIDTH_PER_LEGENDEICON + WIDTH_PER_LEGENDETEXT, _nbLibelles - * (LENGHT_PER_LEGENDE + MAX_BORDURE / 2)); - } - - - - + // public static int LENGHT_PER_LEGENDE = 15; + // public static int WIDTH_PER_LEGENDEICON = 100; + // public static int WIDTH_PER_LEGENDETEXT = 120; + // public static int MAX_BORDURE = 12; + + // public static Dimension createSizeForWidget(int _nbLibelles){ + // return new Dimension(WIDTH_PER_LEGENDEICON + WIDTH_PER_LEGENDETEXT, _nbLibelles + // * (LENGHT_PER_LEGENDE + MAX_BORDURE / 2)); + // } + /** - * Creation de la classe widget specifique au calque. Permet de gerer le - * resize via le changement de font - * + * Creation de la classe widget specifique au calque. Permet de gerer le resize via le changement de font */ public static class WidgetCalqueLegende extends EbliWidget { @@ -55,8 +48,7 @@ super(scene, _controller); oldFont_ = getFormeFont(); } - - + protected Rectangle resizeMaxLegende() { this.getGraphics().setFont(getFormeFont()); int maxHeight = 0; @@ -71,22 +63,20 @@ EbliWidgetTitle tw = null; - if (new_widget.getChildren().get(0) instanceof EbliWidgetTitle) - tw = (EbliWidgetTitle) new_widget.getChildren().get(0); - else - if (new_widget.getChildren().get(1) instanceof EbliWidgetTitle) - tw = (EbliWidgetTitle) new_widget.getChildren().get(1); - + if (new_widget.getChildren().get(0) instanceof EbliWidgetTitle) tw = (EbliWidgetTitle) new_widget + .getChildren().get(0); + else if (new_widget.getChildren().get(1) instanceof EbliWidgetTitle) tw = (EbliWidgetTitle) new_widget + .getChildren().get(1); + if (tw != null) { - // -- recuperation des tailles des font pour les textes saisies + // -- recuperation des tailles des font pour les textes saisies - FontMetrics ftm = this.getGraphics().getFontMetrics(); + FontMetrics ftm = this.getGraphics().getFontMetrics(); - int newWidth = ftm.stringWidth(tw.intern_.getLabel()); - int newHeight = ftm.getHeight(); - if (maxWidth < newWidth) - maxWidth = newWidth; - maxHeight = newHeight; + int newWidth = ftm.stringWidth(tw.intern_.getLabel()); + int newHeight = ftm.getHeight(); + if (maxWidth < newWidth) maxWidth = newWidth; + maxHeight = newHeight; } } @@ -105,7 +95,7 @@ // -- calcul des max height et width pour resize les composants --// Rectangle newBounds = resizeMaxLegende(); - + // -- mise a jour de la widget avec la nouvelle font List<Widget> listePlage = getChildren(); for (Iterator<Widget> it = listePlage.iterator(); it.hasNext();) { @@ -113,24 +103,22 @@ // -- test si il s agit d un widget plage --// if (widget instanceof EbliWidget && widget.getChildren().size() == 2) { EbliWidget new_widget = (EbliWidget) widget; - + EbliWidgetLine lw = null; EbliWidgetTitle tw = null; - - if (new_widget.getChildren().get(0) instanceof EbliWidgetLine) - lw = (EbliWidgetLine) new_widget.getChildren().get(0); - else - tw = (EbliWidgetTitle) new_widget.getChildren().get(0); - - if (new_widget.getChildren().get(1) instanceof EbliWidgetLine) - lw = (EbliWidgetLine) new_widget.getChildren().get(1); - else - tw = (EbliWidgetTitle) new_widget.getChildren().get(1); + + if (new_widget.getChildren().get(0) instanceof EbliWidgetLine) lw = (EbliWidgetLine) new_widget + .getChildren().get(0); + else tw = (EbliWidgetTitle) new_widget.getChildren().get(0); + + if (new_widget.getChildren().get(1) instanceof EbliWidgetLine) lw = (EbliWidgetLine) new_widget + .getChildren().get(1); + else tw = (EbliWidgetTitle) new_widget.getChildren().get(1); if (lw != null && tw != null) { - + tw.getIntern_().setFont(getFormeFont()); - // resize du composant texte + // resize du composant texte Rectangle internBounds = tw.getIntern_().getBounds(); // internBounds.height += (getFormeFont().getSize() - // oldFont_.getSize()) * 2; @@ -140,16 +128,16 @@ internBounds.height = (int) (newBounds.height); tw.getIntern_().setPreferredBounds(internBounds); - // resize pour le logo: forme carr\xE9 + // resize pour le logo: forme carr\xE9 Rectangle boundsLogo = lw.getBounds(); // boundsLogo.height = internBounds.height; // boundsLogo.width = internBounds.height; boundsLogo.height = (int) (newBounds.height); boundsLogo.width = (int) (newBounds.height); lw.setPreferredBounds(boundsLogo); - + } - } + } } // Resize de la widget @@ -190,16 +178,15 @@ public boolean canFont() { return true; } - + } - + /** * Creation de la legende * * @param g * @param scene - * @param PreferredLocation - * peut etre null + * @param PreferredLocation peut etre null * @return */ public static EbliWidget createLegende(final EGGraphe g, final EbliScene scene, final Point PreferredLocation) { @@ -263,14 +250,13 @@ }); } - + res.setController(new EbliWidgetControllerMenuOnly(res, false)); - // -- prendre en compte le resize automatique --// res.oldFont_ = new Font("Helvetica", Font.BOLD, 40); res.repaint(); - + return res; } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/save/FudaaFilleVisuPersistence.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/save/FudaaFilleVisuPersistence.java 2008-09-24 17:58:35 UTC (rev 3976) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/save/FudaaFilleVisuPersistence.java 2008-09-24 21:15:55 UTC (rev 3977) @@ -118,9 +118,7 @@ // pas joli joli mais c'est pour \xE9viter certaines erreurs de db4o try { final FilleVisuSaver saveData = findDataInDb(_db); - if (saveData == null) { - return null; - } + if (saveData == null) { return null; } final BCalque parent = visu_.getDonneesCalque(); if (saveData.props_ != null) { final BCalquePersistenceGroupe gr = new BCalquePersistenceGroupe(); @@ -136,9 +134,7 @@ private Runnable restoreFille(final FilleVisuSaver _saveData, final BuCommonImplementation _impl, final BCalque _parent) { - if (_saveData == null) { - return null; - } + if (_saveData == null) { return null; } final BuDesktop ds = _impl.getMainPanel().getDesktop(); if (ds != null) { if (Fu.DEBUG) { @@ -173,10 +169,9 @@ } private FilleVisuSaver findDataInDb(final ObjectContainer _db) { - if (_db == null) { - return null; - } + if (_db == null) { return null; } final Query q = _db.query(); + if (q == null || visu_ == null) return null; q.constrain(FilleVisuSaver.class); q.descend("name_").constrain(visu_.getName()); final ObjectSet set = q.execute(); Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/save/FudaaSaveLib.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/save/FudaaSaveLib.java 2008-09-24 17:58:35 UTC (rev 3976) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/save/FudaaSaveLib.java 2008-09-24 21:15:55 UTC (rev 3977) @@ -49,9 +49,7 @@ } public static synchronized void configureDb4o() { - if (isConfigure_) { - return; - } + if (isConfigure_) { return; } isConfigure_ = true; final Configuration conf = Db4o.configure(); // conf.objectClass(FilleVisuSaver.class).cascadeOnDelete(true); @@ -119,27 +117,21 @@ } public static int count(final ObjectContainer _db, final Class _c) { - if (_db == null) { - return 0; - } + if (_db == null) { return 0; } final Query q = _db.query(); q.constrain(_c); return q.execute().size(); } public static void deleteAll(final ObjectContainer _db, final Class _c) { - if (_db == null) { - return; - } + if (_db == null) { return; } final Query q = _db.query(); q.constrain(_c); deleteAll(_db, q); } public static void deleteAll(final ObjectContainer _db, final ObjectSet _set) { - if (_db == null) { - return; - } + if (_db == null) { return; } while (_set.hasNext()) { _db.delete(_set.next()); } @@ -176,13 +168,9 @@ } public static FudaaSaveMainData getProjectDataOld(final File _file) { - if (_file == null) { - return null; - } + if (_file == null) { return null; } final File dbFile = _file; - if (!dbFile.exists()) { - return null; - } + if (!dbFile.exists()) { return null; } final ObjectContainer container = Db4o.openFile(dbFile.getAbsolutePath()); FudaaSaveMainData res = null; try { @@ -199,13 +187,9 @@ } public static Object getUniqueDataInDb(final File _dbFile, final Class _class) { - if (_dbFile == null) { - return null; - } + if (_dbFile == null) { return null; } final File dbFile = _dbFile; - if (!dbFile.exists()) { - return null; - } + if (!dbFile.exists()) { return null; } ObjectContainer container = null; Object res = null; try { @@ -223,9 +207,7 @@ } public static FudaaSaveMainData getProjectMainData(final ObjectContainer _cont) { - if (_cont == null) { - return null; - } + if (_cont == null) { return null; } final FudaaSaveMainData data = (FudaaSaveMainData) getUniqueData(FudaaSaveMainData.class, _cont); return data == null ? null : data; } @@ -240,15 +222,11 @@ * @return l'unique objet de class _class. Sinon null */ public static Object getUniqueData(final Class _class, final ObjectContainer _db) { - if (_db == null) { - return null; - } + if (_db == null) { return null; } final Query query = _db.query(); query.constrain(_class); final ObjectSet res = query.execute(); - if (res.size() != 1) { - return null; - } + if (res.size() != 1) { return null; } return res.next(); } @@ -298,7 +276,7 @@ Runnable res = null; final File zip = _zipFile; - if (zip != null && zip.exists()) { + if (zip != null && zip.exists() && _fille != null) { res = FudaaSaveLib.restoreFille(_impl, _fille, _prog, zip); } else { final File oldDb = _oldFile; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |