mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
switch outline
This commit is contained in:
+13
-10
@@ -222,6 +222,8 @@ public class MiniToggleSwitch extends
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Shape body = getBody();
|
Shape body = getBody();
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
// Draw body if available.
|
// Draw body if available.
|
||||||
if (body != null) {
|
if (body != null) {
|
||||||
Composite oldComposite = g2d.getComposite();
|
Composite oldComposite = g2d.getComposite();
|
||||||
@@ -237,9 +239,6 @@ public class MiniToggleSwitch extends
|
|||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
Color finalBorderColor;
|
Color finalBorderColor;
|
||||||
if (outlineMode) {
|
if (outlineMode) {
|
||||||
Theme theme = (Theme) ConfigurationManager.getInstance()
|
|
||||||
.readObject(IPlugInPort.THEME_KEY,
|
|
||||||
Constants.DEFAULT_THEME);
|
|
||||||
finalBorderColor = componentState == ComponentState.SELECTED
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
: theme.getOutlineColor();
|
: theme.getOutlineColor();
|
||||||
@@ -259,15 +258,19 @@ public class MiniToggleSwitch extends
|
|||||||
int lugWidth = getClosestOdd((int) LUG_WIDTH.convertToPixels());
|
int lugWidth = getClosestOdd((int) LUG_WIDTH.convertToPixels());
|
||||||
int lugHeight = getClosestOdd((int) LUG_THICKNESS.convertToPixels());
|
int lugHeight = getClosestOdd((int) LUG_THICKNESS.convertToPixels());
|
||||||
for (Point p : controlPoints) {
|
for (Point p : controlPoints) {
|
||||||
if (!outlineMode) {
|
if (outlineMode) {
|
||||||
|
g2d.setColor(theme.getOutlineColor());
|
||||||
|
g2d.drawRect(p.x - lugWidth / 2, p.y - lugHeight / 2, lugWidth,
|
||||||
|
lugHeight);
|
||||||
|
} else {
|
||||||
g2d.setColor(CIRCLE_COLOR);
|
g2d.setColor(CIRCLE_COLOR);
|
||||||
g2d.fillOval(p.x - circleDiameter / 2,
|
g2d.fillOval(p.x - circleDiameter / 2,
|
||||||
p.y - circleDiameter / 2, circleDiameter,
|
p.y - circleDiameter / 2, circleDiameter,
|
||||||
circleDiameter);
|
circleDiameter);
|
||||||
|
g2d.setColor(METAL_COLOR);
|
||||||
|
g2d.fillRect(p.x - lugWidth / 2, p.y - lugHeight / 2, lugWidth,
|
||||||
|
lugHeight);
|
||||||
}
|
}
|
||||||
g2d.setColor(METAL_COLOR);
|
|
||||||
g2d.fillRect(p.x - lugWidth / 2, p.y - lugHeight / 2, lugWidth,
|
|
||||||
lugHeight);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,10 +312,10 @@ public class MiniToggleSwitch extends
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (getOrientation() == OrientationHV.HORIZONTAL) {
|
if (getOrientation() == OrientationHV.HORIZONTAL) {
|
||||||
AffineTransform xform = AffineTransform.getRotateInstance(-Math.PI / 2,
|
AffineTransform xform = AffineTransform.getRotateInstance(
|
||||||
firstPoint.x, firstPoint.y);
|
-Math.PI / 2, firstPoint.x, firstPoint.y);
|
||||||
body = new Area(body);
|
body = new Area(body);
|
||||||
((Area)body).transform(xform);
|
((Area) body).transform(xform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return body;
|
return body;
|
||||||
|
|||||||
Reference in New Issue
Block a user