Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Geometric Line Resize
Geometric Line Resize [message #1793183] Wed, 01 August 2018 08:05 Go to next message
cenk Mising name is currently offline cenk Mising nameFriend
Messages: 159
Registered: July 2009
Senior Member
Hi,

We are created Line node on Gef5.(Visual is attached) Which drag handler class can be used to resize line. (Which drag class is bind to CircleSegmentHandlePart.class). Have to we create as custom?
  • Attachment: Line.jpg
    (Size: 75.51KB, Downloaded 164 times)
Re: Geometric Line Resize [message #1793280 is a reply to message #1793183] Thu, 02 August 2018 21:20 Go to previous messageGo to next message
cenk Mising name is currently offline cenk Mising nameFriend
Messages: 159
Registered: July 2009
Senior Member
How can I get a support for this issue?
Is there any suggest. This issue is very important for us?
Re: Geometric Line Resize [message #1793354 is a reply to message #1793280] Mon, 06 August 2018 11:06 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
Hi,

you can look up the bindings from the MVC Logo Example. They are specified within the MvcLogoExampleModule: https://github.com/eclipse/gef/blob/master/org.eclipse.gef.mvc.examples.logo/src/org/eclipse/gef/mvc/examples/logo/MvcLogoExampleModule.java#L108

Resizement of bendables can be performed via default ResizePolicy.

Bending (changing/dragging start/end/way points) can be performed via BendConnectionPolicy.

GEF provides some handlers that utilise these policies, e.g. BendFirstAnchorageOnSegmentHandleDragHandler (operates on bend point handles) and ResizeTranslateFirstAnchorageOnHandleDragHandler (operates on multi-selection handles).

Best regards,
Matthias
Re: Geometric Line Resize [message #1793382 is a reply to message #1793354] Tue, 07 August 2018 06:35 Go to previous messageGo to next message
cenk Mising name is currently offline cenk Mising nameFriend
Messages: 159
Registered: July 2009
Senior Member
Ok. But our Visual is Line.It is below

public class GeometricLineVisual extends GeometryNode<Line> {

	public GeometricLineVisual() {
		super(new Line(10, 10, 100, 100));
	}

}





And Part class is below
public class LinePart extends AbstractContentPart<GeometricLineVisual>
		implements ITransformableContentPart<GeometricLineVisual>, IResizableContentPart<GeometricLineVisual>,
		PropertyChangeListener {

	@Override
	protected GeometricLineVisual doCreateVisual() {
		return new GeometricLineVisual();
	}

	@Override
	protected SetMultimap<? extends Object, String> doGetContentAnchorages() {
		// Nothing to anchor to
		return HashMultimap.create();
	}

	@Override
	protected List<? extends Object> doGetContentChildren() {
		// we don't have any children.
		return Collections.emptyList();
	}

	@Override
	protected void doRefreshVisual(GeometricLineVisual visual) {
		// use the IResizableContentPart API to resize the visual

		
		setVisualSize(getContentSize());
		// use the ITransformableContentPart API to position the visual
		setVisualTransform(getContentTransform());

	}

	@Override
	public GeometricLine getContent() {
		return (GeometricLine) super.getContent();
	}

	@Override
	public Dimension getContentSize() {

		return getContent().getBounds().getSize();
	}

	@Override
	public Affine getContentTransform() {
		Rectangle bounds = getContent().getBounds();
		
		return new Affine(new Translate(bounds.getX(), bounds.getY()));
	}

	@Override
	public void propertyChange(PropertyChangeEvent evt) {
		// TODO Auto-generated method stub

		
	}

	@Override
	public void setContentSize(Dimension totalSize) {
		
		getContent().getBounds().setSize(totalSize);

	}

	@Override
	public void setContentTransform(Affine totalTransform) {
		// storing the new position
		Rectangle bounds = getContent().getBounds().getCopy();
		bounds.setX(totalTransform.getTx());
		bounds.setY(totalTransform.getTy());
		getContent().setBounds(bounds);
		
	}

	@Override
	public void setVisualSize(Dimension totalSize) {
		
		IResizableContentPart.super.setVisualSize(totalSize);
		// perform layout pass to apply size
		getVisual().getParent().layout();
	}

}


BendFirstAnchorageOnSegmentHandleDragHandler is support only Connection as visual.

How can I use BendFirstAnchorageOnSegmentHandleDragHandler with our line visual
Re: Geometric Line Resize [message #1793607 is a reply to message #1793382] Sat, 11 August 2018 13:42 Go to previous message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
Hi cenk,

unfortunately, GEF FX Connection is deeply integrated into the default policies and interaction handlers. However, you can at least use TransformPolicy and ResizePolicy to reshape the visual (and update the model thereby), whereas bending will be more complicated (but that also demands for a more complex visual, such as Polyline).

Since you already implement IResizableContentPart and ITransformableContentPart, you should be able to use ResizeTranslateFirstAnchorageOnHandleDragHandler in combination with handles at start and end point (but you could start with the default multi-selection handles in all corners).

However, if you want to attach/detach start/end points, you will need a custom implementation. Maybe you can get inspiration from BendConnectionPolicy, but a simpler solution should be possible for the case of just start and end points.

Best regards,
Matthias
Previous Topic:GEF5 Problem Setting Graph Background
Next Topic:[GEF5] EMF Commands and Undo/Redo
Goto Forum:
  


Current Time: Fri Apr 19 15:48:18 GMT 2024

Powered by FUDForum. Page generated in 0.02621 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top