Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Diamond Primitives
Diamond Primitives [message #210890] Mon, 06 March 2006 21:09 Go to next message
Eclipse Webmaster is currently offline Eclipse WebmasterFriend
Messages: 607343
Registered: July 2009
Senior Member
Russel wrote:

I sent this message to the [gef-dev] list to share them, but I'm not
interested in joining the list. Could you forward this on, please? Just
wanted to share, since there aren't enough basic primitives included with
GEF, but as I no longer do GEF development, I'm not interested in being on
the list.

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

I made these classes as part of a flowchart project, and thought they
might be useful as base classes bundled with GEF, since there aren't very
many primitives, and it took longer than it should have to figure out how
to make these.

http://lucision.com/legal/java/Diamond.java
http://lucision.com/legal/java/DiamondAnchor.java
Re: Diamond Primitives [message #210906 is a reply to message #210890] Tue, 07 March 2006 02:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: uniera.gmail.com

Good, Thanks

Eclipse WebMaster (Denis Roy) wrote:
> Russel wrote:
>
> I sent this message to the [gef-dev] list to share them, but I'm not
> interested in joining the list. Could you forward this on, please?
> Just wanted to share, since there aren't enough basic primitives
> included with GEF, but as I no longer do GEF development, I'm not
> interested in being on the list.
>
> -------------------------------
>
> I made these classes as part of a flowchart project, and thought they
> might be useful as base classes bundled with GEF, since there aren't
> very many primitives, and it took longer than it should have to figure
> out how to make these.
>
> http://lucision.com/legal/java/Diamond.java
> http://lucision.com/legal/java/DiamondAnchor.java
>
>
Re: Diamond Primitives [message #210982 is a reply to message #210890] Tue, 07 March 2006 17:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

For legal reasons, we can not accept any contribution that has not been
uploaded to Eclipse.org. Attaching the contributions to a newsgroup message
(or bugzilla) would suffice, but even then we will have to perform "due
dilligence" to verify the author, etc.

"Eclipse WebMaster (Denis Roy)" <webmaster@eclipse.org> wrote in message
news:fa058b399c6745bb4cbc3b7ba4e5870d$1@www.eclipse.org...
> Russel wrote:
>
> I sent this message to the [gef-dev] list to share them, but I'm not
> interested in joining the list. Could you forward this on, please? Just
> wanted to share, since there aren't enough basic primitives included with
> GEF, but as I no longer do GEF development, I'm not interested in being on
> the list.
>
> -------------------------------
>
> I made these classes as part of a flowchart project, and thought they
> might be useful as base classes bundled with GEF, since there aren't very
> many primitives, and it took longer than it should have to figure out how
> to make these.
>
> http://lucision.com/legal/java/Diamond.java
> http://lucision.com/legal/java/DiamondAnchor.java
>
>
Re: Diamond Primitives [message #211863 is a reply to message #210982] Thu, 16 March 2006 03:47 Go to previous message
Eclipse UserFriend
Originally posted by: uniera.gmail.com

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>I noticed that the red code lines should follow with the blue code
lines immediately?<br>
</tt>
<hr size="2" width="100%"><tt>
<blockquote type="cite">import
org.eclipse.draw2d.AbstractConnectionAnchor;<br>
import org.eclipse.draw2d.IFigure;<br>
import org.eclipse.draw2d.geometry.Point;<br>
import org.eclipse.draw2d.geometry.Rectangle;<br>
<br>
public class DiamondAnchor extends AbstractConnectionAnchor {<br>
<br>
&nbsp;&nbsp; &nbsp;public DiamondAnchor() {<br>
&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;public DiamondAnchor(IFigure owner){<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;super(owner);<br>
&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;/*** This function returns the point on which the anchor should
reside.<br>
&nbsp;&nbsp; &nbsp;The anchors will fall only at the four corners of the diamond.&nbsp;
This is fitting with flowchart standards.<br>
&nbsp;&nbsp;&nbsp; &nbsp;In order to determine which point we should allocate as the anchor
point, we will determine which quadrant the <br>
&nbsp;&nbsp;&nbsp; &nbsp;point lies in, and then which is greater: dx, or dy, to decide
which side of the quadrant to place the anchor.<br>
&nbsp;&nbsp;&nbsp; &nbsp;***/ <br>
&nbsp;&nbsp; &nbsp;public Point getLocation(Point reference){&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// Pixel offset required to get it to look right<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int pixelOffset = 2;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// The four corners of the diamond<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Point top, bottom, left, right;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
<b><font color="#000099">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Rectangle r = Rectangle.SINGLETON;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;r.setBounds(getOwner().getBounds());</font></b><br >
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// Assign the 4 corners their coordinates<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;top = new Point(r.x + r.width / 2, r.y);<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;right = new Point(((r.x + r.width) - pixelOffset), r.y +
r.height/2);<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;bottom = new Point(((r.x + r.width/2) - pixelOffset), r.y +
r.height);<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;left = new Point(r.x, r.y + r.height/2);<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
<b><font color="#ff0000">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// Process for... processing<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;r.translate(-1, -1);<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;r.resize(1, 1);<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;getOwner().translateToAbsolute(r);</font><br>
</b><br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;float centerX = r.x + 0.5f * r.width;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;float centerY = r.y + 0.5f * r.height;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (r.isEmpty() || (reference.x == (int)centerX &amp;&amp;
reference.y == (int)centerY)) {<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return new Point((int)centerX, (int)centerY);&nbsp; //This
avoids divide-by-zero<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// Compute our center<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;float dx = reference.x - centerX;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;float dy = reference.y - centerY;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/*** Cases for quadrant assignment ***/<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// If |y| &gt; |x| then we want top or bottom corner<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(Math.abs(dy) &gt; Math.abs(dx) || Math.abs(dy) ==
Math.abs(dx)){<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(dy &lt; 0 || dy == 0)<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return top;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(dy &gt; 0){<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return bottom;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(Math.abs(dy) &lt; Math.abs(dx)){<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(dx &lt; 0 || dx == 0){<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return left;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(dx &gt; 0){<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return right;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// Otherwise... return the center.&nbsp; Something has gone wrong.<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return new Point(Math.round(centerX), Math.round(centerY));<br>
&nbsp;&nbsp; &nbsp;}<br>
<br>
}<br>
</blockquote>
</tt><br>
<br>
Randy Hudson wrote:
<blockquote cite="middukgm8$b1a$1@eclipse.org" type="cite">
<pre wrap="">For legal reasons, we can not accept any contribution that has not been
uploaded to Eclipse.org. Attaching the contributions to a newsgroup message
(or bugzilla) would suffice, but even then we will have to perform "due
dilligence" to verify the author, etc.

"Eclipse WebMaster (Denis Roy)" <a class="moz-txt-link-rfc2396E" href="mailto:webmaster@eclipse.org">&lt;webmaster@eclipse.org&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:fa058b399c6745bb4cbc3b7ba4e5870d$1@www.eclipse.org">news:fa058b399c6745bb4cbc3b7ba4e5870d$1@www.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Russel wrote:

I sent this message to the [gef-dev] list to share them, but I'm not
interested in joining the list. Could you forward this on, please? Just
wanted to share, since there aren't enough basic primitives included with
GEF, but as I no longer do GEF development, I'm not interested in being on
the list.

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

I made these classes as part of a flowchart project, and thought they
might be useful as base classes bundled with GEF, since there aren't very
many primitives, and it took longer than it should have to figure out how
to make these.

<a class="moz-txt-link-freetext" href="http://lucision.com/legal/java/Diamond.java">http://lucision.com/legal/java/Diamond.java</a>
<a class="moz-txt-link-freetext" href="http://lucision.com/legal/java/DiamondAnchor.java">http://lucision.com/legal/java/DiamondAnchor.java</a>


</pre>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
</body>
</html>
Previous Topic:Contacting rlemaigr
Next Topic:A possibe Bug in draw2d Label
Goto Forum:
  


Current Time: Fri Apr 19 09:00:39 GMT 2024

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

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

Back to the top