From: <had...@us...> - 2008-08-09 14:57:36
|
Revision: 3749 http://fudaa.svn.sourceforge.net/fudaa/?rev=3749&view=rev Author: hadouxad Date: 2008-08-09 14:57:45 +0000 (Sat, 09 Aug 2008) Log Message: ----------- implementation de la fonction de duplication et test pour le rectangle objet graphe Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliNode.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliNodeDefault.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidgetRectangle.java branches/Prepro-0.92-SNAPSHOT/ebli/test/org/fudaa/ebli/all/TestGraphe2.java Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliNode.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliNode.java 2008-08-09 14:06:31 UTC (rev 3748) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliNode.java 2008-08-09 14:57:45 UTC (rev 3749) @@ -5,20 +5,21 @@ import java.util.Map; public interface EbliNode { + String getTitle(); - + void setTitle(String title); + EbliWidgetCreator getCreator(); - + void setCreator(EbliWidgetCreator creator); + + Dimension getPreferedSize(); void setPreferedSize(Dimension d); - - Dimension getPreferedSize(); - EbliNode duplicate(Map options); + Point getPreferedLocation(); void setPreferedLocation(Point p); - Point getPreferedLocation(); public String toString(); Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliNodeDefault.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliNodeDefault.java 2008-08-09 14:06:31 UTC (rev 3748) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliNodeDefault.java 2008-08-09 14:57:45 UTC (rev 3749) @@ -18,10 +18,34 @@ } - + /** + * methode qui permet de dupliquer un node + */ public EbliNode duplicate(Map options) { // TODO Auto-generated method stub - return null; + EbliNode duplique= new EbliNodeDefault(); + + duplique.setTitle(getTitle()); + + + + //-- creation d une instance similaire du creator--// + EbliWidgetCreator creatorDuplique=null; + + System.err.println("je suis instance de la classe "+creator.toString()); + //-- duplique rectangle + if(creator instanceof EbliWidgetCreatorRectangle){ + + + duplique.setCreator(new EbliWidgetCreatorRectangle(((EbliWidgetCreatorRectangle)getCreator()).getG())); + + + } + + duplique.setPreferedSize(getPreferedSize()); + duplique.setPreferedLocation(getPreferedLocation()); + + return duplique; } @@ -86,6 +110,6 @@ } + - } Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java 2008-08-09 14:06:31 UTC (rev 3748) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java 2008-08-09 14:57:45 UTC (rev 3749) @@ -28,8 +28,12 @@ public class EbliWidget extends Widget { private EbliScene scene_; - private boolean useBorder_ = true; + public EbliScene getScene_() { + return scene_; +} +private boolean useBorder_ = true; + /** * @param scene * @param Point @@ -68,25 +72,25 @@ (int) (EbliWidget.this.getLocation().x + EbliWidget.this.getClientArea().width / 2), (int) (EbliWidget.this .getLocation().y + EbliWidget.this.getClientArea().height / 2)); - EbliWidget duplique; + + //-- recuperation du node a dupliquer --// + EbliNode n = (EbliNode) EbliWidget.this.getEbliScene().findObject(EbliWidget.this); + + // duplication du node en question + EbliNode duplique=n.duplicate(null); + + // nouvelle position a cote de son predecesseur + // duplique.setPreferedLocation(nouvellePosition); - try { - // clonage de l'objet - duplique = (EbliWidget) EbliWidget.this.clone(); - duplique.setPreferredSize(EbliWidget.this.getScene().getPreferredSize()); - duplique.setPreferredLocation(nouvellePosition); - - // -- ajout dans la scene --// - if (EbliWidget.this.getScene() != null) { - EbliWidget.this.getScene().addChild(duplique); - } - - } catch (CloneNotSupportedException e1) { - // TODO que fqire si ca pete? une peite fenetre d'erreur, - // widget pas duplicable? ou alors surcharger la methode - // dans les filles? - e1.printStackTrace(); + // -- ajout dans la scene --// + if (EbliWidget.this.getScene() != null) { + EbliWidget.this.getEbliScene().addNode(duplique); + //info debug widget duplique + //duplique.getCreator().getWidget().setPreferredBounds(n.getCreator().getWidget().getPreferredBounds()); + } + + } }); @@ -161,4 +165,16 @@ useBorder_ = _useBorder; } + /** + * methode qui construit une widget duplication pqr default, doit etre surchargee pour reproduire l' evenement + * @return + */ + public EbliNode duplicate(){ + EbliNode duplique =null; + + + return duplique; + } + + } \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidgetRectangle.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidgetRectangle.java 2008-08-09 14:06:31 UTC (rev 3748) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidgetRectangle.java 2008-08-09 14:57:45 UTC (rev 3749) @@ -107,5 +107,7 @@ revalidate(); } + + } \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/ebli/test/org/fudaa/ebli/all/TestGraphe2.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/test/org/fudaa/ebli/all/TestGraphe2.java 2008-08-09 14:06:31 UTC (rev 3748) +++ branches/Prepro-0.92-SNAPSHOT/ebli/test/org/fudaa/ebli/all/TestGraphe2.java 2008-08-09 14:57:45 UTC (rev 3749) @@ -11,6 +11,8 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import javax.swing.Box; import javax.swing.JButton; @@ -41,6 +43,7 @@ import org.fudaa.ebli.courbe.EGGroup; import org.fudaa.ebli.trace.TraceLigne; import org.fudaa.ebli.trace.TraceLigneModel; +import org.fudaa.ebli.visuallibrary.EbliNode; import org.fudaa.ebli.visuallibrary.EbliNodeDefault; import org.fudaa.ebli.visuallibrary.EbliScene; import org.fudaa.ebli.visuallibrary.EbliWidgetCreatorDblFleche; @@ -147,7 +150,7 @@ final EGFillePanel pn = new EGFillePanel(g); // creation de la scene EBLI - EbliScene scene = new EbliScene(); + final EbliScene scene = new EbliScene(); // -- construction du jtree @@ -206,12 +209,14 @@ // test.getVisuPanel().getVueCalque())); // -- ajout du rectangle --// - EbliNodeDefault nodeRect = new EbliNodeDefault(); + final EbliNodeDefault nodeRect = new EbliNodeDefault(); nodeRect.setTitle("Rectangle"); nodeRect.setCreator(new EbliWidgetCreatorRectangle("Test recangle")); nodeRect.setPreferedSize(new Dimension(200, 100)); nodeRect.setPreferedLocation(new Point(350, 125)); scene.addNode(nodeRect); + + // -- ajout du fleche double sens diagonale--// node = new EbliNodeDefault(); @@ -330,6 +335,19 @@ bar.add(new EbliWidgetActionAlign(scene, EbliWidgetActionAlign.ALIGNCENTERVERTICAL)); bar.add(new EbliWidgetActionAlign(scene, EbliWidgetActionAlign.ALIGNTOP)); bar.add(new EbliWidgetActionAlign(scene, EbliWidgetActionAlign.ALIGNBOTTOM)); - p.doLayout(); + +JButton boutontestAjout = new JButton("dupliquer rectangle"); +boutontestAjout.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + EbliNode node = nodeRect.duplicate(null); + scene.addNode(node); + scene.getView().repaint(); + + } + +}); +bar.add(boutontestAjout); +p.doLayout(); } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |