Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Draw2d and modifying default Canvas scrolling
Draw2d and modifying default Canvas scrolling [message #186732] Wed, 06 July 2005 21:54 Go to next message
Brad Reynolds is currently offline Brad ReynoldsFriend
Messages: 309
Registered: July 2009
Senior Member
I am creating a Table and utilizing a Canvas, not a ScrollPane, to
handle scrolling. This scrolls all content, header and all. What would
be the correct way to modify the scrolling behavior to allow for my
header to stay in place when scrolling occurs? I still don't have my
head around the whole process and if someone could point me in the right
direction I'd appreciate it.

Thanks,
Brad
Re: Draw2d and modifying default Canvas scrolling [message #186741 is a reply to message #186732] Thu, 07 July 2005 02:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Use a FigureCanvas with a viewport. The Viewport's border does not scroll.
You could use the border. Or, you could create a viewport which support more
than a single child. But this would be tricky because of coordinate
systems. An easy way might be to create a viewport which wrappers a default
viewport. The wrapper would override layout and place a header figure and
the real viewport.

"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
news:dahjtr$mc0$1@news.eclipse.org...
>I am creating a Table and utilizing a Canvas, not a ScrollPane, to handle
>scrolling. This scrolls all content, header and all. What would be the
>correct way to modify the scrolling behavior to allow for my header to stay
>in place when scrolling occurs? I still don't have my head around the
>whole process and if someone could point me in the right direction I'd
>appreciate it.
>
> Thanks,
> Brad
Re: Draw2d and modifying default Canvas scrolling [message #186826 is a reply to message #186741] Thu, 07 July 2005 05:16 Go to previous messageGo to next message
Dazhen Gao is currently offline Dazhen GaoFriend
Messages: 21
Registered: July 2009
Junior Member
If you use the border draw the header, It is difficulty to catch the mouse
event.

I think you should create two composite. the example see the logic ruler.

"Randy Hudson" <none@us.ibm.com> wrote in message
news:dai2h9$2q1$1@news.eclipse.org...
> Use a FigureCanvas with a viewport. The Viewport's border does not
> scroll. You could use the border. Or, you could create a viewport which
> support more than a single child. But this would be tricky because of
> coordinate systems. An easy way might be to create a viewport which
> wrappers a default viewport. The wrapper would override layout and place
> a header figure and the real viewport.
>
> "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
> news:dahjtr$mc0$1@news.eclipse.org...
>>I am creating a Table and utilizing a Canvas, not a ScrollPane, to handle
>>scrolling. This scrolls all content, header and all. What would be the
>>correct way to modify the scrolling behavior to allow for my header to
>>stay in place when scrolling occurs? I still don't have my head around
>>the whole process and if someone could point me in the right direction I'd
>>appreciate it.
>>
>> Thanks,
>> Brad
>
>
Re: Draw2d and modifying default Canvas scrolling [message #186920 is a reply to message #186741] Thu, 07 July 2005 15:18 Go to previous messageGo to next message
Brad Reynolds is currently offline Brad ReynoldsFriend
Messages: 309
Registered: July 2009
Senior Member
Thanks for the response. I hadn't thought of using the border, I'll try
that. The thing that might make this even more difficult is that I have
to also allow for the locking of a column. So if I have a Table that
has 20 columns and I horizontally scroll the Table the first column (or
whatever column is designated as the lock column) will stay in place and
all columns to the right will horizontally scroll header and all. I'm
assuming this will complicate things even more. But I'll mess around
with your suggestions and see if I can come up with something. If you
have any words of wisdom on that front I'm all ears.

Thanks,
Brad

Randy Hudson wrote:
> Use a FigureCanvas with a viewport. The Viewport's border does not scroll.
> You could use the border. Or, you could create a viewport which support more
> than a single child. But this would be tricky because of coordinate
> systems. An easy way might be to create a viewport which wrappers a default
> viewport. The wrapper would override layout and place a header figure and
> the real viewport.
>
> "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
> news:dahjtr$mc0$1@news.eclipse.org...
>
>>I am creating a Table and utilizing a Canvas, not a ScrollPane, to handle
>>scrolling. This scrolls all content, header and all. What would be the
>>correct way to modify the scrolling behavior to allow for my header to stay
>>in place when scrolling occurs? I still don't have my head around the
>>whole process and if someone could point me in the right direction I'd
>>appreciate it.
>>
>>Thanks,
>>Brad
>
>
>
Re: Draw2d and modifying default Canvas scrolling [message #186928 is a reply to message #186826] Thu, 07 July 2005 15:20 Go to previous messageGo to next message
Brad Reynolds is currently offline Brad ReynoldsFriend
Messages: 309
Registered: July 2009
Senior Member
Can you elaborate on what I might run into for mouse events? Is it just
that it's because my header is in the border or is it that mouse events
overall are difficult to handle in draw2d?

gao wrote:
> If you use the border draw the header, It is difficulty to catch the mouse
> event.
>
> I think you should create two composite. the example see the logic ruler.
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:dai2h9$2q1$1@news.eclipse.org...
>
>>Use a FigureCanvas with a viewport. The Viewport's border does not
>>scroll. You could use the border. Or, you could create a viewport which
>>support more than a single child. But this would be tricky because of
>>coordinate systems. An easy way might be to create a viewport which
>>wrappers a default viewport. The wrapper would override layout and place
>>a header figure and the real viewport.
>>
>>"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
>>news:dahjtr$mc0$1@news.eclipse.org...
>>
>>>I am creating a Table and utilizing a Canvas, not a ScrollPane, to handle
>>>scrolling. This scrolls all content, header and all. What would be the
>>>correct way to modify the scrolling behavior to allow for my header to
>>>stay in place when scrolling occurs? I still don't have my head around
>>>the whole process and if someone could point me in the right direction I'd
>>>appreciate it.
>>>
>>>Thanks,
>>>Brad
>>
>>
>
>
Re: Draw2d and modifying default Canvas scrolling [message #187003 is a reply to message #186928] Fri, 08 July 2005 01:54 Go to previous messageGo to next message
Dazhen Gao is currently offline Dazhen GaoFriend
Messages: 21
Registered: July 2009
Junior Member
ok, if you use border to draw the column header , if user want to resize the
column with mouse, how to implement.


I think aother way to implement this table:
you can use layout manager like borderlayout. and fit the column header
to the top(fit the row header to the left),and center fit the viewport.

my idea<S> .


"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
news:dajh88$otq$2@news.eclipse.org...
> Can you elaborate on what I might run into for mouse events? Is it just
> that it's because my header is in the border or is it that mouse events
> overall are difficult to handle in draw2d?
>
> gao wrote:
>> If you use the border draw the header, It is difficulty to catch the
>> mouse event.
>>
>> I think you should create two composite. the example see the logic ruler.
>>
>> "Randy Hudson" <none@us.ibm.com> wrote in message
>> news:dai2h9$2q1$1@news.eclipse.org...
>>
>>>Use a FigureCanvas with a viewport. The Viewport's border does not
>>>scroll. You could use the border. Or, you could create a viewport which
>>>support more than a single child. But this would be tricky because of
>>>coordinate systems. An easy way might be to create a viewport which
>>>wrappers a default viewport. The wrapper would override layout and place
>>>a header figure and the real viewport.
>>>
>>>"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
>>>news:dahjtr$mc0$1@news.eclipse.org...
>>>
>>>>I am creating a Table and utilizing a Canvas, not a ScrollPane, to
>>>>handle scrolling. This scrolls all content, header and all. What would
>>>>be the correct way to modify the scrolling behavior to allow for my
>>>>header to stay in place when scrolling occurs? I still don't have my
>>>>head around the whole process and if someone could point me in the right
>>>>direction I'd appreciate it.
>>>>
>>>>Thanks,
>>>>Brad
>>>
>>>
>>
Re: Draw2d and modifying default Canvas scrolling [message #187084 is a reply to message #187003] Fri, 08 July 2005 12:42 Go to previous messageGo to next message
Brad Reynolds is currently offline Brad ReynoldsFriend
Messages: 309
Registered: July 2009
Senior Member
The reason I asked about mouse events is that I haven't done anything in
draw2d before attempting this so I haven't yet dealt with mouse
events. If I can't receive them when setting something as the border
it's news to me so thank you for that information.

I'll give border layout a shot but my question is how will this behave
when scrolling? This has been my biggest hangup so far with trying to
implement this using draw2d. It seems like whenever scrolling it's
wanting to scroll all figures on the Canvas and not just certain
children. I'm wanting to stick with the native scroll bars so that I
get the native bitblitting and well. I currently have it implemented
with multiple canvases and when scrolling I sync up the 2 canvases.
It's working so far with a header and body. I still need to attempt to
implement a third canvas for the locked columns. I might take a look at
the GEF table to see how this was implemented.

gao wrote:
> ok, if you use border to draw the column header , if user want to resize the
> column with mouse, how to implement.
>
>
> I think aother way to implement this table:
> you can use layout manager like borderlayout. and fit the column header
> to the top(fit the row header to the left),and center fit the viewport.
>
> my idea<S> .
>
>
> "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
> news:dajh88$otq$2@news.eclipse.org...
>
>>Can you elaborate on what I might run into for mouse events? Is it just
>>that it's because my header is in the border or is it that mouse events
>>overall are difficult to handle in draw2d?
>>
>>gao wrote:
>>
>>>If you use the border draw the header, It is difficulty to catch the
>>>mouse event.
>>>
>>>I think you should create two composite. the example see the logic ruler.
>>>
>>>"Randy Hudson" <none@us.ibm.com> wrote in message
>>>news:dai2h9$2q1$1@news.eclipse.org...
>>>
>>>
>>>>Use a FigureCanvas with a viewport. The Viewport's border does not
>>>>scroll. You could use the border. Or, you could create a viewport which
>>>>support more than a single child. But this would be tricky because of
>>>>coordinate systems. An easy way might be to create a viewport which
>>>>wrappers a default viewport. The wrapper would override layout and place
>>>>a header figure and the real viewport.
>>>>
>>>>"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
>>>>news:dahjtr$mc0$1@news.eclipse.org...
>>>>
>>>>
>>>>>I am creating a Table and utilizing a Canvas, not a ScrollPane, to
>>>>>handle scrolling. This scrolls all content, header and all. What would
>>>>>be the correct way to modify the scrolling behavior to allow for my
>>>>>header to stay in place when scrolling occurs? I still don't have my
>>>>>head around the whole process and if someone could point me in the right
>>>>>direction I'd appreciate it.
>>>>>
>>>>>Thanks,
>>>>>Brad
>>>>
>>>>
>
Re: Draw2d and modifying default Canvas scrolling [message #187126 is a reply to message #187084] Fri, 08 July 2005 15:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

The figure owning the border would definitely receive the mouse events.
Re: Draw2d and modifying default Canvas scrolling [message #187176 is a reply to message #187126] Fri, 08 July 2005 17:50 Go to previous messageGo to next message
Brad Reynolds is currently offline Brad ReynoldsFriend
Messages: 309
Registered: July 2009
Senior Member
Thanks Randy. I'm going to try your suggestions with the Veiwport as
well. I'll post my findings.

Randy Hudson wrote:
> The figure owning the border would definitely receive the mouse events.
>
>
Re: Draw2d and modifying default Canvas scrolling [message #187206 is a reply to message #187176] Fri, 08 July 2005 20:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

For a fixed column, you may consider using multiple viewports, or even
multiple Canvases with linked RangeModels to sync the scrolling.

"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
news:42CEBCD1.7000100@gmail.com...
> Thanks Randy. I'm going to try your suggestions with the Veiwport as
> well. I'll post my findings.
>
> Randy Hudson wrote:
>> The figure owning the border would definitely receive the mouse events.
Re: Draw2d and modifying default Canvas scrolling [message #187296 is a reply to message #187206] Mon, 11 July 2005 20:00 Go to previous messageGo to next message
Brad Reynolds is currently offline Brad ReynoldsFriend
Messages: 309
Registered: July 2009
Senior Member
I tried using multiple canvases and wasn't happy with the results. For
one on OS X this creates space between the two canvases for some reason.
I think you responded to this inquiry previously but I haven't dug
into why this is exactly happening. Also with two canvases it displayed
a behavior where it looke like the header canvas was always lagging
behind the body canvas. It worked when everything was said and done but
it felt a little odd like it was playing catch up. I think this is
because since it was 2 separate canvases it was 2 different paint
events. So there appeared to be a lag in the update. It worked but
wasn't ideal and was hoping to avoid it if possible. The other
interesting thing I saw was that on OS X with 2 canvases the second
header wouldn't update until mouse up of the scrollbar on the body
canvas. This was something I wanted to dig into to see if I had an
error in my code or if it was maybe a SWT thing. I haven't gotten back
to that so I can't confirm it.

What about using LayeredPanes? Would there be any reason not to use
them? I'll look into multiple viewports as well, thanks for the suggestion.

Randy Hudson wrote:
> For a fixed column, you may consider using multiple viewports, or even
> multiple Canvases with linked RangeModels to sync the scrolling.
>
> "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
> news:42CEBCD1.7000100@gmail.com...
>
>>Thanks Randy. I'm going to try your suggestions with the Veiwport as
>>well. I'll post my findings.
>>
>>Randy Hudson wrote:
>>
>>>The figure owning the border would definitely receive the mouse events.
>
>
>
Re: Draw2d and modifying default Canvas scrolling [message #187304 is a reply to message #187296] Mon, 11 July 2005 21:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
news:42D2CFF9.90708@gmail.com...
> I tried using multiple canvases and wasn't happy with the results. For
> one on OS X this creates space between the two canvases for some reason.
> I think you responded to this inquiry previously but I haven't dug
> into why this is exactly happening. Also with two canvases it displayed
> a behavior where it looke like the header canvas was always lagging
> behind the body canvas. It worked when everything was said and done but
> it felt a little odd like it was playing catch up. I think this is
> because since it was 2 separate canvases it was 2 different paint
> events. So there appeared to be a lag in the update. It worked but
> wasn't ideal and was hoping to avoid it if possible. The other
> interesting thing I saw was that on OS X with 2 canvases the second
> header wouldn't update until mouse up of the scrollbar on the body
> canvas. This was something I wanted to dig into to see if I had an
> error in my code or if it was maybe a SWT thing. I haven't gotten back
> to that so I can't confirm it.

You can force the updates on the second canvas to happen immediately. This
is what we do for the rulers (the rulers are in separate canvasses). But
this works well only on windows. You'll still see some lagging on other
platforms.

>
> What about using LayeredPanes? Would there be any reason not to use
> them? I'll look into multiple viewports as well, thanks for the
suggestion.
>
> Randy Hudson wrote:
> > For a fixed column, you may consider using multiple viewports, or even
> > multiple Canvases with linked RangeModels to sync the scrolling.
> >
> > "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
> > news:42CEBCD1.7000100@gmail.com...
> >
> >>Thanks Randy. I'm going to try your suggestions with the Veiwport as
> >>well. I'll post my findings.
> >>
> >>Randy Hudson wrote:
> >>
> >>>The figure owning the border would definitely receive the mouse events.
> >
> >
> >
Re: Draw2d and modifying default Canvas scrolling [message #187329 is a reply to message #187296] Mon, 11 July 2005 21:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

> wasn't ideal and was hoping to avoid it if possible. The other
> interesting thing I saw was that on OS X with 2 canvases the second header
> wouldn't update until mouse up of the scrollbar on the body canvas. This
> was something I wanted to dig into to see if I had an error in my code or
> if it was maybe a SWT thing. I haven't gotten back to that so I can't
> confirm it.

Which version of Mac OSX? We have a general problem that ascynExec(runnable)
does not get run while the mouse button is down. But, if you pause the
mouse it usually runs. Scrollbar dragging could be worse than just mouse
dragging on the canvas.
Re: Draw2d and modifying default Canvas scrolling [message #187343 is a reply to message #187329] Mon, 11 July 2005 22:11 Go to previous messageGo to next message
Brad Reynolds is currently offline Brad ReynoldsFriend
Messages: 309
Registered: July 2009
Senior Member
It was 10.3. What do you mean when you say "pause the mouse"?

Randy Hudson wrote:
>>wasn't ideal and was hoping to avoid it if possible. The other
>>interesting thing I saw was that on OS X with 2 canvases the second header
>>wouldn't update until mouse up of the scrollbar on the body canvas. This
>>was something I wanted to dig into to see if I had an error in my code or
>>if it was maybe a SWT thing. I haven't gotten back to that so I can't
>>confirm it.
>
>
> Which version of Mac OSX? We have a general problem that ascynExec(runnable)
> does not get run while the mouse button is down. But, if you pause the
> mouse it usually runs. Scrollbar dragging could be worse than just mouse
> dragging on the canvas.
>
>
Re: Draw2d and modifying default Canvas scrolling [message #187350 is a reply to message #187343] Mon, 11 July 2005 22:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Stop dragging but with the button still pressed.
"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
news:dauqqk$a1i$1@news.eclipse.org...
> It was 10.3. What do you mean when you say "pause the mouse"?
>
> Randy Hudson wrote:
>>>wasn't ideal and was hoping to avoid it if possible. The other
>>>interesting thing I saw was that on OS X with 2 canvases the second
>>>header wouldn't update until mouse up of the scrollbar on the body
>>>canvas. This was something I wanted to dig into to see if I had an error
>>>in my code or if it was maybe a SWT thing. I haven't gotten back to that
>>>so I can't confirm it.
>>
>>
>> Which version of Mac OSX? We have a general problem that
>> ascynExec(runnable) does not get run while the mouse button is down.
>> But, if you pause the mouse it usually runs. Scrollbar dragging could be
>> worse than just mouse dragging on the canvas.
>>
Re: Draw2d and modifying default Canvas scrolling [message #187410 is a reply to message #187350] Tue, 12 July 2005 14:07 Go to previous messageGo to next message
Brad Reynolds is currently offline Brad ReynoldsFriend
Messages: 309
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030402080809090601080504
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Attached is a quick test with a Viewport as the body. It just has a
header and body for testing purposes. It's a little jumpy. Is there a
better way of going about constraining the header and body to the
appropriate locations?


Randy Hudson wrote:
> Stop dragging but with the button still pressed.
> "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
> news:dauqqk$a1i$1@news.eclipse.org...
>
>>It was 10.3. What do you mean when you say "pause the mouse"?
>>
>>Randy Hudson wrote:
>>
>>>>wasn't ideal and was hoping to avoid it if possible. The other
>>>>interesting thing I saw was that on OS X with 2 canvases the second
>>>>header wouldn't update until mouse up of the scrollbar on the body
>>>>canvas. This was something I wanted to dig into to see if I had an error
>>>>in my code or if it was maybe a SWT thing. I haven't gotten back to that
>>>>so I can't confirm it.
>>>
>>>
>>>Which version of Mac OSX? We have a general problem that
>>>ascynExec(runnable) does not get run while the mouse button is down.
>>>But, if you pause the mouse it usually runs. Scrollbar dragging could be
>>>worse than just mouse dragging on the canvas.
>>>
>
>


--------------030402080809090601080504
Content-Type: text/plain;
name="ViewportsTest.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ViewportsTest.java"

package com.cerner.client.components.custom.table;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.RangeModel;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.Viewport;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class ViewportsTest {
public void run() {
Display display = new Display();
Shell shell = new Shell(display);
GridLayout layout = new GridLayout();
shell.setLayout(layout);

GridData data = new GridData(GridData.FILL_BOTH);
final FigureCanvas canvas = new FigureCanvas(shell);
canvas.setLayoutData(data);

// Create a figure that changes the preferred size to create scrollbars
// properly on the Canvas.
final Contents contents = new Contents();
contents.setLayoutManager(new XYLayout());
canvas.setContents(contents);

final IFigure header = new Figure();
header.setLayoutManager(new ToolbarLayout());
header.add(new Label("header")); //$NON-NLS-1$
contents.addHeader(header);

final Viewport body = new Viewport();
IFigure bodyContents = new Figure();
bodyContents.setLayoutManager(new ToolbarLayout());
body.setContents(bodyContents);

// Add items to the body.
for (int i = 0; i < 1000; i++) {
bodyContents.add(new Label("body " + i)); //$NON-NLS-1$
}

contents.addBody(body);

// Set initial constraints for header and body, values are hard coded for testing purposes.
contents.setConstraint(header, new Rectangle(0, 0, -1, -1));
contents.setConstraint(body, new Rectangle(0, 50, -1, 500));

// Add a change listener for the vertical scrolling of the main
// viewport.
final Viewport mainvp = canvas.getViewport();
mainvp.getVerticalRangeModel().addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
RangeModel rangeModel = (RangeModel) event.getSource();

// Anchor the header to the top of the viewport.
Point location = mainvp.getViewLocation();
contents.setConstraint(header, new Rectangle(location.x, location.y, -1, -1));

// Position body below the header.
contents.setConstraint(body, new Rectangle(location.x, location.y + 50, -1, 500));
body.setVerticalLocation(rangeModel.getValue());
}
});

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}

public static void main(String[] args) {
new ViewportsTest().run();
}

/**
* Returns a preferred size that is a body's perferred size.
*/
private class Contents extends Figure {
private IFigure body;
private IFigure header;

public void addHeader(IFigure header) {
super.add(header);

this.header = header;
}

public void addBody(IFigure body) {
super.add(body);

this.body = body;
}

public Dimension getPreferredSize(int wHint, int hHint) {
return body.getPreferredSize(wHint, hHint);
}
}
}

--------------030402080809090601080504--
Re: Draw2d and modifying default Canvas scrolling [message #187442 is a reply to message #187304] Tue, 12 July 2005 14:26 Go to previous messageGo to next message
Brad Reynolds is currently offline Brad ReynoldsFriend
Messages: 309
Registered: July 2009
Senior Member
So how do you force the updates on the second canvas to happen
immediately? Where exactly is the ruler example?

Pratik Shah wrote:
> "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
> news:42D2CFF9.90708@gmail.com...
>
>>I tried using multiple canvases and wasn't happy with the results. For
>>one on OS X this creates space between the two canvases for some reason.
>> I think you responded to this inquiry previously but I haven't dug
>>into why this is exactly happening. Also with two canvases it displayed
>>a behavior where it looke like the header canvas was always lagging
>>behind the body canvas. It worked when everything was said and done but
>>it felt a little odd like it was playing catch up. I think this is
>>because since it was 2 separate canvases it was 2 different paint
>>events. So there appeared to be a lag in the update. It worked but
>>wasn't ideal and was hoping to avoid it if possible. The other
>>interesting thing I saw was that on OS X with 2 canvases the second
>>header wouldn't update until mouse up of the scrollbar on the body
>>canvas. This was something I wanted to dig into to see if I had an
>>error in my code or if it was maybe a SWT thing. I haven't gotten back
>>to that so I can't confirm it.
>
>
> You can force the updates on the second canvas to happen immediately. This
> is what we do for the rulers (the rulers are in separate canvasses). But
> this works well only on windows. You'll still see some lagging on other
> platforms.
>
>
>>What about using LayeredPanes? Would there be any reason not to use
>>them? I'll look into multiple viewports as well, thanks for the
>
> suggestion.
>
>>Randy Hudson wrote:
>>
>>>For a fixed column, you may consider using multiple viewports, or even
>>>multiple Canvases with linked RangeModels to sync the scrolling.
>>>
>>>"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
>>>news:42CEBCD1.7000100@gmail.com...
>>>
>>>
>>>>Thanks Randy. I'm going to try your suggestions with the Veiwport as
>>>>well. I'll post my findings.
>>>>
>>>>Randy Hudson wrote:
>>>>
>>>>
>>>>>The figure owning the border would definitely receive the mouse events.
>>>
>>>
>>>
>
>
Re: Draw2d and modifying default Canvas scrolling [message #187449 is a reply to message #187442] Tue, 12 July 2005 15:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

getUpdateManager().performUpdate();

"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
news:db0jup$e17$1@news.eclipse.org...
> So how do you force the updates on the second canvas to happen
> immediately? Where exactly is the ruler example?
>
> Pratik Shah wrote:
> > "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
> > news:42D2CFF9.90708@gmail.com...
> >
> >>I tried using multiple canvases and wasn't happy with the results. For
> >>one on OS X this creates space between the two canvases for some reason.
> >> I think you responded to this inquiry previously but I haven't dug
> >>into why this is exactly happening. Also with two canvases it displayed
> >>a behavior where it looke like the header canvas was always lagging
> >>behind the body canvas. It worked when everything was said and done but
> >>it felt a little odd like it was playing catch up. I think this is
> >>because since it was 2 separate canvases it was 2 different paint
> >>events. So there appeared to be a lag in the update. It worked but
> >>wasn't ideal and was hoping to avoid it if possible. The other
> >>interesting thing I saw was that on OS X with 2 canvases the second
> >>header wouldn't update until mouse up of the scrollbar on the body
> >>canvas. This was something I wanted to dig into to see if I had an
> >>error in my code or if it was maybe a SWT thing. I haven't gotten back
> >>to that so I can't confirm it.
> >
> >
> > You can force the updates on the second canvas to happen immediately.
This
> > is what we do for the rulers (the rulers are in separate canvasses).
But
> > this works well only on windows. You'll still see some lagging on other
> > platforms.
> >
> >
> >>What about using LayeredPanes? Would there be any reason not to use
> >>them? I'll look into multiple viewports as well, thanks for the
> >
> > suggestion.
> >
> >>Randy Hudson wrote:
> >>
> >>>For a fixed column, you may consider using multiple viewports, or even
> >>>multiple Canvases with linked RangeModels to sync the scrolling.
> >>>
> >>>"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
> >>>news:42CEBCD1.7000100@gmail.com...
> >>>
> >>>
> >>>>Thanks Randy. I'm going to try your suggestions with the Veiwport as
> >>>>well. I'll post my findings.
> >>>>
> >>>>Randy Hudson wrote:
> >>>>
> >>>>
> >>>>>The figure owning the border would definitely receive the mouse
events.
> >>>
> >>>
> >>>
> >
> >
Re: Draw2d and modifying default Canvas scrolling [message #187479 is a reply to message #187449] Tue, 12 July 2005 19:04 Go to previous messageGo to next message
Brad Reynolds is currently offline Brad ReynoldsFriend
Messages: 309
Registered: July 2009
Senior Member
Thanks. That helped out quite a bit.

Pratik Shah wrote:
> getUpdateManager().performUpdate();
>
> "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
> news:db0jup$e17$1@news.eclipse.org...
>
>>So how do you force the updates on the second canvas to happen
>>immediately? Where exactly is the ruler example?
>>
>>Pratik Shah wrote:
>>
>>>"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
>>>news:42D2CFF9.90708@gmail.com...
>>>
>>>
>>>>I tried using multiple canvases and wasn't happy with the results. For
>>>>one on OS X this creates space between the two canvases for some reason.
>>>> I think you responded to this inquiry previously but I haven't dug
>>>>into why this is exactly happening. Also with two canvases it displayed
>>>>a behavior where it looke like the header canvas was always lagging
>>>>behind the body canvas. It worked when everything was said and done but
>>>>it felt a little odd like it was playing catch up. I think this is
>>>>because since it was 2 separate canvases it was 2 different paint
>>>>events. So there appeared to be a lag in the update. It worked but
>>>>wasn't ideal and was hoping to avoid it if possible. The other
>>>>interesting thing I saw was that on OS X with 2 canvases the second
>>>>header wouldn't update until mouse up of the scrollbar on the body
>>>>canvas. This was something I wanted to dig into to see if I had an
>>>>error in my code or if it was maybe a SWT thing. I haven't gotten back
>>>>to that so I can't confirm it.
>>>
>>>
>>>You can force the updates on the second canvas to happen immediately.
>
> This
>
>>>is what we do for the rulers (the rulers are in separate canvasses).
>
> But
>
>>>this works well only on windows. You'll still see some lagging on other
>>>platforms.
>>>
>>>
>>>
>>>>What about using LayeredPanes? Would there be any reason not to use
>>>>them? I'll look into multiple viewports as well, thanks for the
>>>
>>>suggestion.
>>>
>>>
>>>>Randy Hudson wrote:
>>>>
>>>>
>>>>>For a fixed column, you may consider using multiple viewports, or even
>>>>>multiple Canvases with linked RangeModels to sync the scrolling.
>>>>>
>>>>>"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
>>>>>news:42CEBCD1.7000100@gmail.com...
>>>>>
>>>>>
>>>>>
>>>>>>Thanks Randy. I'm going to try your suggestions with the Veiwport as
>>>>>>well. I'll post my findings.
>>>>>>
>>>>>>Randy Hudson wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>>The figure owning the border would definitely receive the mouse
>
> events.
>
>>>>>
>>>>>
>>>
>
>
Re: Draw2d and modifying default Canvas scrolling [message #187516 is a reply to message #187410] Tue, 12 July 2005 21:33 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

The problem you are seeing is related to FigureCanvas and the way it calls
scroll(int, int, int....)
The contents are being copied on top of the header.


"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
news:db0iqg$c5n$1@news.eclipse.org...
> Attached is a quick test with a Viewport as the body. It just has a
> header and body for testing purposes. It's a little jumpy. Is there a
> better way of going about constraining the header and body to the
> appropriate locations?
>
>
> Randy Hudson wrote:
>> Stop dragging but with the button still pressed.
>> "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
>> news:dauqqk$a1i$1@news.eclipse.org...
>>
>>>It was 10.3. What do you mean when you say "pause the mouse"?
>>>
>>>Randy Hudson wrote:
>>>
>>>>>wasn't ideal and was hoping to avoid it if possible. The other
>>>>>interesting thing I saw was that on OS X with 2 canvases the second
>>>>>header wouldn't update until mouse up of the scrollbar on the body
>>>>>canvas. This was something I wanted to dig into to see if I had an
>>>>>error
>>>>>in my code or if it was maybe a SWT thing. I haven't gotten back to
>>>>>that
>>>>>so I can't confirm it.
>>>>
>>>>
>>>>Which version of Mac OSX? We have a general problem that
>>>>ascynExec(runnable) does not get run while the mouse button is down.
>>>>But, if you pause the mouse it usually runs. Scrollbar dragging could be
>>>>worse than just mouse dragging on the canvas.
>>>>
>>
>>
>
>


------------------------------------------------------------ --------------------


> package com.cerner.client.components.custom.table;
>
> import java.beans.PropertyChangeEvent;
> import java.beans.PropertyChangeListener;
>
> import org.eclipse.draw2d.Figure;
> import org.eclipse.draw2d.FigureCanvas;
> import org.eclipse.draw2d.IFigure;
> import org.eclipse.draw2d.Label;
> import org.eclipse.draw2d.RangeModel;
> import org.eclipse.draw2d.ToolbarLayout;
> import org.eclipse.draw2d.Viewport;
> import org.eclipse.draw2d.XYLayout;
> import org.eclipse.draw2d.geometry.Dimension;
> import org.eclipse.draw2d.geometry.Point;
> import org.eclipse.draw2d.geometry.Rectangle;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> public class ViewportsTest {
> public void run() {
> Display display = new Display();
> Shell shell = new Shell(display);
> GridLayout layout = new GridLayout();
> shell.setLayout(layout);
>
> GridData data = new GridData(GridData.FILL_BOTH);
> final FigureCanvas canvas = new FigureCanvas(shell);
> canvas.setLayoutData(data);
>
> // Create a figure that changes the preferred size to create scrollbars
> // properly on the Canvas.
> final Contents contents = new Contents();
> contents.setLayoutManager(new XYLayout());
> canvas.setContents(contents);
>
> final IFigure header = new Figure();
> header.setLayoutManager(new ToolbarLayout());
> header.add(new Label("header")); //$NON-NLS-1$
> contents.addHeader(header);
>
> final Viewport body = new Viewport();
> IFigure bodyContents = new Figure();
> bodyContents.setLayoutManager(new ToolbarLayout());
> body.setContents(bodyContents);
>
> // Add items to the body.
> for (int i = 0; i < 1000; i++) {
> bodyContents.add(new Label("body " + i)); //$NON-NLS-1$
> }
>
> contents.addBody(body);
>
> // Set initial constraints for header and body, values are hard coded for
> testing purposes.
> contents.setConstraint(header, new Rectangle(0, 0, -1, -1));
> contents.setConstraint(body, new Rectangle(0, 50, -1, 500));
>
> // Add a change listener for the vertical scrolling of the main
> // viewport.
> final Viewport mainvp = canvas.getViewport();
> mainvp.getVerticalRangeModel().addPropertyChangeListener(new
> PropertyChangeListener() {
> public void propertyChange(PropertyChangeEvent event) {
> RangeModel rangeModel = (RangeModel) event.getSource();
>
> // Anchor the header to the top of the viewport.
> Point location = mainvp.getViewLocation();
> contents.setConstraint(header, new Rectangle(location.x,
> location.y, -1, -1));
>
> // Position body below the header.
> contents.setConstraint(body, new Rectangle(location.x, location.y +
> 50, -1, 500));
> body.setVerticalLocation(rangeModel.getValue());
> }
> });
>
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
> }
>
> public static void main(String[] args) {
> new ViewportsTest().run();
> }
>
> /**
> * Returns a preferred size that is a body's perferred size.
> */
> private class Contents extends Figure {
> private IFigure body;
> private IFigure header;
>
> public void addHeader(IFigure header) {
> super.add(header);
>
> this.header = header;
> }
>
> public void addBody(IFigure body) {
> super.add(body);
>
> this.body = body;
> }
>
> public Dimension getPreferredSize(int wHint, int hHint) {
> return body.getPreferredSize(wHint, hHint);
> }
> }
> }
>
Previous Topic:How to connect to one node within a composite Figure
Next Topic:Getting Started in GEF
Goto Forum:
  


Current Time: Fri Apr 26 09:56:41 GMT 2024

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

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

Back to the top