mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
use red rectangle when selected
This commit is contained in:
Binary file not shown.
+3
@@ -1,5 +1,6 @@
|
|||||||
package org.diylc.core;
|
package org.diylc.core;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -39,6 +40,8 @@ public interface IDIYComponent<T> extends Serializable {
|
|||||||
public static final int COMPONENT = 7;
|
public static final int COMPONENT = 7;
|
||||||
public static final int ABOVE_COMPONENT = 8;
|
public static final int ABOVE_COMPONENT = 8;
|
||||||
|
|
||||||
|
public static Color SELECTION_COLOR = Color.red;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return component instance name.
|
* @return component instance name.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Binary file not shown.
+2
-1
@@ -43,7 +43,8 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
- controlPoints[0].x, controlPoints[1].y - controlPoints[0].y);
|
- controlPoints[0].x, controlPoints[1].y - controlPoints[0].y);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
}
|
}
|
||||||
g2d.setColor(borderColor);
|
g2d.setColor(componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
||||||
g2d.drawRect(controlPoints[0].x, controlPoints[0].y, controlPoints[1].x
|
g2d.drawRect(controlPoints[0].x, controlPoints[0].y, controlPoints[1].x
|
||||||
- controlPoints[0].x, controlPoints[1].y - controlPoints[0].y);
|
- controlPoints[0].x, controlPoints[1].y - controlPoints[0].y);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -168,7 +168,8 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
}
|
}
|
||||||
g2d.setStroke(new BasicStroke());
|
g2d.setStroke(new BasicStroke());
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : BORDER_COLOR);
|
||||||
g2d.draw(body);
|
g2d.draw(body);
|
||||||
}
|
}
|
||||||
// Draw lugs.
|
// Draw lugs.
|
||||||
|
|||||||
+4
-9
@@ -34,7 +34,6 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
|||||||
public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
|
public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
|
||||||
public static Color INDENT_COLOR = Color.lightGray;
|
public static Color INDENT_COLOR = Color.lightGray;
|
||||||
public static Color LABEL_COLOR = Color.white;
|
public static Color LABEL_COLOR = Color.white;
|
||||||
public static Color LABEL_COLOR_SELECTED = Color.red;
|
|
||||||
public static int EDGE_RADIUS = 6;
|
public static int EDGE_RADIUS = 6;
|
||||||
public static Size PIN_SIZE = new Size(0.04d, SizeUnit.in);
|
public static Size PIN_SIZE = new Size(0.04d, SizeUnit.in);
|
||||||
public static Size INDENT_SIZE = new Size(0.15d, SizeUnit.in);
|
public static Size INDENT_SIZE = new Size(0.15d, SizeUnit.in);
|
||||||
@@ -229,19 +228,15 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
|||||||
g2d.fill(getBody());
|
g2d.fill(getBody());
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
}
|
}
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : BORDER_COLOR);
|
||||||
g2d.setStroke(new BasicStroke());
|
g2d.setStroke(new BasicStroke());
|
||||||
g2d.draw(getBody());
|
g2d.draw(getBody());
|
||||||
// Draw label.
|
// Draw label.
|
||||||
g2d.setFont(Constants.LABEL_FONT);
|
g2d.setFont(Constants.LABEL_FONT);
|
||||||
switch (componentState) {
|
if (componentState == ComponentState.DRAGGING) {
|
||||||
case DRAGGING:
|
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
break;
|
} else {
|
||||||
case SELECTED:
|
|
||||||
g2d.setColor(LABEL_COLOR_SELECTED);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g2d.setColor(LABEL_COLOR);
|
g2d.setColor(LABEL_COLOR);
|
||||||
}
|
}
|
||||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||||
|
|||||||
Reference in New Issue
Block a user