mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
added label
This commit is contained in:
+8
@@ -1,5 +1,8 @@
|
||||
package org.diylc.components;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
@@ -16,6 +19,11 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected String name = "";
|
||||
|
||||
public static Color SELECTION_COLOR = Color.red;
|
||||
public static Color LABEL_COLOR = Color.black;
|
||||
public static Color LABEL_COLOR_SELECTED = Color.red;
|
||||
public static Font LABEL_FONT = new Font("Tahoma", Font.PLAIN, 12);
|
||||
|
||||
@EditableProperty(defaultable = false)
|
||||
@Override
|
||||
|
||||
+3
-11
@@ -19,7 +19,6 @@ import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
/**
|
||||
* Base class for all leaded components such as resistors or capacitors. Has two
|
||||
@@ -33,8 +32,6 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color LEAD_COLOR = Color.decode("#236B8E");
|
||||
public static Color LABEL_COLOR = Color.black;
|
||||
public static Color LABEL_COLOR_SELECTED = Color.red;
|
||||
public static Size LEAD_THICKNESS = new Size(0.6d, SizeUnit.mm);
|
||||
public static Size DEFAULT_SIZE = new Size(1d, SizeUnit.in);
|
||||
|
||||
@@ -45,6 +42,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
new Point(DEFAULT_SIZE.convertToPixels() / 2, 0) };
|
||||
protected Color bodyColor = getDefaultBodyColor();
|
||||
protected Color borderColor = getDefaultBorderColor();
|
||||
protected Color labelColor = LABEL_COLOR;
|
||||
protected Display display = Display.NAME;
|
||||
|
||||
protected AbstractLeadedComponent() {
|
||||
@@ -124,10 +122,8 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
// Do not track the label because that area was already covered.
|
||||
drawingObserver.stopTracking();
|
||||
// Draw label.
|
||||
g2d.setFont(Constants.LABEL_FONT);
|
||||
g2d
|
||||
.setColor(componentState == ComponentState.SELECTED ? LABEL_COLOR_SELECTED
|
||||
: getLabelColor());
|
||||
g2d.setFont(LABEL_FONT);
|
||||
g2d.setColor(componentState == ComponentState.SELECTED ? LABEL_COLOR_SELECTED : labelColor);
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||
String label = display == Display.NAME ? getName() : getValue().toString();
|
||||
// Adjust label angle if needed to make sure that it's readable.
|
||||
@@ -144,10 +140,6 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
protected Color getLabelColor() {
|
||||
return LABEL_COLOR;
|
||||
}
|
||||
|
||||
protected boolean shouldShadeLeads() {
|
||||
return true;
|
||||
}
|
||||
|
||||
+3
-5
@@ -1,6 +1,5 @@
|
||||
package org.diylc.core;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.io.Serializable;
|
||||
@@ -37,10 +36,9 @@ public interface IDIYComponent<T> extends Serializable {
|
||||
public static final int BELOW_BOARD = 4;
|
||||
public static final int BOARD = 5;
|
||||
public static final int ABOVE_BOARD = 6;
|
||||
public static final int COMPONENT = 7;
|
||||
public static final int ABOVE_COMPONENT = 8;
|
||||
|
||||
public static Color SELECTION_COLOR = Color.red;
|
||||
public static final int BELOW_COMPONENT = 7;
|
||||
public static final int COMPONENT = 8;
|
||||
public static final int ABOVE_COMPONENT = 9;
|
||||
|
||||
/**
|
||||
* @return component instance name.
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ public class AbstractMeasure<T extends Enum<? extends Unit>> implements Serializ
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected static final Format format = new DecimalFormat("#.00##");
|
||||
protected static final Format format = new DecimalFormat("0.####");
|
||||
|
||||
protected Double value;
|
||||
protected T unit;
|
||||
|
||||
+8
-6
@@ -41,7 +41,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
private Clipboard clipboard;
|
||||
private Cloner cloner;
|
||||
|
||||
private CutAction cutAction;
|
||||
// private CutAction cutAction;
|
||||
private CopyAction copyAction;
|
||||
private PasteAction pasteAction;
|
||||
|
||||
@@ -72,8 +72,8 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
plugInPort.injectMenuAction(undoHandler.getUndoAction(), EDIT_TITLE);
|
||||
plugInPort.injectMenuAction(undoHandler.getRedoAction(), EDIT_TITLE);
|
||||
plugInPort.injectMenuAction(null, EDIT_TITLE);
|
||||
cutAction = new CutAction();
|
||||
plugInPort.injectMenuAction(cutAction, EDIT_TITLE);
|
||||
// cutAction = new CutAction();
|
||||
// plugInPort.injectMenuAction(cutAction, EDIT_TITLE);
|
||||
copyAction = new CopyAction();
|
||||
plugInPort.injectMenuAction(copyAction, EDIT_TITLE);
|
||||
pasteAction = new PasteAction();
|
||||
@@ -109,7 +109,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
|
||||
private void refreshActions() {
|
||||
boolean enabled = !plugInPort.getSelectedComponents().isEmpty();
|
||||
cutAction.setEnabled(enabled);
|
||||
// cutAction.setEnabled(enabled);
|
||||
copyAction.setEnabled(enabled);
|
||||
try {
|
||||
pasteAction.setEnabled(clipboard.isDataFlavorAvailable(ComponentSelection.listFlavor));
|
||||
@@ -264,7 +264,8 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
// Save default values.
|
||||
for (PropertyWrapper property : editor.getDefaultedProperties()) {
|
||||
if (property.getValue() != null) {
|
||||
plugInPort.setProjectDefaultPropertyValue(property.getName(), property.getValue());
|
||||
plugInPort.setProjectDefaultPropertyValue(property.getName(), property
|
||||
.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,7 +300,8 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
// Save default values.
|
||||
for (PropertyWrapper property : editor.getDefaultedProperties()) {
|
||||
if (property.getValue() != null) {
|
||||
plugInPort.setSelectionDefaultPropertyValue(property.getName(), property.getValue());
|
||||
plugInPort.setSelectionDefaultPropertyValue(property.getName(), property
|
||||
.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -68,9 +68,9 @@ public class LayersMenuPlugin implements IPlugIn {
|
||||
BELOW_CHASSIS("Below Chassis", IDIYComponent.BELOW_CHASSIS), CHASSIS("Chassis",
|
||||
IDIYComponent.CHASSIS), ABOVE_CHASSIS("Above Chassis", IDIYComponent.ABOVE_CHASSIS), BELOW_BOARD(
|
||||
"Below Board", IDIYComponent.BELOW_BOARD), BOARD("Board", IDIYComponent.BOARD), ABOVE_BOARD(
|
||||
"Above Board", IDIYComponent.ABOVE_BOARD), COMPONENT("Component",
|
||||
IDIYComponent.COMPONENT), ABOVE_COMPONENT("Above Component",
|
||||
IDIYComponent.ABOVE_COMPONENT);
|
||||
"Above Board", IDIYComponent.ABOVE_BOARD), BELOW_COMPONENT("Below Component",
|
||||
IDIYComponent.BELOW_COMPONENT), COMPONENT("Component", IDIYComponent.COMPONENT), ABOVE_COMPONENT(
|
||||
"Above Component", IDIYComponent.ABOVE_COMPONENT);
|
||||
|
||||
String title;
|
||||
int zOrder;
|
||||
|
||||
-3
@@ -2,7 +2,6 @@ package org.diylc.utils;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.Toolkit;
|
||||
|
||||
@@ -14,8 +13,6 @@ public class Constants {
|
||||
|
||||
public static Color CANVAS_COLOR = Color.white;
|
||||
|
||||
public static Font LABEL_FONT = new Font("Tahoma", Font.PLAIN, 12);
|
||||
|
||||
public static final Stroke DASHED_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
|
||||
BasicStroke.JOIN_MITER, 10f, new float[] { 2.0f }, 0.0f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user