multi-section can caps

This commit is contained in:
Branislav Stojkovic
2019-01-06 14:16:50 +01:00
parent b9613fa72d
commit 8dd1b74f96
7 changed files with 425 additions and 359 deletions
Binary file not shown.
@@ -1,362 +1,428 @@
///* /*
//
// DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
// Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
//
// This file is part of DIYLC. This file is part of DIYLC.
//
// DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. (at your option) any later version.
//
// DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
// along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
//
//*/ */
//package org.diylc.components.passive; package org.diylc.components.passive;
//
//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.FontMetrics; import java.awt.Graphics2D;
//import java.awt.Graphics2D; import java.awt.Point;
//import java.awt.Point; import java.awt.Rectangle;
//import java.awt.Rectangle; import java.awt.geom.Area;
//import java.awt.geom.Area; import java.awt.geom.Ellipse2D;
//import java.awt.geom.Ellipse2D; import java.text.DecimalFormat;
//import java.awt.geom.Rectangle2D; import java.text.Format;
//
//import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
//import org.diylc.common.Display; import org.diylc.common.Display;
//import org.diylc.common.IPlugInPort; import org.diylc.common.HorizontalAlignment;
//import org.diylc.common.ObjectCache; import org.diylc.common.IPlugInPort;
//import org.diylc.common.Orientation; import org.diylc.common.ObjectCache;
//import org.diylc.components.AbstractTransparentComponent; import org.diylc.common.Orientation;
//import org.diylc.core.ComponentState; import org.diylc.common.VerticalAlignment;
//import org.diylc.core.IDIYComponent; import org.diylc.components.AbstractTransparentComponent;
//import org.diylc.core.IDrawingObserver; import org.diylc.core.ComponentState;
//import org.diylc.core.Project; import org.diylc.core.IDIYComponent;
//import org.diylc.core.Theme; import org.diylc.core.IDrawingObserver;
//import org.diylc.core.VisibilityPolicy; import org.diylc.core.Project;
//import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.Theme;
//import org.diylc.core.annotations.EditableProperty; import org.diylc.core.VisibilityPolicy;
//import org.diylc.core.annotations.KeywordPolicy; import org.diylc.core.annotations.ComponentDescriptor;
//import org.diylc.core.measures.Capacitance; import org.diylc.core.annotations.EditableProperty;
//import org.diylc.core.measures.Size; import org.diylc.core.annotations.KeywordPolicy;
//import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.Capacitance;
//import org.diylc.utils.Constants; import org.diylc.core.measures.Size;
// import org.diylc.core.measures.SizeUnit;
////@ComponentDescriptor(name = "Electrolytic Capacitor (can)", author = "Branislav Stojkovic", category = "Passive", import org.diylc.utils.Constants;
//// instanceNamePrefix = "C", description = "Vertical chassis-mount electrolytic capacitor similar to JJ",
//// stretchable = false, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE) @ComponentDescriptor(name = "Electrolytic Capacitor (can)", author = "Branislav Stojkovic", category = "Passive",
//public class ElectrolyticCanCapacitor extends AbstractTransparentComponent<Capacitance[]> { instanceNamePrefix = "C", description = "Multi-section vertically mounted electrolytic capacitor, similar to JJ, CE and others",
// stretchable = false, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
// private static final long serialVersionUID = 1L; public class ElectrolyticCanCapacitor extends AbstractTransparentComponent<Capacitance[]> {
//
// public static Color BODY_COLOR = Color.lightGray; private static final long serialVersionUID = 1L;
// public static Color BASE_COLOR = Color.gray;
// public static Color BORDER_COLOR = BODY_COLOR.darker(); public static Color BODY_COLOR = Color.decode("#6B6DCE");
// public static Color PIN_COLOR = Color.decode("#00B2EE"); public static Color BASE_COLOR = Color.decode("#333333");
// public static Color PIN_BORDER_COLOR = PIN_COLOR.darker(); public static Color BORDER_COLOR = BODY_COLOR.darker();
// public static Color LABEL_COLOR = Color.black; public static Color PIN_COLOR = METAL_COLOR;
// public static Size PIN_SIZE = new Size(0.08d, SizeUnit.in); public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
//// public static Size PIN_SPACING = new Size(0.05d, SizeUnit.in); public static Color LABEL_COLOR = Color.white;
// public static Size BODY_DIAMETER = new Size(1d, SizeUnit.in); public static Size PIN_SIZE = new Size(0.08d, SizeUnit.in);
// // public static Size PIN_SPACING = new Size(0.05d, SizeUnit.in);
// private Capacitance[] value = new Capacitance[4]; public static Size BODY_DIAMETER = new Size(1d, SizeUnit.in);
// private org.diylc.core.measures.Voltage voltage = null; private static double RELATIVE_DIAMETER = 0.6d;
// private static final Format format = new DecimalFormat("0.#####");
// private Orientation orientation = Orientation.DEFAULT;
// private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)}; private Capacitance[] value = new Capacitance[3];
// transient private Area body; private org.diylc.core.measures.Voltage voltage = null;
// private Color bodyColor = BODY_COLOR;
// private Color baseColor = BASE_COLOR; private Orientation orientation = Orientation.DEFAULT;
// private Color borderColor = BORDER_COLOR; private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)};
// private Color labelColor = LABEL_COLOR; transient private Area[] body;
// protected Display display = Display.NAME; private Color bodyColor = BODY_COLOR;
//// private Size pinSpacing = PIN_SPACING; private Color baseColor = BASE_COLOR;
// private CanSections sections = CanSections._1; private Color borderColor = BORDER_COLOR;
// private Size diameter = BODY_DIAMETER; private Color labelColor = LABEL_COLOR;
// protected Display display = Display.NAME;
// public ElectrolyticCanCapacitor() { // private Size pinSpacing = PIN_SPACING;
// super(); private Size diameter = BODY_DIAMETER;
// updateControlPoints();
public ElectrolyticCanCapacitor() {
super();
updateControlPoints();
}
@EditableProperty
public Capacitance[] getValue() {
return value;
}
public void setValue(Capacitance[] value) {
boolean needsUpdate = false;
if ((this.value == null ? 0 : this.value.length) != (value == null ? 0 : value.length))
needsUpdate = true;
this.value = value;
if (needsUpdate) {
updateControlPoints();
body = null;
}
}
private String getStringValue() {
if (value == null)
return "";
StringBuilder sb = new StringBuilder();
boolean isFirst = true;
for (Capacitance c : value) {
if (isFirst)
isFirst = false;
else
sb.append(" / ");
sb.append(c == null ? "" : format.format(c.getValue()));
}
if (value[0] != null)
sb.append(" " + value[0].getUnit());
return sb.toString();
}
@EditableProperty
public org.diylc.core.measures.Voltage getVoltage() {
return voltage;
}
public void setVoltage(org.diylc.core.measures.Voltage voltage) {
this.voltage = voltage;
}
@EditableProperty
public Size getDiameter() {
return diameter;
}
public void setDiameter(Size diameter) {
this.diameter = diameter;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
updateControlPoints();
// Reset body shape;
body = null;
}
@Override
public int getControlPointCount() {
return controlPoints.length;
}
@Override
public Point getControlPoint(int index) {
return controlPoints[index];
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.NEVER;
}
@Override
public void setControlPoint(Point point, int index) {
controlPoints[index].setLocation(point);
body = null;
}
private void updateControlPoints() {
// int pinSpacing = (int) getPinSpacing().convertToPixels();
int pinSpacing = (int) (getDiameter().convertToPixels() * RELATIVE_DIAMETER);
// switch (getS)
int newCount = value.length + 1;
if (newCount != controlPoints.length) {
// need new control points
Point[] newPoints = new Point[newCount];
newPoints[0] = controlPoints[0];
for (int i = 1; i < newCount; i++) {
newPoints[i] = new Point(0, 0);
}
controlPoints = newPoints;
}
// Update control points.
int x = controlPoints[0].x;
int y = controlPoints[0].y;
if (newCount == 2) {
controlPoints[1].setLocation(x + pinSpacing, y);
} else if (newCount == 3) {
controlPoints[1].setLocation(x + pinSpacing / 2, y - pinSpacing / 2);
controlPoints[2].setLocation(x + pinSpacing / 2, y + pinSpacing / 2);
} else {
double theta = Math.PI * 2 / newCount;
double centerX = x + pinSpacing / 2;
double centerY = y;
for (int i = 1; i < newCount; i++) {
controlPoints[i].setLocation(centerX + Math.cos(-Math.PI + theta * i) * pinSpacing / 2, centerY + Math.sin(-Math.PI + theta * i) * pinSpacing / 2);
}
}
switch (orientation) {
case DEFAULT:
// controlPoints[1].setLocation(x - pinSpacing, y + pinSpacing);
// controlPoints[2].setLocation(x, y + 2 * pinSpacing);
break;
case _90:
controlPoints[1].setLocation(x - pinSpacing, y - pinSpacing);
controlPoints[2].setLocation(x - 2 * pinSpacing, y);
break;
case _180:
controlPoints[1].setLocation(x + pinSpacing, y - pinSpacing);
controlPoints[2].setLocation(x, y - 2 * pinSpacing);
break;
case _270:
controlPoints[1].setLocation(x + pinSpacing, y + pinSpacing);
controlPoints[2].setLocation(x + 2 * pinSpacing, y);
break;
default:
throw new RuntimeException("Unexpected orientation: " + orientation);
}
}
public Area[] getBody() {
if (body == null) {
double centerX;
double centerY;
int x = controlPoints[0].x;
int y = controlPoints[0].y;
int pinSpacing = (int) (getDiameter().convertToPixels() * RELATIVE_DIAMETER);
if (controlPoints.length == 2 || controlPoints.length == 3) {
centerX = x + pinSpacing / 2;
centerY = y;
// } else if (controlPoints.length == 3) {
// controlPoints[1].setLocation(x + pinSpacing, y);
// controlPoints[2].setLocation(x + pinSpacing / 2, y + pinSpacing / 2);
} else {
centerX = x + pinSpacing / 2;
centerY = y;
}
int bodyDiameter = getClosestOdd(getDiameter().convertToPixels());
int innerDiameter = getClosestOdd(getDiameter().convertToPixels() * 0.85);
body = new Area[] { new Area(new Ellipse2D.Double(centerX - bodyDiameter / 2, centerY - bodyDiameter / 2, bodyDiameter, bodyDiameter)),
new Area(new Ellipse2D.Double(centerX - innerDiameter / 2, centerY - innerDiameter / 2, innerDiameter, innerDiameter))};
}
return body;
}
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
IDrawingObserver drawingObserver) {
if (checkPointsClipped(g2d.getClip())) {
return;
}
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
Area[] area = getBody();
Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
}
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
g2d.fill(area[0]);
drawingObserver.startTracking();
g2d.setComposite(oldComposite);
Color finalBorderColor;
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
if (outlineMode) {
finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: theme.getOutlineColor();
} else {
finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: borderColor;
}
g2d.setColor(finalBorderColor);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
g2d.draw(area[0]);
g2d.setColor(baseColor);
g2d.fill(area[1]);
for (Point point : controlPoints) {
if (!outlineMode) {
g2d.setColor(PIN_COLOR);
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
}
g2d.setColor(outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
}
// Draw label.
g2d.setFont(project.getFont());
Color finalLabelColor;
if (outlineMode) {
finalLabelColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
: theme.getOutlineColor();
} else {
finalLabelColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
: getLabelColor();
}
g2d.setColor(finalLabelColor);
String label = "";
label = (getDisplay() == Display.NAME) ? getName() : getStringValue();
if (getDisplay() == Display.NONE) {
label = "";
} else if (getDisplay() == Display.NAME) {
label = getName();
} else if (getDisplay() == Display.VALUE) {
label = getStringValue();
} else if (getDisplay() == Display.BOTH) {
label = getName() + "\n" + getStringValue();
}
Rectangle bounds = area[0].getBounds();
drawCenteredText(g2d, label, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
// draw polarity markers
g2d.setColor(PIN_BORDER_COLOR);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2f));
double markerSize = pinSize * 0.7;
for (int i = 0; i < controlPoints.length; i++) {
int x = controlPoints[i].x;
int y = controlPoints[i].y;
g2d.drawLine((int)(x - markerSize / 2), y, (int)(x + markerSize / 2), y);
if (i > 0)
g2d.drawLine(x, (int)(y - markerSize / 2), x, (int)(y + markerSize / 2));
}
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
int margin = 2 * width / 32;
Area area = new Area(new Ellipse2D.Double(margin / 2, margin, width - 2 * margin, width - 2 * margin));
g2d.setColor(BODY_COLOR);
g2d.fill(area);
g2d.setColor(BORDER_COLOR);
g2d.draw(area);
g2d.setColor(PIN_COLOR);
int pinSize = 2 * width / 32;
for (int i = 0; i < 3; i++) {
g2d.fillOval((i == 1 ? width * 3 / 8 : width / 2) - pinSize / 2, (height / 4) * (i + 1), pinSize, pinSize);
}
}
@EditableProperty(name = "Body")
public Color getBodyColor() {
return bodyColor;
}
public void setBodyColor(Color bodyColor) {
this.bodyColor = bodyColor;
}
@EditableProperty(name = "Base")
public Color getBaseColor() {
return baseColor;
}
public void setBaseColor(Color baseColor) {
this.baseColor = baseColor;
}
// @EditableProperty(name = "Pin spacing")
// public Size getPinSpacing() {
// return pinSpacing;
// } // }
// //
// @EditableProperty // public void setPinSpacing(Size pinSpacing) {
// public Capacitance[] getValue() { // this.pinSpacing = pinSpacing;
// return value;
// }
//
// public void setValue(Capacitance[] value) {
// this.value = value;
// }
//
// @EditableProperty
// public org.diylc.core.measures.Voltage getVoltage() {
// return voltage;
// }
//
// public void setVoltage(org.diylc.core.measures.Voltage voltage) {
// this.voltage = voltage;
// }
////
//// @EditableProperty
//// public CanSections getSections() {
//// return sections;
//// }
////
//// public void setSections(CanSections sections) {
//// this.sections = sections;
//// }
//
// @EditableProperty
// public Size getDiameter() {
// return diameter;
// }
//
// public void setDiameter(Size diameter) {
// this.diameter = diameter;
// }
//
// @EditableProperty
// public Orientation getOrientation() {
// return orientation;
// }
//
// public void setOrientation(Orientation orientation) {
// this.orientation = orientation;
// updateControlPoints(); // updateControlPoints();
// // Reset body shape; // // Reset body shape;
// body = null; // body = null;
// } // }
//
// @Override @EditableProperty(name = "Border")
// public int getControlPointCount() { public Color getBorderColor() {
// return controlPoints.length; return borderColor;
// } }
//
// @Override public void setBorderColor(Color borderColor) {
// public Point getControlPoint(int index) { this.borderColor = borderColor;
// return controlPoints[index]; }
// }
// @EditableProperty(name = "Label")
// @Override public Color getLabelColor() {
// public boolean isControlPointSticky(int index) { return labelColor;
// return true; }
// }
// public void setLabelColor(Color labelColor) {
// @Override this.labelColor = labelColor;
// public VisibilityPolicy getControlPointVisibilityPolicy(int index) { }
// return VisibilityPolicy.NEVER;
// } @EditableProperty
// public Display getDisplay() {
// @Override if (display == null) {
// public void setControlPoint(Point point, int index) { display = Display.NAME;
// controlPoints[index].setLocation(point); }
// body = null; return display;
// } }
//
// private void updateControlPoints() { public void setDisplay(Display display) {
//// int pinSpacing = (int) getPinSpacing().convertToPixels(); this.display = display;
// int pinSpacing = (int) getDiameter().convertToPixels(); }
//// switch (getS) }
//
// // Update control points.
// int x = controlPoints[0].x;
// int y = controlPoints[0].y;
// switch (orientation) {
// case DEFAULT:
// controlPoints[1].setLocation(x - pinSpacing, y + pinSpacing);
// controlPoints[2].setLocation(x, y + 2 * pinSpacing);
// break;
// case _90:
// controlPoints[1].setLocation(x - pinSpacing, y - pinSpacing);
// controlPoints[2].setLocation(x - 2 * pinSpacing, y);
// break;
// case _180:
// controlPoints[1].setLocation(x + pinSpacing, y - pinSpacing);
// controlPoints[2].setLocation(x, y - 2 * pinSpacing);
// break;
// case _270:
// controlPoints[1].setLocation(x + pinSpacing, y + pinSpacing);
// controlPoints[2].setLocation(x + 2 * pinSpacing, y);
// break;
// default:
// throw new RuntimeException("Unexpected orientation: " + orientation);
// }
// }
//
// public Area getBody() {
// if (body == null) {
// int x = (controlPoints[0].x + controlPoints[1].x + controlPoints[2].x) / 3;
// int y = (controlPoints[0].y + controlPoints[1].y + controlPoints[2].y) / 3;
// int bodyDiameter = getClosestOdd(getDiameter().convertToPixels());
//
// body = new Area(new Ellipse2D.Double(x - bodyDiameter / 2, y - bodyDiameter / 2, bodyDiameter, bodyDiameter));
//
// }
// return body;
// }
//
// @Override
// public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
// IDrawingObserver drawingObserver) {
// if (checkPointsClipped(g2d.getClip())) {
// return;
// }
// int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
// Area mainArea = getBody();
// Composite oldComposite = g2d.getComposite();
// if (alpha < MAX_ALPHA) {
// g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
// }
// g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
// g2d.fill(mainArea);
// g2d.setComposite(oldComposite);
// Color finalBorderColor;
// Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
// if (outlineMode) {
// finalBorderColor =
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
// : theme.getOutlineColor();
// } else {
// finalBorderColor =
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
// : borderColor;
// }
// g2d.setColor(finalBorderColor);
// g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
// g2d.draw(mainArea);
//
// for (Point point : controlPoints) {
// if (!outlineMode) {
// g2d.setColor(PIN_COLOR);
// g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
// }
// g2d.setColor(outlineMode ? theme.getOutlineColor() : PIN_BORDER_COLOR);
// g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
// }
//
// // Draw label.
// g2d.setFont(project.getFont());
// Color finalLabelColor;
// if (outlineMode) {
// finalLabelColor =
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
// : theme.getOutlineColor();
// } else {
// finalLabelColor =
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
// : getLabelColor();
// }
// g2d.setColor(finalLabelColor);
// String label = "";
// label = (getDisplay() == Display.NAME) ? getName() : getValue().toString();
// if (getDisplay() == Display.NONE) {
// label = "";
// }
// if (getDisplay() == Display.BOTH) {
// label = getName() + " " + (getValue() == null ? "" : getValue().toString());
// }
// FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
// Rectangle2D rect = fontMetrics.getStringBounds(label, g2d);
// int textHeight = (int) (rect.getHeight());
// int textWidth = (int) (rect.getWidth());
// // Center text horizontally and vertically
// Rectangle bounds = mainArea.getBounds();
// int x = bounds.x + (bounds.width - textWidth) / 2;
// int y = bounds.y + (bounds.height - textHeight) / 2 + fontMetrics.getAscent();
// g2d.drawString(label, x, y);
// }
//
// @Override
// public void drawIcon(Graphics2D g2d, int width, int height) {
// int margin = 2 * width / 32;
// Area area = new Area(new Ellipse2D.Double(margin / 2, margin, width - 2 * margin, width - 2 * margin));
// g2d.setColor(BODY_COLOR);
// g2d.fill(area);
// g2d.setColor(BORDER_COLOR);
// g2d.draw(area);
// g2d.setColor(PIN_COLOR);
// int pinSize = 2 * width / 32;
// for (int i = 0; i < 3; i++) {
// g2d.fillOval((i == 1 ? width * 3 / 8 : width / 2) - pinSize / 2, (height / 4) * (i + 1), pinSize, pinSize);
// }
// }
//
// @EditableProperty(name = "Body")
// public Color getBodyColor() {
// return bodyColor;
// }
//
// public void setBodyColor(Color bodyColor) {
// this.bodyColor = bodyColor;
// }
//
// @EditableProperty(name = "Base")
// public Color getBaseColor() {
// return baseColor;
// }
//
// public void setBaseColor(Color baseColor) {
// this.baseColor = baseColor;
// }
//
//// @EditableProperty(name = "Pin spacing")
//// public Size getPinSpacing() {
//// return pinSpacing;
//// }
////
//// public void setPinSpacing(Size pinSpacing) {
//// this.pinSpacing = pinSpacing;
//// updateControlPoints();
//// // Reset body shape;
//// body = null;
//// }
//
// @EditableProperty(name = "Border")
// public Color getBorderColor() {
// return borderColor;
// }
//
// public void setBorderColor(Color borderColor) {
// this.borderColor = borderColor;
// }
//
// @EditableProperty(name = "Label")
// public Color getLabelColor() {
// return labelColor;
// }
//
// public void setLabelColor(Color labelColor) {
// this.labelColor = labelColor;
// }
//
// @EditableProperty
// public Display getDisplay() {
// if (display == null) {
// display = Display.NAME;
// }
// return display;
// }
//
// public void setDisplay(Display display) {
// this.display = display;
// }
//
// public enum CanSections {
// _1, _2, _3, _4, _5;
//
// @Override
// public String toString() {
// return name().substring(1);
// }
// }
//}
+1 -1
View File
@@ -7,7 +7,7 @@
<property name="jar.dir" value="${build.dir}/jar" /> <property name="jar.dir" value="${build.dir}/jar" />
<property name="report.dir" value="${build.dir}/junitreport" /> <property name="report.dir" value="${build.dir}/junitreport" />
<property name="main.class" value="org.diylc.DIYLCStarter" /> <property name="main.class" value="org.diylc.DIYLCStarter" />
<property name="diylc.version" value="3.46.1" /> <property name="diylc.version" value="3.47.0" />
<property name="classes.dir" value="${build.dir}/temp/${ant.project.name}/classes" /> <property name="classes.dir" value="${build.dir}/temp/${ant.project.name}/classes" />
<property name="test.classes.dir" value="${build.dir}/temp/${ant.project.name}/test.classes" /> <property name="test.classes.dir" value="${build.dir}/temp/${ant.project.name}/test.classes" />
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -60,7 +60,7 @@ public class MeasureArrayEditor extends Container {
.getValue()); .getValue());
Double[] values = new Double[measure.length]; Double[] values = new Double[measure.length];
for (int i = 0; i < measure.length; i++) { for (int i = 0; i < measure.length; i++) {
values[i] = measure[i].getValue(); values[i] = measure[i] == null ? null : measure[i].getValue();
} }
valueField = new DoubleArrayTextField(measure == null ? null : values); valueField = new DoubleArrayTextField(measure == null ? null : values);
oldBg = valueField.getBackground(); oldBg = valueField.getBackground();
@@ -101,7 +101,7 @@ public class MeasureArrayEditor extends Container {
.getGenericSuperclass()).getActualTypeArguments()[0]; .getGenericSuperclass()).getActualTypeArguments()[0];
Method method = ((Class<?>) type).getMethod("values"); Method method = ((Class<?>) type).getMethod("values");
unitBox = new JComboBox((Object[]) method.invoke(null)); unitBox = new JComboBox((Object[]) method.invoke(null));
unitBox.setSelectedItem(measure == null || measure.length == 0 ? null unitBox.setSelectedItem(measure == null || measure.length == 0 || measure[0] == null ? null
: measure[0].getUnit()); : measure[0].getUnit());
unitBox.addActionListener(new ActionListener() { unitBox.addActionListener(new ActionListener() {