Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Problem with custom GridLayer
Problem with custom GridLayer [message #187914] Sun, 17 July 2005 22:35 Go to next message
Matt is currently offline MattFriend
Messages: 40
Registered: July 2009
Member
Hi,

I subclassed GridLayer and rewrote paintGrid() with
FigureUtilities.paintGrid(). That worked. But I took out the two
g.drawLine() loops and replaced them with:

for (int j = origin.y; j < clip.y + clip.height; j += gridY)
for (int i = origin.x; i < clip.x + clip.width; i += gridX)
g.drawPoint(clip.x + i, clip.y + j);

Initially, the grid points look fine. But when I add a Figure or use the
MarqueeSelectionTool, it changes the point positions or removes them. The
grid layer doesn't seem to be repainting.

Any thoughts would be appreciated. Thanks!

Matt
Re: Problem with custom GridLayer [message #187921 is a reply to message #187914] Mon, 18 July 2005 03:06 Go to previous messageGo to next message
Dazhen Gao is currently offline Dazhen GaoFriend
Messages: 21
Registered: July 2009
Junior Member
Code like this:

protected void paintGrid( Graphics g )
{
Rectangle clip = g.getClip( Rectangle.SINGLETON ;

if ( gridX > 0 )
{
if ( origin.x >= clip.x )
while ( origin.x - gridX >= clip.x )
origin.x -= gridX;
else
while ( origin.x < clip.x )
origin.x += gridX;

if ( gridX > 0 )
{
if ( origin.y >= clip.y )
while ( origin.y - gridX >= clip.y )
origin.y -= gridX;
else
while ( origin.y < clip.y )
origin.y += gridX;
}

for ( int j = origin.y; j < clip.y + clip.height; j += gridX )
for ( int i = origin.x; i < clip.x + clip.width; i += gridX )
g.drawPoint( i, j );

}
}



"MattS" <mattscar@yahoo.com> wrote in message
news:5a1d988cd132593ebdffac030af58735$1@www.eclipse.org...
> Hi,
>
> I subclassed GridLayer and rewrote paintGrid() with
> FigureUtilities.paintGrid(). That worked. But I took out the two
> g.drawLine() loops and replaced them with:
>
> for (int j = origin.y; j < clip.y + clip.height; j += gridY)
> for (int i = origin.x; i < clip.x + clip.width; i += gridX)
> g.drawPoint(clip.x + i, clip.y + j);
>
> Initially, the grid points look fine. But when I add a Figure or use the
> MarqueeSelectionTool, it changes the point positions or removes them. The
> grid layer doesn't seem to be repainting.
>
> Any thoughts would be appreciated. Thanks!
>
> Matt
>
Re: Problem with custom GridLayer [message #187991 is a reply to message #187921] Mon, 18 July 2005 15:33 Go to previous message
Matt is currently offline MattFriend
Messages: 40
Registered: July 2009
Member
Perfect. Many thanks!
Previous Topic:Actions and Editors
Next Topic:Problem when using ZoomIn
Goto Forum:
  


Current Time: Tue Dec 10 15:02:43 GMT 2024

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

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

Back to the top