Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Creating Graphviz "Record" shape in Draw2D(How to create Graphviz "Record" shapes in Draw2D?)
Creating Graphviz "Record" shape in Draw2D [message #545088] Tue, 06 July 2010 15:16 Go to next message
Namratha  is currently offline Namratha
Messages: 6
Registered: July 2010
Junior Member
Hi,

I am able to create most of the graphviz shapes that are related to polygons (like trapezium, inverted trapezium and the like) in Draw2d.

But i dont know how to create the "record" shape available in Graphviz using Draw2d, as this shape needs to be variable. There is nothing fixedin the record shape.

So please if any of you know how it can be drawn in Draw2d, just help me out in this?

Thanks
Namratha
Re: Creating Graphviz "Record" shape in Draw2D [message #545256 is a reply to message #545088] Wed, 07 July 2010 10:14 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
can you pls attach some sample images of the same...

---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Creating Graphviz "Record" shape in Draw2D [message #545266 is a reply to message #545256] Wed, 07 July 2010 10:29 Go to previous messageGo to next message
Namratha  is currently offline Namratha
Messages: 6
Registered: July 2010
Junior Member
Hi,

Just check on this page for Record-based nodes. I am not able to attach images in the reply here.

http://www.graphviz.org/doc/info/shapes.html

Re: Creating Graphviz "Record" shape in Draw2D [message #545280 is a reply to message #545266] Wed, 07 July 2010 11:03 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
u have to parse each structure and accordingly u have to create the figure...

u have write the logic,try it out....

mean while i will try to impliment structure for
"hello\nworld |{ b |{c|<here> d|e}| f}| g | h"
and will post the code in one or two days...(if i am able to)

but after that there will be many hurdels to completly implement records u have to manage that...


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Creating Graphviz "Record" shape in Draw2D [message #545363 is a reply to message #545280] Wed, 07 July 2010 14:18 Go to previous messageGo to next message
Namratha  is currently offline Namratha
Messages: 6
Registered: July 2010
Junior Member
Hi,

Actually i am new to this draw2d and GEF, so I don't know how to define these structures for Draw2d.
So it would be nice if you could explain me how could structures for Draw2d be defined. Or any example you have for it?

Re: Creating Graphviz "Record" shape in Draw2D [message #545447 is a reply to message #545363] Wed, 07 July 2010 19:34 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
you have to extend shapes class and draw each compartments according to the specified script....

how did u manage to do box3d, component, Mcircle,note, tab folder etc..

if you could manage these then u should be able to do this also..


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Creating Graphviz "Record" shape in Draw2D [message #545532 is a reply to message #545447] Thu, 08 July 2010 07:56 Go to previous messageGo to next message
Namratha  is currently offline Namratha
Messages: 6
Registered: July 2010
Junior Member
Hi,

I din't implement everything in the polygon shapes of graphviz. Only a few of them like trapezium, inverted trapezium and note were required for my work, along with the record structure.

If u want i could post the code for note shape in draw2d. But i have created it by extending the Figure class.

I am using Draw2d with the GEF view.
Just could you tell me what is the difference in extending the Figure class and the Shape class.

Re: Creating Graphviz "Record" shape in Draw2D [message #545579 is a reply to message #545532] Thu, 08 July 2010 10:14 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
Not much but Shapes is much more generic way to create shapes,

u have to just override fillShape and outlineShape and implement it.

u can see RectangularFigure and Ellipse for specifics...

for example
package org.eclipse.gef.examples.flow;

import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
 * A test class to display a UMLFigure
 */
public class StructureShape
{
    public static void main(String args[])
    {
        Display d = new Display();
        final Shell shell = new Shell(d);
        shell.setSize(400, 400);
        shell.setText("UMLClassFigure Test");
        LightweightSystem lws = new LightweightSystem(shell);
        Figure contents = new Figure();
        XYLayout contentsLayout = new XYLayout();
        contents.setLayoutManager(contentsLayout);

        Structure c = new Structure();
        c.setBounds(new Rectangle(50, 50, 200, 100));
        contents.add(c);

        lws.setContents(contents);
        shell.open();
        while (!shell.isDisposed())
            while (!d.readAndDispatch())
                d.sleep();
    }

    public static class Structure extends Shape
    {

        @Override
        protected void fillShape(Graphics graphics)
        {
            graphics.fillRectangle(bounds.getCopy().crop(new Insets(1, 1, 1, 1)));

        }

        @Override
        protected void outlineShape(Graphics graphics)
        {
            Rectangle copy = bounds.getCopy();
            copy = copy.crop(new Insets(1, 1, 1, 1));
            graphics.drawRectangle(copy);
            graphics.drawLine(copy.x + copy.width / 3, copy.y, copy.x + bounds.width / 3, copy.y
                    + copy.height);
            graphics.drawLine(copy.x + copy.width * 2 / 3, copy.y, copy.x + copy.width * 2 / 3,
                    copy.y + copy.height);
            graphics.drawLine(copy.x + copy.width / 3, copy.y + copy.height / 3, copy.x
                    + bounds.width * 2 / 3, copy.y + copy.height / 3);
            graphics.drawLine(copy.x + copy.width / 3, copy.y + copy.height * 2 / 3, copy.x
                    + bounds.width * 2 / 3, copy.y + copy.height * 2 / 3);

        }

    }
}


here the fraction which are multiplied will be decided by the structure script.

and how many times also will be decided by the script.


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Creating Graphviz "Record" shape in Draw2D [message #545628 is a reply to message #545579] Thu, 08 July 2010 13:23 Go to previous messageGo to next message
Namratha  is currently offline Namratha
Messages: 6
Registered: July 2010
Junior Member
how do i run the code example you have given? Eclipse IDE gives error for the functions crop and setBounds.

Is there any particular version of Draw2d or Eclipse that must be used for running the code above?
Re: Creating Graphviz "Record" shape in Draw2D [message #545655 is a reply to message #545579] Thu, 08 July 2010 14:09 Go to previous messageGo to next message
Namratha  is currently offline Namratha
Messages: 6
Registered: July 2010
Junior Member
And also i dint understand the following statement:
"here the fraction which are multiplied will be decided by the structure script.

and how many times also will be decided by the script."

What is the script here?
Re: Creating Graphviz "Record" shape in Draw2D [message #545776 is a reply to message #545655] Fri, 09 July 2010 05:20 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
The version of draw2d was 3.6 here,

u can remove the crop methods and do the crop manually,


The script is
digraph structs {
node [shape=record];
struct1 [label="<f0> left|<f1> mid\ dle|<f2> right"];
struct2 [label="<f0> one|<f1> two"];
struct3 [label="hello\nworld |{ b |{c|<here> d|e}| f}| g | h"];
struct1:f1 -> struct2:f0;
struct1:f2 -> struct3:here;
}

in purticular
struct3 [label="hello\nworld |{ b |{c|<here> d|e}| f}| g | h"];

which decides how many columns(sub columns) and rows(sub rows)

but as i told u
Quote:
but after that there will be many hurdels to completly implement records u have to manage that...

even if i want to help i will not be able to cuz there are many things to take care of...i can not dectate them from here...


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Creating Graphviz "Record" shape in Draw2D [message #545844 is a reply to message #545776] Fri, 09 July 2010 11:52 Go to previous message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
But still i am here for any major problems Smile

---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Previous Topic:distribute freehand drawing extension for GEF
Next Topic:Problem using GEF,ZEST GraphViewer in RCP views
Goto Forum:
  


Current Time: Wed Sep 03 04:43:33 GMT 2014

Powered by FUDForum. Page generated in 0.02109 seconds