mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Outline mode for trimmers, potentiometers and transistors
This commit is contained in:
Binary file not shown.
+113
-63
@@ -10,6 +10,8 @@ import java.awt.geom.Area;
|
|||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
@@ -17,10 +19,12 @@ import org.diylc.core.CreationMethod;
|
|||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.Theme;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Potentiometer (panel mount)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.SINGLE_CLICK, instanceNamePrefix = "VR", description = "Panel mount potentiometer with solder lugs", zOrder = IDIYComponent.COMPONENT, stretchable = false)
|
@ComponentDescriptor(name = "Potentiometer (panel mount)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.SINGLE_CLICK, instanceNamePrefix = "VR", description = "Panel mount potentiometer with solder lugs", zOrder = IDIYComponent.COMPONENT, stretchable = false)
|
||||||
public class PotentiometerPanel extends AbstractPotentiometer {
|
public class PotentiometerPanel extends AbstractPotentiometer {
|
||||||
@@ -42,7 +46,8 @@ public class PotentiometerPanel extends AbstractPotentiometer {
|
|||||||
transient protected Area[] body = null;
|
transient protected Area[] body = null;
|
||||||
|
|
||||||
public PotentiometerPanel() {
|
public PotentiometerPanel() {
|
||||||
controlPoints = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0) };
|
controlPoints = new Point[] { new Point(0, 0), new Point(0, 0),
|
||||||
|
new Point(0, 0) };
|
||||||
updateControlPoints();
|
updateControlPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,20 +55,28 @@ public class PotentiometerPanel extends AbstractPotentiometer {
|
|||||||
int spacing = (int) this.spacing.convertToPixels();
|
int spacing = (int) this.spacing.convertToPixels();
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
controlPoints[1].setLocation(controlPoints[0].x + spacing, controlPoints[0].y);
|
controlPoints[1].setLocation(controlPoints[0].x + spacing,
|
||||||
controlPoints[2].setLocation(controlPoints[0].x + 2 * spacing, controlPoints[0].y);
|
controlPoints[0].y);
|
||||||
|
controlPoints[2].setLocation(controlPoints[0].x + 2 * spacing,
|
||||||
|
controlPoints[0].y);
|
||||||
break;
|
break;
|
||||||
case _90:
|
case _90:
|
||||||
controlPoints[1].setLocation(controlPoints[0].x, controlPoints[0].y + spacing);
|
controlPoints[1].setLocation(controlPoints[0].x, controlPoints[0].y
|
||||||
controlPoints[2].setLocation(controlPoints[0].x, controlPoints[0].y + 2 * spacing);
|
+ spacing);
|
||||||
|
controlPoints[2].setLocation(controlPoints[0].x, controlPoints[0].y
|
||||||
|
+ 2 * spacing);
|
||||||
break;
|
break;
|
||||||
case _180:
|
case _180:
|
||||||
controlPoints[1].setLocation(controlPoints[0].x - spacing, controlPoints[0].y);
|
controlPoints[1].setLocation(controlPoints[0].x - spacing,
|
||||||
controlPoints[2].setLocation(controlPoints[0].x - 2 * spacing, controlPoints[0].y);
|
controlPoints[0].y);
|
||||||
|
controlPoints[2].setLocation(controlPoints[0].x - 2 * spacing,
|
||||||
|
controlPoints[0].y);
|
||||||
break;
|
break;
|
||||||
case _270:
|
case _270:
|
||||||
controlPoints[1].setLocation(controlPoints[0].x, controlPoints[0].y - spacing);
|
controlPoints[1].setLocation(controlPoints[0].x, controlPoints[0].y
|
||||||
controlPoints[2].setLocation(controlPoints[0].x, controlPoints[0].y - 2 * spacing);
|
- spacing);
|
||||||
|
controlPoints[2].setLocation(controlPoints[0].x, controlPoints[0].y
|
||||||
|
- 2 * spacing);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -80,49 +93,55 @@ public class PotentiometerPanel extends AbstractPotentiometer {
|
|||||||
int lugDiameter = getClosestOdd(this.lugDiameter.convertToPixels());
|
int lugDiameter = getClosestOdd(this.lugDiameter.convertToPixels());
|
||||||
int holeDiameter = getClosestOdd(this.lugDiameter.convertToPixels() / 2);
|
int holeDiameter = getClosestOdd(this.lugDiameter.convertToPixels() / 2);
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
Area area = new Area(new Ellipse2D.Double(controlPoints[i].x - lugDiameter / 2,
|
Area area = new Area(new Ellipse2D.Double(controlPoints[i].x
|
||||||
controlPoints[i].y - lugDiameter / 2, lugDiameter, lugDiameter));
|
- lugDiameter / 2,
|
||||||
|
controlPoints[i].y - lugDiameter / 2, lugDiameter,
|
||||||
|
lugDiameter));
|
||||||
body[4 + i] = area;
|
body[4 + i] = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
body[3] = new Area(new Ellipse2D.Double(
|
body[3] = new Area(new Ellipse2D.Double(controlPoints[0].x
|
||||||
controlPoints[0].x + spacing - diameter / 2, controlPoints[0].y - spacing
|
+ spacing - diameter / 2, controlPoints[0].y - spacing
|
||||||
/ 2 - diameter, diameter, diameter));
|
/ 2 - diameter, diameter, diameter));
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
body[i] = new Area(new Rectangle2D.Double(
|
body[i] = new Area(new Rectangle2D.Double(
|
||||||
controlPoints[i].x - holeDiameter / 2, controlPoints[i].y
|
controlPoints[i].x - holeDiameter / 2,
|
||||||
- (spacing + diameter) / 2, holeDiameter,
|
controlPoints[i].y - (spacing + diameter) / 2,
|
||||||
(spacing + diameter) / 2));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case _90:
|
|
||||||
body[3] = new Area(new Ellipse2D.Double(controlPoints[0].x + spacing / 2,
|
|
||||||
controlPoints[0].y + spacing - diameter / 2, diameter, diameter));
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
body[i] = new Area(new Rectangle2D.Double(controlPoints[i].x,
|
|
||||||
controlPoints[i].y - holeDiameter / 2, (spacing + diameter) / 2,
|
|
||||||
holeDiameter));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case _180:
|
|
||||||
body[3] = new Area(new Ellipse2D.Double(
|
|
||||||
controlPoints[0].x - spacing - diameter / 2, controlPoints[0].y + spacing
|
|
||||||
/ 2, diameter, diameter));
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
body[i] = new Area(new Rectangle2D.Double(
|
|
||||||
controlPoints[i].x - holeDiameter / 2, controlPoints[i].y,
|
|
||||||
holeDiameter, (spacing + diameter) / 2));
|
holeDiameter, (spacing + diameter) / 2));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _270:
|
case _90:
|
||||||
body[3] = new Area(new Ellipse2D.Double(
|
body[3] = new Area(new Ellipse2D.Double(controlPoints[0].x
|
||||||
controlPoints[0].x - spacing / 2 - diameter, controlPoints[0].y - spacing
|
+ spacing / 2, controlPoints[0].y + spacing - diameter
|
||||||
- diameter / 2, diameter, diameter));
|
/ 2, diameter, diameter));
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
body[i] = new Area(new Rectangle2D.Double(controlPoints[i].x
|
body[i] = new Area(new Rectangle2D.Double(
|
||||||
- (spacing + diameter) / 2, controlPoints[i].y - holeDiameter / 2,
|
controlPoints[i].x, controlPoints[i].y
|
||||||
|
- holeDiameter / 2,
|
||||||
|
(spacing + diameter) / 2, holeDiameter));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case _180:
|
||||||
|
body[3] = new Area(new Ellipse2D.Double(controlPoints[0].x
|
||||||
|
- spacing - diameter / 2, controlPoints[0].y + spacing
|
||||||
|
/ 2, diameter, diameter));
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
body[i] = new Area(new Rectangle2D.Double(
|
||||||
|
controlPoints[i].x - holeDiameter / 2,
|
||||||
|
controlPoints[i].y, holeDiameter,
|
||||||
|
(spacing + diameter) / 2));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case _270:
|
||||||
|
body[3] = new Area(new Ellipse2D.Double(controlPoints[0].x
|
||||||
|
- spacing / 2 - diameter, controlPoints[0].y - spacing
|
||||||
|
- diameter / 2, diameter, diameter));
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
body[i] = new Area(new Rectangle2D.Double(
|
||||||
|
controlPoints[i].x - (spacing + diameter) / 2,
|
||||||
|
controlPoints[i].y - holeDiameter / 2,
|
||||||
(spacing + diameter) / 2, holeDiameter));
|
(spacing + diameter) / 2, holeDiameter));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -136,8 +155,9 @@ public class PotentiometerPanel extends AbstractPotentiometer {
|
|||||||
}
|
}
|
||||||
// Make holes in the lugs.
|
// Make holes in the lugs.
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
body[4 + i].subtract(new Area(new Ellipse2D.Double(controlPoints[i].x
|
body[4 + i].subtract(new Area(new Ellipse2D.Double(
|
||||||
- holeDiameter / 2, controlPoints[i].y - holeDiameter / 2, holeDiameter,
|
controlPoints[i].x - holeDiameter / 2,
|
||||||
|
controlPoints[i].y - holeDiameter / 2, holeDiameter,
|
||||||
holeDiameter)));
|
holeDiameter)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,30 +178,51 @@ public class PotentiometerPanel extends AbstractPotentiometer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
public void draw(Graphics2D g2d, ComponentState componentState,
|
||||||
Project project, IDrawingObserver drawingObserver) {
|
boolean outlineMode, Project project,
|
||||||
|
IDrawingObserver drawingObserver) {
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
for (Area shape : getBody()) {
|
for (Area shape : getBody()) {
|
||||||
if (shape != null) {
|
if (shape != null) {
|
||||||
g2d.setColor(bodyColor);
|
g2d.setColor(bodyColor);
|
||||||
Composite oldComposite = g2d.getComposite();
|
Composite oldComposite = g2d.getComposite();
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(
|
||||||
/ MAX_ALPHA));
|
AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
|
}
|
||||||
|
if (!outlineMode) {
|
||||||
|
g2d.fill(shape);
|
||||||
}
|
}
|
||||||
g2d.fill(shape);
|
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED
|
Color finalBorderColor;
|
||||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
if (outlineMode) {
|
||||||
: borderColor);
|
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(shape);
|
g2d.draw(shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Draw caption.
|
// Draw caption.
|
||||||
g2d.setFont(LABEL_FONT);
|
g2d.setFont(LABEL_FONT);
|
||||||
g2d
|
Color finalLabelColor;
|
||||||
.setColor(componentState == ComponentState.SELECTED ? LABEL_COLOR_SELECTED
|
if (outlineMode) {
|
||||||
: LABEL_COLOR);
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
|
: theme.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
|
: LABEL_COLOR;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalLabelColor);
|
||||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||||
Rectangle2D bodyRect = getBody()[3].getBounds2D();
|
Rectangle2D bodyRect = getBody()[3].getBounds2D();
|
||||||
Rectangle2D rect = fontMetrics.getStringBounds(getName(), g2d);
|
Rectangle2D rect = fontMetrics.getStringBounds(getName(), g2d);
|
||||||
@@ -194,7 +235,8 @@ public class PotentiometerPanel extends AbstractPotentiometer {
|
|||||||
int x = (panelWidth - textWidth) / 2;
|
int x = (panelWidth - textWidth) / 2;
|
||||||
int y = panelHeight / 2 - textHeight + fontMetrics.getAscent();
|
int y = panelHeight / 2 - textHeight + fontMetrics.getAscent();
|
||||||
|
|
||||||
g2d.drawString(getName(), (int) (bodyRect.getX() + x), (int) (bodyRect.getY() + y));
|
g2d.drawString(getName(), (int) (bodyRect.getX() + x), (int) (bodyRect
|
||||||
|
.getY() + y));
|
||||||
|
|
||||||
// Draw value.
|
// Draw value.
|
||||||
rect = fontMetrics.getStringBounds(getValueForDisplay(), g2d);
|
rect = fontMetrics.getStringBounds(getValueForDisplay(), g2d);
|
||||||
@@ -214,19 +256,27 @@ public class PotentiometerPanel extends AbstractPotentiometer {
|
|||||||
int margin = 4 * width / 32;
|
int margin = 4 * width / 32;
|
||||||
int spacing = width / 3 - 1;
|
int spacing = width / 3 - 1;
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2 * width / 32));
|
g2d.setStroke(ObjectCache.getInstance()
|
||||||
g2d.drawLine(width / 2 - spacing, height / 2, width / 2 - spacing, height - margin);
|
.fetchBasicStroke(2 * width / 32));
|
||||||
g2d.drawLine(width / 2 + spacing, height / 2, width / 2 + spacing, height - margin);
|
g2d.drawLine(width / 2 - spacing, height / 2, width / 2 - spacing,
|
||||||
|
height - margin);
|
||||||
|
g2d.drawLine(width / 2 + spacing, height / 2, width / 2 + spacing,
|
||||||
|
height - margin);
|
||||||
g2d.drawLine(width / 2, height / 2, width / 2, height - margin);
|
g2d.drawLine(width / 2, height / 2, width / 2, height - margin);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(4 * width / 32));
|
g2d.setStroke(ObjectCache.getInstance()
|
||||||
g2d.drawLine(width / 2 - spacing, height - margin, width / 2 - spacing, height - margin);
|
.fetchBasicStroke(4 * width / 32));
|
||||||
g2d.drawLine(width / 2 + spacing, height - margin, width / 2 + spacing, height - margin);
|
g2d.drawLine(width / 2 - spacing, height - margin, width / 2 - spacing,
|
||||||
|
height - margin);
|
||||||
|
g2d.drawLine(width / 2 + spacing, height - margin, width / 2 + spacing,
|
||||||
|
height - margin);
|
||||||
g2d.drawLine(width / 2, height - margin, width / 2, height - margin);
|
g2d.drawLine(width / 2, height - margin, width / 2, height - margin);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
g2d.setColor(BODY_COLOR);
|
g2d.setColor(BODY_COLOR);
|
||||||
g2d.fillOval(margin, margin / 2, width - 2 * margin, height - 2 * margin);
|
g2d.fillOval(margin, margin / 2, width - 2 * margin, height - 2
|
||||||
|
* margin);
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.drawOval(margin, margin / 2, width - 2 * margin, height - 2 * margin);
|
g2d.drawOval(margin, margin / 2, width - 2 * margin, height - 2
|
||||||
|
* margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
|
|||||||
+84
-40
@@ -12,6 +12,8 @@ import java.awt.geom.Area;
|
|||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
@@ -19,10 +21,12 @@ import org.diylc.core.CreationMethod;
|
|||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.Theme;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Trimmer Potentiometer", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.SINGLE_CLICK, instanceNamePrefix = "VR", description = "Various types of board mounted trimmer potentiometers", zOrder = IDIYComponent.COMPONENT, stretchable = false)
|
@ComponentDescriptor(name = "Trimmer Potentiometer", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.SINGLE_CLICK, instanceNamePrefix = "VR", description = "Various types of board mounted trimmer potentiometers", zOrder = IDIYComponent.COMPONENT, stretchable = false)
|
||||||
public class TrimmerPotentiometer extends AbstractPotentiometer {
|
public class TrimmerPotentiometer extends AbstractPotentiometer {
|
||||||
@@ -50,7 +54,8 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
|||||||
protected TrimmerType type = TrimmerType.FLAT_SMALL;
|
protected TrimmerType type = TrimmerType.FLAT_SMALL;
|
||||||
|
|
||||||
public TrimmerPotentiometer() {
|
public TrimmerPotentiometer() {
|
||||||
controlPoints = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0) };
|
controlPoints = new Point[] { new Point(0, 0), new Point(0, 0),
|
||||||
|
new Point(0, 0) };
|
||||||
updateControlPoints();
|
updateControlPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,8 +181,10 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
controlPoints[1].setLocation(controlPoints[0].x + dx1, controlPoints[0].y + dy1);
|
controlPoints[1].setLocation(controlPoints[0].x + dx1,
|
||||||
controlPoints[2].setLocation(controlPoints[0].x + dx2, controlPoints[0].y + dy2);
|
controlPoints[0].y + dy1);
|
||||||
|
controlPoints[2].setLocation(controlPoints[0].x + dx2,
|
||||||
|
controlPoints[0].y + dy2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shape[] getBody() {
|
public Shape[] getBody() {
|
||||||
@@ -186,12 +193,14 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
|||||||
|
|
||||||
// Calculate the center point as center of the minimum bounding
|
// Calculate the center point as center of the minimum bounding
|
||||||
// rectangle.
|
// rectangle.
|
||||||
int centerX = (Math.max(Math.max(controlPoints[0].x, controlPoints[1].x),
|
int centerX = (Math.max(Math.max(controlPoints[0].x,
|
||||||
controlPoints[2].x) + Math.min(
|
controlPoints[1].x), controlPoints[2].x) + Math.min(Math
|
||||||
Math.min(controlPoints[0].x, controlPoints[1].x), controlPoints[2].x)) / 2;
|
.min(controlPoints[0].x, controlPoints[1].x),
|
||||||
int centerY = (Math.max(Math.max(controlPoints[0].y, controlPoints[1].y),
|
controlPoints[2].x)) / 2;
|
||||||
controlPoints[2].y) + Math.min(
|
int centerY = (Math.max(Math.max(controlPoints[0].y,
|
||||||
Math.min(controlPoints[0].y, controlPoints[1].y), controlPoints[2].y)) / 2;
|
controlPoints[1].y), controlPoints[2].y) + Math.min(Math
|
||||||
|
.min(controlPoints[0].y, controlPoints[1].y),
|
||||||
|
controlPoints[2].y)) / 2;
|
||||||
|
|
||||||
// Calculate body dimensions based on the selected type.
|
// Calculate body dimensions based on the selected type.
|
||||||
int length = 0;
|
int length = 0;
|
||||||
@@ -202,11 +211,12 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
|||||||
length = getClosestOdd(FLAT_BODY_SIZE.convertToPixels());
|
length = getClosestOdd(FLAT_BODY_SIZE.convertToPixels());
|
||||||
width = length;
|
width = length;
|
||||||
int shaftSize = getClosestOdd(FLAT_SHAFT_SIZE.convertToPixels());
|
int shaftSize = getClosestOdd(FLAT_SHAFT_SIZE.convertToPixels());
|
||||||
Area shaft = new Area(new Ellipse2D.Double(centerX - shaftSize / 2, centerY
|
Area shaft = new Area(new Ellipse2D.Double(centerX - shaftSize
|
||||||
- shaftSize / 2, shaftSize, shaftSize));
|
/ 2, centerY - shaftSize / 2, shaftSize, shaftSize));
|
||||||
Area slot = new Area(new Rectangle2D.Double(centerX - shaftSize / 2, centerY
|
Area slot = new Area(new Rectangle2D.Double(centerX - shaftSize
|
||||||
- shaftSize / 8, shaftSize, shaftSize / 4));
|
/ 2, centerY - shaftSize / 8, shaftSize, shaftSize / 4));
|
||||||
slot.transform(AffineTransform.getRotateInstance(Math.PI / 4, centerX, centerY));
|
slot.transform(AffineTransform.getRotateInstance(Math.PI / 4,
|
||||||
|
centerX, centerY));
|
||||||
shaft.subtract(slot);
|
shaft.subtract(slot);
|
||||||
body[1] = shaft;
|
body[1] = shaft;
|
||||||
break;
|
break;
|
||||||
@@ -216,13 +226,14 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
|||||||
width = getClosestOdd(VERTICAL_BODY_WIDTH.convertToPixels());
|
width = getClosestOdd(VERTICAL_BODY_WIDTH.convertToPixels());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (orientation == Orientation.DEFAULT || orientation == Orientation._180) {
|
if (orientation == Orientation.DEFAULT
|
||||||
|
|| orientation == Orientation._180) {
|
||||||
int p = length;
|
int p = length;
|
||||||
length = width;
|
length = width;
|
||||||
width = p;
|
width = p;
|
||||||
}
|
}
|
||||||
body[0] = new Rectangle2D.Double(centerX - length / 2, centerY - width / 2, length,
|
body[0] = new Rectangle2D.Double(centerX - length / 2, centerY
|
||||||
width);
|
- width / 2, length, width);
|
||||||
}
|
}
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
@@ -241,48 +252,75 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
public void draw(Graphics2D g2d, ComponentState componentState,
|
||||||
Project project, IDrawingObserver drawingObserver) {
|
boolean outlineMode, Project project,
|
||||||
|
IDrawingObserver drawingObserver) {
|
||||||
if (checkPointsClipped(g2d.getClip())) {
|
if (checkPointsClipped(g2d.getClip())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
Shape mainShape = getBody()[0];
|
Shape mainShape = getBody()[0];
|
||||||
Shape shaftShape = getBody()[1];
|
Shape shaftShape = getBody()[1];
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
if (mainShape != null) {
|
if (mainShape != null) {
|
||||||
g2d.setColor(bodyColor);
|
g2d.setColor(bodyColor);
|
||||||
Composite oldComposite = g2d.getComposite();
|
Composite oldComposite = g2d.getComposite();
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(
|
||||||
/ MAX_ALPHA));
|
AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
}
|
}
|
||||||
g2d.fill(mainShape);
|
if (!outlineMode) {
|
||||||
if (shaftShape != null) {
|
g2d.fill(mainShape);
|
||||||
|
}
|
||||||
|
if (!outlineMode && shaftShape != null) {
|
||||||
g2d.setColor(SHAFT_COLOR);
|
g2d.setColor(SHAFT_COLOR);
|
||||||
g2d.fill(shaftShape);
|
g2d.fill(shaftShape);
|
||||||
g2d.setColor(SHAFT_BORDER_COLOR);
|
g2d.setColor(SHAFT_BORDER_COLOR);
|
||||||
g2d.draw(shaftShape);
|
g2d.draw(shaftShape);
|
||||||
}
|
}
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED
|
Color finalBorderColor;
|
||||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
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(mainShape);
|
g2d.draw(mainShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw pins.
|
// Draw pins.
|
||||||
int pinSize = getClosestOdd(PIN_SIZE.convertToPixels());
|
int pinSize = getClosestOdd(PIN_SIZE.convertToPixels());
|
||||||
for (Point point : controlPoints) {
|
for (Point point : controlPoints) {
|
||||||
g2d.setColor(PIN_COLOR);
|
if (!outlineMode) {
|
||||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
g2d.setColor(PIN_COLOR);
|
||||||
g2d.setColor(PIN_BORDER_COLOR);
|
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2,
|
||||||
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
pinSize, pinSize);
|
||||||
|
}
|
||||||
|
g2d.setColor(outlineMode ? theme.getOutlineColor()
|
||||||
|
: PIN_BORDER_COLOR);
|
||||||
|
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize,
|
||||||
|
pinSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw label.
|
// Draw label.
|
||||||
g2d.setFont(LABEL_FONT);
|
g2d.setFont(LABEL_FONT);
|
||||||
g2d
|
Color finalLabelColor;
|
||||||
.setColor(componentState == ComponentState.SELECTED ? LABEL_COLOR_SELECTED
|
if (outlineMode) {
|
||||||
: LABEL_COLOR);
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
|
: theme.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
|
: LABEL_COLOR;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalLabelColor);
|
||||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||||
Rectangle2D bodyRect = getBody()[0].getBounds2D();
|
Rectangle2D bodyRect = getBody()[0].getBounds2D();
|
||||||
Rectangle2D rect = fontMetrics.getStringBounds(getName(), g2d);
|
Rectangle2D rect = fontMetrics.getStringBounds(getName(), g2d);
|
||||||
@@ -295,7 +333,8 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
|||||||
int x = (panelWidth - textWidth) / 2;
|
int x = (panelWidth - textWidth) / 2;
|
||||||
int y = (panelHeight - textHeight) / 2 + fontMetrics.getAscent();
|
int y = (panelHeight - textHeight) / 2 + fontMetrics.getAscent();
|
||||||
|
|
||||||
g2d.drawString(getName(), (int) (bodyRect.getX() + x), (int) (bodyRect.getY() + y));
|
g2d.drawString(getName(), (int) (bodyRect.getX() + x), (int) (bodyRect
|
||||||
|
.getY() + y));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -308,10 +347,12 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
|||||||
g2d.drawRect(margin, margin, width - 2 * margin, width - 2 * margin);
|
g2d.drawRect(margin, margin, width - 2 * margin, width - 2 * margin);
|
||||||
int shaftSize = 11;
|
int shaftSize = 11;
|
||||||
int slotSize = 2;
|
int slotSize = 2;
|
||||||
Area area = new Area(new Ellipse2D.Double(width / 2 - shaftSize / 2, width / 2 - shaftSize
|
Area area = new Area(new Ellipse2D.Double(width / 2 - shaftSize / 2,
|
||||||
/ 2, shaftSize, shaftSize));
|
width / 2 - shaftSize / 2, shaftSize, shaftSize));
|
||||||
Area slot = new Area(new Rectangle2D.Double(0, width / 2 - slotSize / 2, width, slotSize));
|
Area slot = new Area(new Rectangle2D.Double(0,
|
||||||
slot.transform(AffineTransform.getRotateInstance(Math.PI / 4, width / 2, width / 2));
|
width / 2 - slotSize / 2, width, slotSize));
|
||||||
|
slot.transform(AffineTransform.getRotateInstance(Math.PI / 4,
|
||||||
|
width / 2, width / 2));
|
||||||
area.subtract(slot);
|
area.subtract(slot);
|
||||||
g2d.setColor(SHAFT_COLOR);
|
g2d.setColor(SHAFT_COLOR);
|
||||||
g2d.fill(area);
|
g2d.fill(area);
|
||||||
@@ -330,9 +371,11 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
|||||||
g2d.drawOval(margin - pinSize / 2, 21 - pinSize / 2, pinSize, pinSize);
|
g2d.drawOval(margin - pinSize / 2, 21 - pinSize / 2, pinSize, pinSize);
|
||||||
|
|
||||||
g2d.setColor(PIN_COLOR);
|
g2d.setColor(PIN_COLOR);
|
||||||
g2d.fillOval(width - margin - pinSize / 2, width / 2 - pinSize / 2, pinSize, pinSize);
|
g2d.fillOval(width - margin - pinSize / 2, width / 2 - pinSize / 2,
|
||||||
|
pinSize, pinSize);
|
||||||
g2d.setColor(PIN_BORDER_COLOR);
|
g2d.setColor(PIN_BORDER_COLOR);
|
||||||
g2d.drawOval(width - margin - pinSize / 2, width / 2 - pinSize / 2, pinSize, pinSize);
|
g2d.drawOval(width - margin - pinSize / 2, width / 2 - pinSize / 2,
|
||||||
|
pinSize, pinSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Body")
|
@EditableProperty(name = "Body")
|
||||||
@@ -369,7 +412,8 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name().substring(0, 1) + name().substring(1).toLowerCase().replace("_", " ");
|
return name().substring(0, 1)
|
||||||
|
+ name().substring(1).toLowerCase().replace("_", " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-19
@@ -152,23 +152,38 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
|||||||
if (folded) {
|
if (folded) {
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
body = new Area(new RoundRectangle2D.Double(x - bodyLength, y - bodyDiameter / 2, bodyLength, bodyDiameter, edgeRadius, edgeRadius));
|
body = new Area(new RoundRectangle2D.Double(x - bodyLength,
|
||||||
body.add(new Area(new Rectangle2D.Double(x - bodyLength / 2, y - bodyDiameter / 2, bodyLength / 2, bodyDiameter)));
|
y - bodyDiameter / 2, bodyLength, bodyDiameter,
|
||||||
|
edgeRadius, edgeRadius));
|
||||||
|
body.add(new Area(new Rectangle2D.Double(
|
||||||
|
x - bodyLength / 2, y - bodyDiameter / 2,
|
||||||
|
bodyLength / 2, bodyDiameter)));
|
||||||
break;
|
break;
|
||||||
case _90:
|
case _90:
|
||||||
body = new Area(new RoundRectangle2D.Double(x - bodyDiameter / 2, y - bodyLength, bodyDiameter, bodyLength, edgeRadius, edgeRadius));
|
body = new Area(new RoundRectangle2D.Double(x
|
||||||
body.add(new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y - bodyLength / 2, bodyDiameter, bodyLength / 2)));
|
- bodyDiameter / 2, y - bodyLength, bodyDiameter,
|
||||||
|
bodyLength, edgeRadius, edgeRadius));
|
||||||
|
body.add(new Area(new Rectangle2D.Double(x - bodyDiameter
|
||||||
|
/ 2, y - bodyLength / 2, bodyDiameter,
|
||||||
|
bodyLength / 2)));
|
||||||
break;
|
break;
|
||||||
case _180:
|
case _180:
|
||||||
body = new Area(new RoundRectangle2D.Double(x, y - bodyDiameter / 2, bodyLength, bodyDiameter, edgeRadius, edgeRadius));
|
body = new Area(new RoundRectangle2D.Double(x, y
|
||||||
body.add(new Area(new Rectangle2D.Double(x, y - bodyDiameter / 2, bodyLength / 2, bodyDiameter)));
|
- bodyDiameter / 2, bodyLength, bodyDiameter,
|
||||||
|
edgeRadius, edgeRadius));
|
||||||
|
body.add(new Area(new Rectangle2D.Double(x, y
|
||||||
|
- bodyDiameter / 2, bodyLength / 2, bodyDiameter)));
|
||||||
break;
|
break;
|
||||||
case _270:
|
case _270:
|
||||||
body = new Area(new RoundRectangle2D.Double(x - bodyDiameter / 2, y, bodyDiameter, bodyLength, edgeRadius, edgeRadius));
|
body = new Area(new RoundRectangle2D.Double(x
|
||||||
body.add(new Area(new Rectangle2D.Double(x - bodyDiameter / 2, y, bodyDiameter, bodyLength / 2)));
|
- bodyDiameter / 2, y, bodyDiameter, bodyLength,
|
||||||
|
edgeRadius, edgeRadius));
|
||||||
|
body.add(new Area(new Rectangle2D.Double(x - bodyDiameter
|
||||||
|
/ 2, y, bodyDiameter, bodyLength / 2)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
throw new RuntimeException("Unexpected orientation: "
|
||||||
|
+ orientation);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
body = new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y
|
body = new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y
|
||||||
@@ -197,9 +212,9 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.fill(mainArea);
|
g2d.fill(mainArea);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
Color finalBorderColor;
|
Color finalBorderColor;
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
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();
|
||||||
@@ -212,23 +227,22 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
g2d.draw(mainArea);
|
g2d.draw(mainArea);
|
||||||
|
|
||||||
if (!outlineMode) {
|
for (Point point : controlPoints) {
|
||||||
for (Point point : controlPoints) {
|
if (!outlineMode) {
|
||||||
g2d.setColor(PIN_COLOR);
|
g2d.setColor(PIN_COLOR);
|
||||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2,
|
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2,
|
||||||
pinSize, pinSize);
|
pinSize, pinSize);
|
||||||
g2d.setColor(PIN_BORDER_COLOR);
|
|
||||||
g2d.drawOval(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.
|
// Draw label.
|
||||||
g2d.setFont(LABEL_FONT);
|
g2d.setFont(LABEL_FONT);
|
||||||
Color finalLabelColor;
|
Color finalLabelColor;
|
||||||
if (outlineMode) {
|
if (outlineMode) {
|
||||||
Theme theme = (Theme) ConfigurationManager.getInstance()
|
|
||||||
.readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
|
||||||
finalLabelColor = componentState == ComponentState.SELECTED
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
: theme.getOutlineColor();
|
: theme.getOutlineColor();
|
||||||
@@ -283,7 +297,7 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
|||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name="Pin spacing")
|
@EditableProperty(name = "Pin spacing")
|
||||||
public Size getPinSpacing() {
|
public Size getPinSpacing() {
|
||||||
return pinSpacing;
|
return pinSpacing;
|
||||||
}
|
}
|
||||||
|
|||||||
+73
-62
@@ -285,9 +285,9 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.draw(tabArea);
|
g2d.draw(tabArea);
|
||||||
}
|
}
|
||||||
Color finalBorderColor;
|
Color finalBorderColor;
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
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();
|
||||||
@@ -303,69 +303,82 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw pins.
|
// Draw pins.
|
||||||
if (!outlineMode) {
|
|
||||||
if (folded) {
|
if (folded) {
|
||||||
int leadThickness = getClosestOdd(LEAD_THICKNESS
|
int leadThickness = getClosestOdd(LEAD_THICKNESS.convertToPixels());
|
||||||
.convertToPixels());
|
int leadLength = (int) getLeadLength().convertToPixels();
|
||||||
int leadLength = (int) getLeadLength().convertToPixels();
|
Color finalPinColor;
|
||||||
for (Point point : controlPoints) {
|
Color finalPinBorderColor;
|
||||||
switch (orientation) {
|
if (outlineMode) {
|
||||||
case DEFAULT:
|
finalPinColor = new Color(0, 0, 0, 0);
|
||||||
g2d.setStroke(ObjectCache.getInstance()
|
finalPinBorderColor = componentState == ComponentState.SELECTED
|
||||||
.fetchBasicStroke(leadThickness));
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
g2d.setColor(METAL_COLOR.darker());
|
: theme.getOutlineColor();
|
||||||
g2d.drawLine(point.x, point.y, point.x + leadLength
|
|
||||||
- leadThickness / 2, point.y);
|
|
||||||
g2d.setStroke(ObjectCache.getInstance()
|
|
||||||
.fetchBasicStroke(leadThickness - 2));
|
|
||||||
g2d.setColor(METAL_COLOR);
|
|
||||||
g2d.drawLine(point.x, point.y, point.x + leadLength
|
|
||||||
- leadThickness / 2, point.y);
|
|
||||||
break;
|
|
||||||
case _90:
|
|
||||||
g2d.setStroke(ObjectCache.getInstance()
|
|
||||||
.fetchBasicStroke(leadThickness));
|
|
||||||
g2d.setColor(METAL_COLOR.darker());
|
|
||||||
g2d.drawLine(point.x, point.y, point.x, point.y
|
|
||||||
+ leadLength - leadThickness / 2);
|
|
||||||
g2d.setStroke(ObjectCache.getInstance()
|
|
||||||
.fetchBasicStroke(leadThickness - 2));
|
|
||||||
g2d.setColor(METAL_COLOR);
|
|
||||||
g2d.drawLine(point.x, point.y, point.x, point.y
|
|
||||||
+ leadLength - leadThickness / 2);
|
|
||||||
break;
|
|
||||||
case _180:
|
|
||||||
g2d.setStroke(ObjectCache.getInstance()
|
|
||||||
.fetchBasicStroke(leadThickness));
|
|
||||||
g2d.setColor(METAL_COLOR.darker());
|
|
||||||
g2d.drawLine(point.x, point.y, point.x - leadLength
|
|
||||||
- leadThickness / 2, point.y);
|
|
||||||
g2d.setStroke(ObjectCache.getInstance()
|
|
||||||
.fetchBasicStroke(leadThickness - 2));
|
|
||||||
g2d.setColor(METAL_COLOR);
|
|
||||||
g2d.drawLine(point.x, point.y, point.x - leadLength
|
|
||||||
- leadThickness / 2, point.y);
|
|
||||||
break;
|
|
||||||
case _270:
|
|
||||||
g2d.setStroke(ObjectCache.getInstance()
|
|
||||||
.fetchBasicStroke(leadThickness));
|
|
||||||
g2d.setColor(METAL_COLOR.darker());
|
|
||||||
g2d.drawLine(point.x, point.y, point.x, point.y
|
|
||||||
- leadLength);
|
|
||||||
g2d.setStroke(ObjectCache.getInstance()
|
|
||||||
.fetchBasicStroke(leadThickness - 2));
|
|
||||||
g2d.setColor(METAL_COLOR);
|
|
||||||
g2d.drawLine(point.x, point.y, point.x, point.y
|
|
||||||
- leadLength);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
finalPinColor = METAL_COLOR;
|
||||||
|
finalPinBorderColor = METAL_COLOR.darker();
|
||||||
|
}
|
||||||
|
for (Point point : controlPoints) {
|
||||||
|
switch (orientation) {
|
||||||
|
case DEFAULT:
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness));
|
||||||
|
g2d.setColor(finalPinBorderColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x + leadLength
|
||||||
|
- leadThickness / 2, point.y);
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness - 2));
|
||||||
|
g2d.setColor(finalPinColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x + leadLength
|
||||||
|
- leadThickness / 2, point.y);
|
||||||
|
break;
|
||||||
|
case _90:
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness));
|
||||||
|
g2d.setColor(finalPinBorderColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x, point.y
|
||||||
|
+ leadLength - leadThickness / 2);
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness - 2));
|
||||||
|
g2d.setColor(finalPinColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x, point.y
|
||||||
|
+ leadLength - leadThickness / 2);
|
||||||
|
break;
|
||||||
|
case _180:
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness));
|
||||||
|
g2d.setColor(finalPinBorderColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x - leadLength
|
||||||
|
- leadThickness / 2, point.y);
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness - 2));
|
||||||
|
g2d.setColor(finalPinColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x - leadLength
|
||||||
|
- leadThickness / 2, point.y);
|
||||||
|
break;
|
||||||
|
case _270:
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness));
|
||||||
|
g2d.setColor(finalPinBorderColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x, point.y
|
||||||
|
- leadLength);
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness - 2));
|
||||||
|
g2d.setColor(finalPinColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x, point.y
|
||||||
|
- leadLength);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!outlineMode) {
|
||||||
for (Point point : controlPoints) {
|
for (Point point : controlPoints) {
|
||||||
|
|
||||||
g2d.setColor(PIN_COLOR);
|
g2d.setColor(PIN_COLOR);
|
||||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2,
|
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2,
|
||||||
pinSize, pinSize);
|
pinSize, pinSize);
|
||||||
g2d.setColor(PIN_BORDER_COLOR);
|
g2d.setColor(outlineMode ? theme.getOutlineColor()
|
||||||
|
: PIN_BORDER_COLOR);
|
||||||
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2,
|
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2,
|
||||||
pinSize, pinSize);
|
pinSize, pinSize);
|
||||||
}
|
}
|
||||||
@@ -376,8 +389,6 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.setFont(LABEL_FONT);
|
g2d.setFont(LABEL_FONT);
|
||||||
Color finalLabelColor;
|
Color finalLabelColor;
|
||||||
if (outlineMode) {
|
if (outlineMode) {
|
||||||
Theme theme = (Theme) ConfigurationManager.getInstance()
|
|
||||||
.readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
|
||||||
finalLabelColor = componentState == ComponentState.SELECTED
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
: theme.getOutlineColor();
|
: theme.getOutlineColor();
|
||||||
|
|||||||
+24
-25
@@ -250,9 +250,9 @@ public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.fill(mainArea);
|
g2d.fill(mainArea);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
Color finalBorderColor;
|
Color finalBorderColor;
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
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();
|
||||||
@@ -266,23 +266,22 @@ public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.draw(mainArea);
|
g2d.draw(mainArea);
|
||||||
g2d.draw(innerArea);
|
g2d.draw(innerArea);
|
||||||
|
|
||||||
if (!outlineMode) {
|
for (Point point : controlPoints) {
|
||||||
for (Point point : controlPoints) {
|
if (!outlineMode) {
|
||||||
g2d.setColor(PIN_COLOR);
|
g2d.setColor(PIN_COLOR);
|
||||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2,
|
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2,
|
||||||
pinSize, pinSize);
|
pinSize, pinSize);
|
||||||
g2d.setColor(PIN_BORDER_COLOR);
|
|
||||||
g2d.drawOval(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.
|
// Draw label.
|
||||||
g2d.setFont(LABEL_FONT);
|
g2d.setFont(LABEL_FONT);
|
||||||
Color finalLabelColor;
|
Color finalLabelColor;
|
||||||
if (outlineMode) {
|
if (outlineMode) {
|
||||||
Theme theme = (Theme) ConfigurationManager.getInstance()
|
|
||||||
.readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
|
||||||
finalLabelColor = componentState == ComponentState.SELECTED
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
: theme.getOutlineColor();
|
: theme.getOutlineColor();
|
||||||
@@ -313,20 +312,20 @@ public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
|||||||
int hole = 4 * width / 32;
|
int hole = 4 * width / 32;
|
||||||
Area area = new Area(new Ellipse2D.Double((width - sizeLarge) / 2,
|
Area area = new Area(new Ellipse2D.Double((width - sizeLarge) / 2,
|
||||||
(height - sizeLarge) / 2, sizeLarge, sizeLarge));
|
(height - sizeLarge) / 2, sizeLarge, sizeLarge));
|
||||||
// int[] x = new int[] { width / 2 + sizeSmall / 2,
|
// int[] x = new int[] { width / 2 + sizeSmall / 2,
|
||||||
// width / 2 + sizeLarge / 2, width / 2 + sizeSmall / 2,
|
// width / 2 + sizeLarge / 2, width / 2 + sizeSmall / 2,
|
||||||
// width / 2 - sizeSmall / 2, width / 2 - sizeLarge / 2,
|
// width / 2 - sizeSmall / 2, width / 2 - sizeLarge / 2,
|
||||||
// width / 2 - sizeSmall / 2 };
|
// width / 2 - sizeSmall / 2 };
|
||||||
// int[] y = new int[] { height / 8, height / 2, height * 7 / 8,
|
// int[] y = new int[] { height / 8, height / 2, height * 7 / 8,
|
||||||
// height * 7 / 8, height / 2, height / 8 };
|
// height * 7 / 8, height / 2, height / 8 };
|
||||||
// Area p = new Area(new Polygon(x, y, x.length));
|
// Area p = new Area(new Polygon(x, y, x.length));
|
||||||
// AffineTransform t = AffineTransform.getTranslateInstance(width / 2,
|
// AffineTransform t = AffineTransform.getTranslateInstance(width / 2,
|
||||||
// height / 2);
|
// height / 2);
|
||||||
// t.concatenate(AffineTransform.getScaleInstance(1.05, 1.05));
|
// t.concatenate(AffineTransform.getScaleInstance(1.05, 1.05));
|
||||||
// t.concatenate(AffineTransform.getTranslateInstance(-width / 2,
|
// t.concatenate(AffineTransform.getTranslateInstance(-width / 2,
|
||||||
// -height / 2));
|
// -height / 2));
|
||||||
// p.transform(t);
|
// p.transform(t);
|
||||||
// area.add(new Area(p));
|
// area.add(new Area(p));
|
||||||
area.add(new Area(new Ellipse2D.Double((width - sizeSmall) / 2, height
|
area.add(new Area(new Ellipse2D.Double((width - sizeSmall) / 2, height
|
||||||
/ 8 - sizeSmall / 2, sizeSmall, sizeSmall)));
|
/ 8 - sizeSmall / 2, sizeSmall, sizeSmall)));
|
||||||
area.add(new Area(new Ellipse2D.Double((width - sizeSmall) / 2, height
|
area.add(new Area(new Ellipse2D.Double((width - sizeSmall) / 2, height
|
||||||
@@ -341,8 +340,8 @@ public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.fill(area);
|
g2d.fill(area);
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.draw(area);
|
g2d.draw(area);
|
||||||
g2d.drawOval((width - sizeInner) / 2, (height - sizeInner) / 2, sizeInner,
|
g2d.drawOval((width - sizeInner) / 2, (height - sizeInner) / 2,
|
||||||
sizeInner);
|
sizeInner, sizeInner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Body")
|
@EditableProperty(name = "Body")
|
||||||
|
|||||||
Reference in New Issue
Block a user