[Zest/Draw2d] Custom figure button event [message #247248] |
Thu, 12 February 2009 07:43  |
Eclipse User |
|
|
|
Hello everybody,
I have a Zest graph to which a custom figure can be added. The simplest
graph looks like this:
--------------
| Step 2 | + | <- StepFigure extends IFigure
--------------
| Document | <- DocumentFigure extends IFigure
--------------
^
|
|
--------------
| Step 1 | + | <- StepFigure extends IFigure
--------------
<- DocumentFigures aren't displayed...
Via the plus button document figures can be added to the step figure.
This works perfectly - but only for the last step figure added to the
graph (in this case Step 2). A document figure can be added to any other
step figure (here Step 1) but it isn't displayed. I've tried calling
revalidate and repaint on the step figure in question but that didn't
help. Does anybody know what I'll have to do to force Step 1 to display
the document figures added?
Kind regards,
Bianca
|
|
|
|
|
Re: [Zest/Draw2d] Custom figure button event [message #247453 is a reply to message #247312] |
Fri, 20 February 2009 10:41   |
Eclipse User |
|
|
|
>> It is likely a layout issue.
I've had some more time to debug and found the following.
AbstractLayout#getPreferredSize returns the preferredSize of the figure
to which other figures can be added with no problem. So when I set the
preferredSize to null while debugging this code was run:
Thread [main] (Suspended (breakpoint at line 164 in ToolbarLayout))
ToolbarLayout.calculatePreferredSize(IFigure, int, int) line: 164
ToolbarLayout(AbstractLayout).getPreferredSize(IFigure, int, int) line: 96
ToolbarLayout(AbstractHintLayout).getPreferredSize(IFigure, int, int)
line: 87
StepContainerFigure(Figure).getPreferredSize(int, int) line: 735
FreeformLayout(XYLayout).layout(IFigure) line: 103
Figure$LayoutNotifier.layout(IFigure) line: 1812
ZestRootLayer(Figure).layout() line: 1029
ZestRootLayer(Figure).validate() line: 1739
ScalableFreeformLayeredPane(Figure).validate() line: 1741
FreeformViewport$FreeformViewportLayout.calculatePreferredSi ze(IFigure,
int, int) line: 28
FreeformViewport$FreeformViewportLayout(AbstractLayout).getP referredSize(IFigure,
int, int) line: 93
FreeformViewport$FreeformViewportLayout(AbstractHintLayout). getPreferredSize(IFigure,
int, int) line: 85
FreeformViewport(Figure).getPreferredSize(int, int) line: 735
ScrollPaneSolver.solve(Rectangle, Viewport, int, int, int, int) line: 75
Graph(FigureCanvas).layoutViewport() line: 297
FigureCanvas.access$4(FigureCanvas) line: 295
FigureCanvas$3.notifyValidating() line: 260
DeferredUpdateManager(UpdateManager).fireValidating() line: 123
DeferredUpdateManager.performValidation() line: 203
DeferredUpdateManager.performUpdate() line: 179
DeferredUpdateManager$UpdateRequest.run() line: 48
RunnableLock.run() line: 35
Synchronizer.runAsyncMessages(boolean) line: 133
Display.runAsyncMessages(boolean) line: 3800
Display.readAndDispatch() line: 3425
GraphTest.main(String[]) line: 85
The thing that differs now from the other figure that does resize when a
figure is added to it is this code. But I have no idea where that might
be triggered...
Thread [main] (Suspended (breakpoint at line 164 in ToolbarLayout))
ToolbarLayout.calculatePreferredSize(IFigure, int, int) line: 164
ToolbarLayout(AbstractLayout).getPreferredSize(IFigure, int, int) line: 96
ToolbarLayout(AbstractHintLayout).getPreferredSize(IFigure, int, int)
line: 87
StepContainerFigure(Figure).getPreferredSize(int, int) line: 735
FreeformLayout(XYLayout).layout(IFigure) line: 103
Figure$LayoutNotifier.layout(IFigure) line: 1812
ZestRootLayer(Figure).layout() line: 1029
ZestRootLayer(Figure).validate() line: 1739
ScalableFreeformLayeredPane(Figure).validate() line: 1741
FreeformViewport(Figure).validate() line: 1741
FreeformViewport(Viewport).validate() line: 363
LightweightSystem$RootFigure(Figure).validate() line: 1741
DeferredUpdateManager.performValidation() line: 207
DeferredUpdateManager.performUpdate() line: 179
DeferredUpdateManager$UpdateRequest.run() line: 48
RunnableLock.run() line: 35
Synchronizer.runAsyncMessages(boolean) line: 133
Display.runAsyncMessages(boolean) line: 3800
Display.readAndDispatch() line: 3425
GraphTest.main(String[]) line: 85
|
|
|
|
|
Re: Problem with custom figures when moving in the graph [message #248926 is a reply to message #248807] |
Tue, 12 May 2009 18:46  |
Eclipse User |
|
|
|
I found two solutions:
1) override the method getSize() of GraphNode and return a new
Dimension(-1,-1);
2) When you are collapsing/expanding, before call the algorithm, get the
node's figure and do:
Point loc = getLocation();
Dimension size = new Dimension(-1,-1);
Rectangle bounds = new Rectangle(loc, size);
fig.getParent().setConstraint(fig,bounds);
// Call the collapse/expand algorithm
:)
Tiago Proenca wrote:
> This move issue is happening with me also... Basically I have a custom
> figure that expand/collapse... It works well when I open my view and
> switch from expand to collapse and vice-versa. However, if I move some
> node the figure doesn't adjust the size. In other words, it stop to
> collapse.
>
> Any ideas about that?
>
> Tiago
>
> Bianca wrote:
>> > --------------
>> > | Step 2 | + | <- StepFigure extends IFigure
>> > --------------
>> > | Document | <- DocumentFigure extends IFigure
>> > --------------
>> > ^
>> > |
>> > |
>> > --------------
>> > | Step 1 | + | <- StepFigure extends IFigure
>> > --------------
>> > <- DocumentFigures aren't displayed...
>> >
>> > Via the plus button document figures can be added to the step figure.
>>
>>>>> It is likely a layout issue.
>>
>> As soon as a figure is moved it isn't repainted/resized when the
>> button is clicked. Do I need to call any special method or set a flag
>> so that the figure is repainted again?
|
|
|
Powered by
FUDForum. Page generated in 0.30337 seconds