From: <had...@us...> - 2008-08-09 13:42:37
|
Revision: 3747 http://fudaa.svn.sourceforge.net/fudaa/?rev=3747&view=rev Author: hadouxad Date: 2008-08-09 13:42:46 +0000 (Sat, 09 Aug 2008) Log Message: ----------- correction class action align Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/actions/EbliWidgetActionAlign.java Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/actions/EbliWidgetActionAlign.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/actions/EbliWidgetActionAlign.java 2008-08-08 20:08:31 UTC (rev 3746) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/actions/EbliWidgetActionAlign.java 2008-08-09 13:42:46 UTC (rev 3747) @@ -2,6 +2,7 @@ import java.awt.Dimension; import java.awt.Point; +import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; @@ -92,6 +93,24 @@ } +private Point calculeNewLocation(Point _previousLocation,Rectangle _dimensionWidget,Dimension _dimensionScene){ + + + switch(typeAlignement_){ + case ALIGNLEFT: return new Point(0,_previousLocation.y); + case ALIGNRIGHT: return new Point(_dimensionScene.width-_dimensionWidget.width,_previousLocation.y); + case ALIGNCENTERHORIZONTAL: return new Point(_dimensionScene.width/2 -_dimensionWidget.width/2 ,_previousLocation.y); + case ALIGNCENTERVERTICAL: return new Point(_previousLocation.x,_dimensionScene.height/2 -_dimensionWidget.height/2); + case ALIGNTOP: return new Point(_previousLocation.x,0); + case ALIGNBOTTOM: return new Point(_previousLocation.x,_dimensionScene.height-_dimensionWidget.height); + + + default: return _previousLocation; + } + + + } + private String traduct(int _align){ switch(typeAlignement_){ @@ -128,7 +147,7 @@ listPreviousPositions_.add(currentNode.getPreferedLocation()); //-- calcul de la nouvelle position du node en fonction de l alignement choisi --// - Point newLocation=calculeNewLocation(currentNode.getPreferedLocation(), currentNode.getCreator().getWidget().getPreferredSize(),scene_.getView().getSize()); + Point newLocation=calculeNewLocation(currentNode.getCreator().getWidget().getLocation(), currentNode.getCreator().getWidget().getBounds(),scene_.getView().getSize()); //-- tentative de modification de la position du node --// currentNode.setPreferedLocation(newLocation); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <had...@us...> - 2008-08-11 07:49:20
|
Revision: 3755 http://fudaa.svn.sourceforge.net/fudaa/?rev=3755&view=rev Author: hadouxad Date: 2008-08-11 07:49:27 +0000 (Mon, 11 Aug 2008) Log Message: ----------- Resolution du FIXME: lorsque la widget est selectionnee, son state est a isselected: test poru recuperer les widgets selectionnees: myWidget.getState().isSelected Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/actions/EbliWidgetActionAlign.java Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/actions/EbliWidgetActionAlign.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/actions/EbliWidgetActionAlign.java 2008-08-11 07:43:50 UTC (rev 3754) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/actions/EbliWidgetActionAlign.java 2008-08-11 07:49:27 UTC (rev 3755) @@ -49,13 +49,13 @@ public final static int ALIGNCENTERVERTICAL=3; public final static int ALIGNTOP=4; public final static int ALIGNBOTTOM=5; - + int typeAlignement_; - + //liste des positions precedentes pour chaque widgets List<Point> listPreviousPositions_; - + public EbliWidgetActionAlign(EbliScene _scene, int _typeAlignement) { super(); // TODO Auto-generated constructor stub @@ -76,8 +76,8 @@ * methode qui recalcule la nouvelle position par rapport a la scene et a l alignement choisiT. */ private Point calculeNewLocation(Point _previousLocation,Dimension _dimensionWidget,Dimension _dimensionScene){ - - + + switch(typeAlignement_){ case ALIGNLEFT: return new Point(0,_previousLocation.y); case ALIGNRIGHT: return new Point(_dimensionScene.width-_dimensionWidget.width,_previousLocation.y); @@ -85,17 +85,17 @@ case ALIGNCENTERVERTICAL: return new Point(_previousLocation.x,_dimensionScene.height/2 -_dimensionWidget.height/2); case ALIGNTOP: return new Point(_previousLocation.x,0); case ALIGNBOTTOM: return new Point(_previousLocation.x,_dimensionScene.height-_dimensionWidget.height); - - + + default: return _previousLocation; } - - + + } - -private Point calculeNewLocation(Point _previousLocation,Rectangle _dimensionWidget,Dimension _dimensionScene){ - - + + private Point calculeNewLocation(Point _previousLocation,Rectangle _dimensionWidget,Dimension _dimensionScene){ + + switch(typeAlignement_){ case ALIGNLEFT: return new Point(0,_previousLocation.y); case ALIGNRIGHT: return new Point(_dimensionScene.width-_dimensionWidget.width,_previousLocation.y); @@ -103,15 +103,15 @@ case ALIGNCENTERVERTICAL: return new Point(_previousLocation.x,_dimensionScene.height/2 -_dimensionWidget.height/2); case ALIGNTOP: return new Point(_previousLocation.x,0); case ALIGNBOTTOM: return new Point(_previousLocation.x,_dimensionScene.height-_dimensionWidget.height); - - + + default: return _previousLocation; } - - + + } - + private String traduct(int _align){ switch(typeAlignement_){ case ALIGNLEFT: return "\xE0 gauche"; @@ -120,50 +120,56 @@ case ALIGNCENTERVERTICAL: return "centr\xE9 vertical"; case ALIGNTOP: return "en haut"; case ALIGNBOTTOM: return "en bas"; - - + + default: return ""; } } - + /** * action alignement qui realise l alignements de tous les composants */ public void alignComponents(){ - + //-- reinitialisation de la liste des historique des positions --// listPreviousPositions_=new ArrayList<Point>(); + + //-- recuperation de la liste des widgets selectionnees --// - //-- recuperation de la liste des widgets selectionnees --// - //FIXME comment recuperer les nodes uniquements selectionnes? la je recupere tout... Set<EbliNode> listeNode = (Set<EbliNode>) scene_.getNodes(); - + //-- parcours des nodes for(Iterator<EbliNode> it=listeNode.iterator();it.hasNext();){ - + EbliNode currentNode=it.next(); if(currentNode!=null && currentNode.isMovable()){ - //-- enregistrement de la previous position --// - listPreviousPositions_.add(currentNode.getPreferedLocation()); - - //-- calcul de la nouvelle position du node en fonction de l alignement choisi --// - Point newLocation=calculeNewLocation(currentNode.getCreator().getWidget().getLocation(), currentNode.getCreator().getWidget().getBounds(),scene_.getView().getSize()); - - //-- tentative de modification de la position du node --// - currentNode.setPreferedLocation(newLocation); - - currentNode.getCreator().getWidget().revalidate(); - currentNode.getCreator().getWidget().repaint(); + + //-- deplacement que si la widget est selectionnee --// + if(currentNode.getCreator().getWidget().getState().isSelected()){ + + //-- enregistrement de la previous position --// + listPreviousPositions_.add(currentNode.getPreferedLocation()); + + //-- calcul de la nouvelle position du node en fonction de l alignement choisi --// + Point newLocation=calculeNewLocation(currentNode.getCreator().getWidget().getLocation(), currentNode.getCreator().getWidget().getBounds(),scene_.getView().getSize()); + + //-- tentative de modification de la position du node --// + currentNode.setPreferedLocation(newLocation); + + currentNode.getCreator().getWidget().revalidate(); + currentNode.getCreator().getWidget().repaint(); + + } } - + } //-- rafraichissement de la scene --// scene_.refresh(); - - + + } - + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <had...@us...> - 2008-08-12 07:45:41
|
Revision: 3772 http://fudaa.svn.sourceforge.net/fudaa/?rev=3772&view=rev Author: hadouxad Date: 2008-08-12 07:45:50 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Creation des vrais alignements relatifs Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/actions/EbliWidgetActionAlign.java Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/actions/EbliWidgetActionAlign.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/actions/EbliWidgetActionAlign.java 2008-08-11 22:46:51 UTC (rev 3771) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/actions/EbliWidgetActionAlign.java 2008-08-12 07:45:50 UTC (rev 3772) @@ -47,8 +47,30 @@ @Override protected List<Point> getNewPositionFor(List<Widget> _widgetToMove) { - // TODO A terminer pour aligner en haut les widget - return null; + // on recupere le premier + // minx est le x min dans le repere de la scene + // on est oblige de passer par la car on la location ne suffit pas pour + // determiner + // la position d'un widget: ily a aussi les bounds + int maxY = _widgetToMove.get(0).convertLocalToScene(_widgetToMove.get(0).getBounds()).y+_widgetToMove.get(0).convertLocalToScene(_widgetToMove.get(0).getBounds()).height; + for (Widget widget : _widgetToMove) { + maxY = Math.max(maxY, widget.convertLocalToScene(widget.getBounds()).y+ widget.convertLocalToScene(widget.getBounds()).height); + } + List<Point> newPoints = new ArrayList<Point>(_widgetToMove.size()); + for (Widget widget : _widgetToMove) { + Point p = widget.getPreferredLocation(); + // celui la ne change pas + int oldX = p.x; + p.y = maxY; + widget.getParentWidget().convertSceneToLocal(p); + //maintenant le p.x contient la position de bounds dans le repere qu'il faut. + //la location + bounds.x vaut la postion final du dessin donc + //la location final vaut=le point du dessin - bounds.x + p.y = p.y - widget.getBounds().height- widget.getBounds().y; + p.x = oldX; + newPoints.add(p); + } + return newPoints; } } @@ -63,7 +85,34 @@ @Override protected List<Point> getNewPositionFor(List<Widget> _widgetToMove) { // TODO A terminer pour centrer horizontalement les widgets - return null; + + //on recupere les coordonnees les plus a gauche + int minx = _widgetToMove.get(0).convertLocalToScene(_widgetToMove.get(0).getBounds()).y; + for (Widget widget : _widgetToMove) { + minx = Math.min(minx, widget.convertLocalToScene(widget.getBounds()).y); + } + //on recupere les coordonnees les plus a droite + int maxx = _widgetToMove.get(0).convertLocalToScene(_widgetToMove.get(0).getBounds()).y+_widgetToMove.get(0).convertLocalToScene(_widgetToMove.get(0).getBounds()).height; + for (Widget widget : _widgetToMove) { + maxx = Math.max(maxx, widget.convertLocalToScene(widget.getBounds()).y+ widget.convertLocalToScene(widget.getBounds()).height); + } + List<Point> newPoints = new ArrayList<Point>(_widgetToMove.size()); + for (Widget widget : _widgetToMove) { + Point p = widget.getPreferredLocation(); + // toutes les coordonnees changent, elles s alignent entre elles au centre, cf le super logiciel powerpoint + int oldY = p.x; + + // p.x se trouve a la moyenne des 2 + p.y = (maxx+minx)/2; + widget.getParentWidget().convertSceneToLocal(p); + //maintenant le p.x contient la position du centre des widgets dans le repere qu'il faut. + // + //la location final vaut=le point du milieu du dessin - sa taille/2 - sa bordure + p.y = p.y - widget.getBounds().height/2- widget.getBounds().y; + p.x = oldY; + newPoints.add(p); + } + return newPoints; } } @@ -114,8 +163,35 @@ @Override protected List<Point> getNewPositionFor(List<Widget> _widgetToMove) { - // TODO A terminer pour centrer horizontalement les widgets - return null; + // TODO A terminer pour centrer horizontalement les widgets + + //on recupere les coordonnees les plus a gauche + int minx = _widgetToMove.get(0).convertLocalToScene(_widgetToMove.get(0).getBounds()).x; + for (Widget widget : _widgetToMove) { + minx = Math.min(minx, widget.convertLocalToScene(widget.getBounds()).x); + } + //on recupere les coordonnees les plus a droite + int maxx = _widgetToMove.get(0).convertLocalToScene(_widgetToMove.get(0).getBounds()).x+_widgetToMove.get(0).convertLocalToScene(_widgetToMove.get(0).getBounds()).width; + for (Widget widget : _widgetToMove) { + maxx = Math.max(maxx, widget.convertLocalToScene(widget.getBounds()).x+ widget.convertLocalToScene(widget.getBounds()).width); + } + List<Point> newPoints = new ArrayList<Point>(_widgetToMove.size()); + for (Widget widget : _widgetToMove) { + Point p = widget.getPreferredLocation(); + // toutes les coordonnees changent, elles s alignent entre elles au centre, cf le super logiciel powerpoint + int oldY = p.y; + + // p.x se trouve a la moyenne des 2 + p.x = (maxx+minx)/2; + widget.getParentWidget().convertSceneToLocal(p); + //maintenant le p.x contient la position du centre des widgets dans le repere qu'il faut. + // + //la location final vaut=le point du milieu du dessin - sa taille/2 - sa bordure + p.x = p.x - widget.getBounds().width/2- widget.getBounds().x; + p.y = oldY; + newPoints.add(p); + } + return newPoints; } } @@ -130,8 +206,30 @@ @Override protected List<Point> getNewPositionFor(List<Widget> _widgetToMove) { - // TODO A terminer pour aligner a droite les widget - return null; + // on recupere le premier + // minx est le x min dans le repere de la scene + // on est oblige de passer par la car on la location ne suffit pas pour + // determiner + // la position d'un widget: ily a aussi les bounds + int maxx = _widgetToMove.get(0).convertLocalToScene(_widgetToMove.get(0).getBounds()).x+_widgetToMove.get(0).convertLocalToScene(_widgetToMove.get(0).getBounds()).width; + for (Widget widget : _widgetToMove) { + maxx = Math.max(maxx, widget.convertLocalToScene(widget.getBounds()).x+ widget.convertLocalToScene(widget.getBounds()).width); + } + List<Point> newPoints = new ArrayList<Point>(_widgetToMove.size()); + for (Widget widget : _widgetToMove) { + Point p = widget.getPreferredLocation(); + // celui la ne change pas + int oldY = p.y; + p.x = maxx; + widget.getParentWidget().convertSceneToLocal(p); + //maintenant le p.x contient la position de bounds dans le repere qu'il faut. + //la location + bounds.x vaut la postion final du dessin donc + //la location final vaut=le point du dessin - bounds.x + p.x = p.x - widget.getBounds().width- widget.getBounds().x; + p.y = oldY; + newPoints.add(p); + } + return newPoints; } } @@ -144,8 +242,30 @@ @Override protected List<Point> getNewPositionFor(List<Widget> _widgetToMove) { - // TODO A terminer pour aligner en haut les widget - return null; + // on recupere le premier + // miny est le y min dans le repere de la scene + // on est oblige de passer par la car on la location ne suffit pas pour + // determiner + // la position d'un widget: il y a aussi les bounds + int miny = _widgetToMove.get(0).convertLocalToScene(_widgetToMove.get(0).getBounds()).y; + for (Widget widget : _widgetToMove) { + miny = Math.min(miny, widget.convertLocalToScene(widget.getBounds()).y); + } + List<Point> newPoints = new ArrayList<Point>(_widgetToMove.size()); + for (Widget widget : _widgetToMove) { + Point p = widget.getPreferredLocation(); + // celui la ne change pas + int oldX = p.x; + p.y = miny; + widget.getParentWidget().convertSceneToLocal(p); + //maintenant le p.y contient la position de bounds dans le repere qu'il faut. + //la location + bounds.x vaut la postion final du dessin donc + //la location final vaut=le point du dessin - bounds.x + p.y = p.y - widget.getBounds().y; + p.x = oldX; + newPoints.add(p); + } + return newPoints; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |