TranslateToAbsolute() with ScrollPane [message #227284] |
Fri, 01 December 2006 12:41 |
Eclipse User |
|
|
|
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 #227361 is a reply to message #227346] |
Mon, 04 December 2006 08:20 |
Eclipse User |
|
|
|
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);
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03935 seconds