Creating Graphviz "Record" shape in Draw2D [message #545088] |
Tue, 06 July 2010 11:16  |
Eclipse User |
|
|
|
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 #545579 is a reply to message #545532] |
Thu, 08 July 2010 06:14   |
Eclipse User |
|
|
|
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.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05184 seconds