mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
use red when selected
This commit is contained in:
Binary file not shown.
+6
-3
@@ -57,6 +57,8 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
double distance = points[0].distance(points[1]);
|
double distance = points[0].distance(points[1]);
|
||||||
Shape shape = getBodyShape();
|
Shape shape = getBodyShape();
|
||||||
if (shape == null) {
|
if (shape == null) {
|
||||||
|
g2d.setStroke(new BasicStroke(getLeadThickness().convertToPixels()));
|
||||||
|
g2d.setColor(getLeadColor(componentState));
|
||||||
g2d.drawLine(points[0].x, points[0].y, points[1].x, points[1].y);
|
g2d.drawLine(points[0].x, points[0].y, points[1].x, points[1].y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -85,7 +87,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
g2d.draw(shape);
|
g2d.draw(shape);
|
||||||
// Draw leads.
|
// Draw leads.
|
||||||
g2d.setStroke(new BasicStroke(getLeadThickness().convertToPixels()));
|
g2d.setStroke(new BasicStroke(getLeadThickness().convertToPixels()));
|
||||||
g2d.setColor(getLeadColor());
|
g2d.setColor(getLeadColor(componentState));
|
||||||
g2d.drawLine((int) (shapeRect.width - distance) / 2, (int) shapeRect.height / 2,
|
g2d.drawLine((int) (shapeRect.width - distance) / 2, (int) shapeRect.height / 2,
|
||||||
(int) ((shapeRect.width - distance) / 2 + leadLenght), (int) shapeRect.height / 2);
|
(int) ((shapeRect.width - distance) / 2 + leadLenght), (int) shapeRect.height / 2);
|
||||||
g2d.drawLine((int) (shapeRect.width + distance) / 2, (int) shapeRect.height / 2,
|
g2d.drawLine((int) (shapeRect.width + distance) / 2, (int) shapeRect.height / 2,
|
||||||
@@ -139,8 +141,9 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
/**
|
/**
|
||||||
* @return default lead color. Override this method to change it.
|
* @return default lead color. Override this method to change it.
|
||||||
*/
|
*/
|
||||||
protected Color getLeadColor() {
|
protected Color getLeadColor(ComponentState componentState) {
|
||||||
return LEAD_COLOR;
|
return componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : LEAD_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Binary file not shown.
+4
-2
@@ -6,6 +6,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
|
|
||||||
import org.diylc.components.AbstractLeadedComponent;
|
import org.diylc.components.AbstractLeadedComponent;
|
||||||
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
@@ -32,8 +33,9 @@ public class CopperTrace extends AbstractLeadedComponent<Void> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@EditableProperty(name = "Color")
|
@EditableProperty(name = "Color")
|
||||||
public Color getLeadColor() {
|
public Color getLeadColor(ComponentState componentState) {
|
||||||
return leadColor;
|
return componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : leadColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeadColor(Color leadColor) {
|
public void setLeadColor(Color leadColor) {
|
||||||
|
|||||||
+6
-2
@@ -6,8 +6,10 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
|
|
||||||
import org.diylc.components.AbstractLeadedComponent;
|
import org.diylc.components.AbstractLeadedComponent;
|
||||||
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Jumper", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "J", description = "", zOrder = IDIYComponent.ABOVE_BOARD)
|
@ComponentDescriptor(name = "Jumper", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "J", description = "", zOrder = IDIYComponent.ABOVE_BOARD)
|
||||||
@@ -25,8 +27,10 @@ public class Jumper extends AbstractLeadedComponent<Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Color getLeadColor() {
|
@EditableProperty(name = "Color")
|
||||||
return COLOR;
|
public Color getLeadColor(ComponentState componentState) {
|
||||||
|
return componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|||||||
+2
-1
@@ -31,7 +31,8 @@ public class SolderPad extends AbstractComponent<Color> {
|
|||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
||||||
int diameter = getClosestOdd(size.convertToPixels());
|
int diameter = getClosestOdd(size.convertToPixels());
|
||||||
int holeDiameter = getClosestOdd(HOLE_SIZE.convertToPixels());
|
int holeDiameter = getClosestOdd(HOLE_SIZE.convertToPixels());
|
||||||
g2d.setColor(color);
|
g2d.setColor(componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : color);
|
||||||
g2d.fillOval(point.x - diameter / 2, point.y - diameter / 2, diameter, diameter);
|
g2d.fillOval(point.x - diameter / 2, point.y - diameter / 2, diameter, diameter);
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(point.x - holeDiameter / 2, point.y - holeDiameter / 2, holeDiameter,
|
g2d.fillOval(point.x - holeDiameter / 2, point.y - holeDiameter / 2, holeDiameter,
|
||||||
|
|||||||
+3
-1
@@ -21,6 +21,7 @@ public class TraceCut extends AbstractSinglePointComponent {
|
|||||||
public static Size SIZE = new Size(0.085d, SizeUnit.in);
|
public static Size SIZE = new Size(0.085d, SizeUnit.in);
|
||||||
public static Color FILL_COLOR = Color.white;
|
public static Color FILL_COLOR = Color.white;
|
||||||
public static Color BORDER_COLOR = Color.red;
|
public static Color BORDER_COLOR = Color.red;
|
||||||
|
public static Color SELECTION_COLOR = Color.blue;
|
||||||
|
|
||||||
private Size size = SIZE;
|
private Size size = SIZE;
|
||||||
private Color fillColor = FILL_COLOR;
|
private Color fillColor = FILL_COLOR;
|
||||||
@@ -32,7 +33,8 @@ public class TraceCut extends AbstractSinglePointComponent {
|
|||||||
int dotDiameter = (size / 3 * 2) / 2 * 2 + 1;
|
int dotDiameter = (size / 3 * 2) / 2 * 2 + 1;
|
||||||
g2d.setColor(fillColor);
|
g2d.setColor(fillColor);
|
||||||
g2d.fillRect(point.x - size / 2, point.y - size / 2, size, size);
|
g2d.fillRect(point.x - size / 2, point.y - size / 2, size, size);
|
||||||
g2d.setColor(borderColor);
|
g2d.setColor(componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
||||||
g2d.setStroke(new BasicStroke(1));
|
g2d.setStroke(new BasicStroke(1));
|
||||||
g2d.drawRect(point.x - size / 2, point.y - size / 2, size, size);
|
g2d.drawRect(point.x - size / 2, point.y - size / 2, size, size);
|
||||||
g2d
|
g2d
|
||||||
|
|||||||
Reference in New Issue
Block a user