mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
editable colors for boards
This commit is contained in:
+25
-5
@@ -17,15 +17,17 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color BOARD_COLOR = Color.decode("#BCED91");
|
||||
public static Color BORDER_COLOR = BOARD_COLOR.darker();
|
||||
|
||||
protected String name;
|
||||
protected String value;
|
||||
protected Point[] controlPoints = new Point[] {
|
||||
new Point((int) (-5 * Constants.GRID), (int) (-5 * Constants.GRID)),
|
||||
new Point((int) (5 * Constants.GRID), (int) (5 * Constants.GRID)) };
|
||||
|
||||
protected abstract Color getBoardColor();
|
||||
|
||||
protected abstract Color getBorderColor();
|
||||
protected Color boardColor = BOARD_COLOR;
|
||||
protected Color borderColor = BORDER_COLOR;
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
||||
@@ -36,16 +38,34 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||
/ MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(getBoardColor());
|
||||
g2d.setColor(boardColor);
|
||||
g2d.fillRect(controlPoints[0].x, controlPoints[0].y, controlPoints[1].x
|
||||
- controlPoints[0].x, controlPoints[1].y - controlPoints[0].y);
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
g2d.setColor(getBorderColor());
|
||||
g2d.setColor(borderColor);
|
||||
g2d.drawRect(controlPoints[0].x, controlPoints[0].y, controlPoints[1].x
|
||||
- controlPoints[0].x, controlPoints[1].y - controlPoints[0].y);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Color")
|
||||
public Color getBoardColor() {
|
||||
return boardColor;
|
||||
}
|
||||
|
||||
public void setBoardColor(Color boardColor) {
|
||||
this.boardColor = boardColor;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Border")
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return controlPoints.length;
|
||||
|
||||
-14
@@ -1,6 +1,5 @@
|
||||
package org.diylc.components.boards;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -11,19 +10,6 @@ public class BlankBoard extends AbstractBoard {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color BOARD_COLOR = Color.decode("#BCED91");
|
||||
public static Color BORDER_COLOR = BOARD_COLOR.darker();
|
||||
|
||||
@Override
|
||||
protected Color getBoardColor() {
|
||||
return BOARD_COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Color getBorderColor() {
|
||||
return BORDER_COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.setColor(BOARD_COLOR);
|
||||
|
||||
-12
@@ -20,9 +20,7 @@ public class PerfBoard extends AbstractBoard {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color BOARD_COLOR = Color.decode("#BCED91");
|
||||
public static Color COPPER_COLOR = Color.decode("#B87333");
|
||||
public static Color BORDER_COLOR = BOARD_COLOR.darker();
|
||||
|
||||
private static Size SPACING = new Size(0.1d, SizeUnit.in);
|
||||
private static Size PAD_SIZE = new Size(0.08d, SizeUnit.in);
|
||||
@@ -133,16 +131,6 @@ public class PerfBoard extends AbstractBoard {
|
||||
this.spacing = spacing;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Color getBoardColor() {
|
||||
return BOARD_COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Color getBorderColor() {
|
||||
return BORDER_COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.setColor(BOARD_COLOR);
|
||||
|
||||
-10
@@ -135,16 +135,6 @@ public class VeroBoard extends AbstractBoard {
|
||||
this.spacing = spacing;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Color getBoardColor() {
|
||||
return BOARD_COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Color getBorderColor() {
|
||||
return BORDER_COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.setColor(BOARD_COLOR);
|
||||
|
||||
Reference in New Issue
Block a user