Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » TranslateToAbsolute() with ScrollPane
TranslateToAbsolute() with ScrollPane [message #227284] Fri, 01 December 2006 12:41 Go to next message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

i try to calculate feedback in my OrderedLayoutPolicy, but i have a
problem with it when scrollbar is active. How TranslateToAbsolute() work
in this case? And what have i do to solve this problem?
Re: TranslateToAbsolute() with ScrollPane [message #227346 is a reply to message #227284] Mon, 04 December 2006 02:57 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi Alexey,

I doubt that the problem is with TranslateToAbsolute() it always works the
same way... I guess, when you scroll the feedback is not fixed anymore and
moves with the scrolling, in this case you might be translating it
relatively to a figure? Can you provide a more detailed description of the
problem, provide the code of your edit policy? You can try not translating
your feedback bounds into absolute coordinates, maybe that would work. I'd
like to try helping you out, but simply need more information about the
problem.
Thanks in advance.

Cheers,
Alex
Re: TranslateToAbsolute() with ScrollPane [message #227361 is a reply to message #227346] Mon, 04 December 2006 08:20 Go to previous message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

Hi Alex,

I just investigate feedback from this example
http://eclipsewiki.editme.com/GefDescription2
and try to use this for my purposes.. this example don't use
TranslateToAbsolute() but work incorrect in some cases.. I add here
TranslateToAbsolute() and point to show feedback calculating correctly.
But when diafram too large and scroll appear - absolute coordinates have
some offset and feedback showing wrong with the same calculating method..

> You can try not translating your feedback bounds into absolute coordinates
how i can do that?


Thanks for help me!


here some methods from my EditPolisy class :

protected IFigure createLayoutTargetFeedback()
{
Shape f = new RectangleFigure();
f.setBackgroundColor(ColorConstants.black);
addFeedback(f);
return f;
}

protected void showLayoutTargetFeedback(Request request)
{

ToolbarLayout layout =
(ToolbarLayout)((AbstractGraphicalEditPart)getHost()).getCon tentPane().getLayoutManager();
boolean verticalLayout = !layout.isHorizontal();
IFigure l = getLayoutTargetFeedback();
AbstractGraphicalEditPart after =
(AbstractGraphicalEditPart)getInsertionReference(request);

Point loc = null;
Dimension size = null;

if(after == null)
{ // нет
следу& #1102;щего
if(getHost().getChildren().size() == 0)
{ // если
вообщ& #1077; нет
детей
Figure contentPane =
(Figure)((AbstractGraphicalEditPart)getHost()).getContentPan e();

int mid = verticalLayout? contentPane.getBounds().height/2 +
contentPane.getLocation().y
: contentPane.getBounds().width/2 +
contentPane.getLocation().x;

loc = verticalLayout? new Point(contentPane.getLocation().x, mid) :
new Point(mid,contentPane.getLocation().y);

contentPane.translateToAbsolute(loc);

if(verticalLayout)
loc.translate(0, FEEDBACK_WIDTH/2);
else
loc.translate(FEEDBACK_WIDTH/2,0);

size = verticalLayout? new
Dimension(contentPane.getSize().width,FEEDBACK_WIDTH)
: new
Dimension(FEEDBACK_WIDTH,contentPane.getSize().height);
}
else
{ // если дети
уже были,
прост& #1086;
добав& #1083;яем в
конец..
int lastIndex = getHost().getChildren().size()-1;
Figure last =
(Figure)((GraphicalEditPart)getHost().getChildren().get(last Index)).getFigure();
loc = last.getLocation();
loc = verticalLayout?
loc.getTranslated(0,last.getSize().height):loc.getTranslated (last.getSize().width,0);
last.translateToAbsolute(loc);
size = verticalLayout?
new Dimension(last.getBounds().width , FEEDBACK_WIDTH)
: new Dimension(FEEDBACK_WIDTH,last.getBounds().height);
}
}
else
{ // встав& #1083;яем
перед кем-то
int indexAfter = getHost().getChildren().indexOf(after);
// IFigure f = after.getFigure();

if(indexAfter == 0)
{// встав& #1083;яем
перед самым
первы& #1084;
Figure first =
(Figure)((GraphicalEditPart)getHost().getChildren().get(0)). getFigure();
loc = first.getLocation();
first.translateToAbsolute(loc);
loc = verticalLayout?
loc.getTranslated(0,-FEEDBACK_WIDTH):loc.getTranslated(-FEED BACK_WIDTH,0);
size = verticalLayout?
new Dimension(first.getBounds().width , FEEDBACK_WIDTH)
: new Dimension(FEEDBACK_WIDTH,first.getBounds().height);
}
else
{// прост& #1086;
перед кем-то
Figure prec =
(Figure)((GraphicalEditPart)getHost().getChildren().get(inde xAfter-1)).getFigure();
Figure next =
(Figure)((GraphicalEditPart)getHost().getChildren().get(inde xAfter)).getFigure();
if(verticalLayout)
{
int minPrec = prec.getLocation().y + prec.getBounds().height;
int maxNext = next.getLocation().y;
int interval = minPrec - maxNext;
int midInterval = minPrec + interval/2;
loc = new Point(prec.getBounds().x, midInterval);
prec.translateToAbsolute(loc);

size = new Dimension(prec.getSize().width, FEEDBACK_WIDTH);
}
else
{
int maxPrec = prec.getLocation().x + prec.getBounds().width;
int minNext = next.getLocation().x;
int interval = minNext - maxPrec;
int midInterval = maxPrec + interval/2;
loc = new Point(midInterval, prec.getBounds().y);
prec.translateToAbsolute(loc);
size = new Dimension(FEEDBACK_WIDTH, prec.getSize().height);
}
}
}
Previous Topic:Delete action/button is dissabled
Next Topic:Best way to refresh GraphicalEditor when resource changes outside GEF
Goto Forum:
  


Current Time: Tue Oct 19 00:05:50 GMT 2021

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

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

Back to the top