Two new trimmer potentiometer types

This commit is contained in:
Branislav Stojkovic
2018-12-15 19:19:05 +01:00
parent 3939d2c5a7
commit 1b7f24bae4
3 changed files with 515 additions and 467 deletions
@@ -1,23 +1,19 @@
/* /*
*
DIY Layout Creator (DIYLC). * DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
Copyright (c) 2009-2018 held jointly by the individual authors. *
* This file is part of DIYLC.
This file is part of DIYLC. *
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
DIYLC is free software: you can redistribute it and/or modify * General Public License as published by the Free Software Foundation, either version 3 of the
it under the terms of the GNU General Public License as published by * License, or (at your option) any later version.
the Free Software Foundation, either version 3 of the License, or *
(at your option) any later version. * DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
DIYLC is distributed in the hope that it will be useful, * Public License for more details.
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * You should have received a copy of the GNU General Public License along with DIYLC. If not, see
GNU General Public License for more details. * <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.components.passive; package org.diylc.components.passive;
@@ -32,6 +28,7 @@ import java.awt.geom.AffineTransform;
import java.awt.geom.Area; 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 java.awt.geom.RoundRectangle2D;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.Display; import org.diylc.common.Display;
@@ -59,9 +56,12 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
protected static Size FLAT_BODY_SIZE = new Size(9.5d, SizeUnit.mm); protected static Size FLAT_BODY_SIZE = new Size(9.5d, SizeUnit.mm);
protected static Size FLAT_SHAFT_SIZE = new Size(4d, SizeUnit.mm); protected static Size FLAT_LARGE_SIZE = new Size(13d, SizeUnit.mm);
protected static Size FLAT_SMALL_BODY_SIZE = new Size(5d, SizeUnit.mm);
protected static Size FLAT_SHAFT_SIZE = new Size(4.5d, SizeUnit.mm);
protected static Size VERTICAL_BODY_LENGTH = new Size(9.5d, SizeUnit.mm); protected static Size VERTICAL_BODY_LENGTH = new Size(9.5d, SizeUnit.mm);
protected static Size VERTICAL_BODY_WIDTH = new Size(4.5d, SizeUnit.mm); protected static Size VERTICAL_BODY_WIDTH = new Size(4.5d, SizeUnit.mm);
protected static Size ROUNDED_EDGE = new Size(1d, SizeUnit.mm);
protected static Size SPACING = new Size(0.1d, SizeUnit.in); protected static Size SPACING = new Size(0.1d, SizeUnit.in);
private static Color BODY_COLOR = Color.decode("#FFFFE0"); private static Color BODY_COLOR = Color.decode("#FFFFE0");
private static Color BORDER_COLOR = Color.decode("#8E8E38"); private static Color BORDER_COLOR = Color.decode("#8E8E38");
@@ -91,10 +91,11 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
int dy1 = 0; int dy1 = 0;
int dx2 = 0; int dx2 = 0;
int dy2 = 0; int dy2 = 0;
switch (orientation) { switch (getOrientation()) {
case DEFAULT: case DEFAULT:
switch (type) { switch (getType()) {
case FLAT_SMALL: case FLAT_SMALL:
case FLAT_XSMALL:
dx1 = 2 * spacing; dx1 = 2 * spacing;
dy1 = spacing; dy1 = spacing;
dx2 = 0; dx2 = 0;
@@ -106,6 +107,12 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
dx2 = 0; dx2 = 0;
dy2 = 2 * spacing; dy2 = 2 * spacing;
break; break;
case FLAT_XLARGE:
dx1 = 5 * spacing;
dy1 = 2 * spacing;
dx2 = 0;
dy2 = 4 * spacing;
break;
case VERTICAL_INLINE: case VERTICAL_INLINE:
dx1 = 0; dx1 = 0;
dy1 = spacing; dy1 = spacing;
@@ -127,8 +134,9 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
} }
break; break;
case _90: case _90:
switch (type) { switch (getType()) {
case FLAT_SMALL: case FLAT_SMALL:
case FLAT_XSMALL:
dx1 = -spacing; dx1 = -spacing;
dy1 = 2 * spacing; dy1 = 2 * spacing;
dx2 = -2 * spacing; dx2 = -2 * spacing;
@@ -140,6 +148,12 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
dx2 = -2 * spacing; dx2 = -2 * spacing;
dy2 = 0; dy2 = 0;
break; break;
case FLAT_XLARGE:
dx1 = -2 * spacing;
dy1 = 5 * spacing;
dx2 = -4 * spacing;
dy2 = 0;
break;
case VERTICAL_INLINE: case VERTICAL_INLINE:
dx1 = -spacing; dx1 = -spacing;
dy1 = 0; dy1 = 0;
@@ -161,8 +175,9 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
} }
break; break;
case _180: case _180:
switch (type) { switch (getType()) {
case FLAT_SMALL: case FLAT_SMALL:
case FLAT_XSMALL:
dx1 = -2 * spacing; dx1 = -2 * spacing;
dy1 = -spacing; dy1 = -spacing;
dx2 = 0; dx2 = 0;
@@ -174,6 +189,12 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
dx2 = 0; dx2 = 0;
dy2 = -2 * spacing; dy2 = -2 * spacing;
break; break;
case FLAT_XLARGE:
dx1 = -5 * spacing;
dy1 = -2 * spacing;
dx2 = 0;
dy2 = -4 * spacing;
break;
case VERTICAL_INLINE: case VERTICAL_INLINE:
dx1 = 0; dx1 = 0;
dy1 = -spacing; dy1 = -spacing;
@@ -195,8 +216,9 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
} }
break; break;
case _270: case _270:
switch (type) { switch (getType()) {
case FLAT_SMALL: case FLAT_SMALL:
case FLAT_XSMALL:
dx1 = spacing; dx1 = spacing;
dy1 = -2 * spacing; dy1 = -2 * spacing;
dx2 = 2 * spacing; dx2 = 2 * spacing;
@@ -208,6 +230,12 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
dx2 = 2 * spacing; dx2 = 2 * spacing;
dy2 = 0; dy2 = 0;
break; break;
case FLAT_XLARGE:
dx1 = 2 * spacing;
dy1 = -5 * spacing;
dx2 = 4 * spacing;
dy2 = 0;
break;
case VERTICAL_INLINE: case VERTICAL_INLINE:
dx1 = spacing; dx1 = spacing;
dy1 = 0; dy1 = 0;
@@ -251,9 +279,16 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
// Calculate body dimensions based on the selected type. // Calculate body dimensions based on the selected type.
int length = 0; int length = 0;
int width = 0; int width = 0;
switch (type) { switch (getType()) {
case FLAT_LARGE: case FLAT_LARGE:
case FLAT_SMALL: case FLAT_SMALL:
case FLAT_XSMALL:
case FLAT_XLARGE:
if (getType() == TrimmerType.FLAT_XSMALL)
length = getClosestOdd(FLAT_SMALL_BODY_SIZE.convertToPixels());
else if (getType() == TrimmerType.FLAT_XLARGE)
length = getClosestOdd(FLAT_LARGE_SIZE.convertToPixels());
else
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());
@@ -278,7 +313,8 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
length = width; length = width;
width = p; width = p;
} }
body[0] = new Rectangle2D.Double(centerX - length / 2, centerY - width / 2, length, width); double edge = ROUNDED_EDGE.convertToPixels();
body[0] = new RoundRectangle2D.Double(centerX - length / 2, centerY - width / 2, length, width, edge, edge);
} }
return body; return body;
} }
@@ -464,11 +500,19 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
} }
public static enum TrimmerType { public static enum TrimmerType {
FLAT_LARGE, FLAT_SMALL, VERTICAL_INLINE, VERTICAL_OFFSET, VERTICAL_OFFSET_BIG_GAP; FLAT_SMALL("Horizontal Small 1"), FLAT_XSMALL("Horizontal Small 2"), FLAT_LARGE("Horizontal Medium"), FLAT_XLARGE(
"Horizontal Large"), VERTICAL_INLINE("Vertical Inline"), VERTICAL_OFFSET("Vertical Offset 1"), VERTICAL_OFFSET_BIG_GAP(
"Vertical Offset 2");
String label;
private TrimmerType(String label) {
this.label = label;
}
@Override @Override
public String toString() { public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase().replace("_", " "); return label;// name().substring(0, 1) + name().substring(1).toLowerCase().replace("_", " ");
} }
} }
} }
Binary file not shown.
+4
View File
@@ -1878,6 +1878,10 @@
<changeType>NEW_FEATURE</changeType> <changeType>NEW_FEATURE</changeType>
<description>Holding "shift" key switches mouse wheel scrolling from vertical to horizontal</description> <description>Holding "shift" key switches mouse wheel scrolling from vertical to horizontal</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Two new trimmer potentiometer types</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Preserve z-order of components when copy-pasting</description> <description>Preserve z-order of components when copy-pasting</description>