Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r1334 - trunk/src/org/tigris/gef: base presentation

gef
Discussion topic

Back to topic list

svn commit: r1334 - trunk/src/org/tigris/gef: base presentation

Author bobtarling
Full name Bob Tarling
Date 2011-05-23 03:30:22 PDT
Message Author: bobtarling
Date: 2011-05-23 03:30:22-0700
New Revision: 1334

Modified:
   trunk/src/org/tigris​/gef/base/SelectionR​esize.java
   trunk/src/org/tigris​/gef/presentation/Fi​gNode.java

Log:
Attach connectors to bounds of their node

Modified: trunk/src/org/tigris​/gef/base/SelectionR​esize.java
Url: http://gef.tigris.or​g/source/browse/gef/​trunk/src/org/tigris​/gef/base/SelectionR​esize.java?view=diff​&pathrev=1334​&r1=1333&r2=133​4
====================​====================​====================​==================
--- trunk/src/org/tigris​/gef/base/SelectionR​esize.java (original)
+++ trunk/src/org/tigris​/gef/base/SelectionR​esize.java 2011-05-23 03:30:22-0700
@@ -30,11 +30,15 @@
 
 import java.awt.Dimension;
 import java.awt.Graphics;
+import java.awt.Point;
 import java.awt.Rectangle;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.l​ogging.LogFactory;
+
+import org.tigris.gef.prese​ntation.Connector;
 import org.tigris.gef.prese​ntation.Fig;
+import org.tigris.gef.prese​ntation.FigNode;
 import org.tigris.gef.prese​ntation.Handle;
 
 /**
@@ -191,67 +195,81 @@
         Dimension minSize = fig.getMinimumSize();
         int minWidth = minSize.width, minHeight = minSize.height;
         switch (hand.index) {
- case -1:
- fig.translate(anX - mX, anY - mY);
- return;
- case Handle.NORTHWEST:
- newWidth = x + w - mX;
- newWidth = (newWidth < minWidth) ? minWidth : newWidth;
- newHeight = y + h - mY;
- newHeight = (newHeight < minHeight) ? minHeight : newHeight;
- newX = x + w - newWidth;
- newY = y + h - newHeight;
- fig.setHandleBox(newX, newY, newWidth, newHeight);
- if ((newX + newWidth) != (x + w)) {
- newX += (newX + newWidth) - (x + w);
- }
- if ((newY + newHeight) != (y + h)) {
- newY += (newY + newHeight) - (y + h);
- }
- fig.setHandleBox(newX, newY, newWidth, newHeight);
- return;
- case Handle.NORTH:
- break;
- case Handle.NORTHEAST:
- newWidth = mX - x;
- newWidth = (newWidth < minWidth) ? minWidth : newWidth;
- newHeight = y + h - mY;
- newHeight = (newHeight < minHeight) ? minHeight : newHeight;
- newY = y + h - newHeight;
- fig.setHandleBox(newX, newY, newWidth, newHeight);
- if ((newY + newHeight) != (y + h)) {
- newY += (newY + newHeight) - (y + h);
- }
- fig.setHandleBox(newX, newY, newWidth, newHeight);
- break;
- case Handle.WEST:
- break;
- case Handle.EAST:
- break;
- case Handle.SOUTHWEST:
- newWidth = x + w - mX;
- newWidth = (newWidth < minWidth) ? minWidth : newWidth;
- newHeight = mY - y;
- newHeight = (newHeight < minHeight) ? minHeight : newHeight;
- newX = x + w - newWidth;
- fig.setHandleBox(newX, newY, newWidth, newHeight);
- if ((newX + newWidth) != (x + w)) {
- newX += (newX + newWidth) - (x + w);
+ case -1:
+ fig.translate(anX - mX, anY - mY);
+ return;
+ case Handle.NORTHWEST:
+ newWidth = x + w - mX;
+ newWidth = (newWidth < minWidth) ? minWidth : newWidth;
+ newHeight = y + h - mY;
+ newHeight = (newHeight < minHeight) ? minHeight : newHeight;
+ newX = x + w - newWidth;
+ newY = y + h - newHeight;
+ fig.setHandleBox(newX, newY, newWidth, newHeight);
+ if ((newX + newWidth) != (x + w)) {
+ newX += (newX + newWidth) - (x + w);
+ }
+ if ((newY + newHeight) != (y + h)) {
+ newY += (newY + newHeight) - (y + h);
+ }
+ fig.setHandleBox(newX, newY, newWidth, newHeight);
+ return;
+ case Handle.NORTH:
+ break;
+ case Handle.NORTHEAST:
+ newWidth = mX - x;
+ newWidth = (newWidth < minWidth) ? minWidth : newWidth;
+ newHeight = y + h - mY;
+ newHeight = (newHeight < minHeight) ? minHeight : newHeight;
+ newY = y + h - newHeight;
+ fig.setHandleBox(newX, newY, newWidth, newHeight);
+ if ((newY + newHeight) != (y + h)) {
+ newY += (newY + newHeight) - (y + h);
+ }
+ fig.setHandleBox(newX, newY, newWidth, newHeight);
+ break;
+ case Handle.WEST:
+ break;
+ case Handle.EAST:
+ break;
+ case Handle.SOUTHWEST:
+ newWidth = x + w - mX;
+ newWidth = (newWidth < minWidth) ? minWidth : newWidth;
+ newHeight = mY - y;
+ newHeight = (newHeight < minHeight) ? minHeight : newHeight;
+ newX = x + w - newWidth;
+ fig.setHandleBox(newX, newY, newWidth, newHeight);
+ if ((newX + newWidth) != (x + w)) {
+ newX += (newX + newWidth) - (x + w);
+ }
+ fig.setHandleBox(newX, newY, newWidth, newHeight);
+ break;
+ case Handle.SOUTH:
+ break;
+ case Handle.SOUTHEAST:
+ newWidth = mX - x;
+ newWidth = (newWidth < minWidth) ? minWidth : newWidth;
+ newHeight = mY - y;
+ newHeight = (newHeight < minHeight) ? minHeight : newHeight;
+ fig.setHandleBox(newX, newY, newWidth, newHeight);
+ break;
+ default:
+ log.error("invalid handle number for resizing fig");
+ return;
+ }
+ if (fig instanceof FigNode) {
+ FigNode figNode = (FigNode) fig;
+ for (Connector connector : figNode.getConnectors()) {
+
+ Fig connectorFig = (Fig) connector;
+ Point centre = new Point(
+ connectorFig.getX() + connectorFig.getHalfWidth(),
+ connectorFig.getY() + connectorFig.getHalfHeight());
+ Point attachPoint = figNode.getClosestPo​int(centre);
+ connectorFig.setLocation(
+ attachPoint.x - connectorFig.getHalfWidth(),
+ attachPoint.y - connectorFig.getHalfHeight());
             }
- fig.setHandleBox(newX, newY, newWidth, newHeight);
- break;
- case Handle.SOUTH:
- break;
- case Handle.SOUTHEAST:
- newWidth = mX - x;
- newWidth = (newWidth < minWidth) ? minWidth : newWidth;
- newHeight = mY - y;
- newHeight = (newHeight < minHeight) ? minHeight : newHeight;
- fig.setHandleBox(newX, newY, newWidth, newHeight);
- break;
- default:
- log.error("invalid handle number for resizing fig");
- break;
         }
     }
 

Modified: trunk/src/org/tigris​/gef/presentation/Fi​gNode.java
Url: http://gef.tigris.or​g/source/browse/gef/​trunk/src/org/tigris​/gef/presentation/Fi​gNode.java?view=diff​&pathrev=1334​&r1=1333&r2=133​4
====================​====================​====================​==================
--- trunk/src/org/tigris​/gef/presentation/Fi​gNode.java (original)
+++ trunk/src/org/tigris​/gef/presentation/Fi​gNode.java 2011-05-23 03:30:22-0700
@@ -30,6 +30,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.l​ogging.LogFactory;
+
 import org.tigris.gef.base.Globals;
 import org.tigris.gef.di.GraphEdge;
 import org.tigris.gef.di.GraphNode;
@@ -214,6 +215,31 @@
     public void addFigEdge(FigEdge fe) {
         figEdges.add(fe);
     }
+
+ /**
+ * Add a new connector to this node
+ * @param connector the connector to add.
+ */
+ public void addConnector(Connector connector) {
+ connectors.add(connector);
+ Fig connectorFig = (Fig) connector;
+ Point centre = new Point(
+ connectorFig.getX() + connectorFig.getHalfWidth(),
+ connectorFig.getY() + connectorFig.getHalfHeight());
+ Point attachPoint = getClosestPoint(centre);
+ connectorFig.setLocation(
+ attachPoint.x - connectorFig.getHalfWidth(),
+ attachPoint.y - connectorFig.getHalfHeight());
+ connector.setGraphNode(this);
+ }
+
+ /**
+ * Remove a connector from this node
+ * @param connector the connector to remove.
+ */
+ public void removeConnector(Connector connector) {
+ connectors.remove(connector);
+ }
 
     /**
      * removes a FigEdge from the list of them that need to be rerouted when

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r1334 - trunk/src/org/tigris/gef: base presentation bobtarling Bob Tarling 2011-05-23 03:30:22 PDT
Messages per page: