Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Special border problem: Problems detecting when a figure goes outside the screen.
Special border problem: Problems detecting when a figure goes outside the screen. [message #221165] Thu, 10 August 2006 08:30
Eclipse UserFriend
Originally posted by: mateu.yabar.justinmind.com

Hi to everyone,

I have a problem which I don't know how to solve. My "situation" is the
following:
I have created a "special" border for an editPart. I wanted this border to
be drawn in a layer on top of the figures. My solution to it has been to add
a Rectangle in the FEEDBACK_LAYER in the funcion paint. I attach the source
code of the paint funcion at the end of this post.
As this border is not painted inside the graphics of the figure (which has
the border) I need to delete the border myself so I have reimplemented
removeNotify() to delete the border.
All works properly except for one situation. After the border is drawn, if
the figure containing this border is moved outside the viewer (you need to
use the scrollbars to see it) the border is not deleted. Anyone knows how I
can control when a figure goes from inside to outside the viewer?

I have also attached 2 screenshots describing my problem.

Thanks to all


------source Code------------
public void paint(IFigure figure, Graphics graphics, Insets insets) {
Rectangle bounds=new Rectangle(figure.getBounds());
if (oldBounds == null || !oldBounds.equals(bounds)) {
if(oldBounds!=null)
removePaint();
oldBounds=bounds;
layer = (Layer) LayerManager.Helper.find(editPart.getParent())
.getLayer(LayerConstants.FEEDBACK_LAYER);

panel= new ZonesTitleTransparentPanel();
panel.setTransparentFill(75);
panel.setOpaque(true);
panel.setBackgroundColor(ColorConstants.lightBlue);
panel.setBorderColor(ColorConstants.blue);

GridLayout layout=new GridLayout();
layout.marginHeight=0;
layout.marginWidth=0;

panel.setLayoutManager(layout);
Label label=new Label(text);
panel.add(label);

layout.setConstraint(label, new GridData(GridData.GRAB_HORIZONTAL |
GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_CENTER |
GridData.VERTICAL_ALIGN_CENTER));
layer.add(panel);

Dimension textExtents = new
Dimension(FigureUtilities.getTextExtents(text, getFont(label)));
textExtents.height+=verticalSpacing;

textExtents.width+=horizonatlSpacing;
if(textExtents.width < minHorizontalTitleSize)
textExtents.width=minHorizontalTitleSize;

Rectangle panelBounds=new Rectangle(figure.getBounds());
panelBounds.y-=textExtents.height;
panelBounds.x+=panelBounds.width-textExtents.width;
panelBounds.width=textExtents.width;
panelBounds.height=textExtents.height;
panel.setBounds(panelBounds);

polyLine=new TransparentPolyLine();
PointList pointList=new PointList();

pointList.addPoint(bounds.x+bounds.width, bounds.y);
pointList.addPoint(bounds.x+bounds.width, bounds.y+bounds.height);
pointList.addPoint(bounds.x, bounds.y+bounds.height);
pointList.addPoint(bounds.x, bounds.y);
pointList.addPoint(panelBounds.x, bounds.y);
polyLine.setPoints(pointList);
polyLine.setLineStyle(Graphics.LINE_DASH);
polyLine.setForegroundColor(ColorConstants.blue);
layer.add(polyLine);
}
}



  • Attachment: post1.gif
    (Size: 2.43KB, Downloaded 168 times)
  • Attachment: post2.gif
    (Size: 3.01KB, Downloaded 154 times)
Previous Topic:How to draw the Draw2D diagrams for plain multi-page editors?
Next Topic:EContentAdapter behaviour ?
Goto Forum:
  


Current Time: Wed Sep 25 04:10:53 GMT 2024

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

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

Back to the top