Home » Eclipse Projects » GEF » Diamond Primitives
|
Re: Diamond Primitives [message #210906 is a reply to message #210890] |
Tue, 07 March 2006 02:42 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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 message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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 Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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>
public DiamondAnchor() {<br>
}<br>
<br>
public DiamondAnchor(IFigure owner){<br>
super(owner);<br>
}<br>
<br>
/*** This function returns the point on which the anchor should
reside.<br>
The anchors will fall only at the four corners of the diamond.
This is fitting with flowchart standards.<br>
In order to determine which point we should allocate as the anchor
point, we will determine which quadrant the <br>
point lies in, and then which is greater: dx, or dy, to decide
which side of the quadrant to place the anchor.<br>
***/ <br>
public Point getLocation(Point reference){ <br>
<br>
// Pixel offset required to get it to look right<br>
int pixelOffset = 2;<br>
<br>
// The four corners of the diamond<br>
Point top, bottom, left, right;<br>
<br>
<b><font color="#000099"> Rectangle r = Rectangle.SINGLETON;<br>
r.setBounds(getOwner().getBounds());</font></b><br >
<br>
// Assign the 4 corners their coordinates<br>
top = new Point(r.x + r.width / 2, r.y);<br>
right = new Point(((r.x + r.width) - pixelOffset), r.y +
r.height/2);<br>
bottom = new Point(((r.x + r.width/2) - pixelOffset), r.y +
r.height);<br>
left = new Point(r.x, r.y + r.height/2);<br>
<br>
<b><font color="#ff0000"> // Process for... processing<br>
r.translate(-1, -1);<br>
r.resize(1, 1);<br>
getOwner().translateToAbsolute(r);</font><br>
</b><br>
float centerX = r.x + 0.5f * r.width;<br>
float centerY = r.y + 0.5f * r.height;<br>
<br>
if (r.isEmpty() || (reference.x == (int)centerX &&
reference.y == (int)centerY)) {<br>
return new Point((int)centerX, (int)centerY); //This
avoids divide-by-zero<br>
}<br>
<br>
// Compute our center<br>
float dx = reference.x - centerX;<br>
float dy = reference.y - centerY;<br>
<br>
/*** Cases for quadrant assignment ***/<br>
// If |y| > |x| then we want top or bottom corner<br>
if(Math.abs(dy) > Math.abs(dx) || Math.abs(dy) ==
Math.abs(dx)){<br>
if(dy < 0 || dy == 0)<br>
{<br>
return top;<br>
}<br>
if(dy > 0){<br>
return bottom;<br>
}<br>
}<br>
if(Math.abs(dy) < Math.abs(dx)){<br>
if(dx < 0 || dx == 0){<br>
return left;<br>
}<br>
if(dx > 0){<br>
return right;<br>
}<br>
}<br>
<br>
// Otherwise... return the center. Something has gone wrong.<br>
return new Point(Math.round(centerX), Math.round(centerY));<br>
}<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"><webmaster@eclipse.org></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>
|
|
|
Goto Forum:
Current Time: Sat Jan 18 08:43:08 GMT 2025
Powered by FUDForum. Page generated in 0.03166 seconds
|