Skip to main content



      Home
Home » Eclipse Projects » GEF » adding a label to a subgraph
adding a label to a subgraph [message #97482] Mon, 06 October 2003 12:36 Go to next message
Eclipse UserFriend
Originally posted by: rpenner.cs.usask.ca

Hello, I am tring to add labels to a subgraph but am having some trouble.
I had this working in a previous version of Draw2d but it seems to have
broken when I upgraded to the latest version.

Basically all that I am doing is grabing the text from subgraphs data with:
String text = s.data.toString();

I then create a label adding "text" to the label and then I add the label
to the figure. In the pervious version my label was place in the top left
hand corner of the subgraph and all node that were drawn in the subgraph
were placed in such a maner that the label was not obstructed. Now
however, with the latest version of Draw2d the nodes are not being drawn
the same way. In some of my subgraphs my labels work ok but in others node
are being drawn over top of my label.

What might have changed in node placemnet, it there away that I can
control the node placement so as to have no obstructed labels being placed
on my subgraphs?

thanks ......... Reagan
Re: adding a label to a subgraph [message #97496 is a reply to message #97482] Mon, 06 October 2003 13:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Subgraph.insets was changed from a default value of 15 pixels on all 4
sides, to just 1 pixel. You need to set the subgraph's insets to reflect
the real space that you need on the top, bottom, left, and right for things
like labels. The reason that sometimes you have enough space is that there
is another "real" node on the same row whose height is larger. The top
boundary (and bottom) of a subgraph is essentially a fake node. All nodes
in a row have their heights stretched to be the MAX height for that row.

"Reagan Penner" <rpenner@cs.usask.ca> wrote in message
news:bls5m0$8q0$1@eclipse.org...
> Hello, I am tring to add labels to a subgraph but am having some trouble.
> I had this working in a previous version of Draw2d but it seems to have
> broken when I upgraded to the latest version.
>
> Basically all that I am doing is grabing the text from subgraphs data
with:
> String text = s.data.toString();
>
> I then create a label adding "text" to the label and then I add the label
> to the figure. In the pervious version my label was place in the top left
> hand corner of the subgraph and all node that were drawn in the subgraph
> were placed in such a maner that the label was not obstructed. Now
> however, with the latest version of Draw2d the nodes are not being drawn
> the same way. In some of my subgraphs my labels work ok but in others node
> are being drawn over top of my label.
>
> What might have changed in node placemnet, it there away that I can
> control the node placement so as to have no obstructed labels being placed
> on my subgraphs?
>
> thanks ......... Reagan
>
>
>
Re: adding a label to a subgraph [message #97971 is a reply to message #97496] Wed, 08 October 2003 18:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rpenner.cs.usask.ca

Hey Randy, thanks for the reply. The insets however do not seem to make a
difference. I can set them to 20 and greater and all they seem to affect
is the width of the border of the subgraph. My labels are still being
covered up by nodes/subgraphs.

.......... Reagan Penner

Randy Hudson wrote:

> Subgraph.insets was changed from a default value of 15 pixels on all 4
> sides, to just 1 pixel. You need to set the subgraph's insets to reflect
> the real space that you need on the top, bottom, left, and right for things
> like labels. The reason that sometimes you have enough space is that there
> is another "real" node on the same row whose height is larger. The top
> boundary (and bottom) of a subgraph is essentially a fake node. All nodes
> in a row have their heights stretched to be the MAX height for that row.

> "Reagan Penner" <rpenner@cs.usask.ca> wrote in message
> news:bls5m0$8q0$1@eclipse.org...
> > Hello, I am tring to add labels to a subgraph but am having some trouble.
> > I had this working in a previous version of Draw2d but it seems to have
> > broken when I upgraded to the latest version.
> >
> > Basically all that I am doing is grabing the text from subgraphs data
> with:
> > String text = s.data.toString();
> >
> > I then create a label adding "text" to the label and then I add the label
> > to the figure. In the pervious version my label was place in the top left
> > hand corner of the subgraph and all node that were drawn in the subgraph
> > were placed in such a maner that the label was not obstructed. Now
> > however, with the latest version of Draw2d the nodes are not being drawn
> > the same way. In some of my subgraphs my labels work ok but in others node
> > are being drawn over top of my label.
> >
> > What might have changed in node placemnet, it there away that I can
> > control the node placement so as to have no obstructed labels being placed
> > on my subgraphs?
> >
> > thanks ......... Reagan
> >
> >
> >
Re: adding a label to a subgraph [message #98001 is a reply to message #97971] Wed, 08 October 2003 20:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Sorry, but I don't know where you are adding labels and how you are placing
them. We place the labels in the locations of Subgraph.head. Check out the
class CompoundGraphTests in draw2d.examples project.

"Reagan Penner" <rpenner@cs.usask.ca> wrote in message
news:bm2255$sb7$1@eclipse.org...
> Hey Randy, thanks for the reply. The insets however do not seem to make a
> difference. I can set them to 20 and greater and all they seem to affect
> is the width of the border of the subgraph. My labels are still being
> covered up by nodes/subgraphs.
>
> ......... Reagan Penner
>
> Randy Hudson wrote:
>
> > Subgraph.insets was changed from a default value of 15 pixels on all 4
> > sides, to just 1 pixel. You need to set the subgraph's insets to
reflect
> > the real space that you need on the top, bottom, left, and right for
things
> > like labels. The reason that sometimes you have enough space is that
there
> > is another "real" node on the same row whose height is larger. The top
> > boundary (and bottom) of a subgraph is essentially a fake node. All
nodes
> > in a row have their heights stretched to be the MAX height for that row.
>
> > "Reagan Penner" <rpenner@cs.usask.ca> wrote in message
> > news:bls5m0$8q0$1@eclipse.org...
> > > Hello, I am tring to add labels to a subgraph but am having some
trouble.
> > > I had this working in a previous version of Draw2d but it seems to
have
> > > broken when I upgraded to the latest version.
> > >
> > > Basically all that I am doing is grabing the text from subgraphs data
> > with:
> > > String text = s.data.toString();
> > >
> > > I then create a label adding "text" to the label and then I add the
label
> > > to the figure. In the pervious version my label was place in the top
left
> > > hand corner of the subgraph and all node that were drawn in the
subgraph
> > > were placed in such a maner that the label was not obstructed. Now
> > > however, with the latest version of Draw2d the nodes are not being
drawn
> > > the same way. In some of my subgraphs my labels work ok but in others
node
> > > are being drawn over top of my label.
> > >
> > > What might have changed in node placemnet, it there away that I can
> > > control the node placement so as to have no obstructed labels being
placed
> > > on my subgraphs?
> > >
> > > thanks ......... Reagan
> > >
> > >
> > >
>
>
Re: adding a label to a subgraph [message #98148 is a reply to message #98001] Thu, 09 October 2003 19:06 Go to previous message
Eclipse UserFriend
Originally posted by: rpenner.cs.usask.ca

Hey Randy, I am trying to add a label to the upper left hand corner of all
my subgraphs. I have tried to set subgraph.insets, I have also tried to
set subgraph.innerpadding but niether of these have created more room for
my labels. What I mean by more room is that the nodes/subgraphs that are
also being drawn in this subgraph are crowding out my label. I hope this
makes sense.

I am including the code for the buildsubgraph method this is where I
create and add my labels to the figure. I am also including a screencap
that can be viewed at the following URL: http://hci.usask.ca/screencap.bmp

private static void buildSubgraphFigure(Figure contents, Subgraph s) {
Label label;
label = new Label();
label.setBackgroundColor(ColorConstants.white);
label.setOpaque(true);
label.setFont(contents.getFont());
label.setBorder(new LineBorder(0));

// from the original demo code
Figure figure = new Figure();
figure.setBorder(new LineBorder(ColorConstants.blue, s.insets.left));

String text = s.data.toString();
int length = text.length();
label.setText(text);
s.data = label;
double w = (double)label.getPreferredSize().width;
w = w * 1.3;
label.setSize((int) w + 5, label.getPreferredSize().height + 10);
figure.add(label);

contents.add(figure, new Rectangle(s.x, s.y, s.width, s.height));
}

thanks for your help ............ Reagan

Randy Hudson wrote:

> Sorry, but I don't know where you are adding labels and how you are placing
> them. We place the labels in the locations of Subgraph.head. Check out the
> class CompoundGraphTests in draw2d.examples project.

> "Reagan Penner" <rpenner@cs.usask.ca> wrote in message
> news:bm2255$sb7$1@eclipse.org...
> > Hey Randy, thanks for the reply. The insets however do not seem to make a
> > difference. I can set them to 20 and greater and all they seem to affect
> > is the width of the border of the subgraph. My labels are still being
> > covered up by nodes/subgraphs.
> >
> > ......... Reagan Penner
> >
> > Randy Hudson wrote:
> >
> > > Subgraph.insets was changed from a default value of 15 pixels on all 4
> > > sides, to just 1 pixel. You need to set the subgraph's insets to
> reflect
> > > the real space that you need on the top, bottom, left, and right for
> things
> > > like labels. The reason that sometimes you have enough space is that
> there
> > > is another "real" node on the same row whose height is larger. The top
> > > boundary (and bottom) of a subgraph is essentially a fake node. All
> nodes
> > > in a row have their heights stretched to be the MAX height for that row.
> >
> > > "Reagan Penner" <rpenner@cs.usask.ca> wrote in message
> > > news:bls5m0$8q0$1@eclipse.org...
> > > > Hello, I am tring to add labels to a subgraph but am having some
> trouble.
> > > > I had this working in a previous version of Draw2d but it seems to
> have
> > > > broken when I upgraded to the latest version.
> > > >
> > > > Basically all that I am doing is grabing the text from subgraphs data
> > > with:
> > > > String text = s.data.toString();
> > > >
> > > > I then create a label adding "text" to the label and then I add the
> label
> > > > to the figure. In the pervious version my label was place in the top
> left
> > > > hand corner of the subgraph and all node that were drawn in the
> subgraph
> > > > were placed in such a maner that the label was not obstructed. Now
> > > > however, with the latest version of Draw2d the nodes are not being
> drawn
> > > > the same way. In some of my subgraphs my labels work ok but in others
> node
> > > > are being drawn over top of my label.
> > > >
> > > > What might have changed in node placemnet, it there away that I can
> > > > control the node placement so as to have no obstructed labels being
> placed
> > > > on my subgraphs?
> > > >
> > > > thanks ......... Reagan
> > > >
> > > >
> > > >
> >
> >
Previous Topic:Viewer finds EditParts?
Next Topic:how do I layout the graph from left to right
Goto Forum:
  


Current Time: Fri Jul 25 11:05:22 EDT 2025

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

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

Back to the top