Hi,
What Nagin says is not the problem I'm having. My problem is that the
text is not showing at all. Is ther any way I send you a video to show
you the behavior I'm having?
This is how I create the object and how I move it when cursor moves:
private String backgroundColor = "white";
private static final int WEST_MARGIN = 15;
private static final int EAST_MARGIN = 15;
private static final int SOUTH_MARGIN = 15;
private static final int RECTANGLE_STROKE_WIDTH = 2;
private static final int RECTANGLE_CORNERS_RADIUS = 10;
private static final int CONNECT_PANEL_HEIGHT = 15;
private static final int CONNECT_PANEL_WIDTH = 15;
private static final int CONNECT_PANEL_X_RELATION = 10;
private static final int CONNECT_PANEL_Y_RELATION = -
CONNECT_PANEL_HEIGHT - RECTANGLE_STROKE_WIDTH;
private static final int CONNECT_PANEL_MARGIN = 2;
private Text text;
protected Rectangle rectangle;
protected DrawingArea canvas;
public SVGElement(DrawingArea canvas, String name, int x, int y,
String backgroundColor) {
super();
this.canvas = canvas;
this.text = new Text(x + WEST_MARGIN, y, name);
this.text.setStrokeColor("black");
this.text.setFontSize(50);
this.text.setFillColor("black");
this.backgroundColor = backgroundColor;
int rectangleWidth = WEST_MARGIN + this.text.getTextWidth() +
EAST_MARGIN;
int rectangleHeight = this.text.getTextHeight();
this.rectangle = new Rectangle(x, y, rectangleWidth,
rectangleHeight);
this.rectangle.setStrokeColor("black");
this.rectangle.setFillColor(this.backgroundColor);
this.rectangle.setStrokeWidth(RECTANGLE_STROKE_WIDTH);
this.rectangle.setRoundedCorners(RECTANGLE_CORNERS_RADIUS);
//reposition text because y coordinate is left-down corner for
text instead of left-up
this.text.setY(y + rectangleHeight - SOUTH_MARGIN);
this.add(this.rectangle);
this.add(this.text);
this.canvas.add(this);
this.startConnectionPanelsAnimation();
}
public void move(Movement movement) {
int newX = this.rectangle.getX() + movement.getHComponent();
int newY = this.rectangle.getY() + movement.getVComponent();
this.mashupElement.setLeft(new Integer(newX));
this.mashupElement.setTop(new Integer(newY));
this.rectangle.setX(newX);
this.rectangle.setY(newY);
this.text.setX(this.text.getX() + movement.getHComponent());
this.text.setY(this.text.getY() + movement.getVComponent());
}
Thanks,
Jorge