tree improvements

perfboard improvements
trace cut improvements
This commit is contained in:
bancika
2016-12-28 13:58:32 +01:00
parent 7a5de6bad0
commit 8b0af57c35
10 changed files with 90 additions and 45 deletions
@@ -42,6 +42,7 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
public static Color LABEL_COLOR_SELECTED = Color.red; public static Color LABEL_COLOR_SELECTED = Color.red;
public static Font LABEL_FONT = new Font("Tahoma", Font.PLAIN, 14); public static Font LABEL_FONT = new Font("Tahoma", Font.PLAIN, 14);
public static Color METAL_COLOR = Color.decode("#236B8E"); public static Color METAL_COLOR = Color.decode("#236B8E");
public static Color COPPER_COLOR = Color.decode("#DA8A67");
@EditableProperty(defaultable = false) @EditableProperty(defaultable = false)
@Override @Override
Binary file not shown.
@@ -79,7 +79,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
t = 1; t = 1;
while (p.x < secondPoint.x - spacing) { while (p.x < secondPoint.x - spacing) {
p.x += spacing; p.x += spacing;
super.drawCenteredText(g2d, getCoordinateLabel(t++), p.x, p.y - 2, HorizontalAlignment.CENTER, super.drawCenteredText(g2d, Integer.toString(t++), p.x, p.y - 2, HorizontalAlignment.CENTER,
VerticalAlignment.TOP); VerticalAlignment.TOP);
} }
} }
@@ -27,7 +27,6 @@ public class TriPadBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static Color STRIP_COLOR = Color.decode("#DA8A67");
public static Color BORDER_COLOR = BOARD_COLOR.darker(); public static Color BORDER_COLOR = BOARD_COLOR.darker();
public static Size SPACING = new Size(0.1d, SizeUnit.in); public static Size SPACING = new Size(0.1d, SizeUnit.in);
@@ -37,7 +36,7 @@ public class TriPadBoard extends AbstractBoard {
protected int stripSpan = 3; // determines how many holes are covered by a protected int stripSpan = 3; // determines how many holes are covered by a
// strip // strip
protected Size spacing = SPACING; protected Size spacing = SPACING;
protected Color stripColor = STRIP_COLOR; protected Color stripColor = COPPER_COLOR;
protected OrientationHV orientation = OrientationHV.HORIZONTAL; protected OrientationHV orientation = OrientationHV.HORIZONTAL;
@Override @Override
@@ -132,6 +131,8 @@ public class TriPadBoard extends AbstractBoard {
} }
} }
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
super.drawCoordinates(g2d, spacing);
} }
} }
@@ -174,10 +175,10 @@ public class TriPadBoard extends AbstractBoard {
final int verticalIndent = verticalSpacing / 2; final int verticalIndent = verticalSpacing / 2;
for (int row = 0; row < 5; row++) { for (int row = 0; row < 5; row++) {
g2d.setColor(STRIP_COLOR); g2d.setColor(COPPER_COLOR);
g2d.fillRect(0, row * verticalSpacing + 2, horizontalIndent / 2 + horizontalSpacing, verticalSpacing - 1); g2d.fillRect(0, row * verticalSpacing + 2, horizontalIndent / 2 + horizontalSpacing, verticalSpacing - 1);
g2d.setColor(STRIP_COLOR); g2d.setColor(COPPER_COLOR);
g2d.fillRect(horizontalSpacing + 2, row * verticalSpacing + 2, horizontalSpacing * 3 - 1, verticalSpacing - 1); g2d.fillRect(horizontalSpacing + 2, row * verticalSpacing + 2, horizontalSpacing * 3 - 1, verticalSpacing - 1);
g2d.fillRect(horizontalSpacing * 4 + 2, row * verticalSpacing + 2, horizontalIndent / 2 + horizontalSpacing, g2d.fillRect(horizontalSpacing * 4 + 2, row * verticalSpacing + 2, horizontalIndent / 2 + horizontalSpacing,
@@ -191,7 +192,7 @@ public class TriPadBoard extends AbstractBoard {
int x = (horizontalSpacing * col) + horizontalIndent; int x = (horizontalSpacing * col) + horizontalIndent;
g2d.setColor(Constants.CANVAS_COLOR); g2d.setColor(Constants.CANVAS_COLOR);
g2d.fillOval(x, y, 2, 2); g2d.fillOval(x, y, 2, 2);
g2d.setColor(STRIP_COLOR.darker()); g2d.setColor(COPPER_COLOR.darker());
g2d.drawOval(x, y, 2, 2); g2d.drawOval(x, y, 2, 2);
} }
} }
@@ -28,7 +28,6 @@ public class VeroBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static Color STRIP_COLOR = Color.decode("#DA8A67");
public static Color BORDER_COLOR = BOARD_COLOR.darker(); public static Color BORDER_COLOR = BOARD_COLOR.darker();
public static Size SPACING = new Size(0.1d, SizeUnit.in); public static Size SPACING = new Size(0.1d, SizeUnit.in);
@@ -36,7 +35,7 @@ public class VeroBoard extends AbstractBoard {
public static Size HOLE_SIZE = new Size(0.7d, SizeUnit.mm); public static Size HOLE_SIZE = new Size(0.7d, SizeUnit.mm);
protected Size spacing = SPACING; protected Size spacing = SPACING;
protected Color stripColor = STRIP_COLOR; protected Color stripColor = COPPER_COLOR;
protected OrientationHV orientation = OrientationHV.HORIZONTAL; protected OrientationHV orientation = OrientationHV.HORIZONTAL;
@Override @Override
@@ -127,19 +126,27 @@ public class VeroBoard extends AbstractBoard {
public void drawIcon(Graphics2D g2d, int width, int height) { public void drawIcon(Graphics2D g2d, int width, int height) {
int factor = 32 / width; int factor = 32 / width;
g2d.setColor(BOARD_COLOR); g2d.setColor(BOARD_COLOR);
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor); g2d.fillRect(0, 2 / factor, width - 1, height - 4 / factor);
g2d.setColor(BORDER_COLOR); g2d.setColor(BORDER_COLOR);
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor); g2d.drawRect(0, 2 / factor, width - 1, height - 4 / factor);
g2d.setColor(STRIP_COLOR); g2d.setColor(COPPER_COLOR);
g2d.fillRect(4 / factor, width / 4, width - 8 / factor, width / 2); g2d.fillRect(1 / factor, width / 4, width - 2 / factor, width / 2);
g2d.setColor(STRIP_COLOR.darker()); g2d.setColor(COPPER_COLOR.darker());
g2d.drawRect(4 / factor, width / 4, width - 8 / factor, width / 2); g2d.drawRect(1 / factor, width / 4, width - 2 / factor, width / 2);
g2d.setColor(COPPER_COLOR);
g2d.fillRect(1 / factor, 2 / factor, width - 2 / factor, 3 / factor);
g2d.fillRect(1 / factor, height - 5 / factor, width - 2 / factor, 3 / factor);
g2d.setColor(COPPER_COLOR.darker());
g2d.drawRect(1 / factor, 2 / factor, width - 2 / factor, 3 / factor);
g2d.drawRect(1 / factor, height - 5 / factor, width - 2 / factor, 3 / factor);
g2d.setColor(Constants.CANVAS_COLOR); g2d.setColor(Constants.CANVAS_COLOR);
g2d.fillOval(width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor), g2d.fillOval(width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
getClosestOdd(5.0 / factor)); getClosestOdd(5.0 / factor));
g2d.fillOval(2 * width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor), g2d.fillOval(2 * width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
getClosestOdd(5.0 / factor)); getClosestOdd(5.0 / factor));
g2d.setColor(STRIP_COLOR.darker()); g2d.setColor(COPPER_COLOR.darker());
g2d.drawOval(width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor), g2d.drawOval(width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
getClosestOdd(5.0 / factor)); getClosestOdd(5.0 / factor));
g2d.drawOval(2 * width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor), g2d.drawOval(2 * width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
@@ -4,7 +4,6 @@ import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import org.diylc.common.ObjectCache;
import org.diylc.components.AbstractComponent; import org.diylc.components.AbstractComponent;
import org.diylc.components.boards.AbstractBoard; import org.diylc.components.boards.AbstractBoard;
import org.diylc.components.boards.VeroBoard; import org.diylc.components.boards.VeroBoard;
@@ -18,6 +17,7 @@ import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Trace Cut", category = "Connectivity", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Trace Cut", category = "Connectivity", author = "Branislav Stojkovic",
description = "Designates the place where a trace on the vero board needs to be cut", instanceNamePrefix = "Cut", description = "Designates the place where a trace on the vero board needs to be cut", instanceNamePrefix = "Cut",
@@ -26,14 +26,16 @@ public class TraceCut extends AbstractComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static Size SIZE = new Size(0.07d, SizeUnit.in); public static Size SIZE = new Size(0.08d, SizeUnit.in);
public static Size CUT_WIDTH = new Size(0.5d, SizeUnit.mm); public static Size CUT_WIDTH = new Size(0.5d, SizeUnit.mm);
public static Color FILL_COLOR = Color.white; public static Color FILL_COLOR = Color.white;
public static Color BORDER_COLOR = Color.red; public static Color BORDER_COLOR = Color.red;
public static Color SELECTION_COLOR = Color.blue; public static Color SELECTION_COLOR = Color.red;
public static Size HOLE_SIZE = new Size(0.7d, SizeUnit.mm);
private Size size = SIZE; private Size size = SIZE;
private Color fillColor = FILL_COLOR; private Color fillColor = FILL_COLOR;
@Deprecated
private Color borderColor = BORDER_COLOR; private Color borderColor = BORDER_COLOR;
private Color boardColor = AbstractBoard.BOARD_COLOR; private Color boardColor = AbstractBoard.BOARD_COLOR;
private Boolean cutBetweenHoles = false; private Boolean cutBetweenHoles = false;
@@ -55,27 +57,49 @@ public class TraceCut extends AbstractComponent<Void> {
: boardColor); : boardColor);
g2d.fillRect(point.x - holeSpacing / 2 - cutWidth / 2, point.y - size / 2 - 1, cutWidth, size + 2); g2d.fillRect(point.x - holeSpacing / 2 - cutWidth / 2, point.y - size / 2 - 1, cutWidth, size + 2);
} else { } else {
int dotDiameter = size - 6;
g2d.setColor(fillColor);
g2d.fillRect(point.x - size / 2, point.y - size / 2, size, size);
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: borderColor); : boardColor);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1)); g2d.fillRoundRect(point.x - size / 2, point.y - size / 2, size, size, size, size);
g2d.drawRect(point.x - size / 2, point.y - size / 2, size, size);
g2d.fillOval(point.x - dotDiameter / 2, point.y - dotDiameter / 2, dotDiameter, dotDiameter); g2d.setColor(Constants.CANVAS_COLOR);
int holeSize = getClosestOdd((int) HOLE_SIZE.convertToPixels());
g2d.fillOval(point.x - holeSize / 2, point.y - holeSize / 2, holeSize, holeSize);
g2d.setColor(boardColor.darker());
g2d.drawOval(point.x - holeSize / 2, point.y - holeSize / 2, holeSize, holeSize);
} }
} }
@Override @Override
public void drawIcon(Graphics2D g2d, int width, int height) { public void drawIcon(Graphics2D g2d, int width, int height) {
int size = 16; int factor = 32 / width;
int dotDiameter = size / 4 * 2; g2d.setColor(AbstractBoard.BOARD_COLOR);
g2d.setColor(FILL_COLOR); g2d.fillRect(0, 2 / factor, width - 1, height - 4 / factor);
g2d.fillRect((width - size) / 2, (height - size) / 2, size, size); g2d.setColor(AbstractBoard.BORDER_COLOR);
g2d.setColor(BORDER_COLOR); g2d.drawRect(0, 2 / factor, width - 1, height - 4 / factor);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1)); g2d.setColor(COPPER_COLOR);
g2d.drawRect((width - size) / 2, (height - size) / 2, size, size); g2d.fillRect(1 / factor, width / 3, width - 2 / factor, getClosestOdd(width / 3) + 1);
g2d.fillOval((width - dotDiameter) / 2, (height - dotDiameter) / 2, dotDiameter, dotDiameter); g2d.setColor(COPPER_COLOR.darker());
g2d.drawRect(1 / factor, width / 3, width - 2 / factor, getClosestOdd(width / 3) + 1);
g2d.setColor(AbstractBoard.BOARD_COLOR);
g2d.fillRoundRect(width / 3, width / 3, getClosestOdd(width / 3) + 2, getClosestOdd(width / 3) + 2, width / 3,
width / 3);
g2d.setColor(COPPER_COLOR);
g2d.fillRect(1 / factor, 2 / factor, width - 2 / factor, 4 / factor);
g2d.fillRect(1 / factor, height - 6 / factor, width - 2 / factor, 4 / factor);
g2d.setColor(COPPER_COLOR.darker());
g2d.drawRect(1 / factor, 2 / factor, width - 2 / factor, 4 / factor);
g2d.drawRect(1 / factor, height - 6 / factor, width - 2 / factor, 4 / factor);
g2d.setColor(Constants.CANVAS_COLOR);
g2d.fillOval(width / 6 - 1, width / 2 - 1, getClosestOdd(3.0 / factor), getClosestOdd(3.0 / factor));
g2d.fillOval(width / 2 - 1, width / 2 - 1, getClosestOdd(3.0 / factor), getClosestOdd(3.0 / factor));
g2d.fillOval(5 * width / 6 - 1, width / 2 - 1, getClosestOdd(3.0 / factor), getClosestOdd(3.0 / factor));
g2d.setColor(COPPER_COLOR.darker());
g2d.drawOval(width / 6 - 1, width / 2 - 1, getClosestOdd(3.0 / factor), getClosestOdd(3.0 / factor));
g2d.drawOval(width / 2 - 1, width / 2 - 1, getClosestOdd(3.0 / factor), getClosestOdd(3.0 / factor));
g2d.drawOval(5 * width / 6 - 1, width / 2 - 1, getClosestOdd(3.0 / factor), getClosestOdd(3.0 / factor));
} }
@Override @Override
@@ -129,11 +153,12 @@ public class TraceCut extends AbstractComponent<Void> {
this.fillColor = fillColor; this.fillColor = fillColor;
} }
@EditableProperty(name = "Border") @Deprecated
public Color getBorderColor() { public Color getBorderColor() {
return borderColor; return borderColor;
} }
@Deprecated
public void setBorderColor(Color borderColor) { public void setBorderColor(Color borderColor) {
this.borderColor = borderColor; this.borderColor = borderColor;
} }
Binary file not shown.
Binary file not shown.
@@ -197,11 +197,6 @@ public class TreePanel extends JPanel {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
int row = tree.getClosestRowForLocation(e.getX(), e.getY());
tree.setSelectionRow(row);
getPopup().show(e.getComponent(), e.getX(), e.getY());
} else {
TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY()); TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
if (node != null && node.getUserObject() != null) { if (node != null && node.getUserObject() != null) {
@@ -210,6 +205,10 @@ public class TreePanel extends JPanel {
plugInPort.setNewComponentTypeSlot(payload.getComponentType(), null); plugInPort.setNewComponentTypeSlot(payload.getComponentType(), null);
} }
} }
if (SwingUtilities.isRightMouseButton(e)) {
int row = tree.getClosestRowForLocation(e.getX(), e.getY());
tree.setSelectionRow(row);
getPopup().show(e.getComponent(), e.getX(), e.getY());
} }
} }
}); });
+12
View File
@@ -1470,6 +1470,14 @@
<changeType>NEW_FEATURE</changeType> <changeType>NEW_FEATURE</changeType>
<description>Mini humbucker pickup added as a variation of Humbucker pickup</description> <description>Mini humbucker pickup added as a variation of Humbucker pickup</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>X-axis coordinates for all perfboards are now numberical</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Improved trace cut rendering to look more natural</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Improved guitar pickup look</description> <description>Improved guitar pickup look</description>
@@ -1482,6 +1490,10 @@
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
<description>Fixed broken links in the Help menu</description> <description>Fixed broken links in the Help menu</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>TriPad board didn't show coordinate labels even when configured to do so</description>
</org.diylc.appframework.update.Change>
</changes> </changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url> <url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version> </org.diylc.appframework.update.Version>