1

I am doing an Eclipse plugin using gef. Does anybody knows how to draw a vertical label?

Kind Regards, Kyriakos Georgiou

Kyriakos
  • 757
  • 8
  • 23

2 Answers2

1

Check out this thread, at the end of the thread.

vainolo
  • 6,907
  • 4
  • 24
  • 47
1

Using ImageUtilities as in the linked post worked well. Here is how to use it in a Label.

@Override
protected void paintFigure(Graphics graphics) {
    if (vertical) {
        Image image = ImageUtilities.createRotatedImageOfString(getSubStringText(), getFont(), getForegroundColor(), getBackgroundColor());
        graphics.drawImage(image, new Point(getTextLocation()).translate(getLocation()));
    image.dispose();
    } else {
        super.paintFigure(graphics);
    }
}
David D
  • 11
  • 1
  • would it be good practice to cache the image and only dispose it when the label is disposed? What method is the best to dispose the image? Label#removeNotify? – lolung Jan 31 '18 at 09:28