Skip to main content



      Home
Home » Eclipse Projects » GEF » How to find the bound of the parent Figure
How to find the bound of the parent Figure [message #24318] Sun, 06 October 2002 15:54 Go to next message
Eclipse UserFriend
I have a Figure class which extends the Shape class, it needs to draw a
straight hort. line across its container (parent). First it needs to figure
out how wide is it parent, and then it the paint() method, it just draw a
hort line.

My question is how can a Figure find out its container's class? I call
getParentingFigure() method but it returns null.
And I try to call the getParent() method in its EditPart, it returns null
also.

Any help is appreciated.
Re: How to find the bound of the parent Figure [message #24685 is a reply to message #24318] Sun, 06 October 2002 21:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

A child figure can only paint within its own bounds. This is unsured by
clipping the Graphics to that region. What are you trying to do? Create a
"separator"?

"Hal" <otaconss2@hotmail.com> wrote in message
news:anq32r$nu6$1@rogue.oti.com...
> I have a Figure class which extends the Shape class, it needs to draw a
> straight hort. line across its container (parent). First it needs to
figure
> out how wide is it parent, and then it the paint() method, it just draw a
> hort line.
>
> My question is how can a Figure find out its container's class? I call
> getParentingFigure() method but it returns null.
> And I try to call the getParent() method in its EditPart, it returns null
> also.
>
> Any help is appreciated.
>
>
>
>
Re: How to find the bound of the parent Figure [message #24869 is a reply to message #24685] Mon, 07 October 2002 10:26 Go to previous messageGo to next message
Eclipse UserFriend
Yes. Is there something like that in GEF already? Or I need to do it myself
like I said? But if a child figure can only paint within its own bounds, I
need to find out how LONG it should draw, (in other words, the width of it
parent) right?

Thanks for your help.

"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:anql3r$u2h$1@rogue.oti.com...
> A child figure can only paint within its own bounds. This is unsured by
> clipping the Graphics to that region. What are you trying to do? Create
a
> "separator"?
>
> "Hal" <otaconss2@hotmail.com> wrote in message
> news:anq32r$nu6$1@rogue.oti.com...
> > I have a Figure class which extends the Shape class, it needs to draw a
> > straight hort. line across its container (parent). First it needs to
> figure
> > out how wide is it parent, and then it the paint() method, it just draw
a
> > hort line.
> >
> > My question is how can a Figure find out its container's class? I call
> > getParentingFigure() method but it returns null.
> > And I try to call the getParent() method in its EditPart, it returns
null
> > also.
> >
> > Any help is appreciated.
> >
> >
> >
> >
>
>
Re: How to find the bound of the parent Figure [message #25202 is a reply to message #24869] Mon, 07 October 2002 19:23 Go to previous messageGo to next message
Eclipse UserFriend
Thanks. In my SeparatorFigure class, I get the width of it parents by
calling the getBounds() method, but
it always gives me r.width= 64 and r.height=36 and these values are wrong. I
set the parent's size to be width = 100, and height = 100.
It stays the same evern if I manually resize the parent.
Could you please tell me how to draw the separator to the parent figure?
Thanks for you help.
------------------------------------------------------------ ----------------
------------------------------------------------------------ ----------------
--------------------------
protected void fillShape(Graphics graphics) {
Rectangle r = new Rectangle(getBounds());
System.out.println ("r.width" + r.width + "r.height" + r.height);
}

"Hal" <otaconss2@hotmail.com> wrote in message
news:ans470$ljq$1@rogue.oti.com...
> Yes. Is there something like that in GEF already? Or I need to do it
myself
> like I said? But if a child figure can only paint within its own bounds, I
> need to find out how LONG it should draw, (in other words, the width of it
> parent) right?
>
> Thanks for your help.
>
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> news:anql3r$u2h$1@rogue.oti.com...
> > A child figure can only paint within its own bounds. This is unsured by
> > clipping the Graphics to that region. What are you trying to do?
Create
> a
> > "separator"?
> >
> > "Hal" <otaconss2@hotmail.com> wrote in message
> > news:anq32r$nu6$1@rogue.oti.com...
> > > I have a Figure class which extends the Shape class, it needs to draw
a
> > > straight hort. line across its container (parent). First it needs to
> > figure
> > > out how wide is it parent, and then it the paint() method, it just
draw
> a
> > > hort line.
> > >
> > > My question is how can a Figure find out its container's class? I call
> > > getParentingFigure() method but it returns null.
> > > And I try to call the getParent() method in its EditPart, it returns
> null
> > > also.
> > >
> > > Any help is appreciated.
> > >
> > >
> > >
> > >
> >
> >
>
>
Re: How to find the bound of the parent Figure [message #25284 is a reply to message #24869] Mon, 07 October 2002 21:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

> Yes. Is there something like that in GEF already? Or I need to do it
myself
> like I said? But if a child figure can only paint within its own bounds, I
> need to find out how LONG it should draw, (in other words, the width of it
> parent) right?
>
You can just use a regular Figure. Here is an example:

import org.eclipse.draw2d.*;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class SeparatorExample {

public static void main(String[] args) {
Display d = new Display();
Shell shell = new Shell(d);
shell.setText("Separator example");
shell.setLayout(new FillLayout());
FigureCanvas canvas = new FigureCanvas(shell);

Figure umlType = new Figure();
ToolbarLayout layout = new ToolbarLayout();
layout.setSpacing(3);
//method below was recently renamed from setMatchWidth()
layout.setStretchMinorAxis(true);
umlType.setLayoutManager(layout);

Label typeName = new Label("Image");
umlType.add(typeName);

Figure separator = new Figure();
separator.setPreferredSize(1,1);
separator.setBackgroundColor(ColorConstants.black);
separator.setOpaque(true);
umlType.add(separator);

Label attrName = new Label(" + handle : int");
attrName.setLabelAlignment(Label.LEFT);
umlType.add(attrName);

Label attrPal = new Label(" + palette : PaletteData");
attrPal.setLabelAlignment(Label.LEFT);
umlType.add(attrPal);

canvas.setContents(umlType);

shell.setSize(300,260);
shell.open();
while (!shell.isDisposed())
while (!d.readAndDispatch())
d.sleep();
}

}
Re: How to find the bound of the parent Figure [message #26570 is a reply to message #25284] Wed, 09 October 2002 10:57 Go to previous messageGo to next message
Eclipse UserFriend
Randy,

Thanks for the example. But how I apply that to Logic Editor Example?
Each figure is create by the EditPart (e.g. CircuitEditPart creates
CircuitFigure, AndGateEditPart creates AndGateFigure).

And the parentFigure does not explicitly add its childFigure
(CircuitEditPart never adds AndFigure, it is just Circuit adds AndGate, and
in your example, you need add the childFigure (SeparateFigure) to the
parentFigure (umlType). So how can I apply your example to application using
MVC patterns (e.g. Logic Editor Example)

Thanks for your help again.


"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:anta0f$d5r$1@rogue.oti.com...
> > Yes. Is there something like that in GEF already? Or I need to do it
> myself
> > like I said? But if a child figure can only paint within its own bounds,
I
> > need to find out how LONG it should draw, (in other words, the width of
it
> > parent) right?
> >
> You can just use a regular Figure. Here is an example:
>
> import org.eclipse.draw2d.*;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> public class SeparatorExample {
>
> public static void main(String[] args) {
> Display d = new Display();
> Shell shell = new Shell(d);
> shell.setText("Separator example");
> shell.setLayout(new FillLayout());
> FigureCanvas canvas = new FigureCanvas(shell);
>
> Figure umlType = new Figure();
> ToolbarLayout layout = new ToolbarLayout();
> layout.setSpacing(3);
> //method below was recently renamed from setMatchWidth()
> layout.setStretchMinorAxis(true);
> umlType.setLayoutManager(layout);
>
> Label typeName = new Label("Image");
> umlType.add(typeName);
>
> Figure separator = new Figure();
> separator.setPreferredSize(1,1);
> separator.setBackgroundColor(ColorConstants.black);
> separator.setOpaque(true);
> umlType.add(separator);
>
> Label attrName = new Label(" + handle : int");
> attrName.setLabelAlignment(Label.LEFT);
> umlType.add(attrName);
>
> Label attrPal = new Label(" + palette : PaletteData");
> attrPal.setLabelAlignment(Label.LEFT);
> umlType.add(attrPal);
>
> canvas.setContents(umlType);
>
> shell.setSize(300,260);
> shell.open();
> while (!shell.isDisposed())
> while (!d.readAndDispatch())
> d.sleep();
> }
>
> }
>
>
>
Re: How to find the bound of the parent Figure [message #26734 is a reply to message #26570] Wed, 09 October 2002 15:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

> Randy,
>
> Thanks for the example. But how I apply that to Logic Editor Example?
> Each figure is create by the EditPart (e.g. CircuitEditPart creates
> CircuitFigure, AndGateEditPart creates AndGateFigure).
>
> And the parentFigure does not explicitly add its childFigure
> (CircuitEditPart never adds AndFigure, it is just Circuit adds AndGate,
and
> in your example, you need add the childFigure (SeparateFigure) to the
> parentFigure (umlType). So how can I apply your example to application
using
> MVC patterns (e.g. Logic Editor Example)
>
> Thanks for your help again.
>

What are you trying to do? Draw a separator between every child in a
container?

One way to do that is to make the entire container black, and the children
are all white or whatever color you want for the normal background. Then,
use some layout with a gap set to 1 or more pixels, so the black part is
exposed between children.

>
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> news:anta0f$d5r$1@rogue.oti.com...
> > > Yes. Is there something like that in GEF already? Or I need to do it
> > myself
> > > like I said? But if a child figure can only paint within its own
bounds,
> I
> > > need to find out how LONG it should draw, (in other words, the width
of
> it
> > > parent) right?
> > >
> > You can just use a regular Figure. Here is an example:
> >
> > import org.eclipse.draw2d.*;
> > import org.eclipse.swt.layout.FillLayout;
> > import org.eclipse.swt.widgets.Display;
> > import org.eclipse.swt.widgets.Shell;
> >
> > public class SeparatorExample {
> >
> > public static void main(String[] args) {
> > Display d = new Display();
> > Shell shell = new Shell(d);
> > shell.setText("Separator example");
> > shell.setLayout(new FillLayout());
> > FigureCanvas canvas = new FigureCanvas(shell);
> >
> > Figure umlType = new Figure();
> > ToolbarLayout layout = new ToolbarLayout();
> > layout.setSpacing(3);
> > //method below was recently renamed from setMatchWidth()
> > layout.setStretchMinorAxis(true);
> > umlType.setLayoutManager(layout);
> >
> > Label typeName = new Label("Image");
> > umlType.add(typeName);
> >
> > Figure separator = new Figure();
> > separator.setPreferredSize(1,1);
> > separator.setBackgroundColor(ColorConstants.black);
> > separator.setOpaque(true);
> > umlType.add(separator);
> >
> > Label attrName = new Label(" + handle : int");
> > attrName.setLabelAlignment(Label.LEFT);
> > umlType.add(attrName);
> >
> > Label attrPal = new Label(" + palette : PaletteData");
> > attrPal.setLabelAlignment(Label.LEFT);
> > umlType.add(attrPal);
> >
> > canvas.setContents(umlType);
> >
> > shell.setSize(300,260);
> > shell.open();
> > while (!shell.isDisposed())
> > while (!d.readAndDispatch())
> > d.sleep();
> > }
> >
> > }
> >
> >
> >
>
>
Re: How to find the bound of the parent Figure [message #26813 is a reply to message #26734] Wed, 09 October 2002 16:00 Go to previous messageGo to next message
Eclipse UserFriend
Randy,

I am trying to draw a Hortizontal line across each Circuit Figure in the
Logic Editor Example. When you resize Circuit Figure, the hortizontal line
will get either (longer/shorter) depending on the size of teh Circuit
Figure.

Thanks for your help again.


"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:ao1us1$7gu$1@rogue.oti.com...
> > Randy,
> >
> > Thanks for the example. But how I apply that to Logic Editor Example?
> > Each figure is create by the EditPart (e.g. CircuitEditPart creates
> > CircuitFigure, AndGateEditPart creates AndGateFigure).
> >
> > And the parentFigure does not explicitly add its childFigure
> > (CircuitEditPart never adds AndFigure, it is just Circuit adds AndGate,
> and
> > in your example, you need add the childFigure (SeparateFigure) to the
> > parentFigure (umlType). So how can I apply your example to application
> using
> > MVC patterns (e.g. Logic Editor Example)
> >
> > Thanks for your help again.
> >
>
> What are you trying to do? Draw a separator between every child in a
> container?
>
> One way to do that is to make the entire container black, and the children
> are all white or whatever color you want for the normal background. Then,
> use some layout with a gap set to 1 or more pixels, so the black part is
> exposed between children.
>
> >
> > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > news:anta0f$d5r$1@rogue.oti.com...
> > > > Yes. Is there something like that in GEF already? Or I need to do it
> > > myself
> > > > like I said? But if a child figure can only paint within its own
> bounds,
> > I
> > > > need to find out how LONG it should draw, (in other words, the width
> of
> > it
> > > > parent) right?
> > > >
> > > You can just use a regular Figure. Here is an example:
> > >
> > > import org.eclipse.draw2d.*;
> > > import org.eclipse.swt.layout.FillLayout;
> > > import org.eclipse.swt.widgets.Display;
> > > import org.eclipse.swt.widgets.Shell;
> > >
> > > public class SeparatorExample {
> > >
> > > public static void main(String[] args) {
> > > Display d = new Display();
> > > Shell shell = new Shell(d);
> > > shell.setText("Separator example");
> > > shell.setLayout(new FillLayout());
> > > FigureCanvas canvas = new FigureCanvas(shell);
> > >
> > > Figure umlType = new Figure();
> > > ToolbarLayout layout = new ToolbarLayout();
> > > layout.setSpacing(3);
> > > //method below was recently renamed from setMatchWidth()
> > > layout.setStretchMinorAxis(true);
> > > umlType.setLayoutManager(layout);
> > >
> > > Label typeName = new Label("Image");
> > > umlType.add(typeName);
> > >
> > > Figure separator = new Figure();
> > > separator.setPreferredSize(1,1);
> > > separator.setBackgroundColor(ColorConstants.black);
> > > separator.setOpaque(true);
> > > umlType.add(separator);
> > >
> > > Label attrName = new Label(" + handle : int");
> > > attrName.setLabelAlignment(Label.LEFT);
> > > umlType.add(attrName);
> > >
> > > Label attrPal = new Label(" + palette : PaletteData");
> > > attrPal.setLabelAlignment(Label.LEFT);
> > > umlType.add(attrPal);
> > >
> > > canvas.setContents(umlType);
> > >
> > > shell.setSize(300,260);
> > > shell.open();
> > > while (!shell.isDisposed())
> > > while (!d.readAndDispatch())
> > > d.sleep();
> > > }
> > >
> > > }
> > >
> > >
> > >
> >
> >
>
>
Re: How to find the bound of the parent Figure [message #27014 is a reply to message #26813] Wed, 09 October 2002 18:24 Go to previous message
Eclipse UserFriend
To be more specify, I wan to draw a Hortizontal line 5 pixels from the top
of the Circuit Figure and it always touches the left & right side of the
Circuit Figure.

Thanks for your help.

"Hal" <otaconss2@hotmail.com> wrote in message
news:ao20g9$8hr$1@rogue.oti.com...
> Randy,
>
> I am trying to draw a Hortizontal line across each Circuit Figure in the
> Logic Editor Example. When you resize Circuit Figure, the hortizontal line
> will get either (longer/shorter) depending on the size of teh Circuit
> Figure.
>
> Thanks for your help again.
>
>
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> news:ao1us1$7gu$1@rogue.oti.com...
> > > Randy,
> > >
> > > Thanks for the example. But how I apply that to Logic Editor Example?
> > > Each figure is create by the EditPart (e.g. CircuitEditPart creates
> > > CircuitFigure, AndGateEditPart creates AndGateFigure).
> > >
> > > And the parentFigure does not explicitly add its childFigure
> > > (CircuitEditPart never adds AndFigure, it is just Circuit adds
AndGate,
> > and
> > > in your example, you need add the childFigure (SeparateFigure) to the
> > > parentFigure (umlType). So how can I apply your example to application
> > using
> > > MVC patterns (e.g. Logic Editor Example)
> > >
> > > Thanks for your help again.
> > >
> >
> > What are you trying to do? Draw a separator between every child in a
> > container?
> >
> > One way to do that is to make the entire container black, and the
children
> > are all white or whatever color you want for the normal background.
Then,
> > use some layout with a gap set to 1 or more pixels, so the black part is
> > exposed between children.
> >
> > >
> > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > news:anta0f$d5r$1@rogue.oti.com...
> > > > > Yes. Is there something like that in GEF already? Or I need to do
it
> > > > myself
> > > > > like I said? But if a child figure can only paint within its own
> > bounds,
> > > I
> > > > > need to find out how LONG it should draw, (in other words, the
width
> > of
> > > it
> > > > > parent) right?
> > > > >
> > > > You can just use a regular Figure. Here is an example:
> > > >
> > > > import org.eclipse.draw2d.*;
> > > > import org.eclipse.swt.layout.FillLayout;
> > > > import org.eclipse.swt.widgets.Display;
> > > > import org.eclipse.swt.widgets.Shell;
> > > >
> > > > public class SeparatorExample {
> > > >
> > > > public static void main(String[] args) {
> > > > Display d = new Display();
> > > > Shell shell = new Shell(d);
> > > > shell.setText("Separator example");
> > > > shell.setLayout(new FillLayout());
> > > > FigureCanvas canvas = new FigureCanvas(shell);
> > > >
> > > > Figure umlType = new Figure();
> > > > ToolbarLayout layout = new ToolbarLayout();
> > > > layout.setSpacing(3);
> > > > //method below was recently renamed from setMatchWidth()
> > > > layout.setStretchMinorAxis(true);
> > > > umlType.setLayoutManager(layout);
> > > >
> > > > Label typeName = new Label("Image");
> > > > umlType.add(typeName);
> > > >
> > > > Figure separator = new Figure();
> > > > separator.setPreferredSize(1,1);
> > > > separator.setBackgroundColor(ColorConstants.black);
> > > > separator.setOpaque(true);
> > > > umlType.add(separator);
> > > >
> > > > Label attrName = new Label(" + handle : int");
> > > > attrName.setLabelAlignment(Label.LEFT);
> > > > umlType.add(attrName);
> > > >
> > > > Label attrPal = new Label(" + palette : PaletteData");
> > > > attrPal.setLabelAlignment(Label.LEFT);
> > > > umlType.add(attrPal);
> > > >
> > > > canvas.setContents(umlType);
> > > >
> > > > shell.setSize(300,260);
> > > > shell.open();
> > > > while (!shell.isDisposed())
> > > > while (!d.readAndDispatch())
> > > > d.sleep();
> > > > }
> > > >
> > > > }
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Previous Topic:ToolTip for Label figure
Next Topic:Mailing List or News Group
Goto Forum:
  


Current Time: Sun May 11 08:50:34 EDT 2025

Powered by FUDForum. Page generated in 0.04376 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top