mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
tree improvements
LP switch added
This commit is contained in:
Binary file not shown.
@@ -1,322 +1,301 @@
|
|||||||
// package org.diylc.components.guitar;
|
package org.diylc.components.guitar;
|
||||||
//
|
|
||||||
// import java.awt.AlphaComposite;
|
import java.awt.AlphaComposite;
|
||||||
// import java.awt.Color;
|
import java.awt.Color;
|
||||||
// import java.awt.Composite;
|
import java.awt.Composite;
|
||||||
// import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
// import java.awt.Point;
|
import java.awt.Point;
|
||||||
// import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
// import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
// import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
// import java.awt.geom.Ellipse2D;
|
import java.awt.geom.GeneralPath;
|
||||||
// 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.IPlugInPort;
|
||||||
// import org.diylc.common.IPlugInPort;
|
import org.diylc.common.ObjectCache;
|
||||||
// import org.diylc.common.ObjectCache;
|
import org.diylc.common.Orientation;
|
||||||
// import org.diylc.common.Orientation;
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
// import org.diylc.components.AbstractTransparentComponent;
|
import org.diylc.core.ComponentState;
|
||||||
// import org.diylc.core.ComponentState;
|
import org.diylc.core.IDIYComponent;
|
||||||
// import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDrawingObserver;
|
||||||
// import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.Project;
|
||||||
// import org.diylc.core.Project;
|
import org.diylc.core.Theme;
|
||||||
// import org.diylc.core.Theme;
|
import org.diylc.core.VisibilityPolicy;
|
||||||
// import org.diylc.core.VisibilityPolicy;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
// 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;
|
||||||
// import org.diylc.utils.Constants;
|
|
||||||
//
|
@ComponentDescriptor(name = "LP Switch", category = "Guitar", author = "Branislav Stojkovic",
|
||||||
// //@ComponentDescriptor(name = "Les Paul Switch", category = "Guitar", author =
|
description = "Les Paul style 3 position toggle switch", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
||||||
// "Branislav Stojkovic", description = "Les Paul-style 3 position switch", stretchable = false,
|
instanceNamePrefix = "SW")
|
||||||
// zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "SW")
|
public class LPSwitch extends AbstractTransparentComponent<String> {
|
||||||
// public class LPSwitch extends AbstractTransparentComponent<String> {
|
|
||||||
//
|
private static final long serialVersionUID = 1L;
|
||||||
// private static final long serialVersionUID = 1L;
|
|
||||||
//
|
private static Color BASE_COLOR = Color.lightGray;
|
||||||
// private static Color BASE_COLOR = Color.lightGray;
|
private static Color WAFER_COLOR = Color.decode("#CD8500");
|
||||||
// private static Color WAFER_COLOR = Color.decode("#CD8500");
|
|
||||||
//
|
private static Size LENGTH = new Size(1.3d, SizeUnit.in);
|
||||||
// private static Size BASE_WIDTH = new Size(0.5d, SizeUnit.in);
|
private static Size BASE_LENGTH = new Size(18d, SizeUnit.mm);
|
||||||
// private static Size BASE_LENGTH = new Size(47.5d, SizeUnit.mm);
|
private static Size WAFER_THICKNESS = new Size(0.05d, SizeUnit.in);
|
||||||
// private static Size WAFER_LENGTH = new Size(40d, SizeUnit.mm);
|
private static Size TERMINAL_SPACING = new Size(0.2d, SizeUnit.in);
|
||||||
// private static Size WAFER_SPACING = new Size(7.62d, SizeUnit.mm);
|
|
||||||
// private static Size WAFER_THICKNESS = new Size(0.05d, SizeUnit.in);
|
private String value = "";
|
||||||
// private static Size HOLE_SIZE = new Size(2d, SizeUnit.mm);
|
private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)};
|
||||||
// private static Size HOLE_SPACING = new Size(41.2d, SizeUnit.mm);
|
transient Shape[] body;
|
||||||
// private static Size TERMINAL_LENGTH = new Size(3d, SizeUnit.mm);
|
private Orientation orientation = Orientation.DEFAULT;
|
||||||
// private static Size TERMINAL_SPACING = new Size(0.1d, SizeUnit.in);
|
|
||||||
// private static Size TERMINAL_THICKNESS = new Size(0.02d, SizeUnit.in);
|
public LPSwitch() {
|
||||||
//
|
super();
|
||||||
// private String value = "";
|
updateControlPoints();
|
||||||
// private Point[] controlPoints = new Point[] { new Point(0, 0), new Point(0, 0),
|
}
|
||||||
// new Point(0, 0), new Point(0, 0) };
|
|
||||||
// transient Shape[] body;
|
@Override
|
||||||
// private Orientation orientation = Orientation.DEFAULT;
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
//
|
IDrawingObserver drawingObserver) {
|
||||||
// public LPSwitch() {
|
Shape[] body = getBody();
|
||||||
// super();
|
|
||||||
// updateControlPoints();
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
// }
|
if (componentState != ComponentState.DRAGGING) {
|
||||||
//
|
Composite oldComposite = g2d.getComposite();
|
||||||
// @Override
|
if (alpha < MAX_ALPHA) {
|
||||||
// public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
// Project project, IDrawingObserver drawingObserver) {
|
}
|
||||||
// Shape[] body = getBody();
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : WAFER_COLOR);
|
||||||
//
|
g2d.fill(body[1]);
|
||||||
// g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : BASE_COLOR);
|
||||||
// if (componentState != ComponentState.DRAGGING) {
|
g2d.fill(body[0]);
|
||||||
// Composite oldComposite = g2d.getComposite();
|
g2d.setComposite(oldComposite);
|
||||||
// if (alpha < MAX_ALPHA) {
|
}
|
||||||
// g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
|
||||||
// / MAX_ALPHA));
|
Color finalBorderColor;
|
||||||
// }
|
|
||||||
// g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : BASE_COLOR);
|
if (outlineMode) {
|
||||||
// g2d.fill(body[0]);
|
Theme theme =
|
||||||
// g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : WAFER_COLOR);
|
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
// g2d.fill(body[1]);
|
finalBorderColor =
|
||||||
// g2d.setComposite(oldComposite);
|
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
// }
|
: theme.getOutlineColor();
|
||||||
//
|
} else {
|
||||||
// Color finalBorderColor;
|
finalBorderColor =
|
||||||
// if (outlineMode) {
|
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
// Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
: WAFER_COLOR.darker();
|
||||||
// IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
}
|
||||||
// finalBorderColor = componentState == ComponentState.SELECTED
|
|
||||||
// || componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme
|
g2d.setColor(finalBorderColor);
|
||||||
// .getOutlineColor();
|
g2d.draw(body[0]);
|
||||||
// } else {
|
|
||||||
// finalBorderColor = componentState == ComponentState.SELECTED
|
if (outlineMode) {
|
||||||
// || componentState == ComponentState.DRAGGING ? SELECTION_COLOR : BASE_COLOR
|
Theme theme =
|
||||||
// .darker();
|
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
// }
|
finalBorderColor =
|
||||||
//
|
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
// g2d.setColor(finalBorderColor);
|
: theme.getOutlineColor();
|
||||||
// g2d.draw(body[0]);
|
} else {
|
||||||
//
|
finalBorderColor =
|
||||||
// if (outlineMode) {
|
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
// Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
: BASE_COLOR.darker();
|
||||||
// IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
}
|
||||||
// finalBorderColor = componentState == ComponentState.SELECTED
|
|
||||||
// || componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme
|
g2d.setColor(finalBorderColor);
|
||||||
// .getOutlineColor();
|
g2d.draw(body[1]);
|
||||||
// } else {
|
|
||||||
// finalBorderColor = componentState == ComponentState.SELECTED
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
||||||
// || componentState == ComponentState.DRAGGING ? SELECTION_COLOR : WAFER_COLOR
|
g2d.setColor(METAL_COLOR);
|
||||||
// .darker();
|
g2d.draw(body[2]);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// g2d.draw(body[1]);
|
@SuppressWarnings("incomplete-switch")
|
||||||
//
|
public Shape[] getBody() {
|
||||||
// g2d.setColor(METAL_COLOR);
|
if (body == null) {
|
||||||
// g2d.fill(body[2]);
|
body = new Shape[3];
|
||||||
// g2d.setColor(METAL_COLOR.darker());
|
|
||||||
// g2d.draw(body[2]);
|
int x = controlPoints[0].x;
|
||||||
// }
|
int y = controlPoints[0].y;
|
||||||
//
|
int baseLength = (int) BASE_LENGTH.convertToPixels();
|
||||||
// public Shape[] getBody() {
|
int length = (int) LENGTH.convertToPixels();
|
||||||
// if (body == null) {
|
int waferThickness = getClosestOdd(WAFER_THICKNESS.convertToPixels());
|
||||||
// body = new Shape[3];
|
|
||||||
//
|
Rectangle2D ground =
|
||||||
// int x = controlPoints[0].x;
|
new Rectangle2D.Double(x - waferThickness / 2, y, waferThickness, baseLength + (length - baseLength) / 2);
|
||||||
// int y = controlPoints[0].y;
|
body[0] = new Area(ground);
|
||||||
// int baseWidth = (int) BASE_WIDTH.convertToPixels();
|
|
||||||
// int baseLength = (int) BASE_LENGTH.convertToPixels();
|
int bodyY = y + (length - baseLength) / 2;
|
||||||
// int holeSize = getClosestOdd(HOLE_SIZE.convertToPixels());
|
|
||||||
// int holeSpacing = (int) HOLE_SPACING.convertToPixels();
|
Area waferArea = new Area(new Rectangle2D.Double(x - waferThickness * 3 / 2, bodyY, waferThickness, baseLength));
|
||||||
// int waferLength = (int) WAFER_LENGTH.convertToPixels();
|
waferArea.add(new Area(new Rectangle2D.Double(x + waferThickness / 2, bodyY, waferThickness, baseLength)));
|
||||||
// int waferSpacing = (int) WAFER_SPACING.convertToPixels();
|
|
||||||
// int waferThickness = (int) WAFER_THICKNESS.convertToPixels();
|
waferArea.add(new Area(new Rectangle2D.Double(x - waferThickness * 5 / 2, bodyY, waferThickness, baseLength)));
|
||||||
// int terminalSpacing = (int) TERMINAL_SPACING.convertToPixels();
|
waferArea.add(new Area(new Rectangle2D.Double(x + waferThickness * 3 / 2, bodyY, waferThickness, baseLength)));
|
||||||
// int terminalLength = getClosestOdd(TERMINAL_LENGTH.convertToPixels());
|
|
||||||
// int terminalWidth = getClosestOdd(TERMINAL_WIDTH.convertToPixels());
|
waferArea.add(new Area(new Rectangle2D.Double(x - waferThickness * 7 / 2, bodyY, waferThickness, baseLength)));
|
||||||
//
|
waferArea.add(new Area(new Rectangle2D.Double(x + waferThickness * 5 / 2, bodyY, waferThickness, baseLength)));
|
||||||
// int baseX = x - terminalLength / 2 - waferSpacing;
|
|
||||||
// int baseY = y
|
body[1] = waferArea;
|
||||||
// - (baseLength - terminalSpacing * (type == LeverSwitchType.DP3T ? 7 : 12)) / 2;
|
|
||||||
// Area baseArea = new Area(new Rectangle2D.Double(baseX, baseY, baseWidth, baseLength));
|
double theta = 0;
|
||||||
// baseArea.subtract(new Area(new Ellipse2D.Double(baseX + baseWidth / 2 - holeSize / 2,
|
// Rotate if needed
|
||||||
// baseY + (baseLength - holeSpacing) / 2 - holeSize / 2, holeSize, holeSize)));
|
if (orientation != Orientation.DEFAULT) {
|
||||||
// baseArea.subtract(new Area(new Ellipse2D.Double(baseX + baseWidth / 2 - holeSize / 2,
|
switch (orientation) {
|
||||||
// baseY + (baseLength - holeSpacing) / 2 - holeSize / 2 + holeSpacing, holeSize,
|
case _90:
|
||||||
// holeSize)));
|
theta = Math.PI / 2;
|
||||||
// body[0] = baseArea;
|
break;
|
||||||
//
|
case _180:
|
||||||
// Area waferArea = new Area(new Rectangle2D.Double(x - terminalLength / 2
|
theta = Math.PI;
|
||||||
// - waferThickness / 2,
|
break;
|
||||||
// y - (waferLength - terminalSpacing * (type == LeverSwitchType.DP3T ? 7 : 12))
|
case _270:
|
||||||
// / 2, waferThickness, waferLength));
|
theta = Math.PI * 3 / 2;
|
||||||
//
|
break;
|
||||||
// if (type == LeverSwitchType._4P5T) {
|
}
|
||||||
// waferArea.add(new Area(new Rectangle2D.Double(x - terminalLength / 2
|
}
|
||||||
// - waferThickness / 2 + waferSpacing, y
|
|
||||||
// - (waferLength - terminalSpacing * (type == LeverSwitchType.DP3T ? 7 : 12))
|
int terminalSpacing = (int) TERMINAL_SPACING.convertToPixels();
|
||||||
// / 2, waferThickness, waferLength)));
|
|
||||||
// }
|
GeneralPath terminalPath = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
|
||||||
// body[1] = waferArea;
|
terminalPath.moveTo(x - waferThickness * 3 / 2, bodyY);
|
||||||
//
|
terminalPath.lineTo(x - waferThickness * 3 / 2, bodyY + baseLength);
|
||||||
// double theta = 0;
|
terminalPath.lineTo(x, y + length);
|
||||||
// // Rotate if needed
|
|
||||||
// if (orientation != Orientation.DEFAULT) {
|
terminalPath.moveTo(x + waferThickness * 3 / 2, bodyY);
|
||||||
// switch (orientation) {
|
terminalPath.lineTo(x + waferThickness * 3 / 2, bodyY + baseLength);
|
||||||
// case _90:
|
terminalPath.lineTo(x, y + length);
|
||||||
// theta = Math.PI / 2;
|
|
||||||
// break;
|
terminalPath.moveTo(x - waferThickness * 5 / 2, bodyY);
|
||||||
// case _180:
|
terminalPath.lineTo(x - waferThickness * 5 / 2, bodyY + baseLength);
|
||||||
// theta = Math.PI;
|
terminalPath.lineTo(x - terminalSpacing, y + length);
|
||||||
// break;
|
|
||||||
// case _270:
|
terminalPath.moveTo(x + waferThickness * 5 / 2, bodyY);
|
||||||
// theta = Math.PI * 3 / 2;
|
terminalPath.lineTo(x + waferThickness * 5 / 2, bodyY + baseLength);
|
||||||
// break;
|
terminalPath.lineTo(x + terminalSpacing, y + length);
|
||||||
// }
|
body[2] = terminalPath;
|
||||||
// }
|
|
||||||
//
|
// Rotate if needed
|
||||||
// Area terminalArea = new Area();
|
if (theta != 0) {
|
||||||
// for (Point point : controlPoints) {
|
AffineTransform rotation = AffineTransform.getRotateInstance(theta, x, y);
|
||||||
// Area terminal = new Area(new RoundRectangle2D.Double(point.x - terminalLength / 2,
|
// Skip the last one because it's already rotated
|
||||||
// point.y - terminalWidth / 2, terminalLength, terminalWidth,
|
for (int i = 0; i < body.length; i++) {
|
||||||
// terminalWidth / 2, terminalWidth / 2));
|
Shape shape = body[i];
|
||||||
// terminal.subtract(new Area(
|
if (shape instanceof Area) {
|
||||||
// new RoundRectangle2D.Double(point.x - terminalLength / 4, point.y
|
Area area = (Area) shape;
|
||||||
// - terminalWidth / 4, terminalLength / 2, terminalWidth / 2,
|
area.transform(rotation);
|
||||||
// terminalWidth / 2, terminalWidth / 2)));
|
} else if (shape instanceof GeneralPath) {
|
||||||
// // Rotate the terminal if needed
|
GeneralPath path = (GeneralPath) shape;
|
||||||
// if (theta != 0) {
|
path.transform(rotation);
|
||||||
// AffineTransform rotation = AffineTransform.getRotateInstance(theta, point.x,
|
}
|
||||||
// point.y);
|
}
|
||||||
// terminal.transform(rotation);
|
}
|
||||||
// }
|
}
|
||||||
// terminalArea.add(terminal);
|
return body;
|
||||||
// }
|
}
|
||||||
// body[2] = terminalArea;
|
|
||||||
//
|
@SuppressWarnings("incomplete-switch")
|
||||||
// // Rotate if needed
|
private void updateControlPoints() {
|
||||||
// if (theta != 0) {
|
int x = controlPoints[0].x;
|
||||||
// AffineTransform rotation = AffineTransform.getRotateInstance(theta, x, y);
|
int y = controlPoints[0].y;
|
||||||
// // Skip the last one because it's already rotated
|
int terminalSpacing = (int) TERMINAL_SPACING.convertToPixels();
|
||||||
// for (int i = 0; i < body.length - 1; i++) {
|
int length = (int) LENGTH.convertToPixels();
|
||||||
// Shape shape = body[i];
|
|
||||||
// Area area = (Area) shape;
|
controlPoints[1].setLocation(x - terminalSpacing, y + length);
|
||||||
// area.transform(rotation);
|
controlPoints[2].setLocation(x, y + length);
|
||||||
// }
|
controlPoints[3].setLocation(x + terminalSpacing, y + length);
|
||||||
// }
|
|
||||||
// }
|
// Rotate if needed
|
||||||
// return body;
|
if (orientation != Orientation.DEFAULT) {
|
||||||
// }
|
double theta = 0;
|
||||||
//
|
switch (orientation) {
|
||||||
// private void updateControlPoints() {
|
case _90:
|
||||||
// int x = controlPoints[0].x;
|
theta = Math.PI / 2;
|
||||||
// int y = controlPoints[0].y;
|
break;
|
||||||
// int terminalSpacing = (int) TERMINAL_SPACING.convertToPixels();
|
case _180:
|
||||||
// int baseLength = (int) BASE_LENGTH.convertToPixels();
|
theta = Math.PI;
|
||||||
//
|
break;
|
||||||
// controlPoints[1].setLocation(x - terminalSpacing * 2 - baseLength, y - terminalSpacing);
|
case _270:
|
||||||
// controlPoints[2].setLocation(x - terminalSpacing * 2 - baseLength, y);
|
theta = Math.PI * 3 / 2;
|
||||||
// controlPoints[3].setLocation(x - terminalSpacing * 2 - baseLength, y);
|
break;
|
||||||
//
|
}
|
||||||
// // Rotate if needed
|
AffineTransform rotation = AffineTransform.getRotateInstance(theta, x, y);
|
||||||
// if (orientation != Orientation.DEFAULT) {
|
for (Point point : controlPoints) {
|
||||||
// double theta = 0;
|
rotation.transform(point, point);
|
||||||
// switch (orientation) {
|
}
|
||||||
// case _90:
|
}
|
||||||
// theta = Math.PI / 2;
|
}
|
||||||
// break;
|
|
||||||
// case _180:
|
@Override
|
||||||
// theta = Math.PI;
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
// break;
|
g2d.rotate(Math.PI / 4, width / 2, height / 2);
|
||||||
// case _270:
|
int baseLength = 20 * width / 32;
|
||||||
// theta = Math.PI * 3 / 2;
|
|
||||||
// break;
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(3f));
|
||||||
// }
|
g2d.setColor(BASE_COLOR);
|
||||||
// AffineTransform rotation = AffineTransform.getRotateInstance(theta, x, y);
|
g2d.drawLine(width / 2, 0, width / 2, baseLength + (width - baseLength) / 2);
|
||||||
// for (Point point : controlPoints) {
|
g2d.setColor(WAFER_COLOR);
|
||||||
// rotation.transform(point, point);
|
g2d.fillRect(8 * width / 32, (width - baseLength) / 2, 16 * width / 32, baseLength);
|
||||||
// }
|
g2d.setColor(METAL_COLOR);
|
||||||
// }
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||||
// }
|
g2d.drawLine(width / 2 - 2, (width - baseLength) / 2, width / 2 - 2, baseLength + (width - baseLength) / 2);
|
||||||
//
|
g2d.drawLine(width / 2 + 2, (width - baseLength) / 2, width / 2 + 2, baseLength + (width - baseLength) / 2);
|
||||||
// @Override
|
g2d.drawLine(width / 2 - 5, (width - baseLength) / 2, width / 2 - 5, baseLength + (width - baseLength) / 2);
|
||||||
// public void drawIcon(Graphics2D g2d, int width, int height) {
|
g2d.drawLine(width / 2 + 5, (width - baseLength) / 2, width / 2 + 5, baseLength + (width - baseLength) / 2);
|
||||||
// g2d.setClip(width / 32, width / 32, width, height);
|
int dx = 2 * width / 32;
|
||||||
// g2d.setColor(BASE_COLOR);
|
int dy = 4 * width / 32;
|
||||||
// g2d.fillRect(0, 0, width * 2 / 3, height);
|
g2d.drawLine(width / 2 - 2, baseLength + (width - baseLength) / 2, width / 2 - 2 + dx, baseLength
|
||||||
// g2d.setColor(BASE_COLOR.darker());
|
+ (width - baseLength) / 2 + dy);
|
||||||
// g2d.drawRect(0, 0, width * 2 / 3, height);
|
g2d.drawLine(width / 2 + 2, baseLength + (width - baseLength) / 2, width / 2 + 2 - dx, baseLength
|
||||||
// g2d.setColor(WAFER_COLOR);
|
+ (width - baseLength) / 2 + dy);
|
||||||
// g2d.fillRect(width / 8 * 3, 0, width / 8, height);
|
|
||||||
// g2d.setColor(WAFER_COLOR.darker());
|
g2d.drawLine(width / 2 - 5, baseLength + (width - baseLength) / 2, width / 2 - 5 - dx, baseLength + (width - baseLength) / 2 + dy);
|
||||||
// g2d.drawRect(width / 8 * 3, 0, width / 8, height);
|
g2d.drawLine(width / 2 + 5, baseLength + (width - baseLength) / 2, width / 2 + 5 + dx, baseLength + (width - baseLength) / 2 + dy);
|
||||||
// Area terminals = new Area();
|
}
|
||||||
// int terminalLength = getClosestOdd(11 * width / 32);
|
|
||||||
// int terminalWidth = getClosestOdd(7 * width / 32);
|
@Override
|
||||||
// Area terminal = new Area(new RoundRectangle2D.Double(width / 16 * 7, 4 * width / 32,
|
public int getControlPointCount() {
|
||||||
// terminalLength, terminalWidth, terminalWidth / 2, terminalWidth / 2));
|
return controlPoints.length;
|
||||||
// terminal.subtract(new Area(new RoundRectangle2D.Double(width / 16 * 7 + terminalLength / 4
|
}
|
||||||
// + 1, 4 * width / 32 + terminalWidth / 4 + 1, terminalLength / 2, terminalWidth / 2,
|
|
||||||
// terminalWidth / 4, terminalWidth / 4)));
|
@Override
|
||||||
// terminals.add(terminal);
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
// terminal = new Area(terminal);
|
return VisibilityPolicy.NEVER;
|
||||||
// terminal.transform(AffineTransform.getTranslateInstance(-terminalLength, terminalWidth + 2
|
}
|
||||||
// * width / 32));
|
|
||||||
// terminals.add(terminal);
|
@Override
|
||||||
// terminal = new Area(terminal);
|
public boolean isControlPointSticky(int index) {
|
||||||
// terminal.transform(AffineTransform.getTranslateInstance(terminalLength, terminalWidth + 2
|
return true;
|
||||||
// * width / 32));
|
}
|
||||||
// terminals.add(terminal);
|
|
||||||
// g2d.setColor(METAL_COLOR);
|
@Override
|
||||||
// g2d.fill(terminals);
|
public Point getControlPoint(int index) {
|
||||||
// g2d.setColor(METAL_COLOR.darker());
|
return controlPoints[index];
|
||||||
// g2d.draw(terminals);
|
}
|
||||||
// }
|
|
||||||
//
|
@Override
|
||||||
// @Override
|
public void setControlPoint(Point point, int index) {
|
||||||
// public int getControlPointCount() {
|
this.controlPoints[index].setLocation(point);
|
||||||
// return controlPoints.length;
|
// Invalidate the body
|
||||||
// }
|
body = null;
|
||||||
//
|
}
|
||||||
// @Override
|
|
||||||
// public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
@Override
|
||||||
// return VisibilityPolicy.NEVER;
|
public String getValue() {
|
||||||
// }
|
return value;
|
||||||
//
|
}
|
||||||
// @Override
|
|
||||||
// public boolean isControlPointSticky(int index) {
|
@Override
|
||||||
// return true;
|
public void setValue(String value) {
|
||||||
// }
|
this.value = value;
|
||||||
//
|
}
|
||||||
// @Override
|
|
||||||
// public Point getControlPoint(int index) {
|
@EditableProperty
|
||||||
// return controlPoints[index];
|
public Orientation getOrientation() {
|
||||||
// }
|
return orientation;
|
||||||
//
|
}
|
||||||
// @Override
|
|
||||||
// public void setControlPoint(Point point, int index) {
|
public void setOrientation(Orientation orientation) {
|
||||||
// this.controlPoints[index].setLocation(point);
|
this.orientation = orientation;
|
||||||
// // Invalidate the body
|
updateControlPoints();
|
||||||
// body = null;
|
// Invalidate the body
|
||||||
// }
|
body = null;
|
||||||
//
|
}
|
||||||
// @Override
|
}
|
||||||
// public String getValue() {
|
|
||||||
// return value;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void setValue(String value) {
|
|
||||||
// this.value = value;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @EditableProperty
|
|
||||||
// public Orientation getOrientation() {
|
|
||||||
// return orientation;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setOrientation(Orientation orientation) {
|
|
||||||
// this.orientation = orientation;
|
|
||||||
// updateControlPoints();
|
|
||||||
// // Invalidate the body
|
|
||||||
// body = null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -34,8 +34,6 @@ import javax.swing.event.DocumentEvent;
|
|||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
import javax.swing.event.PopupMenuEvent;
|
import javax.swing.event.PopupMenuEvent;
|
||||||
import javax.swing.event.PopupMenuListener;
|
import javax.swing.event.PopupMenuListener;
|
||||||
import javax.swing.event.TreeSelectionEvent;
|
|
||||||
import javax.swing.event.TreeSelectionListener;
|
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
@@ -60,6 +58,7 @@ public class TreePanel extends JPanel {
|
|||||||
|
|
||||||
private DefaultTreeModel treeModel;
|
private DefaultTreeModel treeModel;
|
||||||
private JTree tree;
|
private JTree tree;
|
||||||
|
private JScrollPane treeScroll;
|
||||||
private JTextField searchField;
|
private JTextField searchField;
|
||||||
private DefaultMutableTreeNode recentNode;
|
private DefaultMutableTreeNode recentNode;
|
||||||
private List<String> recentComponents;
|
private List<String> recentComponents;
|
||||||
@@ -77,17 +76,17 @@ public class TreePanel extends JPanel {
|
|||||||
gbc.gridy = 0;
|
gbc.gridy = 0;
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc.weighty = 0;
|
gbc.weighty = 0;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
|
||||||
add(getSearchField(), gbc);
|
add(getSearchField(), gbc);
|
||||||
|
|
||||||
gbc.gridy++;
|
gbc.gridy++;
|
||||||
|
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.weighty = 1;
|
gbc.weighty = 1;
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
|
|
||||||
JScrollPane scroll = new JScrollPane(getTree());
|
add(getTreeScroll(), gbc);
|
||||||
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
|
||||||
add(scroll, gbc);
|
|
||||||
|
|
||||||
setPreferredSize(new Dimension(240, 200));
|
setPreferredSize(new Dimension(240, 200));
|
||||||
|
|
||||||
@@ -109,6 +108,14 @@ public class TreePanel extends JPanel {
|
|||||||
getTree().expandRow(0);
|
getTree().expandRow(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JScrollPane getTreeScroll() {
|
||||||
|
if (treeScroll == null) {
|
||||||
|
treeScroll = new JScrollPane(getTree());
|
||||||
|
treeScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
}
|
||||||
|
return treeScroll;
|
||||||
|
}
|
||||||
|
|
||||||
public DefaultMutableTreeNode getRecentNode() {
|
public DefaultMutableTreeNode getRecentNode() {
|
||||||
if (this.recentNode == null) {
|
if (this.recentNode == null) {
|
||||||
this.recentNode = new DefaultMutableTreeNode(new Payload("(Recently Used)"), true);
|
this.recentNode = new DefaultMutableTreeNode(new Payload("(Recently Used)"), true);
|
||||||
@@ -170,31 +177,39 @@ public class TreePanel extends JPanel {
|
|||||||
tree.setCellRenderer(new ComponentCellRenderer());
|
tree.setCellRenderer(new ComponentCellRenderer());
|
||||||
tree.setRowHeight(0);
|
tree.setRowHeight(0);
|
||||||
ToolTipManager.sharedInstance().registerComponent(tree);
|
ToolTipManager.sharedInstance().registerComponent(tree);
|
||||||
tree.addTreeSelectionListener(new TreeSelectionListener() {
|
// tree.addTreeSelectionListener(new TreeSelectionListener() {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void valueChanged(TreeSelectionEvent e) {
|
// public void valueChanged(TreeSelectionEvent e) {
|
||||||
Object c = e.getPath().getLastPathComponent();
|
// Object c = e.getPath().getLastPathComponent();
|
||||||
if (c != null && c.getClass().equals(DefaultMutableTreeNode.class)) {
|
// if (c != null && c.getClass().equals(DefaultMutableTreeNode.class)) {
|
||||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) c;
|
// DefaultMutableTreeNode node = (DefaultMutableTreeNode) c;
|
||||||
Object obj = node.getUserObject();
|
// Object obj = node.getUserObject();
|
||||||
if (obj != null && obj.getClass().equals(Payload.class)) {
|
// if (obj != null && obj.getClass().equals(Payload.class)) {
|
||||||
Payload payload = (Payload) obj;
|
// Payload payload = (Payload) obj;
|
||||||
plugInPort.setNewComponentTypeSlot(payload.getComponentType(), null);
|
// plugInPort.setNewComponentTypeSlot(payload.getComponentType(), null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
tree.addMouseListener(new MouseAdapter() {
|
tree.addMouseListener(new MouseAdapter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
|
||||||
if (SwingUtilities.isRightMouseButton(e)) {
|
if (SwingUtilities.isRightMouseButton(e)) {
|
||||||
int row = tree.getClosestRowForLocation(e.getX(), e.getY());
|
int row = tree.getClosestRowForLocation(e.getX(), e.getY());
|
||||||
tree.setSelectionRow(row);
|
tree.setSelectionRow(row);
|
||||||
getPopup().show(e.getComponent(), e.getX(), e.getY());
|
getPopup().show(e.getComponent(), e.getX(), e.getY());
|
||||||
|
} else {
|
||||||
|
TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
|
||||||
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
|
||||||
|
if (node != null && node.getUserObject() != null) {
|
||||||
|
Payload payload = (Payload) node.getUserObject();
|
||||||
|
if (payload.getComponentType() != null) {
|
||||||
|
plugInPort.setNewComponentTypeSlot(payload.getComponentType(), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1458,13 +1458,21 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Searchable toolbox tree instead of the old toolbar (can be changed from "Config" menu)</description>
|
<description>Searchable toolbox tree instead of the old toolbar (can be changed from "Config" menu)</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>LP-style switch added</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>P-90 pickup in both "dog ear" and "soap bar" variations added</description>
|
<description>P-90 pickup in both "dog ear" and "soap bar" variations added</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Mini humbucker pickup added</description>
|
<description>Mini humbucker pickup added as a variation of Humbucker pickup</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Improved guitar pickup look</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>BUG_FIX</changeType>
|
<changeType>BUG_FIX</changeType>
|
||||||
|
|||||||
Reference in New Issue
Block a user