added color properties to abstract leaded comp

This commit is contained in:
bancika
2011-01-09 13:11:46 +00:00
parent f2fa8195b3
commit c898fee28e
10 changed files with 80 additions and 29 deletions
@@ -36,6 +36,8 @@ public abstract class AbstractLeadedDIYComponent<T> extends AbstractTransparentC
protected Size height;
protected Point[] points = new Point[] { new Point((int) (-Constants.GRID * 5), 0),
new Point((int) (Constants.GRID * 5), 0) };
protected Color bodyColor = getDefaultBodyColor();
protected Color borderColor = getDefaultBorderColor();
protected AbstractLeadedDIYComponent() {
super();
@@ -68,14 +70,14 @@ public abstract class AbstractLeadedDIYComponent<T> extends AbstractTransparentC
protected abstract Shape getBodyShape();
/**
* @return component body color.
* @return default component body color.
*/
protected abstract Color getBodyColor();
protected abstract Color getDefaultBodyColor();
/**
* @return component border color.
* @return default component border color.
*/
protected abstract Color getBorderColor();
protected abstract Color getDefaultBorderColor();
/**
* @return default lead thickness. Override this method to change it.
@@ -133,15 +135,15 @@ public abstract class AbstractLeadedDIYComponent<T> extends AbstractTransparentC
if (componentState != ComponentState.DRAGGING) {
Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
1f * alpha / MAX_ALPHA));
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
/ MAX_ALPHA));
}
g2d.setColor(getBodyColor());
g2d.setColor(bodyColor);
g2d.fill(shape);
g2d.setComposite(oldComposite);
}
g2d.setStroke(new BasicStroke(1));
g2d.setColor(getBorderColor());
g2d.setColor(borderColor);
g2d.draw(shape);
// Draw label.
g2d.setFont(Constants.LABEL_FONT);
@@ -154,6 +156,24 @@ public abstract class AbstractLeadedDIYComponent<T> extends AbstractTransparentC
(int) (shapeRect.height - textRect.getHeight()) / 2 + fontMetrics.getAscent());
}
@EditableProperty(name = "Color")
public Color getBodyColor() {
return bodyColor;
}
public void setBodyColor(Color bodyColor) {
this.bodyColor = bodyColor;
}
@EditableProperty(name = "Border")
public Color getBorderColor() {
return borderColor;
}
public void setBorderColor(Color borderColor) {
this.borderColor = borderColor;
}
@EditableProperty(defaultable = true)
public Size getWidth() {
return width;