mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
use red when selected
This commit is contained in:
Binary file not shown.
+10
-5
@@ -20,8 +20,8 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
|
|||||||
public static Color GUIDELINE_COLOR = Color.blue;
|
public static Color GUIDELINE_COLOR = Color.blue;
|
||||||
|
|
||||||
protected Point[] controlPoints = new Point[] {
|
protected Point[] controlPoints = new Point[] {
|
||||||
new Point(-5 * Constants.GRID, -5 * Constants.GRID), new Point(0, -3 * Constants.GRID),
|
new Point(-5 * Constants.GRID, -5 * Constants.GRID), new Point(0, -5 * Constants.GRID),
|
||||||
new Point(0, 3 * Constants.GRID), new Point(5 * Constants.GRID, 5 * Constants.GRID) };
|
new Point(0, 5 * Constants.GRID), new Point(5 * Constants.GRID, 5 * Constants.GRID) };
|
||||||
|
|
||||||
protected Color color = getDefaultColor();
|
protected Color color = getDefaultColor();
|
||||||
|
|
||||||
@@ -30,9 +30,14 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
|
|||||||
*
|
*
|
||||||
* @param curve
|
* @param curve
|
||||||
* @param g2d
|
* @param g2d
|
||||||
|
* @param componentState
|
||||||
|
*/
|
||||||
|
protected abstract void drawCurve(CubicCurve2D curve, Graphics2D g2d,
|
||||||
|
ComponentState componentState);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return default color.
|
||||||
*/
|
*/
|
||||||
protected abstract void drawCurve(CubicCurve2D curve, Graphics2D g2d);
|
|
||||||
|
|
||||||
protected abstract Color getDefaultColor();
|
protected abstract Color getDefaultColor();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -75,7 +80,7 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
|
|||||||
// g2d.setColor(color);
|
// g2d.setColor(color);
|
||||||
// g2d.setStroke(new BasicStroke(thickness - 2));
|
// g2d.setStroke(new BasicStroke(thickness - 2));
|
||||||
// g2d.draw(path);
|
// g2d.draw(path);
|
||||||
drawCurve(curve, g2d);
|
drawCurve(curve, g2d, componentState);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
+4
-2
@@ -6,6 +6,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.geom.CubicCurve2D;
|
import java.awt.geom.CubicCurve2D;
|
||||||
|
|
||||||
import org.diylc.components.AbstractCurvedComponent;
|
import org.diylc.components.AbstractCurvedComponent;
|
||||||
|
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;
|
||||||
@@ -28,10 +29,11 @@ public class CurvedTrace extends AbstractCurvedComponent<Size> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawCurve(CubicCurve2D curve, Graphics2D g2d) {
|
protected void drawCurve(CubicCurve2D curve, Graphics2D g2d, ComponentState componentState) {
|
||||||
int thickness = size.convertToPixels();
|
int thickness = size.convertToPixels();
|
||||||
g2d.setStroke(new BasicStroke(thickness));
|
g2d.setStroke(new BasicStroke(thickness));
|
||||||
g2d.setColor(color);
|
g2d.setColor(componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : color);
|
||||||
g2d.draw(curve);
|
g2d.draw(curve);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-5
@@ -6,6 +6,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.geom.CubicCurve2D;
|
import java.awt.geom.CubicCurve2D;
|
||||||
|
|
||||||
import org.diylc.components.AbstractCurvedComponent;
|
import org.diylc.components.AbstractCurvedComponent;
|
||||||
|
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;
|
||||||
@@ -27,15 +28,18 @@ public class HookupWire extends AbstractCurvedComponent<AWG> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawCurve(CubicCurve2D curve, Graphics2D g2d) {
|
protected void drawCurve(CubicCurve2D curve, Graphics2D g2d, ComponentState componentState) {
|
||||||
int thickness = (int) (Math.pow(Math.E, -1.12436 - 0.11594 * value.getValue())
|
int thickness = (int) (Math.pow(Math.E, -1.12436 - 0.11594 * value.getValue())
|
||||||
* Constants.GRID * Constants.GRIDS_PER_INCH * (1 + 2 * INSULATION_THICKNESS_PCT));
|
* Constants.GRID * Constants.GRIDS_PER_INCH * (1 + 2 * INSULATION_THICKNESS_PCT));
|
||||||
g2d.setColor(color.darker());
|
g2d.setColor(componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : color.darker());
|
||||||
g2d.setStroke(new BasicStroke(thickness));
|
g2d.setStroke(new BasicStroke(thickness));
|
||||||
g2d.draw(curve);
|
g2d.draw(curve);
|
||||||
g2d.setColor(color);
|
if (componentState == ComponentState.NORMAL) {
|
||||||
g2d.setStroke(new BasicStroke(thickness - 2));
|
g2d.setColor(color);
|
||||||
g2d.draw(curve);
|
g2d.setStroke(new BasicStroke(thickness - 2));
|
||||||
|
g2d.draw(curve);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "AWG")
|
@EditableProperty(name = "AWG")
|
||||||
|
|||||||
Reference in New Issue
Block a user