mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 17:52:07 +10:00
improved potentiometer symbol
This commit is contained in:
@@ -8,6 +8,6 @@
|
||||
<classpathentry kind="lib" path="lib/app-framework.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/xstream-1.3.1.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_45"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_40"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
Binary file not shown.
@@ -5,6 +5,6 @@
|
||||
<classpathentry kind="lib" path="lib/app-framework.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/diylc-core"/>
|
||||
<classpathentry kind="lib" path="lib/xstream-1.4.3.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_45"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_40"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
+54
-11
@@ -1,18 +1,26 @@
|
||||
package org.diylc.components.passive;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.components.semiconductors.AbstractTransistorSymbol;
|
||||
|
||||
@ComponentDescriptor(name = "Trimmer Symbol", author = "MCbx", category = "Schematics", instanceNamePrefix = " VR", description = "Trimmer (potentiometer) symbol", stretchable = false, zOrder = IDIYComponent.COMPONENT, rotatable = true)
|
||||
@ComponentDescriptor(name = "Potentiometer Symbol", author = "MCbx", category = "Schematics", instanceNamePrefix = " VR", description = "Potentiometer symbol", stretchable = false, zOrder = IDIYComponent.COMPONENT, rotatable = true)
|
||||
public class PotentiometerSymbol extends AbstractTransistorSymbol {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public PotentiometerSymbol() {
|
||||
this.color = Color.blue;
|
||||
}
|
||||
|
||||
public Shape[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Shape[3];
|
||||
@@ -41,30 +49,65 @@ public class PotentiometerSymbol extends AbstractTransistorSymbol {
|
||||
polyline.lineTo(x + pinSpacing * 2, (y - pinSpacing * 2) + 7 * pinSpacing / 2);
|
||||
polyline.lineTo(x + pinSpacing * 2, y + pinSpacing * 2);
|
||||
polyline.moveTo(x, y);
|
||||
polyline.lineTo(x + pinSpacing * 2 - pinSpacing / 4, y);
|
||||
polyline.lineTo(x + pinSpacing * 2 - 2 * pinSpacing / 3, y - pinSpacing / 2);
|
||||
polyline.moveTo(x + pinSpacing * 2 - pinSpacing / 4, y);
|
||||
polyline.lineTo(x + pinSpacing * 2 - 2 * pinSpacing / 3, y + pinSpacing / 2);
|
||||
|
||||
body[0] = polyline;
|
||||
polyline = new GeneralPath();
|
||||
polyline.lineTo(x + pinSpacing * 2 - pinSpacing / 2, y);
|
||||
|
||||
body[1] = polyline;
|
||||
polyline = new GeneralPath();
|
||||
|
||||
body[0] = polyline;
|
||||
|
||||
polyline = new GeneralPath();
|
||||
polyline.moveTo(x + pinSpacing * 2 - pinSpacing / 3, y);
|
||||
polyline.lineTo(x + pinSpacing * 2 - pinSpacing * 2 / 3, y - pinSpacing / 3);
|
||||
polyline.lineTo(x + pinSpacing * 2 - pinSpacing * 2 / 3, y + pinSpacing / 3);
|
||||
polyline.lineTo(x + pinSpacing * 2 - pinSpacing / 3, y);
|
||||
body[2] = polyline;
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLabelX(Rectangle2D shapeRect, Rectangle2D textRect, FontMetrics fontMetrics, boolean outlineMode) {
|
||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||
if (controlPoints[0].x < controlPoints[1].x && controlPoints[0].x < controlPoints[2].x)
|
||||
return controlPoints[1].x + pinSpacing / 3;
|
||||
if (controlPoints[0].y < controlPoints[1].y && controlPoints[0].y < controlPoints[2].y)
|
||||
return controlPoints[0].x - (int) (textRect.getWidth() / 2);
|
||||
if (controlPoints[0].x > controlPoints[1].x && controlPoints[0].x > controlPoints[2].x)
|
||||
return controlPoints[1].x - pinSpacing / 2 - (int)textRect.getWidth();
|
||||
if (controlPoints[0].y > controlPoints[1].y && controlPoints[0].y > controlPoints[2].y)
|
||||
return controlPoints[0].x - (int) (textRect.getWidth() / 2);
|
||||
return 2 * ((int) (shapeRect.getWidth() - textRect.getWidth()) / 2 + (int) shapeRect.getX());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLabelY(Rectangle2D shapeRect, Rectangle2D textRect, FontMetrics fontMetrics, boolean outlineMode) {
|
||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||
if (controlPoints[0].x < controlPoints[1].x && controlPoints[0].x < controlPoints[2].x)
|
||||
return controlPoints[0].y;
|
||||
if (controlPoints[0].y < controlPoints[1].y && controlPoints[0].y < controlPoints[2].y)
|
||||
return controlPoints[1].y + pinSpacing * 2 / 3;
|
||||
if (controlPoints[0].x > controlPoints[1].x && controlPoints[0].x > controlPoints[2].x)
|
||||
return controlPoints[0].y;
|
||||
if (controlPoints[0].y > controlPoints[1].y && controlPoints[0].y > controlPoints[2].y)
|
||||
return controlPoints[1].y - pinSpacing * 2 / 3;
|
||||
return 2 * ((int) (shapeRect.getHeight() - textRect.getHeight()) / 2 + fontMetrics.getAscent()
|
||||
+ (int) shapeRect.getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||
g2d.setColor(COLOR);
|
||||
g2d.setColor(Color.blue);
|
||||
g2d.drawLine(0, height / 2, 4, height / 2);
|
||||
g2d.drawLine(width - 4, height / 2, width, height / 2);
|
||||
g2d.drawPolyline(new int[] { 4, 6, 10, 14, 18, 22, 26, 28 }, new int[] { height / 2, height / 2 + 2,
|
||||
height / 2 - 2, height / 2 + 2, height / 2 - 2, height / 2 + 2, height / 2 - 2, height / 2 }, 8);
|
||||
g2d.drawPolyline(new int[] { width / 2, width / 2 - 2, width / 2 - 4, width / 2 + 2, width / 2 - 2 },
|
||||
new int[] { height, height / 2 + 2, height / 2 + 6, height / 2 + 6, height / 2 + 2 }, 5);
|
||||
|
||||
g2d.drawPolyline(new int[] { width / 2, width / 2 - 2 }, new int[] { height, height / 2 + 2 }, 2);
|
||||
|
||||
g2d.fill(new Polygon(new int[] { width / 2 - 4, width / 2 + 2, width / 2 - 2 },
|
||||
new int[] { height / 2 + 6, height / 2 + 6, height / 2 + 2 }, 3));
|
||||
}
|
||||
|
||||
}
|
||||
+23
-7
@@ -1,10 +1,13 @@
|
||||
package org.diylc.components.semiconductors;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.common.Display;
|
||||
@@ -35,7 +38,7 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
|
||||
protected Point[] controlPoints = new Point[] { new Point(0, 0), new Point(0, 0),
|
||||
new Point(0, 0) };
|
||||
protected Color color = COLOR;
|
||||
protected SymbolFlipping flipping = FLIPPING;
|
||||
protected SymbolFlipping flip = FLIPPING;
|
||||
protected Display display = Display.NAME;
|
||||
transient protected Shape[] body;
|
||||
|
||||
@@ -90,7 +93,7 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
|
||||
AffineTransform old = g2d.getTransform();
|
||||
g2d.rotate(Math.toRadians(rotation),controlPoints[0].x,controlPoints[0].y);
|
||||
|
||||
if (this.flipping==SymbolFlipping.Y){
|
||||
if (this.flip==SymbolFlipping.Y){
|
||||
g2d.translate(0,controlPoints[0].y);
|
||||
g2d.scale(1, -1);
|
||||
g2d.translate(0, -1*controlPoints[0].y);
|
||||
@@ -129,8 +132,13 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
|
||||
if (display==Display.BOTH) {
|
||||
label=getName()+" "+(getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||
Rectangle2D textRect = fontMetrics.getStringBounds(label, g2d);
|
||||
Rectangle shapeRect = body[0].getBounds().union(body[1].getBounds()).union(body[2].getBounds());
|
||||
|
||||
drawCenteredText(g2d, label,
|
||||
x + pinSpacing * 2, y, HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
|
||||
getLabelX(shapeRect, textRect, fontMetrics, outlineMode), getLabelY(shapeRect, textRect, fontMetrics, outlineMode), HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,6 +150,14 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
|
||||
public int getControlPointCount() {
|
||||
return controlPoints.length;
|
||||
}
|
||||
|
||||
protected int getLabelX(Rectangle2D shapeRect, Rectangle2D textRect, FontMetrics fontMetrics, boolean outlineMode) {
|
||||
return controlPoints[0].x + (int) PIN_SPACING.convertToPixels() * 2;
|
||||
}
|
||||
|
||||
protected int getLabelY(Rectangle2D shapeRect, Rectangle2D textRect, FontMetrics fontMetrics, boolean outlineMode) {
|
||||
return controlPoints[0].y;
|
||||
}
|
||||
|
||||
private void updateControlPoints() {
|
||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||
@@ -185,12 +201,12 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public SymbolFlipping getFlipping() {
|
||||
return flipping;
|
||||
public SymbolFlipping getFlip() {
|
||||
return flip;
|
||||
}
|
||||
|
||||
public void setFlipping(SymbolFlipping flipping) {
|
||||
this.flipping = flipping;
|
||||
public void setFlip(SymbolFlipping flip) {
|
||||
this.flip = flip;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
|
||||
+8
-1
@@ -6,6 +6,13 @@ public enum SymbolFlipping {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name();
|
||||
switch (this) {
|
||||
case Y:
|
||||
return "Y-axis";
|
||||
case NONE:
|
||||
return "None";
|
||||
default:
|
||||
return name();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,6 @@
|
||||
<classpathentry kind="lib" path="lib/swing-framework.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/diylc-core"/>
|
||||
<classpathentry kind="lib" path="lib/xstream-1.4.3.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_45"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_40"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;Library&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;DIYLC&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_40"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.diylc.DIYLCStarter"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="diylc-swing"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms256m -Xmx512m -Dorg.diylc.scriptRun=true -Ddorg.diylc.debugComponentAreas=true"/>
|
||||
|
||||
Binary file not shown.
@@ -1296,6 +1296,22 @@
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>3</major>
|
||||
<minor>30</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2016-04-25 20:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved potentiometer symbol appearance</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
</a>
|
||||
</java.util.Arrays_-ArrayList>
|
||||
Reference in New Issue
Block a user