[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: SlidableAnchor and custom polygon as NodeFigure

Alex Boyko schrieb:
Another option is approximate the figure with a polyline and let the regular Slidableanchor do all the work for you.
This is the best option in my opinion!


Cheers,
Alex



I've just overridden this one method NodeFigure.getPolygonPoints() in the corresponding EditPart and it works fine.


/** * @generated NOT */ protected NodeFigure createNodePlate() { final DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(getMapMode().DPtoLP(40),getMapMode().DPtoLP(40)){

 @Override
 public PointList getPolygonPoints(){

  //just some way to get the polygon points
  Rectangle bounds = new Rectangle(getBounds());
  PointList ptList = new PointList();
  int[] scalePoints = ((EventFigure)getPrimaryShape()).scalePointList();
  for (int i=0;i<scalePoints.length;i+=2){
    ptList.addPoint(scalePoints[i]+bounds.x, scalePoints[i+1]+bounds.y);
  }						
  ptList.addPoint(scalePoints[0]+bounds.x, scalePoints[1]+bounds.y);		
  return ptList;
 }

 };
 return result;
}

hope it helps
Frank