switch outline

This commit is contained in:
bancika
2012-09-21 12:31:20 +00:00
parent 85207733d5
commit e604a54dd8
@@ -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,17 +258,21 @@ 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.setColor(METAL_COLOR);
g2d.fillRect(p.x - lugWidth / 2, p.y - lugHeight / 2, lugWidth, g2d.fillRect(p.x - lugWidth / 2, p.y - lugHeight / 2, lugWidth,
lugHeight); lugHeight);
} }
} }
}
public Shape getBody() { public Shape getBody() {
if (body == null) { if (body == null) {
@@ -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;