MidpointLocator and scrollbar [message #153571] |
Mon, 11 October 2004 09:45 |
Eclipse User |
|
|
|
Originally posted by: penzhan8451.yahoo.com.cn
hi,
There is a PolylineConnection with a MidpointLocator which locate a
Label in my graphical editor. When i scroll the scroll the scrollbar,
the
Label's Y coordinate didn't change. How could i solve it?
Thanks your help in advance !
Best regards.
|
|
|
Re: MidpointLocator and scrollbar [message #153620 is a reply to message #153571] |
Mon, 11 October 2004 17:27 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
The reference point is calculated in absolute coordinates, and then made
relative to the figure beiing relocated. It should work fine. Who parents
the label?
"smallfish" <penzhan8451@yahoo.com.cn> wrote in message
news:ckdko3$lrj$1@eclipse.org...
> hi,
>
> There is a PolylineConnection with a MidpointLocator which locate a
>
> Label in my graphical editor. When i scroll the scroll the scrollbar,
> the
>
> Label's Y coordinate didn't change. How could i solve it?
>
>
> Thanks your help in advance !
>
>
> Best regards.
>
|
|
|
Re: MidpointLocator and scrollbar [message #153691 is a reply to message #153620] |
Tue, 12 October 2004 01:50 |
Eclipse User |
|
|
|
Originally posted by: penzhan8451.yahoo.com.cn
Thanks !
My code is like below:
public ETEWireFigure() {
super();
setSourceDecoration(null);
setTargetDecoration(null);
label.setSize(WIRE.LABEL_W, WIRE.LABEL_H);
label.setToolTip(new Label(""));
labelFig.setPreferredSize(WIRE.LABEL_W, WIRE.LABEL_H);
labelFig.add(label);
labelFig.setOpaque(false);
label.setOpaque(false);
add(labelFig, new ETELabelLocator(this, 0));
}
Randy Hudson wrote:
> The reference point is calculated in absolute coordinates, and then made
> relative to the figure beiing relocated. It should work fine. Who parents
> the label?
> "smallfish" <penzhan8451@yahoo.com.cn> wrote in message
> news:ckdko3$lrj$1@eclipse.org...
> > hi,
> >
> > There is a PolylineConnection with a MidpointLocator which locate a
> >
> > Label in my graphical editor. When i scroll the scroll the scrollbar,
> > the
> >
> > Label's Y coordinate didn't change. How could i solve it?
> >
> >
> > Thanks your help in advance !
> >
> >
> > Best regards.
> >
|
|
|
Re: MidpointLocator and scrollbar [message #153699 is a reply to message #153620] |
Tue, 12 October 2004 01:51 |
Eclipse User |
|
|
|
Originally posted by: penzhan8451.yahoo.com.cn
Thanks !
My code is like below:
public ETEWireFigure() {
super();
setSourceDecoration(null);
setTargetDecoration(null);
label.setSize(WIRE.LABEL_W, WIRE.LABEL_H);
label.setToolTip(new Label(""));
labelFig.setPreferredSize(WIRE.LABEL_W, WIRE.LABEL_H);
labelFig.add(label);
labelFig.setOpaque(false);
label.setOpaque(false);
add(labelFig, new ETELabelLocator(this, 0));
}
Randy Hudson wrote:
> The reference point is calculated in absolute coordinates, and then made
> relative to the figure beiing relocated. It should work fine. Who parents
> the label?
> "smallfish" <penzhan8451@yahoo.com.cn> wrote in message
> news:ckdko3$lrj$1@eclipse.org...
> > hi,
> >
> > There is a PolylineConnection with a MidpointLocator which locate a
> >
> > Label in my graphical editor. When i scroll the scroll the scrollbar,
> > the
> >
> > Label's Y coordinate didn't change. How could i solve it?
> >
> >
> > Thanks your help in advance !
> >
> >
> > Best regards.
> >
|
|
|
Re: MidpointLocator and scrollbar [message #153761 is a reply to message #153691] |
Tue, 12 October 2004 15:28 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
"Thanks" means it is working for you now??
I would need to see what ETELabelLocator is doing.
"smallfish" <penzhan8451@yahoo.com.cn> wrote in message
news:ckfda3$gr$1@eclipse.org...
>
> Thanks !
>
> My code is like below:
>
> public ETEWireFigure() {
> super();
>
> setSourceDecoration(null);
> setTargetDecoration(null);
>
> label.setSize(WIRE.LABEL_W, WIRE.LABEL_H);
> label.setToolTip(new Label(""));
> labelFig.setPreferredSize(WIRE.LABEL_W, WIRE.LABEL_H);
> labelFig.add(label);
> labelFig.setOpaque(false);
> label.setOpaque(false);
>
> add(labelFig, new ETELabelLocator(this, 0));
> }
>
>
>
|
|
|
Re: MidpointLocator and scrollbar [message #153832 is a reply to message #153761] |
Wed, 13 October 2004 02:47 |
Eclipse User |
|
|
|
Originally posted by: penzhan8451.yahoo.com.cn
Hi,
It still doesn't work now.
Below is the more codes of my connection and LabelLocator :
//*** begin
public class ETEWireFigure extends PolylineConnection implements {
private Label label = new Label();
private Figure labelFig = new Figure();
class ETELabelLocator extends MidpointLocator {
private int index;
public ETELabelLocator(Connection c, int i) {
super(c, i);
index = i;
}
protected int getIndex() {
return index;
}
protected Point getReferencePoint() {
ETEWireFigure conn = (ETEWireFigure)getConnection();
if (conn.getPoints().size() < 2) {
return null;
}
Point p = Point.SINGLETON;
Point p1 = conn.getPoints().getPoint(conn.getPoints().size() - 2);
Point p2 = conn.getPoints().getPoint(conn.getPoints().size() - 1);
if ((p2.x - p1.x) < WIRE.LABEL_W){
conn.setLabelSize(p2.x - p1.x, WIRE.LABEL_H);
} else {
int w = conn.getLabelTextWidth();
if (w < WIRE.LABEL_W){
conn.setLabelSize(w, WIRE.LABEL_H);
} else {
conn.setLabelSize(WIRE.LABEL_W, WIRE.LABEL_H);
}
}
p.x = (p2.x - p1.x) / 2 + p1.x;
p.y = (p2.y - p1.y) / 2 + p1.y;
return p;
}
} //_class ETELabelLocator
public ETEWireFigure() {
super();
setSourceDecoration(null);
setTargetDecoration(null);
label.setSize(WIRE.LABEL_W, WIRE.LABEL_H);
label.setToolTip(new Label(""));
labelFig.setPreferredSize(WIRE.LABEL_W, WIRE.LABEL_H);
labelFig.add(label);
labelFig.setOpaque(false);
label.setOpaque(false);
add(labelFig, new ETELabelLocator(this, 0));
}
//**** EnD
When the vertical scrollbar on the right of my graphical editor
appears,
I scroll the scrollbar, the ETELabelLocator doesn't move with the
connection.
many Thanks !
Randy Hudson wrote:
> "Thanks" means it is working for you now??
> I would need to see what ETELabelLocator is doing.
> "smallfish" <penzhan8451@yahoo.com.cn> wrote in message
> news:ckfda3$gr$1@eclipse.org...
> >
> > Thanks !
> >
> > My code is like below:
> >
> > public ETEWireFigure() {
> > super();
> >
> > setSourceDecoration(null);
> > setTargetDecoration(null);
> >
> > label.setSize(WIRE.LABEL_W, WIRE.LABEL_H);
> > label.setToolTip(new Label(""));
> > labelFig.setPreferredSize(WIRE.LABEL_W, WIRE.LABEL_H);
> > labelFig.add(label);
> > labelFig.setOpaque(false);
> > label.setOpaque(false);
> >
> > add(labelFig, new ETELabelLocator(this, 0));
> > }
> >
> >
> >
|
|
|
Re: MidpointLocator and scrollbar [message #153888 is a reply to message #153832] |
Wed, 13 October 2004 17:37 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Looks like getReferencePoint does not comply to the API. The returned point
must be in absolute coordinates.
> protected Point getReferencePoint() {
> ETEWireFigure conn = (ETEWireFigure)getConnection();
>
> if (conn.getPoints().size() < 2) {
> return null;
> }
> Point p = Point.SINGLETON;
> Point p1 = conn.getPoints().getPoint(conn.getPoints().size() - 2);
> Point p2 = conn.getPoints().getPoint(conn.getPoints().size() - 1);
>
>
> if ((p2.x - p1.x) < WIRE.LABEL_W){
> conn.setLabelSize(p2.x - p1.x, WIRE.LABEL_H);
> } else {
> int w = conn.getLabelTextWidth();
> if (w < WIRE.LABEL_W){
> conn.setLabelSize(w, WIRE.LABEL_H);
> } else {
> conn.setLabelSize(WIRE.LABEL_W, WIRE.LABEL_H);
> }
> }
|
|
|
Re: MidpointLocator and scrollbar [message #153896 is a reply to message #153888] |
Wed, 13 October 2004 17:39 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
In the future, please don't refer to your classes ("ETELabelLocator") using
the names of classes found in Draw2d ("MidpointLocator").
"Randy Hudson" <none@us.ibm.com> wrote in message
news:ckjoqt$49t$1@eclipse.org...
> Looks like getReferencePoint does not comply to the API. The returned
point
> must be in absolute coordinates.
> > protected Point getReferencePoint() {
> > ETEWireFigure conn = (ETEWireFigure)getConnection();
> >
> > if (conn.getPoints().size() < 2) {
> > return null;
> > }
> > Point p = Point.SINGLETON;
> > Point p1 = conn.getPoints().getPoint(conn.getPoints().size() - 2);
> > Point p2 = conn.getPoints().getPoint(conn.getPoints().size() - 1);
> >
> >
> > if ((p2.x - p1.x) < WIRE.LABEL_W){
> > conn.setLabelSize(p2.x - p1.x, WIRE.LABEL_H);
> > } else {
> > int w = conn.getLabelTextWidth();
> > if (w < WIRE.LABEL_W){
> > conn.setLabelSize(w, WIRE.LABEL_H);
> > } else {
> > conn.setLabelSize(WIRE.LABEL_W, WIRE.LABEL_H);
> > }
> > }
>
>
|
|
|
Re: MidpointLocator and scrollbar [message #154058 is a reply to message #153896] |
Thu, 14 October 2004 15:53 |
Eclipse User |
|
|
|
Originally posted by: penzhan8451.yahoo.com.cn
Hi,
It works well now.
Thanks very much !
Randy Hudson wrote:
> In the future, please don't refer to your classes ("ETELabelLocator") using
> the names of classes found in Draw2d ("MidpointLocator").
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:ckjoqt$49t$1@eclipse.org...
> > Looks like getReferencePoint does not comply to the API. The returned
> point
> > must be in absolute coordinates.
> > > protected Point getReferencePoint() {
> > > ETEWireFigure conn = (ETEWireFigure)getConnection();
> > >
> > > if (conn.getPoints().size() < 2) {
> > > return null;
> > > }
> > > Point p = Point.SINGLETON;
> > > Point p1 = conn.getPoints().getPoint(conn.getPoints().size() - 2);
> > > Point p2 = conn.getPoints().getPoint(conn.getPoints().size() - 1);
> > >
> > >
> > > if ((p2.x - p1.x) < WIRE.LABEL_W){
> > > conn.setLabelSize(p2.x - p1.x, WIRE.LABEL_H);
> > > } else {
> > > int w = conn.getLabelTextWidth();
> > > if (w < WIRE.LABEL_W){
> > > conn.setLabelSize(w, WIRE.LABEL_H);
> > > } else {
> > > conn.setLabelSize(WIRE.LABEL_W, WIRE.LABEL_H);
> > > }
> > > }
> >
> >
|
|
|
Powered by
FUDForum. Page generated in 0.03386 seconds