From: <had...@us...> - 2008-08-05 15:42:58
|
Revision: 3714 http://fudaa.svn.sourceforge.net/fudaa/?rev=3714&view=rev Author: hadouxad Date: 2008-08-05 15:42:58 +0000 (Tue, 05 Aug 2008) Log Message: ----------- AFFECT?\195?\137 - # 40: L?\195?\169gende pour les courbe 1d http://mantis.genesis-groupe.com//view.php?id=40 - creation de la classe GrapheWidget aui dessine un graphe - creation de la classe scene principale fonctions: - menu popup accessible par clic droit ( ffermer l objet graphique) - fonction de zoom (ctrl + clic) - resolution des bugs rafraichissement simultan?\195?\169 des graphes et legende - recuperation de la vue sattelite de la scene principale reste a extendre d image producer Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/LineWidget.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/TitleWidget.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/WidgetLegendeManager.java branches/Prepro-0.92-SNAPSHOT/ebli/test/org/fudaa/ebli/all/TestGraphe2.java Added Paths: ----------- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliGraphScene.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/GrapheWidget.java Added: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliGraphScene.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliGraphScene.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliGraphScene.java 2008-08-05 15:42:58 UTC (rev 3714) @@ -0,0 +1,166 @@ +package org.fudaa.ebli.visuallibrary; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JComponent; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; + +import org.netbeans.api.visual.action.ActionFactory; +import org.netbeans.api.visual.action.PopupMenuProvider; +import org.netbeans.api.visual.graph.GraphScene; +import org.netbeans.api.visual.widget.LayerWidget; +import org.netbeans.api.visual.widget.Widget; + + +/** + * clqsse de gestion de la scene principale + * @author Adrien Hadoux + * + */ +public class EbliGraphScene extends GraphScene{ + + /** + * la visu du graphscene + */ + private LayerWidget visu_; + + public EbliGraphScene() { + super(); + + // creation du layer de mise en page + visu_ = new LayerWidget(this); + addChild(visu_); + + //-- ajoute l'action du zoom ( ctrl + clic) + getActions ().addAction (ActionFactory.createCenteredZoomAction (1.1)); + + //-- ajouter le menu popup de base + setMenuBase(); + + } + + public LayerWidget getVisu_() { + return visu_; + } + + public void setVisu_(LayerWidget visu_) { + this.visu_ = visu_; + } + + @Override + protected void attachEdgeSourceAnchor(Object edge, Object oldSourceNode, + Object sourceNode) { + // TODO Auto-generated method stub + + } + + @Override + protected void attachEdgeTargetAnchor(Object edge, Object oldTargetNode, + Object targetNode) { + // TODO Auto-generated method stub + + } + + @Override + protected Widget attachEdgeWidget(Object edge) { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Widget attachNodeWidget(Object node) { + // TODO Auto-generated method stub + return null; + } + + /** + * methode qui permet d'ajouter une widget dans la vue principale + */ + public void addWidget(EbliWidget widget){ + + addWidget(widget, null,null); + + } + + public void addWidget(EbliWidget widget,Point preferredLocation, Dimension preferedSize){ + + if(preferedSize!=null){ + widget.setPreferredSize(preferedSize); + } + if(preferredLocation !=null){ + widget.setPreferredLocation(preferredLocation); + } + + getVisu_().addChild(widget); + + + } + + + /** + * recupere une version miniature de la vue aui se rafraichit simultanement avec la scene + * @return + */ + public JComponent getSatteliteView(){ + return this.createSatelliteView(); + } + + /** + * retourne la vue Jcomponent associ\xE9 + * Utile pour l'integration dans les components existants + */ + public JComponent getSwingView(){ + return this.getView(); + } + + public void setMenuBase() { + getActions ().addAction (ActionFactory.createPopupMenuAction (new PopupMenuProvider() { + public JPopupMenu getPopupMenu (Widget widget, Point localLocation) { + JPopupMenu popup = new JPopupMenu (); + + + + JMenuItem menuItem1=popup.add ("Ajouter Graphe"); + menuItem1.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + + + } + + }); + + JMenuItem menuItem2=popup.add ("Ajouter Maillage"); + menuItem2.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + + + } + + }); + + JMenuItem menuItem3=popup.add ("Fermer l'objet"); + menuItem3.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + + //fermeture des widgets children + EbliGraphScene.this.removeChildren(); + //fermeture du widget donne + EbliGraphScene.this.removeFromParent(); + + } + + }); + return popup; + } + })); + } + + + } Property changes on: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliGraphScene.java ___________________________________________________________________ Added: svn:mime-type + text/plain 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-05 15:13:59 UTC (rev 3713) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java 2008-08-05 15:42:58 UTC (rev 3714) @@ -1,7 +1,19 @@ package org.fudaa.ebli.visuallibrary; +import java.awt.Color; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; + import org.netbeans.api.visual.action.ActionFactory; +import org.netbeans.api.visual.action.PopupMenuProvider; +import org.netbeans.api.visual.border.Border; +import org.netbeans.api.visual.border.BorderFactory; import org.netbeans.api.visual.laf.LookFeel; +import org.netbeans.api.visual.layout.LayoutFactory; import org.netbeans.api.visual.model.ObjectState; import org.netbeans.api.visual.widget.Scene; import org.netbeans.api.visual.widget.Widget; @@ -14,22 +26,91 @@ */ class EbliWidget extends Widget { + + private static final Border RESIZE_BORDER = BorderFactory.createResizeBorder(8,Color.blue.brighter().brighter(),true); + private static final Border DEFAULT_BORDER =BorderFactory.createEmptyBorder(8); /** * @param scene + * @param Point : indiaue la location preferentiel. peut etre nul */ - public EbliWidget(Scene scene) { + public EbliWidget(Scene scene, Point preferredLocation) { super(scene); getActions().addAction( ActionFactory.createResizeAction()); getActions().addAction(ActionFactory.createMoveAction()); getActions().addAction(scene.createWidgetHoverAction());//a voir pour que le parent soit //aussi en hover : a voir apr\xE8s. + setBorder(getScene().getLookFeel().getMiniBorder(ObjectState.createNormal())); + + // positionnement de la widget si precise + if(preferredLocation!=null) + setPreferredLocation(preferredLocation); + + //menu clic droit basique (fermeture, duplication) + setMenuBase(); } @Override public void notifyStateChanged(ObjectState previousState, ObjectState newState) { LookFeel lookFeel = getScene().getLookFeel(); - setBorder(lookFeel.getMiniBorder(newState)); + + // setBorder(lookFeel.getMiniBorder(newState)); + + + setBorder( newState.isSelected() ? ( + newState.isHovered() ? RESIZE_BORDER : DEFAULT_BORDER) : ( + newState.isHovered() ? RESIZE_BORDER : DEFAULT_BORDER)); } + + /** + * Methode generique qui fait apparaitre un menuItem propre au composant et offre les op\xE9rations de base + * on ouvre le menu via le clic droit ou le raccourcis shift+F10 + */ + + public void setMenuBase() { + getActions ().addAction (ActionFactory.createPopupMenuAction (new PopupMenuProvider() { + public JPopupMenu getPopupMenu (Widget widget, Point localLocation) { + JPopupMenu popup = new JPopupMenu (); + + JMenuItem menuItem1=popup.add ("Dupliquer l'objet"); + menuItem1.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + + //position a cote de l element initial + Point nouvellePosition=new Point((int)(EbliWidget.this.getLocation().x+EbliWidget.this.getClientArea().width/2),(int)(EbliWidget.this.getLocation().y+EbliWidget.this.getClientArea().height/2)); + + EbliWidget duplique; + + try { + //clonage de l'objet + duplique=(EbliWidget)EbliWidget.this.clone(); + duplique.setPreferredSize(EbliWidget.this.getScene().getPreferredSize()); + + } catch (CloneNotSupportedException e1) { + // TODO que fqire si cq pete? une peite fenetre d'erreur, widget pas duplicable? ou alors surcharger la methode dans les filles? + e1.printStackTrace(); + } + } + + }); + JMenuItem menuItem2=popup.add ("Fermer l'objet"); + menuItem2.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + + //fermeture des widgets children + EbliWidget.this.removeChildren(); + //fermeture du widget donne + EbliWidget.this.removeFromParent(); + + } + + }); + return popup; + } + })); + } + } \ No newline at end of file Added: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/GrapheWidget.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/GrapheWidget.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/GrapheWidget.java 2008-08-05 15:42:58 UTC (rev 3714) @@ -0,0 +1,104 @@ +package org.fudaa.ebli.visuallibrary; + +import java.awt.Point; +import java.awt.Rectangle; + +import org.fudaa.ebli.courbe.EGAxe; +import org.fudaa.ebli.courbe.EGGraphe; +import org.fudaa.ebli.courbe.EGGrapheModelListener; +import org.fudaa.ebli.courbe.EGObject; +import org.netbeans.api.visual.laf.LookFeel; +import org.netbeans.api.visual.model.ObjectState; +import org.netbeans.api.visual.widget.Scene; + + +/** + * widget aui contient un objet courbe + * @author adrien hadoux + * + */ +public class GrapheWidget extends EbliWidget{ + + private EGGraphe graphe; + + public EGGraphe getGraphe() { + return graphe; + } + + public void setGraphe(EGGraphe graphe) { + this.graphe = graphe; + } + + public GrapheWidget(Scene scene, Point preferredLocation, EGGraphe _graphe) { + super(scene, preferredLocation); + // TODO Auto-generated constructor stub + setGraphe(_graphe); + + + //prise en compte du listener d'\xE9coute des modif du graphe + listenGraphe(); + + } + + public void notifyStateChanged(ObjectState previousState, + ObjectState newState) { + LookFeel lookFeel = getScene().getLookFeel(); + // setBorder(lookFeel.getBorder(newState)); + // setForeground(lookFeel.getForeground(newState)); + setBorder(lookFeel.getBorder(newState)); + // setBorder(newState.isSelected() ? + // (DEFAULT_SELECTED_BORDER) : + // (newState.isHovered() ? RESIZE_BORDER + // : DEFAULT_BORDER)); + + } + + protected void paintWidget() { + Rectangle rec = getClientArea(); + + // BufferedImage image = courbe.produceImage( + // rec.width - 1, rec.height - 1, + // Collections.EMPTY_MAP); + getGraphics().translate(rec.x, rec.y); + graphe.setSize(rec.width - 1, + rec.height - 1); + graphe.computeMarges(getGraphics()); + graphe.dessine(getGraphics(), rec.width - 1, + rec.height - 1, false ); + } + + /** + * methode aui permet d ajouter les fonctions de redessin du graphe + */ + private void listenGraphe(){ + graphe.getModel().addModelListener(new EGGrapheModelListener() { + + public void structureChanged() { + repaint(); + + } + + public void courbeContentChanged(EGObject _c, boolean restore) { + repaint(); + + } + + public void courbeAspectChanged(EGObject _c, boolean _visibil) { + //graphe.paint(); + repaint(); + // TODO Auto-generated method stub + + } + + public void axeContentChanged(EGAxe _c) { + repaint(); + + } + + public void axeAspectChanged(EGAxe _c) { + repaint(); + + } + }); + } +} Property changes on: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/GrapheWidget.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/LineWidget.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/LineWidget.java 2008-08-05 15:13:59 UTC (rev 3713) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/LineWidget.java 2008-08-05 15:42:58 UTC (rev 3714) @@ -2,6 +2,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; +import java.awt.Point; import java.awt.Rectangle; import org.fudaa.ebli.courbe.EGCourbe; @@ -24,8 +25,8 @@ /** * @param _scene */ - public LineWidget(Scene _scene, EGCourbe _cb) { - super(_scene); + public LineWidget(Scene _scene, EGCourbe _cb, Point preferedLocation) { + super(_scene,preferedLocation); cb_ = _cb; setMinimumSize(new Dimension(30, 10)); setPreferredSize(new Dimension(40, 10)); Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/TitleWidget.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/TitleWidget.java 2008-08-05 15:13:59 UTC (rev 3713) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/TitleWidget.java 2008-08-05 15:42:58 UTC (rev 3714) @@ -1,5 +1,7 @@ package org.fudaa.ebli.visuallibrary; +import java.awt.Point; + import org.fudaa.ebli.courbe.EGCourbe; import org.netbeans.api.visual.layout.LayoutFactory.SerialAlignment; import org.netbeans.api.visual.widget.LabelWidget; @@ -22,8 +24,8 @@ /** * @param _scene */ - public TitleWidget(Scene _scene, EGCourbe _cb) { - super(_scene); + public TitleWidget(Scene _scene, EGCourbe _cb,Point preferedLocation) { + super(_scene,preferedLocation); setLayout(new FlowLayout(true, SerialAlignment.LEFT_TOP, 0)); intern = new LabelWidget(_scene); intern.setForeground(_cb.getAspectContour()); Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/WidgetLegendeManager.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/WidgetLegendeManager.java 2008-08-05 15:13:59 UTC (rev 3713) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/WidgetLegendeManager.java 2008-08-05 15:42:58 UTC (rev 3714) @@ -6,10 +6,15 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; +import java.awt.Point; import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import javax.swing.JFrame; +import javax.swing.JMenuItem; import javax.swing.JPanel; +import javax.swing.JPopupMenu; import org.fudaa.ctulu.iterator.LogarithmicNumberIterator; import org.fudaa.ebli.courbe.EGAxe; @@ -28,6 +33,7 @@ import org.fudaa.ebli.trace.TraceLigne; import org.fudaa.ebli.trace.TraceLigneModel; import org.netbeans.api.visual.action.ActionFactory; +import org.netbeans.api.visual.action.PopupMenuProvider; import org.netbeans.api.visual.graph.GraphScene; import org.netbeans.api.visual.laf.LookFeel; import org.netbeans.api.visual.layout.LayoutFactory.SerialAlignment; @@ -39,7 +45,7 @@ import org.netbeans.modules.visual.layout.FlowLayout; /** - * @author denf01a adrien hadous + * @author denf01a adrien hadoux * @creation 5 ao\xFBt 2008 * @version * @@ -48,20 +54,26 @@ - //exemple a ameliorer - public static EbliWidget createLegende(EGGraphe g, Scene scene) { + /** + * Creation de la legende + * @param g + * @param scene + * @param PreferredLocation peut etre null + * @return + */ + public static EbliWidget createLegende(EGGraphe g, Scene scene, Point PreferredLocation) { EGCourbe[] cs = g.getModel().getCourbes(); - EbliWidget res = new EbliWidget(scene); + final EbliWidget res = new EbliWidget(scene,PreferredLocation); res.setLayout(new FlowLayout(true, SerialAlignment.LEFT_TOP, 10));// a modifier pour setter le gap for (int i = 0; i < cs.length; i++) { - final EbliWidget line = new EbliWidget(scene); + final EbliWidget line = new EbliWidget(scene,PreferredLocation); line.setLayout(new FlowLayout(false, SerialAlignment.CENTER, 5)); //creation de la widget titre - final TitleWidget tw=new TitleWidget(scene, cs[i]); + final TitleWidget tw=new TitleWidget(scene, cs[i],null); //creation de la widget ligne - LineWidget lw=new LineWidget(scene, cs[i]); + LineWidget lw=new LineWidget(scene, cs[i],null); line.addChild(lw); line.addChild(tw); @@ -100,6 +112,8 @@ }); } + + return res; } 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-05 15:13:59 UTC (rev 3713) +++ branches/Prepro-0.92-SNAPSHOT/ebli/test/org/fudaa/ebli/all/TestGraphe2.java 2008-08-05 15:42:58 UTC (rev 3714) @@ -11,6 +11,7 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics2D; +import java.awt.Point; import java.awt.Rectangle; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; @@ -43,11 +44,14 @@ import org.fudaa.ebli.courbe.EGObject; import org.fudaa.ebli.trace.TraceLigne; import org.fudaa.ebli.trace.TraceLigneModel; +import org.fudaa.ebli.visuallibrary.EbliGraphScene; +import org.fudaa.ebli.visuallibrary.GrapheWidget; import org.fudaa.ebli.visuallibrary.WidgetLegendeManager; import org.fudaa.ebli.visuallibrary.WidgetLegendeManagerOLD; import org.netbeans.api.visual.action.ActionFactory; import org.netbeans.api.visual.graph.GraphScene; import org.netbeans.api.visual.laf.LookFeel; +import org.netbeans.api.visual.layout.LayoutFactory; import org.netbeans.api.visual.model.ObjectState; import org.netbeans.api.visual.widget.ImageWidget; import org.netbeans.api.visual.widget.LabelWidget; @@ -154,240 +158,41 @@ p.doLayout(); f.setContentPane(p); final EGFillePanel pn = new EGFillePanel(g); - final GraphScene scene = new GraphScene() { - LayerWidget visu; + + + // creation de la scene EBLI + EbliGraphScene scene = new EbliGraphScene(); - { - visu = new LayerWidget(this); - addChild(visu); - } - - @Override - protected Widget attachNodeWidget(Object arg0) { - final EGGraphe courbe = (EGGraphe) arg0; - final Widget graphe = new Widget(this) { - public void notifyStateChanged(ObjectState previousState, - ObjectState newState) { - LookFeel lookFeel = getScene().getLookFeel(); - // setBorder(lookFeel.getBorder(newState)); - // setForeground(lookFeel.getForeground(newState)); - setBorder(lookFeel.getBorder(newState)); - // setBorder(newState.isSelected() ? - // (DEFAULT_SELECTED_BORDER) : - // (newState.isHovered() ? RESIZE_BORDER - // : DEFAULT_BORDER)); - - } - - @Override - protected void paintWidget() { - Rectangle rec = getClientArea(); - - // BufferedImage image = courbe.produceImage( - // rec.width - 1, rec.height - 1, - // Collections.EMPTY_MAP); - getGraphics().translate(rec.x, rec.y); - courbe.setSize(rec.width - 1, - rec.height - 1); - courbe.computeMarges(getGraphics()); - courbe.dessine(getGraphics(), rec.width - 1, - rec.height - 1, false ); - } - // } - }; - courbe.getModel().addModelListener(new EGGrapheModelListener() { - - public void structureChanged() { - repaint(); - - } - - public void courbeContentChanged(EGObject _c, boolean restore) { - repaint(); - - } - - public void courbeAspectChanged(EGObject _c, boolean _visibil) { - graphe.paint(); - paint(); - // TODO Auto-generated method stub - - } - - public void axeContentChanged(EGAxe _c) { - repaint(); - - } - - public void axeAspectChanged(EGAxe _c) { - repaint(); - - } - }); - graphe.setPreferredSize(new Dimension(100, 100)); - visu.addChild(graphe); - - -// //creation d un label widget -// LabelWidget labelWidget=new LabelWidget(this, "test") { -// public void notifyStateChanged(ObjectState previousState, -// ObjectState newState) { -// LookFeel lookFeel = getScene().getLookFeel(); -// // setBorder(lookFeel.getBorder(newState)); -// // setForeground(lookFeel.getForeground(newState)); -// -// setBorder(lookFeel.getBorder(newState)); -// // recuperation du rectangle contour -// Rectangle rec = getClientArea(); -// //setFont(new Font("Times New Roman", Font.PLAIN,rec.width )); -// repaint(); -// -// // setBorder(newState.isSelected() ? -// // (DEFAULT_SELECTED_BORDER) : -// // (newState.isHovered() ? RESIZE_BORDER -// // : DEFAULT_BORDER)); -// -// } -// -// -// -// -// -// -// -// }; -// -// -// //marche pas il faut un container jscrollpane -// //graphe.getActions().addAction(ActionFactory.createCenteredZoomAction (500)); -// -// -// labelWidget.getActions().addAction(ActionFactory.createResizeAction()); -// labelWidget.getActions().addAction(ActionFactory.createMoveAction()); -// labelWidget.getActions().addAction(this.createWidgetHoverAction()); -// //zoom de la scene en maintenant ctrl + molette -// labelWidget.getActions().addAction(ActionFactory.createZoomAction()); -// -// -// // -// labelWidget.getActions().addAction(ActionFactory.createPanAction()); -// -// //-- ajout du labelWidget dans le visuel --// -// visu.addChild(labelWidget); -// -// -// //creation d un image widget - ImageWidget imageWidget=new ImageWidget (this,CtuluResource.CTULU.getImage("crystal_oui")){ - public void notifyStateChanged(ObjectState previousState, - ObjectState newState) { - LookFeel lookFeel = getScene().getLookFeel(); - // setBorder(lookFeel.getBorder(newState)); - // setForeground(lookFeel.getForeground(newState)); - - setBorder(lookFeel.getBorder(newState)); - // setBorder(newState.isSelected() ? - // (DEFAULT_SELECTED_BORDER) : - // (newState.isHovered() ? RESIZE_BORDER - // : DEFAULT_BORDER)); - repaint(); - - } - - //-- redessinne la l\xE9gende - protected void paintWidget() { - - // recuperation du rectangle contour - Rectangle rec = getClientArea(); - Graphics2D g=getGraphics(); - - g.translate(rec.x, rec.y); - - - //dimension du cadre de la l\xE9gende // - int widthCadre=rec.width; - int heightCadre=rec.height; - - //cas initial: dessin vide - if(widthCadre==0) - widthCadre=10; - if(heightCadre==0) - heightCadre=10; - - - g.fillRect(rec.x, rec.y,widthCadre - 1, heightCadre - 1); - //courbe.setSize(rec.width - 1,rec.height - 1); - //courbe.computeMarges(getGraphics()); - //courbe.dessine(getGraphics(), rec.width - 1,rec.height - 1, false ); - - - } - - }; - - - //WidgetLegendeManagerOLD.createWidgetLegendeGraphe(this, visu, courbe, graphe.getClientArea()); - - visu.addChild (WidgetLegendeManager.createLegende(courbe, this)); - - //ajout des resize et drag - imageWidget.getActions().addAction( ActionFactory.createResizeAction()); - imageWidget.getActions().addAction(ActionFactory.createMoveAction()); - imageWidget.getActions().addAction(this.createWidgetHoverAction()); - //ajout du label widget - visu.addChild (imageWidget); - - - //test avec iconwidget - IconNodeWidget iconNode = new IconNodeWidget (this); - iconNode.setImage (CtuluResource.CTULU.getImage("crystal_non")); - iconNode.setLabel ("MyIconNode"); - this.addChild (iconNode); - this.getActions ().addAction (ActionFactory.createCenteredZoomAction (1.1)); - this.getActions ().addAction (ActionFactory.createPanAction ()); - // assign HoverAction - the actual hovered widget is held by the scene - iconNode.getActions ().addAction (this.createWidgetHoverAction ()); - // MoveAction has to be after the hover action - // otherwise MoveAction will always consume the event and HoverAction will never be invoked - iconNode.getActions ().addAction (ActionFactory.createMoveAction ()); - - - // proprietes graphes - graphe.getActions().addAction( - ActionFactory.createResizeAction()); - graphe.getActions().addAction(ActionFactory.createMoveAction()); - graphe.getActions().addAction(this.createWidgetHoverAction()); - return graphe; - } - - @Override - protected Widget attachEdgeWidget(Object arg0) { - // TODO Auto-generated method stub - return null; - } - - @Override - protected void attachEdgeTargetAnchor(Object arg0, Object arg1, - Object arg2) { - // TODO Auto-generated method stub - - } - - @Override - protected void attachEdgeSourceAnchor(Object arg0, Object arg1, - Object arg2) { - // TODO Auto-generated method stub - - } - }; - + + + //ajout graphe + GrapheWidget graphe=new GrapheWidget(scene,null,g); + graphe.setPreferredSize(new Dimension(300, 300)); + scene.addChild(graphe); + + //WidgetLegendeManagerOLD.createWidgetLegendeGraphe(this, visu, courbe, graphe.getClientArea()); + scene.addChild (WidgetLegendeManager.createLegende(g, scene,null)); - // debut - // scene.addNode(g); - scene.addNode(g); + //ajout iconenode + IconNodeWidget iconNode = new IconNodeWidget (scene); + iconNode.setImage (CtuluResource.CTULU.getImage("crystal_non")); + iconNode.setLabel ("MyIconNode"); +// this.addChild (iconNode); + iconNode.getActions ().addAction (ActionFactory.createCenteredZoomAction (1.1)); + iconNode.getActions ().addAction (ActionFactory.createPanAction ()); + // assign HoverAction - the actual hovered widget is held by the scene + iconNode.getActions ().addAction (scene.createWidgetHoverAction ()); + // MoveAction has to be after the hover action + // otherwise MoveAction will always consume the event and HoverAction will never be invoked + iconNode.getActions ().addAction (ActionFactory.createMoveAction ()); + iconNode.setPreferredLocation(new Point(400,150)); + scene.addChild(iconNode); + + //scene.addNode(new Object()); // fin p.add(new JScrollPane(scene.createView()), BuBorderLayout.CENTER); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |