Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [gef-dev] Re: Resizing figures.


Please ask questions on the newsgroup where everyone can benefit/help.  The mailing list is for development issues.

-Randy



michaelsun@xxxxxxxxxx
Sent by: gef-dev-admin@xxxxxxxxxxx

02/13/2004 02:13 PM
Please respond to gef-dev

       
        To:        gef-dev@xxxxxxxxxxx
        cc:        bharath@xxxxxxxxxxxx
        Subject:        [gef-dev] Re: Resizing figures.



hello Bharath

After I make the following changes, it works, though I
am not familiar with emf, ecore classes
such as EAttribute, EClass, and the ENotificationImpl.
I try using PropertyChangeListener as my ModelListener
to replace Adapter.


1. modify
NetworkXYLayoutEditPolicy.createChildEditPolicy method

protected EditPolicy createChildEditPolicy(EditPart
child) {
                                 
                                 
                                 NetworkNodeEditPart childEditPart =
(NetworkNodeEditPart) child;

                                 NodeFigure rectangle = (NodeFigure)
childEditPart.getFigure();
                                 
                                 return new ResizableEditPolicy();

}

2. In the interface Node.java,  add two new methods

Dimension getSize();
               
void setSize(Dimension s);

3. In NodeImpl.java add
protected Dimension size_EDEFAULT = new
Dimension(-1,-1);
protected Dimension size=size_EDEFAULT;


public Dimension getSize() {
                                 return size;
}

public void setSize(Dimension dimension) {
                                 
                                 Dimension oldDimension = dimension;
                                 size = dimension;
                                 if (eNotificationRequired())
                                                  eNotify(new ENotificationImpl(this,
Notification.SET, NetworkPackage.NODE_SIZE,
oldDimension, size));
                                 
}

and it is easy for you to modify other methods, for
example, only add more "case return" following the
method pattern.


4. In NetworkPackage.java, add something like
int NODE_SIZE=11; //randomly choose the int
EClass getSize();

5. In NetworkPackageImpl.java, add
public EClass getSize(){
                                 return (EClass)nodeEClass.getEReferences().get(11);
}

6. In SetConstrainCommand.java, add
two new fields:
private Dimension newSize;
private Dimension oldSize;

in execute() add part.setSize(newSize),
also add it to other methods.

7. In NetworkNodeEditPart.java, modify
refreshVisuals(), replace
Dimension size = new Dimension(-1,-1);
with Dimension size = getNetworkNode().getSize();


>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>On Fri, 13 Feb 2004 10:32:07 -0600, "Bharath S" wrote:

>
> Hi Michael,
>
> I am trying to resize figures too and I am having
> problems. Can you guide me
> with this?
>
> Thanks!
>
> Bharath.
>  
>
> -----Original Message-----
> From: gef-dev-admin@xxxxxxxxxxx
> [mailto:gef-dev-admin@xxxxxxxxxxx] On Behalf
> Of michaelsun@xxxxxxxxxx
> Sent: Friday, February 13, 2004 9:03 AM
> To: gef-dev@xxxxxxxxxxx
> Subject: Re: [gef-dev] NodeFigure can not be resized?
>
> Now the problem is fixed by modifying the
> NetworkXYLayoutEditorPolicy, NetworkNodeEditParty,
> Node, NodeImpl and SetConstraintCommand to handle
> resizing the figure. If anyone need help at this
> point, let me know.
>
> Michael
>
> >On Thu, 12 Feb 2004 11:36:56 -0800 (PST),
> michaelsun@xxxxxxxxxx wrote:
>
> >
> > I only modified the NodeFigure to extends
> > RectangleFigure, rendering the Rectangle
> > shape works well in the viewer. But the NodeFigure
> > can not be resized. I take a look at the
> > NetworkNodeEditPart, still can not figure it out.
Any
> > help? thanks!
> >
> > Michael
> > _______________________________________________
> > gef-dev mailing list
> > gef-dev@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/gef-dev
> _______________________________________________
> gef-dev mailing list
> gef-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/gef-dev
_______________________________________________
gef-dev mailing list
gef-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/gef-dev


Back to the top