mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
bugfix: trimmer display should not be static
code cleanup
This commit is contained in:
@@ -15,7 +15,6 @@ import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Dot", category = "Connectivity", author = "Branislav Stojkovic",
|
||||
description = "Connector dot", instanceNamePrefix = "Dot", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
||||
|
||||
@@ -89,6 +89,7 @@ public class BatterySnap9V extends AbstractTransparentComponent<String> {
|
||||
g2d.draw(body[2]);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public Shape[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Shape[3];
|
||||
|
||||
@@ -117,6 +117,7 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
|
||||
VerticalAlignment.CENTER);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public Shape[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Shape[4];
|
||||
|
||||
@@ -115,6 +115,7 @@ public class LeverSwitch extends AbstractTransparentComponent<String> {
|
||||
g2d.draw(body[2]);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public Shape[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Shape[3];
|
||||
@@ -199,6 +200,7 @@ public class LeverSwitch extends AbstractTransparentComponent<String> {
|
||||
return body;
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
private void updateControlPoints() {
|
||||
int x = controlPoints[0].x;
|
||||
int y = controlPoints[0].y;
|
||||
|
||||
@@ -113,6 +113,7 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
|
||||
VerticalAlignment.CENTER);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public Shape[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Shape[3];
|
||||
|
||||
@@ -33,12 +33,14 @@ public class Label extends AbstractComponent<Void> {
|
||||
private String text = DEFAULT_TEXT;
|
||||
private Font font = LABEL_FONT;
|
||||
private Color color = LABEL_COLOR;
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
private boolean center;
|
||||
private HorizontalAlignment horizontalAlignment = HorizontalAlignment.CENTER;
|
||||
private VerticalAlignment verticalAlignment = VerticalAlignment.CENTER;
|
||||
private Orientation orientation = Orientation.DEFAULT;
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
|
||||
@@ -40,6 +40,7 @@ public class PCBText extends AbstractComponent<Void> {
|
||||
private VerticalAlignment verticalAlignment = VerticalAlignment.CENTER;
|
||||
private Orientation orientation = Orientation.DEFAULT;
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
|
||||
@@ -53,7 +53,7 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
||||
|
||||
protected Color bodyColor = BODY_COLOR;
|
||||
protected Color borderColor = BORDER_COLOR;
|
||||
protected static Display display = DISPLAY;
|
||||
protected Display display = DISPLAY;
|
||||
// Array of 7 elements: 3 lug connectors, 1 pot body and 3 lugs
|
||||
transient protected Shape[] body = null;
|
||||
|
||||
@@ -327,7 +327,7 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
||||
int y = (panelHeight - textHeight) / 2 + fontMetrics.getAscent();
|
||||
|
||||
String label = "";
|
||||
label = (getDisplay() == Display.NAME) ? getName() : getValue().toString();
|
||||
label = (getDisplay() == Display.NAME) ? getName() : (getValue() == null ? "" : getValue().toString());
|
||||
if (getDisplay() == Display.NONE) {
|
||||
label = "";
|
||||
}
|
||||
@@ -387,7 +387,7 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
||||
@EditableProperty
|
||||
public Display getDisplay() {
|
||||
if (display == null) {
|
||||
display = Display.VALUE;
|
||||
display = DISPLAY;
|
||||
}
|
||||
return display;
|
||||
}
|
||||
|
||||
+1
-4
@@ -52,7 +52,7 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
|
||||
if (checkPointsClipped(g2d.getClip())) {
|
||||
return;
|
||||
}
|
||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||
|
||||
Color finalColor;
|
||||
if (componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING) {
|
||||
finalColor = SELECTION_COLOR;
|
||||
@@ -67,9 +67,6 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
|
||||
|
||||
// Draw transistor
|
||||
|
||||
int x = controlPoints[0].x;
|
||||
int y = controlPoints[0].y;
|
||||
|
||||
Shape[] body = getBody();
|
||||
|
||||
int rotation = 0;
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
package org.diylc.components.shapes;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
|
||||
Reference in New Issue
Block a user