mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Added 'Font Size Override' property to most components that display text
to allow control over font size
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
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 Public License for more details.
|
||||
|
||||
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;
|
||||
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
public abstract class AbstractLabeledComponent<T> extends AbstractTransparentComponent<T> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected Integer fontSizeOverride;
|
||||
|
||||
@EditableProperty(name = "Font Size Override")
|
||||
public Integer getFontSizeOverride() {
|
||||
return fontSizeOverride;
|
||||
}
|
||||
|
||||
public void setFontSizeOverride(Integer fontSizeOverride) {
|
||||
this.fontSizeOverride = fontSizeOverride;
|
||||
}
|
||||
}
|
||||
@@ -3345,5 +3345,21 @@
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>4</major>
|
||||
<minor>13</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2020-12-06 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Font Size Override' property to most components that display text to allow control over font size</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
</a>
|
||||
</java.util.Arrays_-ArrayList>
|
||||
|
||||
Binary file not shown.
@@ -62,7 +62,7 @@ import org.diylc.utils.Constants;
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComponent<T> {
|
||||
public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponent<T> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -324,6 +324,11 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
if (useShapeRectAsPosition()) {
|
||||
g2d.translate(shapeRect.getX(), shapeRect.getY());
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
|
||||
|
||||
public abstract class AbstractMultiPartComponent<T> extends AbstractTransparentComponent<T> {
|
||||
public abstract class AbstractMultiPartComponent<T> extends AbstractLabeledComponent<T> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -247,7 +247,12 @@ public class CliffJack1_4 extends AbstractMultiPartComponent<String> {
|
||||
: LABEL_COLOR;
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
double centerX = (controlPoints[0].getX() + controlPoints[3].getX()) / 2;
|
||||
double centerY = (controlPoints[0].getY() + controlPoints[3].getY()) / 2;
|
||||
StringUtils.drawCenteredText(g2d, name, centerX, centerY, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
|
||||
@@ -267,7 +267,12 @@ public class ClosedJack1_4 extends AbstractMultiPartComponent<String> {
|
||||
: LABEL_COLOR;
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Rectangle bounds = body[0].getBounds();
|
||||
double centerX = bounds.getX() + bounds.width / 2;
|
||||
double centerY = bounds.getY() + bounds.height / 2;
|
||||
|
||||
@@ -225,6 +225,11 @@ public class FuseHolderPanel extends AbstractMultiPartComponent<String> {
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
finalLabelColor =
|
||||
|
||||
@@ -400,5 +400,11 @@ public class IECSocket extends AbstractMultiPartComponent<String> {
|
||||
int margin = 20;
|
||||
Rectangle2D bounds = getBody()[0].getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Integer getFontSizeOverride() {
|
||||
return super.getFontSizeOverride();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.diylc.common.Display;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -55,7 +55,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Mini Relay", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||
instanceNamePrefix = "RY", description = "Miniature PCB mount relay, like Omron G5V-1 or G5V-2",
|
||||
zOrder = IDIYComponent.COMPONENT, enableCache = true)
|
||||
public class MiniRelay extends AbstractTransparentComponent<String> {
|
||||
public class MiniRelay extends AbstractLabeledComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -341,7 +341,12 @@ public class MiniRelay extends AbstractTransparentComponent<String> {
|
||||
}
|
||||
}
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
finalLabelColor =
|
||||
|
||||
@@ -182,7 +182,7 @@ public class PlasticDCJack extends AbstractMultiPartComponent<String> {
|
||||
if (!outlineMode && getPolarity() != DCPolarity.NONE) {
|
||||
int spacing = (int) SPACING.convertToPixels();
|
||||
g2d.setColor(MARKING_COLOR);
|
||||
g2d.setFont(project.getFont().deriveFont(12f));
|
||||
g2d.setFont(project.getFont().deriveFont(12f));
|
||||
StringUtils.drawCenteredText(g2d, getPolarity() == DCPolarity.CENTER_NEGATIVE ? "+" : "-", controlPoints[0].getX(),
|
||||
controlPoints[0].getY() - spacing * 7 / 16, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
StringUtils.drawCenteredText(g2d, getPolarity() == DCPolarity.CENTER_NEGATIVE ? "_" : "+", controlPoints[2].getX(),
|
||||
@@ -274,5 +274,11 @@ public class PlasticDCJack extends AbstractMultiPartComponent<String> {
|
||||
int margin = 20;
|
||||
Rectangle2D bounds = getBody()[0].getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Integer getFontSizeOverride() {
|
||||
return super.getFontSizeOverride();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,5 +331,11 @@ public class RCAJack extends AbstractMultiPartComponent<String> {
|
||||
int margin = 20;
|
||||
Rectangle2D bounds = getBody()[1].getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Integer getFontSizeOverride() {
|
||||
return super.getFontSizeOverride();
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -152,6 +152,11 @@ public class RotarySelectorSwitch extends AbstractMultiPartComponent<String> {
|
||||
if (showLabels) {
|
||||
g2d.setColor(TERMINAL_COLOR.darker());
|
||||
g2d.setFont(project.getFont().deriveFont(project.getFont().getSize2D() * 0.8f));
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
for (int i = 2; i < body.length; i++) {
|
||||
Rectangle2D bounds = body[i].getBounds2D();
|
||||
double x = (int) ((bounds.getCenterX() + controlPoints[i - 2].getX()) / 2);
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.OrientationHV;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Theme;
|
||||
@@ -44,7 +44,7 @@ import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
public abstract class AbstractGuitarPickup extends AbstractTransparentComponent<String> {
|
||||
public abstract class AbstractGuitarPickup extends AbstractLabeledComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -112,6 +112,11 @@ public abstract class AbstractGuitarPickup extends AbstractTransparentComponent<
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
g2d.setFont(project.getFont().deriveFont(Font.BOLD));
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Rectangle bounds = getBody()[0].getBounds();
|
||||
|
||||
AffineTransform originalTx = g2d.getTransform();
|
||||
|
||||
@@ -24,13 +24,13 @@ package org.diylc.components.passive;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.PositiveMeasureValidator;
|
||||
import org.diylc.core.measures.Resistance;
|
||||
|
||||
public abstract class AbstractPotentiometer extends AbstractTransparentComponent<Resistance> {
|
||||
public abstract class AbstractPotentiometer extends AbstractLabeledComponent<Resistance> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -311,6 +311,10 @@ public class AudioTransformer extends AbstractMultiPartComponent<String> {
|
||||
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
// Draw winding designations
|
||||
Point2D wPoint = new Point2D.Double((int) (controlPoints[0].getX() + project.getFontSize()), (int) (controlPoints[0].getY() + leadSpacing.convertToPixels()));
|
||||
AffineTransform tx = getTx();
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -59,7 +59,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Multi-Section Capacitor", author = "Branislav Stojkovic", category = "Passive",
|
||||
instanceNamePrefix = "C", description = "Multi-section vertically mounted electrolytic capacitor, similar to JJ, CE and others",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, enableCache = true)
|
||||
public class MultiSectionCapacitor extends AbstractTransparentComponent<Capacitance[]> {
|
||||
public class MultiSectionCapacitor extends AbstractLabeledComponent<Capacitance[]> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -390,7 +390,12 @@ public class MultiSectionCapacitor extends AbstractTransparentComponent<Capacita
|
||||
}
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
finalLabelColor =
|
||||
|
||||
@@ -301,7 +301,12 @@ public class PotentiometerPanel extends AbstractPotentiometer {
|
||||
}
|
||||
}
|
||||
// Draw caption.
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
finalLabelColor =
|
||||
|
||||
@@ -417,6 +417,11 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
finalLabelColor =
|
||||
|
||||
+2
-2
@@ -32,12 +32,12 @@ import org.diylc.awt.StringUtils;
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.netlist.ISpiceMapper;
|
||||
|
||||
public abstract class AbstractTransistorPackage extends AbstractTransparentComponent<String> implements ISpiceMapper {
|
||||
public abstract class AbstractTransistorPackage extends AbstractLabeledComponent<String> implements ISpiceMapper {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.components.AbstractLeadedComponent.LabelOriantation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.RoundedPolygon;
|
||||
import org.diylc.components.transform.DIL_ICTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
@@ -66,7 +66,7 @@ import org.diylc.utils.Constants;
|
||||
instanceNamePrefix = "BR", description = "Few variations of bridge rectifier chips",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = DIL_ICTransformer.class,
|
||||
enableCache = true)
|
||||
public class BridgeRectifier extends AbstractTransparentComponent<String> {
|
||||
public class BridgeRectifier extends AbstractLabeledComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -409,7 +409,12 @@ public class BridgeRectifier extends AbstractTransparentComponent<String> {
|
||||
drawingObserver.stopTracking();
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.diylc.common.Display;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.components.transform.DIL_ICTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -59,7 +59,7 @@ import org.diylc.utils.Constants;
|
||||
instanceNamePrefix = "IC", description = "Dual-in-line package IC",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = DIL_ICTransformer.class,
|
||||
enableCache = true)
|
||||
public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
public class DIL_IC extends AbstractLabeledComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -359,7 +359,12 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
drawingObserver.stopTracking();
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
|
||||
@@ -202,7 +202,12 @@ public class TransistorTO1 extends AbstractTransistorPackage {
|
||||
g2d.draw(mainArea);
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
finalLabelColor =
|
||||
|
||||
@@ -290,7 +290,12 @@ public class TransistorTO126 extends AbstractTransistorPackage {
|
||||
g2d.setComposite(oldComposite);
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
finalLabelColor =
|
||||
|
||||
@@ -327,7 +327,12 @@ public class TransistorTO220 extends AbstractTransistorPackage {
|
||||
}
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
finalLabelColor =
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.diylc.common.Display;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -57,7 +57,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Transistor (TO-3)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
instanceNamePrefix = "Q", description = "Transistor with large metal body",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, enableCache = true)
|
||||
public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
||||
public class TransistorTO3 extends AbstractLabeledComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -269,7 +269,12 @@ public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
||||
g2d.draw(innerArea);
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
finalLabelColor =
|
||||
|
||||
@@ -225,7 +225,12 @@ public class TransistorTO92 extends AbstractTransistorPackage {
|
||||
g2d.draw(mainArea);
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.diylc.common.Display;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
@@ -48,7 +48,7 @@ import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
public abstract class PassiveSMDComponent<T> extends AbstractTransparentComponent<T> {
|
||||
public abstract class PassiveSMDComponent<T> extends AbstractLabeledComponent<T> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -290,7 +290,12 @@ public abstract class PassiveSMDComponent<T> extends AbstractTransparentComponen
|
||||
g2d.draw(contactArea);
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.diylc.common.Display;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.components.transform.TO220Transformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -55,7 +55,7 @@ import org.diylc.utils.Constants;
|
||||
instanceNamePrefix = "V", description = "Sub-miniature (pencil) vacuum tube",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE,
|
||||
transformer = TO220Transformer.class)
|
||||
public class SubminiTube extends AbstractTransparentComponent<String> {
|
||||
public class SubminiTube extends AbstractLabeledComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -421,6 +421,11 @@ public class SubminiTube extends AbstractTransparentComponent<String> {
|
||||
|
||||
// Draw label.
|
||||
g2d.setFont(project.getFont());
|
||||
|
||||
// Override font size
|
||||
if (getFontSizeOverride() != null)
|
||||
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
|
||||
|
||||
Color finalLabelColor;
|
||||
if (outlineMode) {
|
||||
finalLabelColor =
|
||||
|
||||
@@ -160,7 +160,8 @@ Folded|Gefaltet
|
||||
Font|Schriftart
|
||||
Font Bold|Fettschrift
|
||||
Font Italic|Kursivschrift
|
||||
Font Size|Schriftgröße
|
||||
Font Size|Schriftgröße
|
||||
Font Size Override|Überschreiben der Schriftgröße
|
||||
Four|Vier
|
||||
Full|Voll
|
||||
Fuse|Sicherung
|
||||
|
||||
@@ -157,6 +157,7 @@ Font
|
||||
Font Bold
|
||||
Font Italic
|
||||
Font Size
|
||||
Font Size Override
|
||||
Four
|
||||
Full
|
||||
Fuse
|
||||
|
||||
@@ -158,6 +158,7 @@ Font|Fuente
|
||||
Font Bold|Negrita
|
||||
Font Italic|Itálica
|
||||
Font Size|Tamaño de fuente
|
||||
Font Size Override|Anulación del tamaño de fuente
|
||||
Four|Cuatro
|
||||
Full|Lleno
|
||||
Fuse|Fusible
|
||||
|
||||
@@ -158,6 +158,7 @@ Font|Police
|
||||
Font Bold|Gras
|
||||
Font Italic|Italic
|
||||
Font Size|Taille de police
|
||||
Font Size Override|Taille de police (re)
|
||||
Four|Quatre
|
||||
Full|Complet
|
||||
Fuse|Fusible
|
||||
|
||||
@@ -161,6 +161,7 @@ Font|Carattere
|
||||
Font Bold|Carattere grassetto
|
||||
Font Italic|Carattere corsivo
|
||||
Font Size|Dimensione carattere
|
||||
Font Size Override|Sostituzione dimensione carattere
|
||||
Four|Quattro
|
||||
Full|Pieno
|
||||
Fuse|Fusibile
|
||||
|
||||
@@ -161,6 +161,7 @@ Font|Lettertype
|
||||
Font Bold|Vet lettertype
|
||||
Font Italic|Cursief lettertype
|
||||
Font Size|Tekengrootte
|
||||
Font Size Override|Tekengrootte overschrijven
|
||||
Four|Vier
|
||||
Full|Vol
|
||||
Fuse|Zekering
|
||||
|
||||
@@ -157,6 +157,7 @@ Font
|
||||
Font Bold
|
||||
Font Italic
|
||||
Font Size|Veličina Fonta
|
||||
Font Size Override|Veličina Fonta
|
||||
Four|Četiri
|
||||
Full|Puno
|
||||
Fuse|Osigurač
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -39,8 +39,9 @@ public class IntEditor extends DoubleTextField {
|
||||
public IntEditor(final PropertyWrapper property) {
|
||||
setLayout(new BorderLayout());
|
||||
if (property.isReadOnly())
|
||||
setEnabled(false);
|
||||
setValue((double) (Integer) property.getValue());
|
||||
setEnabled(false);
|
||||
if (property.getValue() != null)
|
||||
setValue((double) (Integer) property.getValue());
|
||||
addPropertyChangeListener(DoubleTextField.VALUE_PROPERTY, new PropertyChangeListener() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -142,45 +142,49 @@ public class PropertyEditorDialog extends ButtonDialog {
|
||||
gbc.weightx = 1;
|
||||
gbc.insets = new Insets(2, 2, 2, 2);
|
||||
|
||||
Component editor = FieldEditorFactory.createFieldEditor(property);
|
||||
editor.addKeyListener(new KeyAdapter() {
|
||||
try {
|
||||
Component editor = FieldEditorFactory.createFieldEditor(property);
|
||||
editor.addKeyListener(new KeyAdapter() {
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
getButton(OK).doClick();
|
||||
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||
getButton(CANCEL).doClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
editorPanel.add(editor, gbc);
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
getButton(OK).doClick();
|
||||
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||
getButton(CANCEL).doClick();
|
||||
if (property.isDefaultable()) {
|
||||
gbc.gridx = 2;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
gbc.weightx = 0;
|
||||
|
||||
if (saveDefaults && !property.isReadOnly()) {
|
||||
editorPanel.add(createDefaultCheckBox(property), gbc);
|
||||
}
|
||||
}
|
||||
});
|
||||
editorPanel.add(editor, gbc);
|
||||
|
||||
if (property.isDefaultable()) {
|
||||
gbc.gridx = 2;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
gbc.weightx = 0;
|
||||
|
||||
if (saveDefaults && !property.isReadOnly()) {
|
||||
editorPanel.add(createDefaultCheckBox(property), gbc);
|
||||
}
|
||||
}
|
||||
|
||||
if (property.getName().equalsIgnoreCase("value")) {
|
||||
componentToFocus = editor;
|
||||
}
|
||||
|
||||
// Make value field focused
|
||||
try {
|
||||
if (componentToFocus == null
|
||||
&& property.getGetter().getName().equalsIgnoreCase("getValue")) {
|
||||
|
||||
if (property.getName().equalsIgnoreCase("value")) {
|
||||
componentToFocus = editor;
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
LOG.warn("Could not determine editor component to focus", e1);
|
||||
|
||||
// Make value field focused
|
||||
try {
|
||||
if (componentToFocus == null
|
||||
&& property.getGetter().getName().equalsIgnoreCase("getValue")) {
|
||||
componentToFocus = editor;
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
LOG.warn("Could not determine editor component to focus", e1);
|
||||
}
|
||||
|
||||
gbc.gridy++;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error creating editor for " + property.getName(), e);
|
||||
}
|
||||
|
||||
gbc.gridy++;
|
||||
}
|
||||
|
||||
return editorPanel;
|
||||
|
||||
Reference in New Issue
Block a user