Author: bobtarling
Date: 2010-07-19 19:01:24-0700
New Revision: 18539
Added:
trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAcceptEventPoly.java
Modified:
trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java
trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigGravityPoly.java
Log:
Provide specialist gravity for AcceptEventAction so that edges will remain perpendicular when ever possible
Added: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAcceptEventPoly.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAcceptEventPoly.java?view=markup&pathrev=18539
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAcceptEventPoly.java 2010-07-19 19:01:24-0700
@@ -0,0 +1,65 @@
+/* $Id: $
+ *****************************************************************************
+ * Copyright (c) 2009 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bob Tarling
+ *****************************************************************************
+ */
+
+package org.argouml.activity2.diagram;
+
+import java.awt.Color;
+import java.awt.Point;
+import java.awt.Polygon;
+import java.util.List;
+
+import org.tigris.gef.base.Geometry;
+import org.tigris.gef.presentation.FigPoly;
+
+/**
+ * A FigPoly to which edges gravitate to the perimeter instead of the points
+ * @author Bob Tarling
+ *
+ */
+public class FigAcceptEventPoly extends FigGravityPoly {
+
+ FigAcceptEventPoly(int x, int y, int w, int h, Color lineColor, Color fillColor) {
+ super();
+ final int[] xs = new int[6];
+ final int[] ys = new int[6];
+ xs[0] = x; ys[0] = y;
+ xs[1] = x + w; ys[1] = y;
+ xs[2] = x + w; ys[2] = y + h;
+ xs[3] = x; ys[3] = y + h;
+ xs[4] = x + h / 2; ys[4] = y + h / 2;
+ xs[5] = x; ys[5] = y;
+ final Polygon p = new Polygon(xs, ys, 6);
+ setPolygon(p);
+ }
+
+ FigAcceptEventPoly(Polygon p) {
+ super(p);
+ }
+
+ @Override
+ public Point getClosestPoint(Point anotherPt) {
+ if (anotherPt.x < getX() && anotherPt.y >= getY() && anotherPt.y < getY() + getHeight()) {
+ if (anotherPt.y < getY() + getHeight() / 2) {
+ return new Point(getX() + (anotherPt.y - getY()), anotherPt.y);
+ } else {
+ return new Point(getX() + ((getY() + getHeight()) - anotherPt.y), anotherPt.y);
+ }
+ } else {
+ return super.getClosestPoint(anotherPt);
+ }
+ }
+
+ public List getGravityPoints() {
+ return null;
+ }
+}
Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java?view=diff&pathrev=18539&r1=18538&r2=18539
==============================================================================
--- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java (original)
+++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java 2010-07-19 19:01:24-0700
@@ -71,7 +71,7 @@
xs[4] = X0 + HEIGHT / 2; ys[4] = Y0 + HEIGHT / 2;
xs[5] = X0; ys[5] = Y0;
final Polygon p = new Polygon(xs, ys, 6);
- final FigGravityPoly polyFig = new FigGravityPoly(p);
+ final FigGravityPoly polyFig = new FigAcceptEventPoly(X0, Y0, WIDTH, HEIGHT, LINE_COLOR, FILL_COLOR);
// final FigPoly polyFig = new FigPoly();
// polyFig.setPolygon(p);
return polyFig;
Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigGravityPoly.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigGravityPoly.java?view=diff&pathrev=18539&r1=18538&r2=18539
==============================================================================
--- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigGravityPoly.java (original)
+++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigGravityPoly.java 2010-07-19 19:01:24-0700
@@ -21,12 +21,16 @@
import org.tigris.gef.presentation.FigPoly;
/**
- * A FigPoly to which
+ * A FigPoly to which edges gravitate to the perimeter instead of the points
* @author Bob Tarling
*
*/
public class FigGravityPoly extends FigPoly {
+ FigGravityPoly() {
+ super();
+ }
+
FigGravityPoly(Polygon p) {
super();
setPolygon(p);
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2635472
To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.