Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Connections start one pixel away from node
Connections start one pixel away from node [message #201655] Wed, 02 November 2005 15:20 Go to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
I posted about earlier, but I wanted summarize things again.
Below is a snippet of code that shows the problem. In the other post, I also
attached a small GEF project that shows the problem interactively. This is
what's happening:

- There is a 1-pixel gap between the source side of a connection its node;
on the target side everything is okay.
- The 1-pixel gap happens only if the connection leaves the source node at
an angle between 7.30 and 1.30 on a clock (i.e. only in the "evening"). At
other angles the gap vanishes.

public static void main( String[] args ) {

Display d = new Display();
Shell shell = new Shell( d );
shell.setLayout( new FillLayout() );
FigureCanvas canvas = new FigureCanvas( shell );

Figure connectionPanel = new Figure();

RectangleFigure node1 = new RectangleFigure(), node2 = new
RectangleFigure();
node1.setBackgroundColor( ColorConstants.red );
node1.setOutline( false );
node1.setBounds( new Rectangle( 40, 40, 50, 30 ) );
node2.setBackgroundColor( ColorConstants.blue );
node2.setOutline( false );
node2.setBounds( new Rectangle( 100, 140, 50, 30 ) );

PolylineConnection conn = new PolylineConnection();
conn.setSourceAnchor( new ChopboxAnchor( node2 ) );
conn.setTargetAnchor( new ChopboxAnchor( node1 ) );
connectionPanel.add( node1 );
connectionPanel.add( node2 );
connectionPanel.add( conn );

canvas.setContents( connectionPanel );

shell.open();
while( !shell.isDisposed() )
while( !d.readAndDispatch() )
d.sleep();

}//main()
Re: Connections start one pixel away from node [message #201687 is a reply to message #201655] Wed, 02 November 2005 16:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

This would be a factor of the anchor behavior. Have you exaimed closely
the behavior of the ChopBox anchor? it does blow up the size of the
bounding box a bit. Maybe you want a different more accurate way to
place the point?


CL

Felix L J Mayer wrote:
> I posted about earlier, but I wanted summarize things again.
> Below is a snippet of code that shows the problem. In the other post, I also
> attached a small GEF project that shows the problem interactively. This is
> what's happening:
>
> - There is a 1-pixel gap between the source side of a connection its node;
> on the target side everything is okay.
> - The 1-pixel gap happens only if the connection leaves the source node at
> an angle between 7.30 and 1.30 on a clock (i.e. only in the "evening"). At
> other angles the gap vanishes.
>
> public static void main( String[] args ) {
>
> Display d = new Display();
> Shell shell = new Shell( d );
> shell.setLayout( new FillLayout() );
> FigureCanvas canvas = new FigureCanvas( shell );
>
> Figure connectionPanel = new Figure();
>
> RectangleFigure node1 = new RectangleFigure(), node2 = new
> RectangleFigure();
> node1.setBackgroundColor( ColorConstants.red );
> node1.setOutline( false );
> node1.setBounds( new Rectangle( 40, 40, 50, 30 ) );
> node2.setBackgroundColor( ColorConstants.blue );
> node2.setOutline( false );
> node2.setBounds( new Rectangle( 100, 140, 50, 30 ) );
>
> PolylineConnection conn = new PolylineConnection();
> conn.setSourceAnchor( new ChopboxAnchor( node2 ) );
> conn.setTargetAnchor( new ChopboxAnchor( node1 ) );
> connectionPanel.add( node1 );
> connectionPanel.add( node2 );
> connectionPanel.add( conn );
>
> canvas.setContents( connectionPanel );
>
> shell.open();
> while( !shell.isDisposed() )
> while( !d.readAndDispatch() )
> d.sleep();
>
> }//main()
>
>
>
Re: Connections start one pixel away from node [message #201695 is a reply to message #201687] Wed, 02 November 2005 17:00 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
I just think it's a bug ;)

"CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
news:dkaos8$9ra$3@news.eclipse.org...
> This would be a factor of the anchor behavior. Have you exaimed closely
> the behavior of the ChopBox anchor? it does blow up the size of the
> bounding box a bit. Maybe you want a different more accurate way to place
> the point?
>
>
> CL
>
> Felix L J Mayer wrote:
>> I posted about earlier, but I wanted summarize things again.
>> Below is a snippet of code that shows the problem. In the other post, I
>> also attached a small GEF project that shows the problem interactively.
>> This is what's happening:
>>
>> - There is a 1-pixel gap between the source side of a connection its
>> node; on the target side everything is okay.
>> - The 1-pixel gap happens only if the connection leaves the source node
>> at an angle between 7.30 and 1.30 on a clock (i.e. only in the
>> "evening"). At other angles the gap vanishes.
>>
>> public static void main( String[] args ) {
>>
>> Display d = new Display();
>> Shell shell = new Shell( d );
>> shell.setLayout( new FillLayout() );
>> FigureCanvas canvas = new FigureCanvas( shell );
>>
>> Figure connectionPanel = new Figure();
>>
>> RectangleFigure node1 = new RectangleFigure(), node2 = new
>> RectangleFigure();
>> node1.setBackgroundColor( ColorConstants.red );
>> node1.setOutline( false );
>> node1.setBounds( new Rectangle( 40, 40, 50, 30 ) );
>> node2.setBackgroundColor( ColorConstants.blue );
>> node2.setOutline( false );
>> node2.setBounds( new Rectangle( 100, 140, 50, 30 ) );
>>
>> PolylineConnection conn = new PolylineConnection();
>> conn.setSourceAnchor( new ChopboxAnchor( node2 ) );
>> conn.setTargetAnchor( new ChopboxAnchor( node1 ) );
>> connectionPanel.add( node1 );
>> connectionPanel.add( node2 );
>> connectionPanel.add( conn );
>>
>> canvas.setContents( connectionPanel );
>>
>> shell.open();
>> while( !shell.isDisposed() )
>> while( !d.readAndDispatch() )
>> d.sleep();
>>
>> }//main()
>>
>>
Re: Connections start one pixel away from node [message #201710 is a reply to message #201695] Wed, 02 November 2005 20:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

More likely its a compromise. But I bet if you improve the Chopbox
algorithm it would be welcomed. Seems as if its only the 'West' side of
the figure that has the problem. you can do x -=1; and reap all the
accolades :D


CL


Felix L J Mayer wrote:
> I just think it's a bug ;)
>
> "CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
> news:dkaos8$9ra$3@news.eclipse.org...
>
>>This would be a factor of the anchor behavior. Have you exaimed closely
>>the behavior of the ChopBox anchor? it does blow up the size of the
>>bounding box a bit. Maybe you want a different more accurate way to place
>>the point?
>>
>>
>>CL
>>
>>Felix L J Mayer wrote:
>>
>>>I posted about earlier, but I wanted summarize things again.
>>>Below is a snippet of code that shows the problem. In the other post, I
>>>also attached a small GEF project that shows the problem interactively.
>>>This is what's happening:
>>>
>>>- There is a 1-pixel gap between the source side of a connection its
>>>node; on the target side everything is okay.
>>>- The 1-pixel gap happens only if the connection leaves the source node
>>>at an angle between 7.30 and 1.30 on a clock (i.e. only in the
>>>"evening"). At other angles the gap vanishes.
>>>
>>> public static void main( String[] args ) {
>>>
>>> Display d = new Display();
>>> Shell shell = new Shell( d );
>>> shell.setLayout( new FillLayout() );
>>> FigureCanvas canvas = new FigureCanvas( shell );
>>>
>>> Figure connectionPanel = new Figure();
>>>
>>> RectangleFigure node1 = new RectangleFigure(), node2 = new
>>>RectangleFigure();
>>> node1.setBackgroundColor( ColorConstants.red );
>>> node1.setOutline( false );
>>> node1.setBounds( new Rectangle( 40, 40, 50, 30 ) );
>>> node2.setBackgroundColor( ColorConstants.blue );
>>> node2.setOutline( false );
>>> node2.setBounds( new Rectangle( 100, 140, 50, 30 ) );
>>>
>>> PolylineConnection conn = new PolylineConnection();
>>> conn.setSourceAnchor( new ChopboxAnchor( node2 ) );
>>> conn.setTargetAnchor( new ChopboxAnchor( node1 ) );
>>> connectionPanel.add( node1 );
>>> connectionPanel.add( node2 );
>>> connectionPanel.add( conn );
>>>
>>> canvas.setContents( connectionPanel );
>>>
>>> shell.open();
>>> while( !shell.isDisposed() )
>>> while( !d.readAndDispatch() )
>>> d.sleep();
>>>
>>> }//main()
>>>
>>>
>
>
Re: Connections start one pixel away from node [message #201795 is a reply to message #201710] Thu, 03 November 2005 17:01 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
I don't think it's a compromise, the code looks fine to me. The only thing I
would think of changing is to use double instead of float to ensure we don't
get rounding issues.

And doing x-=-1 does not work because:
- This happens only at the source end of the connection, not the target end.
The ChopboxAnchor does not know which end it is.
- This also happens not on the west side, but on the north and west sides
depending on the angle of the connection. For example, beyond an angle of 45
degrees clockwise from the vertical the gap vanishes. It also vanishes
beyond an angle of 135 degrees from the vertical going counterclockwise.

So we would have to do an x+=1 and y+=1 if those conditions are met.

"CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
news:dkb5sl$s8g$2@news.eclipse.org...
> More likely its a compromise. But I bet if you improve the Chopbox
> algorithm it would be welcomed. Seems as if its only the 'West' side of
> the figure that has the problem. you can do x -=1; and reap all the
> accolades :D
>
>
> CL
>
>
> Felix L J Mayer wrote:
>> I just think it's a bug ;)
>>
>> "CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
>> news:dkaos8$9ra$3@news.eclipse.org...
>>
>>>This would be a factor of the anchor behavior. Have you exaimed closely
>>>the behavior of the ChopBox anchor? it does blow up the size of the
>>>bounding box a bit. Maybe you want a different more accurate way to
>>>place the point?
>>>
>>>
>>>CL
>>>
>>>Felix L J Mayer wrote:
>>>
>>>>I posted about earlier, but I wanted summarize things again.
>>>>Below is a snippet of code that shows the problem. In the other post, I
>>>>also attached a small GEF project that shows the problem interactively.
>>>>This is what's happening:
>>>>
>>>>- There is a 1-pixel gap between the source side of a connection its
>>>>node; on the target side everything is okay.
>>>>- The 1-pixel gap happens only if the connection leaves the source node
>>>>at an angle between 7.30 and 1.30 on a clock (i.e. only in the
>>>>"evening"). At other angles the gap vanishes.
>>>>
>>>> public static void main( String[] args ) {
>>>>
>>>> Display d = new Display();
>>>> Shell shell = new Shell( d );
>>>> shell.setLayout( new FillLayout() );
>>>> FigureCanvas canvas = new FigureCanvas( shell );
>>>>
>>>> Figure connectionPanel = new Figure();
>>>>
>>>> RectangleFigure node1 = new RectangleFigure(), node2 = new
>>>> RectangleFigure();
>>>> node1.setBackgroundColor( ColorConstants.red );
>>>> node1.setOutline( false );
>>>> node1.setBounds( new Rectangle( 40, 40, 50, 30 ) );
>>>> node2.setBackgroundColor( ColorConstants.blue );
>>>> node2.setOutline( false );
>>>> node2.setBounds( new Rectangle( 100, 140, 50, 30 ) );
>>>>
>>>> PolylineConnection conn = new PolylineConnection();
>>>> conn.setSourceAnchor( new ChopboxAnchor( node2 ) );
>>>> conn.setTargetAnchor( new ChopboxAnchor( node1 ) );
>>>> connectionPanel.add( node1 );
>>>> connectionPanel.add( node2 );
>>>> connectionPanel.add( conn );
>>>>
>>>> canvas.setContents( connectionPanel );
>>>>
>>>> shell.open();
>>>> while( !shell.isDisposed() )
>>>> while( !d.readAndDispatch() )
>>>> d.sleep();
>>>>
>>>> }//main()
>>>>
>>>>
>>
Re: Connections start one pixel away from node [message #201811 is a reply to message #201795] Thu, 03 November 2005 18:29 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
This actually seems to be an SWT problem. I stepped through the code and
looked and the y coordinate for different angles, and it was always the same
(y=139). But with the proper angle as described below, the line starts with
a one-pixel gap.

So it looks like the SWT problem that Randy Hudson mentioned earlier still
exists.

A possible workaround is to remove some lines in
ChopboxAnchor.getLocation(Point):
r.translate(-1, -1);
r.resize(1, 1);

The effect that they have is that connections on the west and north side
start right outside of the node, whereas connections on the east and south
start just inside the node. So maybe the problem exists on the target side
on the connection as well, but cannot be seen. Anyway, for consistency
either those 2 lines should be removed or the second one should become
r.resize(2, 2);


"Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
news:dkdfp8$pi1$1@news.eclipse.org...
>I don't think it's a compromise, the code looks fine to me. The only thing
>I would think of changing is to use double instead of float to ensure we
>don't get rounding issues.
>
> And doing x-=-1 does not work because:
> - This happens only at the source end of the connection, not the target
> end. The ChopboxAnchor does not know which end it is.
> - This also happens not on the west side, but on the north and west sides
> depending on the angle of the connection. For example, beyond an angle of
> 45 degrees clockwise from the vertical the gap vanishes. It also vanishes
> beyond an angle of 135 degrees from the vertical going counterclockwise.
>
> So we would have to do an x+=1 and y+=1 if those conditions are met.
>
> "CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
> news:dkb5sl$s8g$2@news.eclipse.org...
>> More likely its a compromise. But I bet if you improve the Chopbox
>> algorithm it would be welcomed. Seems as if its only the 'West' side of
>> the figure that has the problem. you can do x -=1; and reap all the
>> accolades :D
>>
>>
>> CL
>>
>>
>> Felix L J Mayer wrote:
>>> I just think it's a bug ;)
>>>
>>> "CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in
>>> message news:dkaos8$9ra$3@news.eclipse.org...
>>>
>>>>This would be a factor of the anchor behavior. Have you exaimed closely
>>>>the behavior of the ChopBox anchor? it does blow up the size of the
>>>>bounding box a bit. Maybe you want a different more accurate way to
>>>>place the point?
>>>>
>>>>
>>>>CL
>>>>
>>>>Felix L J Mayer wrote:
>>>>
>>>>>I posted about earlier, but I wanted summarize things again.
>>>>>Below is a snippet of code that shows the problem. In the other post, I
>>>>>also attached a small GEF project that shows the problem interactively.
>>>>>This is what's happening:
>>>>>
>>>>>- There is a 1-pixel gap between the source side of a connection its
>>>>>node; on the target side everything is okay.
>>>>>- The 1-pixel gap happens only if the connection leaves the source node
>>>>>at an angle between 7.30 and 1.30 on a clock (i.e. only in the
>>>>>"evening"). At other angles the gap vanishes.
>>>>>
>>>>> public static void main( String[] args ) {
>>>>>
>>>>> Display d = new Display();
>>>>> Shell shell = new Shell( d );
>>>>> shell.setLayout( new FillLayout() );
>>>>> FigureCanvas canvas = new FigureCanvas( shell );
>>>>>
>>>>> Figure connectionPanel = new Figure();
>>>>>
>>>>> RectangleFigure node1 = new RectangleFigure(), node2 = new
>>>>> RectangleFigure();
>>>>> node1.setBackgroundColor( ColorConstants.red );
>>>>> node1.setOutline( false );
>>>>> node1.setBounds( new Rectangle( 40, 40, 50, 30 ) );
>>>>> node2.setBackgroundColor( ColorConstants.blue );
>>>>> node2.setOutline( false );
>>>>> node2.setBounds( new Rectangle( 100, 140, 50, 30 ) );
>>>>>
>>>>> PolylineConnection conn = new PolylineConnection();
>>>>> conn.setSourceAnchor( new ChopboxAnchor( node2 ) );
>>>>> conn.setTargetAnchor( new ChopboxAnchor( node1 ) );
>>>>> connectionPanel.add( node1 );
>>>>> connectionPanel.add( node2 );
>>>>> connectionPanel.add( conn );
>>>>>
>>>>> canvas.setContents( connectionPanel );
>>>>>
>>>>> shell.open();
>>>>> while( !shell.isDisposed() )
>>>>> while( !d.readAndDispatch() )
>>>>> d.sleep();
>>>>>
>>>>> }//main()
>>>>>
>>>>>
>>>
>
Re: Connections start one pixel away from node [message #201827 is a reply to message #201811] Thu, 03 November 2005 20:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Perhaps its an antialiasing issue. Did you try turning it on and off?

I figured a double may fix it, that is why i called it a compromise.
Because it uses a smaller primitive type IIRC.

CL


Felix L J Mayer wrote:
> This actually seems to be an SWT problem. I stepped through the code and
> looked and the y coordinate for different angles, and it was always the same
> (y=139). But with the proper angle as described below, the line starts with
> a one-pixel gap.
>
> So it looks like the SWT problem that Randy Hudson mentioned earlier still
> exists.
>
> A possible workaround is to remove some lines in
> ChopboxAnchor.getLocation(Point):
> r.translate(-1, -1);
> r.resize(1, 1);
>
> The effect that they have is that connections on the west and north side
> start right outside of the node, whereas connections on the east and south
> start just inside the node. So maybe the problem exists on the target side
> on the connection as well, but cannot be seen. Anyway, for consistency
> either those 2 lines should be removed or the second one should become
> r.resize(2, 2);
>
>
> "Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
> news:dkdfp8$pi1$1@news.eclipse.org...
>
>>I don't think it's a compromise, the code looks fine to me. The only thing
>>I would think of changing is to use double instead of float to ensure we
>>don't get rounding issues.
>>
>>And doing x-=-1 does not work because:
>>- This happens only at the source end of the connection, not the target
>>end. The ChopboxAnchor does not know which end it is.
>>- This also happens not on the west side, but on the north and west sides
>>depending on the angle of the connection. For example, beyond an angle of
>>45 degrees clockwise from the vertical the gap vanishes. It also vanishes
>>beyond an angle of 135 degrees from the vertical going counterclockwise.
>>
>>So we would have to do an x+=1 and y+=1 if those conditions are met.
>>
>>"CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
>>news:dkb5sl$s8g$2@news.eclipse.org...
>>
>>>More likely its a compromise. But I bet if you improve the Chopbox
>>>algorithm it would be welcomed. Seems as if its only the 'West' side of
>>>the figure that has the problem. you can do x -=1; and reap all the
>>>accolades :D
>>>
>>>
>>>CL
>>>
>>>
>>>Felix L J Mayer wrote:
>>>
>>>>I just think it's a bug ;)
>>>>
>>>>"CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in
>>>>message news:dkaos8$9ra$3@news.eclipse.org...
>>>>
>>>>
>>>>>This would be a factor of the anchor behavior. Have you exaimed closely
>>>>>the behavior of the ChopBox anchor? it does blow up the size of the
>>>>>bounding box a bit. Maybe you want a different more accurate way to
>>>>>place the point?
>>>>>
>>>>>
>>>>>CL
>>>>>
>>>>>Felix L J Mayer wrote:
>>>>>
>>>>>
>>>>>>I posted about earlier, but I wanted summarize things again.
>>>>>>Below is a snippet of code that shows the problem. In the other post, I
>>>>>>also attached a small GEF project that shows the problem interactively.
>>>>>>This is what's happening:
>>>>>>
>>>>>>- There is a 1-pixel gap between the source side of a connection its
>>>>>>node; on the target side everything is okay.
>>>>>>- The 1-pixel gap happens only if the connection leaves the source node
>>>>>>at an angle between 7.30 and 1.30 on a clock (i.e. only in the
>>>>>>"evening"). At other angles the gap vanishes.
>>>>>>
>>>>>> public static void main( String[] args ) {
>>>>>>
>>>>>> Display d = new Display();
>>>>>> Shell shell = new Shell( d );
>>>>>> shell.setLayout( new FillLayout() );
>>>>>> FigureCanvas canvas = new FigureCanvas( shell );
>>>>>>
>>>>>> Figure connectionPanel = new Figure();
>>>>>>
>>>>>> RectangleFigure node1 = new RectangleFigure(), node2 = new
>>>>>>RectangleFigure();
>>>>>> node1.setBackgroundColor( ColorConstants.red );
>>>>>> node1.setOutline( false );
>>>>>> node1.setBounds( new Rectangle( 40, 40, 50, 30 ) );
>>>>>> node2.setBackgroundColor( ColorConstants.blue );
>>>>>> node2.setOutline( false );
>>>>>> node2.setBounds( new Rectangle( 100, 140, 50, 30 ) );
>>>>>>
>>>>>> PolylineConnection conn = new PolylineConnection();
>>>>>> conn.setSourceAnchor( new ChopboxAnchor( node2 ) );
>>>>>> conn.setTargetAnchor( new ChopboxAnchor( node1 ) );
>>>>>> connectionPanel.add( node1 );
>>>>>> connectionPanel.add( node2 );
>>>>>> connectionPanel.add( conn );
>>>>>>
>>>>>> canvas.setContents( connectionPanel );
>>>>>>
>>>>>> shell.open();
>>>>>> while( !shell.isDisposed() )
>>>>>> while( !d.readAndDispatch() )
>>>>>> d.sleep();
>>>>>>
>>>>>> }//main()
>>>>>>
>>>>>>
>>>>
>
>
Re: Connections start one pixel away from node [message #201853 is a reply to message #201827] Thu, 03 November 2005 21:36 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
I tried double, didn't make a difference because the specified coordinates
are correct.
I don't use antialiasing, so it wouldn't be an issue with that either.

"CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
news:dkds68$b91$2@news.eclipse.org...
> Perhaps its an antialiasing issue. Did you try turning it on and off?
>
> I figured a double may fix it, that is why i called it a compromise.
> Because it uses a smaller primitive type IIRC.
>
> CL
>
>
> Felix L J Mayer wrote:
>> This actually seems to be an SWT problem. I stepped through the code and
>> looked and the y coordinate for different angles, and it was always the
>> same (y=139). But with the proper angle as described below, the line
>> starts with a one-pixel gap.
>>
>> So it looks like the SWT problem that Randy Hudson mentioned earlier
>> still exists.
>>
>> A possible workaround is to remove some lines in
>> ChopboxAnchor.getLocation(Point):
>> r.translate(-1, -1);
>> r.resize(1, 1);
>>
>> The effect that they have is that connections on the west and north side
>> start right outside of the node, whereas connections on the east and
>> south start just inside the node. So maybe the problem exists on the
>> target side on the connection as well, but cannot be seen. Anyway, for
>> consistency either those 2 lines should be removed or the second one
>> should become
>> r.resize(2, 2);
>>
>>
>> "Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
>> news:dkdfp8$pi1$1@news.eclipse.org...
>>
>>>I don't think it's a compromise, the code looks fine to me. The only
>>>thing I would think of changing is to use double instead of float to
>>>ensure we don't get rounding issues.
>>>
>>>And doing x-=-1 does not work because:
>>>- This happens only at the source end of the connection, not the target
>>>end. The ChopboxAnchor does not know which end it is.
>>>- This also happens not on the west side, but on the north and west sides
>>>depending on the angle of the connection. For example, beyond an angle of
>>>45 degrees clockwise from the vertical the gap vanishes. It also vanishes
>>>beyond an angle of 135 degrees from the vertical going counterclockwise.
>>>
>>>So we would have to do an x+=1 and y+=1 if those conditions are met.
>>>
>>>"CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
>>>news:dkb5sl$s8g$2@news.eclipse.org...
>>>
>>>>More likely its a compromise. But I bet if you improve the Chopbox
>>>>algorithm it would be welcomed. Seems as if its only the 'West' side of
>>>>the figure that has the problem. you can do x -=1; and reap all the
>>>>accolades :D
>>>>
>>>>
>>>>CL
>>>>
>>>>
>>>>Felix L J Mayer wrote:
>>>>
>>>>>I just think it's a bug ;)
>>>>>
>>>>>"CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in
>>>>>message news:dkaos8$9ra$3@news.eclipse.org...
>>>>>
>>>>>
>>>>>>This would be a factor of the anchor behavior. Have you exaimed
>>>>>>closely the behavior of the ChopBox anchor? it does blow up the size
>>>>>>of the bounding box a bit. Maybe you want a different more accurate
>>>>>>way to place the point?
>>>>>>
>>>>>>
>>>>>>CL
>>>>>>
>>>>>>Felix L J Mayer wrote:
>>>>>>
>>>>>>
>>>>>>>I posted about earlier, but I wanted summarize things again.
>>>>>>>Below is a snippet of code that shows the problem. In the other post,
>>>>>>>I also attached a small GEF project that shows the problem
>>>>>>>interactively. This is what's happening:
>>>>>>>
>>>>>>>- There is a 1-pixel gap between the source side of a connection its
>>>>>>>node; on the target side everything is okay.
>>>>>>>- The 1-pixel gap happens only if the connection leaves the source
>>>>>>>node at an angle between 7.30 and 1.30 on a clock (i.e. only in the
>>>>>>>"evening"). At other angles the gap vanishes.
>>>>>>>
>>>>>>> public static void main( String[] args ) {
>>>>>>>
>>>>>>> Display d = new Display();
>>>>>>> Shell shell = new Shell( d );
>>>>>>> shell.setLayout( new FillLayout() );
>>>>>>> FigureCanvas canvas = new FigureCanvas( shell );
>>>>>>>
>>>>>>> Figure connectionPanel = new Figure();
>>>>>>>
>>>>>>> RectangleFigure node1 = new RectangleFigure(), node2 = new
>>>>>>> RectangleFigure();
>>>>>>> node1.setBackgroundColor( ColorConstants.red );
>>>>>>> node1.setOutline( false );
>>>>>>> node1.setBounds( new Rectangle( 40, 40, 50, 30 ) );
>>>>>>> node2.setBackgroundColor( ColorConstants.blue );
>>>>>>> node2.setOutline( false );
>>>>>>> node2.setBounds( new Rectangle( 100, 140, 50, 30 ) );
>>>>>>>
>>>>>>> PolylineConnection conn = new PolylineConnection();
>>>>>>> conn.setSourceAnchor( new ChopboxAnchor( node2 ) );
>>>>>>> conn.setTargetAnchor( new ChopboxAnchor( node1 ) );
>>>>>>> connectionPanel.add( node1 );
>>>>>>> connectionPanel.add( node2 );
>>>>>>> connectionPanel.add( conn );
>>>>>>>
>>>>>>> canvas.setContents( connectionPanel );
>>>>>>>
>>>>>>> shell.open();
>>>>>>> while( !shell.isDisposed() )
>>>>>>> while( !d.readAndDispatch() )
>>>>>>> d.sleep();
>>>>>>>
>>>>>>> }//main()
>>>>>>>
>>>>>>>
>>>>>
>>
Re: Connections start one pixel away from node [message #202026 is a reply to message #201811] Mon, 07 November 2005 00:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Guys, this sounds like a regression in an SWT bug that was fixed a while
back. When I tested this problem I thought it was working properly in 3.1.
Does anyone know when this snippet started failing? that would be useful to
the SWT team. If you force advanced graphics by setting antialias to OFF,
there is no problem. Of course this is not a recommended workaround.

Change code to read:

PolylineConnection conn = new PolylineConnection() {
public void paintFigure(Graphics graphics) {
graphics.setAntialias(SWT.OFF);
super.paintFigure(graphics);
}
};


"Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
news:dkdkus$18g$1@news.eclipse.org...
> This actually seems to be an SWT problem. I stepped through the code and
> looked and the y coordinate for different angles, and it was always the
> same (y=139). But with the proper angle as described below, the line
> starts with a one-pixel gap.
>
> So it looks like the SWT problem that Randy Hudson mentioned earlier still
> exists.
>
> A possible workaround is to remove some lines in
> ChopboxAnchor.getLocation(Point):
> r.translate(-1, -1);
> r.resize(1, 1);
>
> The effect that they have is that connections on the west and north side
> start right outside of the node, whereas connections on the east and south
> start just inside the node. So maybe the problem exists on the target side
> on the connection as well, but cannot be seen. Anyway, for consistency
> either those 2 lines should be removed or the second one should become
> r.resize(2, 2);
>
>
> "Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
> news:dkdfp8$pi1$1@news.eclipse.org...
>>I don't think it's a compromise, the code looks fine to me. The only thing
>>I would think of changing is to use double instead of float to ensure we
>>don't get rounding issues.
>>
>> And doing x-=-1 does not work because:
>> - This happens only at the source end of the connection, not the target
>> end. The ChopboxAnchor does not know which end it is.
>> - This also happens not on the west side, but on the north and west sides
>> depending on the angle of the connection. For example, beyond an angle of
>> 45 degrees clockwise from the vertical the gap vanishes. It also vanishes
>> beyond an angle of 135 degrees from the vertical going counterclockwise.
>>
>> So we would have to do an x+=1 and y+=1 if those conditions are met.
>>
>> "CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in message
>> news:dkb5sl$s8g$2@news.eclipse.org...
>>> More likely its a compromise. But I bet if you improve the Chopbox
>>> algorithm it would be welcomed. Seems as if its only the 'West' side of
>>> the figure that has the problem. you can do x -=1; and reap all the
>>> accolades :D
>>>
>>>
>>> CL
>>>
>>>
>>> Felix L J Mayer wrote:
>>>> I just think it's a bug ;)
>>>>
>>>> "CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in
>>>> message news:dkaos8$9ra$3@news.eclipse.org...
>>>>
>>>>>This would be a factor of the anchor behavior. Have you exaimed
>>>>>closely the behavior of the ChopBox anchor? it does blow up the size
>>>>>of the bounding box a bit. Maybe you want a different more accurate
>>>>>way to place the point?
>>>>>
>>>>>
>>>>>CL
>>>>>
>>>>>Felix L J Mayer wrote:
>>>>>
>>>>>>I posted about earlier, but I wanted summarize things again.
>>>>>>Below is a snippet of code that shows the problem. In the other post,
>>>>>>I also attached a small GEF project that shows the problem
>>>>>>interactively. This is what's happening:
>>>>>>
>>>>>>- There is a 1-pixel gap between the source side of a connection its
>>>>>>node; on the target side everything is okay.
>>>>>>- The 1-pixel gap happens only if the connection leaves the source
>>>>>>node at an angle between 7.30 and 1.30 on a clock (i.e. only in the
>>>>>>"evening"). At other angles the gap vanishes.
>>>>>>
>>>>>> public static void main( String[] args ) {
>>>>>>
>>>>>> Display d = new Display();
>>>>>> Shell shell = new Shell( d );
>>>>>> shell.setLayout( new FillLayout() );
>>>>>> FigureCanvas canvas = new FigureCanvas( shell );
>>>>>>
>>>>>> Figure connectionPanel = new Figure();
>>>>>>
>>>>>> RectangleFigure node1 = new RectangleFigure(), node2 = new
>>>>>> RectangleFigure();
>>>>>> node1.setBackgroundColor( ColorConstants.red );
>>>>>> node1.setOutline( false );
>>>>>> node1.setBounds( new Rectangle( 40, 40, 50, 30 ) );
>>>>>> node2.setBackgroundColor( ColorConstants.blue );
>>>>>> node2.setOutline( false );
>>>>>> node2.setBounds( new Rectangle( 100, 140, 50, 30 ) );
>>>>>>
>>>>>> PolylineConnection conn = new PolylineConnection();
>>>>>> conn.setSourceAnchor( new ChopboxAnchor( node2 ) );
>>>>>> conn.setTargetAnchor( new ChopboxAnchor( node1 ) );
>>>>>> connectionPanel.add( node1 );
>>>>>> connectionPanel.add( node2 );
>>>>>> connectionPanel.add( conn );
>>>>>>
>>>>>> canvas.setContents( connectionPanel );
>>>>>>
>>>>>> shell.open();
>>>>>> while( !shell.isDisposed() )
>>>>>> while( !d.readAndDispatch() )
>>>>>> d.sleep();
>>>>>>
>>>>>> }//main()
>>>>>>
>>>>>>
>>>>
>>
>
>
Re: Connections start one pixel away from node [message #202252 is a reply to message #202026] Mon, 07 November 2005 22:12 Go to previous message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
I think I saw it failing in 3.1.

"Randy Hudson" <none@us.ibm.com> wrote in message
news:dkm80b$a3u$1@news.eclipse.org...
> Guys, this sounds like a regression in an SWT bug that was fixed a while
> back. When I tested this problem I thought it was working properly in 3.1.
> Does anyone know when this snippet started failing? that would be useful
> to the SWT team. If you force advanced graphics by setting antialias to
> OFF, there is no problem. Of course this is not a recommended workaround.
>
> Change code to read:
>
> PolylineConnection conn = new PolylineConnection() {
> public void paintFigure(Graphics graphics) {
> graphics.setAntialias(SWT.OFF);
> super.paintFigure(graphics);
> }
> };
>
>
> "Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
> news:dkdkus$18g$1@news.eclipse.org...
>> This actually seems to be an SWT problem. I stepped through the code and
>> looked and the y coordinate for different angles, and it was always the
>> same (y=139). But with the proper angle as described below, the line
>> starts with a one-pixel gap.
>>
>> So it looks like the SWT problem that Randy Hudson mentioned earlier
>> still exists.
>>
>> A possible workaround is to remove some lines in
>> ChopboxAnchor.getLocation(Point):
>> r.translate(-1, -1);
>> r.resize(1, 1);
>>
>> The effect that they have is that connections on the west and north side
>> start right outside of the node, whereas connections on the east and
>> south start just inside the node. So maybe the problem exists on the
>> target side on the connection as well, but cannot be seen. Anyway, for
>> consistency either those 2 lines should be removed or the second one
>> should become
>> r.resize(2, 2);
>>
>>
>> "Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
>> news:dkdfp8$pi1$1@news.eclipse.org...
>>>I don't think it's a compromise, the code looks fine to me. The only
>>>thing I would think of changing is to use double instead of float to
>>>ensure we don't get rounding issues.
>>>
>>> And doing x-=-1 does not work because:
>>> - This happens only at the source end of the connection, not the target
>>> end. The ChopboxAnchor does not know which end it is.
>>> - This also happens not on the west side, but on the north and west
>>> sides depending on the angle of the connection. For example, beyond an
>>> angle of 45 degrees clockwise from the vertical the gap vanishes. It
>>> also vanishes beyond an angle of 135 degrees from the vertical going
>>> counterclockwise.
>>>
>>> So we would have to do an x+=1 and y+=1 if those conditions are met.
>>>
>>> "CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in
>>> message news:dkb5sl$s8g$2@news.eclipse.org...
>>>> More likely its a compromise. But I bet if you improve the Chopbox
>>>> algorithm it would be welcomed. Seems as if its only the 'West' side
>>>> of the figure that has the problem. you can do x -=1; and reap all the
>>>> accolades :D
>>>>
>>>>
>>>> CL
>>>>
>>>>
>>>> Felix L J Mayer wrote:
>>>>> I just think it's a bug ;)
>>>>>
>>>>> "CL [dnoyeb] Gilbert" <Lamont_Gilbert@rigidsoftware.com> wrote in
>>>>> message news:dkaos8$9ra$3@news.eclipse.org...
>>>>>
>>>>>>This would be a factor of the anchor behavior. Have you exaimed
>>>>>>closely the behavior of the ChopBox anchor? it does blow up the size
>>>>>>of the bounding box a bit. Maybe you want a different more accurate
>>>>>>way to place the point?
>>>>>>
>>>>>>
>>>>>>CL
>>>>>>
>>>>>>Felix L J Mayer wrote:
>>>>>>
>>>>>>>I posted about earlier, but I wanted summarize things again.
>>>>>>>Below is a snippet of code that shows the problem. In the other post,
>>>>>>>I also attached a small GEF project that shows the problem
>>>>>>>interactively. This is what's happening:
>>>>>>>
>>>>>>>- There is a 1-pixel gap between the source side of a connection its
>>>>>>>node; on the target side everything is okay.
>>>>>>>- The 1-pixel gap happens only if the connection leaves the source
>>>>>>>node at an angle between 7.30 and 1.30 on a clock (i.e. only in the
>>>>>>>"evening"). At other angles the gap vanishes.
>>>>>>>
>>>>>>> public static void main( String[] args ) {
>>>>>>>
>>>>>>> Display d = new Display();
>>>>>>> Shell shell = new Shell( d );
>>>>>>> shell.setLayout( new FillLayout() );
>>>>>>> FigureCanvas canvas = new FigureCanvas( shell );
>>>>>>>
>>>>>>> Figure connectionPanel = new Figure();
>>>>>>>
>>>>>>> RectangleFigure node1 = new RectangleFigure(), node2 = new
>>>>>>> RectangleFigure();
>>>>>>> node1.setBackgroundColor( ColorConstants.red );
>>>>>>> node1.setOutline( false );
>>>>>>> node1.setBounds( new Rectangle( 40, 40, 50, 30 ) );
>>>>>>> node2.setBackgroundColor( ColorConstants.blue );
>>>>>>> node2.setOutline( false );
>>>>>>> node2.setBounds( new Rectangle( 100, 140, 50, 30 ) );
>>>>>>>
>>>>>>> PolylineConnection conn = new PolylineConnection();
>>>>>>> conn.setSourceAnchor( new ChopboxAnchor( node2 ) );
>>>>>>> conn.setTargetAnchor( new ChopboxAnchor( node1 ) );
>>>>>>> connectionPanel.add( node1 );
>>>>>>> connectionPanel.add( node2 );
>>>>>>> connectionPanel.add( conn );
>>>>>>>
>>>>>>> canvas.setContents( connectionPanel );
>>>>>>>
>>>>>>> shell.open();
>>>>>>> while( !shell.isDisposed() )
>>>>>>> while( !d.readAndDispatch() )
>>>>>>> d.sleep();
>>>>>>>
>>>>>>> }//main()
>>>>>>>
>>>>>>>
>>>>>
>>>
>>
>>
>
>
Previous Topic:setMinimumSize() does nothing
Next Topic:Move connection label
Goto Forum:
  


Current Time: Fri Mar 29 06:04:03 GMT 2024

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

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

Back to the top