Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 158339 Details for
Bug 301995
Support option to set only positive coordinates for children figures in FreeformLayout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
FreeformLayout_positive_coordinates (text/plain), 3.36 KB, created by
Alex Boyko
on 2010-02-05 13:52:55 EST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Alex Boyko
Created:
2010-02-05 13:52:55 EST
Size:
3.36 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.draw2d >Index: src/org/eclipse/draw2d/FreeformLayout.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/FreeformLayout.java,v >retrieving revision 1.7 >diff -u -r1.7 FreeformLayout.java >--- src/org/eclipse/draw2d/FreeformLayout.java 30 Mar 2005 21:27:45 -0000 1.7 >+++ src/org/eclipse/draw2d/FreeformLayout.java 5 Feb 2010 18:51:29 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * 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 >@@ -10,21 +10,95 @@ > *******************************************************************************/ > package org.eclipse.draw2d; > >+import java.util.ListIterator; >+ > import org.eclipse.draw2d.geometry.Point; >+import org.eclipse.draw2d.geometry.Rectangle; > > /** > * A layout for {@link org.eclipse.draw2d.FreeformFigure FreeformFigures}. >+ * Supports option to set only positive (x,y) coordinates for children figures. > */ > public class FreeformLayout > extends XYLayout > { > > /** >+ * Option that forces only positive coordinates to children figures by >+ * setting the layout origin appropriately >+ */ >+private static final int FLAG__POSITIVE_COORDINATES = 1; >+ >+/** >+ * Option flags >+ */ >+private int flags; >+ >+/** >+ * Layout origin point >+ */ >+private Point origin = null; >+ >+/** > * Returns the point (0,0) as the origin. > * @see XYLayout#getOrigin(IFigure) > */ > public Point getOrigin(IFigure figure) { >- return new Point(); >+ if (origin == null) { >+ origin = new Point(); >+ if (isPositiveCoordinates()) { >+ ListIterator children = figure.getChildren().listIterator(); >+ while (children.hasNext()) { >+ IFigure f = (IFigure) children.next(); >+ Rectangle constraint = (Rectangle)getConstraint(f); >+ if (constraint != null) { >+ origin.x = Math.min(origin.x, constraint.x); >+ origin.y = Math.min(origin.y, constraint.y); >+ } >+ } >+ origin.negate(); >+ } >+ } >+ return origin; >+} >+ >+/** >+ * Checks whether the positive coordinates flag is on, e.g positive >+ * coordinates for children are inforced by the layout >+ * >+ * @return <code>boolean</code> >+ * @since 3.2 >+ */ >+public boolean isPositiveCoordinates() { >+ return (flags & FLAG__POSITIVE_COORDINATES) != 0; >+} >+ >+/** >+ * Sets/unsets the positive coordinates flag for true/false parameters >+ * respectively. If option is set to on then layout calculates positive >+ * coordinates for children figures by adjusting the layout origin >+ * accordingly. >+ * >+ * @param positiveCoordinates >+ * @since 3.2 >+ */ >+public void setPositiveCoordinates(boolean positiveCoordinates) { >+ if (positiveCoordinates != isPositiveCoordinates()) { >+ if (positiveCoordinates) { >+ flags |= FLAG__POSITIVE_COORDINATES; >+ } else { >+ flags &= ~FLAG__POSITIVE_COORDINATES; >+ } >+ invalidate(); >+ } >+} >+ >+/** >+ * @see org.eclipse.draw2d.AbstractLayout#invalidate() >+ */ >+public void invalidate() { >+ origin = null; >+ super.invalidate(); > } > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 301995
: 158339