MidpointLocator and scrollbar [message #153571] |
Mon, 11 October 2004 05: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 #153832 is a reply to message #153761] |
Tue, 12 October 2004 22: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 #154058 is a reply to message #153896] |
Thu, 14 October 2004 11: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.09735 seconds