Bug 290531 - DEFAULT_TARGET_ANCHOR (and DEFAULT_SOURCE_ANCHOR) should be made public
Summary: DEFAULT_TARGET_ANCHOR (and DEFAULT_SOURCE_ANCHOR) should be made public
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy GEF (MVC) (show other bugs)
Version: 3.5   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-25 08:53 EDT by Jens Von Pilgrim CLA
Modified: 2009-09-25 08:53 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Von Pilgrim CLA 2009-09-25 08:53:14 EDT
The default anchors used by AbstractConnectionEditPart.getTarget/SourceConnectionAnchor(), i.e.
DEFAULT_TARGET_ANCHOR and DEFAULT_SOURCE_ANCHOR resp., should be made public. As stated in bug #29919  (https://bugs.eclipse.org/29919), these anchors are "only there to let the
developer know that something went wrong". Now, it is impossible to check that if the instance cannot be retrieved. E.g, it is impossible to do something like that in a derived class:

ConnectionAnchor anchor = super.getTargetConnectionAnchor();
if (anchor==DEFAULT_TARGET_ANCHOR) {
    .... // something went wrong
}

Background: I need this for a 3D version of AbstractConnectionEditPart, because in case of 3D (in the GEF3D project) the default anchors must be 3D anchors.  I certainly could copy the original behaviour or getTargetConnectionAnchor() and simply return a DEFAULT_TARGET_ANCHOR_3D instead of a 2D version (which I have to do as a workaround), but I would prefer to copy as little as possible -- and I also think it's a general issue.

Cheers

Jens

BTW: Maybe it would be a good idea to make these default anchors immutable as well, as they could be changed even when they are private. 

Here is an immutable version:

/**
 * ImmutableXYAnchor used for default anchors, all setters are overridden
 * to avoid changing an instance of this class.
 *
 * @author 	Jens von Pilgrim
 * @since 	Sep 25, 2009
 */	
public class ImmutableXYAnchor extends XYAnchor {

	/**
	 * Creates an immutable xy anchor with the given location.
	 * @param i_p
	 */
	public ImmutableXYAnchor(Point i_p) {
		super(i_p);
	}

	/** 
	 * As this class is immutable, this method throws an
	 * {@link UnsupportedOperationException}.
	 * @see org.eclipse.draw2d.XYAnchor#setLocation(org.eclipse.draw2d.geometry.Point)
	 */
	@Override
	public void setLocation(Point i_p) {
		throw new UnsupportedOperationException("Anchor is immutable");
	}

	/** 
	 * As this class is immutable, no events will ever been thrown.
	 * Thus, this method does nothing.
	 * @see org.eclipse.draw2d.ConnectionAnchorBase#addAnchorListener(org.eclipse.draw2d.AnchorListener)
	 */
	@Override
	public void addAnchorListener(AnchorListener i_listener) {
	}
}