draw2d Label resize [message #1021037] |
Tue, 19 March 2013 12:12 |
Mokhtar Alshubei Messages: 121 Registered: November 2011 Location: Germany |
Senior Member |
|
|
Hi,
I am trying to resize an org.eclipse.draw2d.Label inside my customized graph node but I couldn't. Could you help me with that please?
I used setSize() or setPreferredSize() after the label got an image, font and text. But didn't work. The goal is to make labels resize to constitute a chart diagram inside the nodes!!
Label histogramLabel = new Label();
histogramLabel.setIcon(image);
histogramLabel.setBackgroundColor(color);
histogramLabel.setOpaque(true);
histogramLabel.setText(Integer.toString(someNum));
histogramLabel.setFont(GraphicsUtils.nodeFont(7));
figPart.add(histogramLabel);
The figPart above is an instance of this class
public class CompartmentFigure extends Figure {
public CompartmentFigure(boolean border,ToolbarLayout layout) {
layout.setHorizontal(true);
layout.setStretchMinorAxis(false);
layout.setSpacing(0);
setLayoutManager(layout);
if (border) setBorder(new CompartmentFigureBorder());
}
public class CompartmentFigureBorder extends AbstractBorder {
public Insets getInsets(IFigure figure) {
return new Insets(1,0,0,0);
}
public void paint(IFigure figure, Graphics graphics, Insets insets) {
graphics.drawLine(getPaintRectangle(figure, insets).getTopLeft(),
tempRect.getTopRight());
}
}
}
If the label could be resized by the layout of the containing figure, then please tell me how? I would also be not angary if some one introduced me a better way to do a histogram (chart diagram) inside a graph node.
Thank you,
Mok
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03563 seconds