Skip to main content



      Home
Home » Eclipse Projects » GEF » Draw2D does not work correct when I change the Label font size
Draw2D does not work correct when I change the Label font size [message #202389] Wed, 09 November 2005 08:40 Go to next message
Eclipse UserFriend
Originally posted by: cleversons.gmail.com

Hi,

I'm having some problems with draw2D. I'm drawing a graph structure made
of nodes. Each node is a box containing 5 labels in one column. The box is
a Figure object with its layout set to ToolbarLayout. As the node
structure is very simple, just boxes with labels inside, I've implemented
the zoom functionality by just changing the font size of the labels inside
the boxes. So, each time the zoom in or zoom out actions are pressed, I
first create a new Font object greather or smaller than the current on
depending on which zoom has been pressed and then I request the figures to
update throuhg a call to invalidateTree on the main layer.

The problem is that sometimes when the zoom in is requested, the labels
are drawn in a messy way, overlapping each other. Instead of being placed
in one separated row (as ToolbarLayout is supposed to work), just half of
each label is drawn leading to a cluttered figure.

Does any of you has ever experienced this problem before?

Thank you very much.

By the way, I'm using the 3.0.1 version

Best Regards

Cleverson Schmidt
Re: Draw2D does not work correct when I change the Label font size [message #202469 is a reply to message #202389] Wed, 09 November 2005 16:26 Go to previous messageGo to next message
Eclipse UserFriend
I just use the zoom functionality that comes with GEF (ZoomInRetargetAction
and ZoomOutRetargetAction). It's not perfect but it seems to work better
than what you describe...

"Cleverson Schmidt" <cleversons@gmail.com> wrote in message
news:6b663dfe3ed7f90cbbbe9a5450f41120$1@www.eclipse.org...
> Hi,
>
> I'm having some problems with draw2D. I'm drawing a graph structure made
> of nodes. Each node is a box containing 5 labels in one column. The box is
> a Figure object with its layout set to ToolbarLayout. As the node
> structure is very simple, just boxes with labels inside, I've implemented
> the zoom functionality by just changing the font size of the labels inside
> the boxes. So, each time the zoom in or zoom out actions are pressed, I
> first create a new Font object greather or smaller than the current on
> depending on which zoom has been pressed and then I request the figures to
> update throuhg a call to invalidateTree on the main layer.
>
> The problem is that sometimes when the zoom in is requested, the labels
> are drawn in a messy way, overlapping each other. Instead of being placed
> in one separated row (as ToolbarLayout is supposed to work), just half of
> each label is drawn leading to a cluttered figure.
>
> Does any of you has ever experienced this problem before?
>
> Thank you very much.
>
> By the way, I'm using the 3.0.1 version
>
> Best Regards
>
> Cleverson Schmidt
>
Re: Draw2D does not work correct when I change the Label font size [message #202485 is a reply to message #202469] Wed, 09 November 2005 17:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cleversons.gmail.com

Thanks for the answer.
I'm not using GEF on this project. It's plain Draw2D, this is why I didn't
use the framework's zoom functionality.
Re: Draw2D does not work correct when I change the Label font size [message #202508 is a reply to message #202485] Thu, 10 November 2005 08:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cleversons.gmail.com

Is there any known bug which could explain this problem on the version
3.0.1 of Draw2D?
Re: Draw2D does not work correct when I change the Label font size [message #202526 is a reply to message #202508] Thu, 10 November 2005 13:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Can you reproduce it in 3.1? If so, I doubt we know about the bug or it
could be a bug in your code.

Please provide us with a test case.

"Cleverson Schmidt" <cleversons@gmail.com> wrote in message
news:fb3e0fded3e2912ad8107d0a5b6d570d$1@www.eclipse.org...
> Is there any known bug which could explain this problem on the version
> 3.0.1 of Draw2D?
>
Re: Draw2D does not work correct when I change the Label font size [message #202596 is a reply to message #202526] Fri, 11 November 2005 08:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cleversons.gmail.com

Usually it's likely a bug in my code :)
But this time I don't know what can be wrong. I'm not handling the layout
myself. I just add the labels in my box figure and let the Toolbar layout
do the job. Afterwards, when the user presses zoom in or zoom out I just
change the label's font size and ask itself to refresh throug a
invalidateTree call in the main layer. I don't know how could I bug this
process.
Re: Draw2D does not work correct when I change the Label font size [message #202603 is a reply to message #202596] Fri, 11 November 2005 08:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cleversons.gmail.com

The source code:

private class BoxFigure extends Figure {

public BoxFigure () {
ToolbarLayout layout = new ToolbarLayout(false);
layout.setSpacing(2);
setLayoutManager(layout);
for (int i = 0; i < attributeNames.length; i++) {
add(new Label(attributeNames[i]);
}
setOpaque(true);
}

}

The method below is in the main layer. The layer which creates and adds
all box figures. When the zoom actions are pressed, the following method
is called.

public void applyZoom(int zoomLevel) {
// gets a new font with the new zoomLevel
this.currentFont = ResourceManager.getInstance().getFont("Arial",
zoomLevel, SWT.NORMAL);
Collection boxFigures = this.boxFigures.values();
Iterator boxFiguresIterator = boxFigures.iterator();
while (boxFiguresIterator.hasNext()) {
BoxFigure bFigure = (BoxFigure) boxFiguresIterator.next();
bFigure.setFont(this.currentFont);
}
invalidateTree();
}

If I press the zoom actions many times, the bug will take place.
Re: Draw2D does not work correct when I change the Label font size [message #202734 is a reply to message #202603] Fri, 11 November 2005 14:04 Go to previous message
Eclipse UserFriend
Originally posted by: cleversons.gmail.com

I've fixe the problem changing the way I do the zoom implementation.
Instead of just changing the label's font size, my application now sets
the scale of the root layer so that all the inner layer are scalled. I had
to change the anchor of the connections because they were not being
scaled. But now everything works good.

Thank you guys.
Previous Topic:FigureUtilities.getTextExtents
Next Topic:Help with polygons
Goto Forum:
  


Current Time: Tue May 20 07:03:02 EDT 2025

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

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

Back to the top