mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 17:52:07 +10:00
Use transparency instead of rendering pins on top of transistor body
This commit is contained in:
Binary file not shown.
@@ -85,6 +85,7 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
||||
public TransistorTO1() {
|
||||
super();
|
||||
updateControlPoints();
|
||||
alpha = (byte) 100;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
@@ -215,6 +216,17 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
||||
return;
|
||||
}
|
||||
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
|
||||
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
|
||||
for (Point point : controlPoints) {
|
||||
if (!outlineMode) {
|
||||
g2d.setColor(PIN_COLOR);
|
||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||
}
|
||||
g2d.setColor(outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||
}
|
||||
|
||||
Area mainArea = getBody();
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
@@ -224,7 +236,7 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
||||
g2d.fill(mainArea);
|
||||
g2d.setComposite(oldComposite);
|
||||
Color finalBorderColor;
|
||||
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
|
||||
if (outlineMode) {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
@@ -238,15 +250,6 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.draw(mainArea);
|
||||
|
||||
for (Point point : controlPoints) {
|
||||
if (!outlineMode) {
|
||||
g2d.setColor(PIN_COLOR);
|
||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||
}
|
||||
g2d.setColor(outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||
}
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
Color finalLabelColor;
|
||||
|
||||
@@ -93,6 +93,7 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
||||
public TransistorTO220() {
|
||||
super();
|
||||
updateControlPoints();
|
||||
alpha = (byte) 100;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
@@ -264,46 +265,8 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
||||
return;
|
||||
}
|
||||
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
|
||||
Shape mainArea = getBody()[0];
|
||||
Shape tabArea = getBody()[1];
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
|
||||
g2d.fill(mainArea);
|
||||
Color finalTabColor;
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalTabColor = theme.getOutlineColor();
|
||||
} else {
|
||||
finalTabColor = tabColor;
|
||||
}
|
||||
g2d.setColor(finalTabColor);
|
||||
g2d.fill(tabArea);
|
||||
g2d.setComposite(oldComposite);
|
||||
if (!outlineMode) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.setColor(tabBorderColor);
|
||||
g2d.draw(tabArea);
|
||||
}
|
||||
Color finalBorderColor;
|
||||
|
||||
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
if (outlineMode) {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor;
|
||||
}
|
||||
g2d.setColor(finalBorderColor);
|
||||
g2d.draw(mainArea);
|
||||
if (folded) {
|
||||
g2d.draw(tabArea);
|
||||
}
|
||||
|
||||
// Draw pins.
|
||||
|
||||
@@ -369,6 +332,46 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Shape mainArea = getBody()[0];
|
||||
Shape tabArea = getBody()[1];
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
|
||||
g2d.fill(mainArea);
|
||||
Color finalTabColor;
|
||||
if (outlineMode) {
|
||||
finalTabColor = theme.getOutlineColor();
|
||||
} else {
|
||||
finalTabColor = tabColor;
|
||||
}
|
||||
g2d.setColor(finalTabColor);
|
||||
g2d.fill(tabArea);
|
||||
g2d.setComposite(oldComposite);
|
||||
if (!outlineMode) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.setColor(tabBorderColor);
|
||||
g2d.draw(tabArea);
|
||||
}
|
||||
Color finalBorderColor;
|
||||
|
||||
if (outlineMode) {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor;
|
||||
}
|
||||
g2d.setColor(finalBorderColor);
|
||||
g2d.draw(mainArea);
|
||||
if (folded) {
|
||||
g2d.draw(tabArea);
|
||||
}
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
Color finalLabelColor;
|
||||
|
||||
@@ -88,6 +88,7 @@ public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
||||
public TransistorTO3() {
|
||||
super();
|
||||
updateControlPoints();
|
||||
alpha = (byte) 100;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
@@ -250,6 +251,17 @@ public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
||||
return;
|
||||
}
|
||||
int pinSize = (int) PIN_DIAMETER.convertToPixels() / 2 * 2;
|
||||
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
|
||||
for (Point point : controlPoints) {
|
||||
if (!outlineMode) {
|
||||
g2d.setColor(PIN_COLOR);
|
||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||
}
|
||||
g2d.setColor(outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||
}
|
||||
|
||||
Area mainArea = getBody()[0];
|
||||
Area innerArea = getBody()[1];
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
@@ -260,7 +272,7 @@ public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
||||
g2d.fill(mainArea);
|
||||
g2d.setComposite(oldComposite);
|
||||
Color finalBorderColor;
|
||||
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
|
||||
if (outlineMode) {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
@@ -275,15 +287,6 @@ public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
||||
g2d.draw(mainArea);
|
||||
g2d.draw(innerArea);
|
||||
|
||||
for (Point point : controlPoints) {
|
||||
if (!outlineMode) {
|
||||
g2d.setColor(PIN_COLOR);
|
||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||
}
|
||||
g2d.setColor(outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
|
||||
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||
}
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
Color finalLabelColor;
|
||||
|
||||
@@ -83,6 +83,7 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
||||
public TransistorTO92() {
|
||||
super();
|
||||
updateControlPoints();
|
||||
alpha = (byte) 100;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
@@ -249,6 +250,16 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
||||
return;
|
||||
}
|
||||
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
|
||||
|
||||
if (!outlineMode) {
|
||||
for (Point point : controlPoints) {
|
||||
g2d.setColor(PIN_COLOR);
|
||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||
g2d.setColor(PIN_BORDER_COLOR);
|
||||
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||
}
|
||||
}
|
||||
|
||||
Area mainArea = getBody();
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
@@ -273,15 +284,6 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.draw(mainArea);
|
||||
|
||||
if (!outlineMode) {
|
||||
for (Point point : controlPoints) {
|
||||
g2d.setColor(PIN_COLOR);
|
||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||
g2d.setColor(PIN_BORDER_COLOR);
|
||||
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
Color finalLabelColor;
|
||||
|
||||
Binary file not shown.
@@ -2226,6 +2226,10 @@
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Use hardware acceleration for rendering to improve performance</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Use transparency instead of rendering pins on top of transistor body</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Leads and wires are rendered better, especially when zoomed in</description>
|
||||
|
||||
Reference in New Issue
Block a user