Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] Figure children appearing over the parent

hi!!
i am new to GEF. i have read the GEF description in the wiki page and
tried to make my own editor. its like a class editor, but the
attributes can be lists and maps as well and i have to show all their
children in a tree form. i have been able to do that but the only
problem is the child figures appear over their parent's label. for ex
if i have a list parent(list1) and its two children (child1 and
child2) the figure appears as given below :
    child2
    child1
  list1
what i want is something like this
  list1
    child1
    child2
i am using the same editpart and figure classes for parent as well as
children, as  the children can be a list or map as well.
i am also enclosing some relevant code of figureclass
(AttributeFigure) and editPart (AttributeEditPart).

public class AttributeFigure extends Figure{
	.....
         .....
         public AttributeFigure() {
		super();
		
		//Layout
		ToolbarLayout layout = new                
ToolbarLayout(ToolbarLayout.VERTICAL);
		layout.setStretchMinorAxis(true);
		setLayoutManager(layout);
		
		//Label
		label = new Label("");
		add(label);
		
	  	//Border
		setBorder(new CompoundBorder(new ShadowBorder(),
				new MyLineBorder(ColorConstants.white)));
		
	}
 ....
....
}

public class AttributeEditPart extends AbstractGraphicalEditPart
	implements PropertyChangeListener{
....
....
   public IFigure createFigure() {
		AttributeFigure figure = new AttributeFigure();
		anchor = new ChopboxAnchor(figure);
		return figure;
	}

	public void refreshVisuals() {
		AttributeFigure figure = (AttributeFigure) getFigure();
		AttributeModel model;
		model = (AttributeModel) getModel();
		figure.setSignature(model.getTypeNum(), model.getType(), model
				.getIdentifier());
	}
        public List getModelChildren() {
		List children = ((AttributeModel) getModel()).getChildren();
		if (children == null)
			return new ArrayList();
		return children;
	}
        public void propertyChange(PropertyChangeEvent ev) {
		if (ev.getPropertyName().equals(       
AttributeModel.PROPERTY_SOURCE_CONNECTIONS_CHANGED))
			refreshSourceConnections();
		else if (ev.getPropertyName().equals(
AttributeModel.PROPERTY_TARGET_CONNECTIONS_CHANGED))
			refreshTargetConnections();
		else if (ev.getPropertyName().equals(
				AttributeModel.PROPERTY_SIGNATURE_CHANGED))
			refreshVisuals();
		else if (ev.getPropertyName().equals(
				AttributeModel.ID_PROPERTY_CHILD))
			refreshChildren();
		else
			super.propertyChange(ev);
	}
    .........
..........

-- 
thanx and regards,
praveen


Back to the top