diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar
index b601d29f..ca3f5281 100644
Binary files a/diylc/diylc-library/lib/diylc-core.jar and b/diylc/diylc-library/lib/diylc-core.jar differ
diff --git a/diylc/diylc-library/src/org/diylc/components/passive/ElectrolyticCanCapacitor.java b/diylc/diylc-library/src/org/diylc/components/passive/ElectrolyticCanCapacitor.java
index 50513ef7..0031ecaf 100644
--- a/diylc/diylc-library/src/org/diylc/components/passive/ElectrolyticCanCapacitor.java
+++ b/diylc/diylc-library/src/org/diylc/components/passive/ElectrolyticCanCapacitor.java
@@ -1,362 +1,428 @@
-///*
-//
-// DIY Layout Creator (DIYLC).
-// Copyright (c) 2009-2018 held jointly by the individual authors.
-//
-// This file is part of DIYLC.
-//
-// DIYLC is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// DIYLC is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with DIYLC. If not, see .
-//
-//*/
-//package org.diylc.components.passive;
-//
-//import java.awt.AlphaComposite;
-//import java.awt.Color;
-//import java.awt.Composite;
-//import java.awt.FontMetrics;
-//import java.awt.Graphics2D;
-//import java.awt.Point;
-//import java.awt.Rectangle;
-//import java.awt.geom.Area;
-//import java.awt.geom.Ellipse2D;
-//import java.awt.geom.Rectangle2D;
-//
-//import org.diylc.appframework.miscutils.ConfigurationManager;
-//import org.diylc.common.Display;
-//import org.diylc.common.IPlugInPort;
-//import org.diylc.common.ObjectCache;
-//import org.diylc.common.Orientation;
-//import org.diylc.components.AbstractTransparentComponent;
-//import org.diylc.core.ComponentState;
-//import org.diylc.core.IDIYComponent;
-//import org.diylc.core.IDrawingObserver;
-//import org.diylc.core.Project;
-//import org.diylc.core.Theme;
-//import org.diylc.core.VisibilityPolicy;
-//import org.diylc.core.annotations.ComponentDescriptor;
-//import org.diylc.core.annotations.EditableProperty;
-//import org.diylc.core.annotations.KeywordPolicy;
-//import org.diylc.core.measures.Capacitance;
-//import org.diylc.core.measures.Size;
-//import org.diylc.core.measures.SizeUnit;
-//import org.diylc.utils.Constants;
-//
-////@ComponentDescriptor(name = "Electrolytic Capacitor (can)", author = "Branislav Stojkovic", category = "Passive",
-//// instanceNamePrefix = "C", description = "Vertical chassis-mount electrolytic capacitor similar to JJ",
-//// stretchable = false, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
-//public class ElectrolyticCanCapacitor extends AbstractTransparentComponent {
-//
-// private static final long serialVersionUID = 1L;
-//
-// public static Color BODY_COLOR = Color.lightGray;
-// public static Color BASE_COLOR = Color.gray;
-// public static Color BORDER_COLOR = BODY_COLOR.darker();
-// public static Color PIN_COLOR = Color.decode("#00B2EE");
-// public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
-// public static Color LABEL_COLOR = Color.black;
-// public static Size PIN_SIZE = new Size(0.08d, SizeUnit.in);
-//// public static Size PIN_SPACING = new Size(0.05d, SizeUnit.in);
-// public static Size BODY_DIAMETER = new Size(1d, SizeUnit.in);
-//
-// private Capacitance[] value = new Capacitance[4];
-// private org.diylc.core.measures.Voltage voltage = null;
-//
-// private Orientation orientation = Orientation.DEFAULT;
-// private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)};
-// transient private Area body;
-// private Color bodyColor = BODY_COLOR;
-// private Color baseColor = BASE_COLOR;
-// private Color borderColor = BORDER_COLOR;
-// private Color labelColor = LABEL_COLOR;
-// protected Display display = Display.NAME;
-//// private Size pinSpacing = PIN_SPACING;
-// private CanSections sections = CanSections._1;
-// private Size diameter = BODY_DIAMETER;
-//
-// public ElectrolyticCanCapacitor() {
-// super();
-// updateControlPoints();
+/*
+
+ DIY Layout Creator (DIYLC).
+ Copyright (c) 2009-2018 held jointly by the individual authors.
+
+ This file is part of DIYLC.
+
+ DIYLC is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ DIYLC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DIYLC. If not, see .
+
+*/
+package org.diylc.components.passive;
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.geom.Area;
+import java.awt.geom.Ellipse2D;
+import java.text.DecimalFormat;
+import java.text.Format;
+
+import org.diylc.appframework.miscutils.ConfigurationManager;
+import org.diylc.common.Display;
+import org.diylc.common.HorizontalAlignment;
+import org.diylc.common.IPlugInPort;
+import org.diylc.common.ObjectCache;
+import org.diylc.common.Orientation;
+import org.diylc.common.VerticalAlignment;
+import org.diylc.components.AbstractTransparentComponent;
+import org.diylc.core.ComponentState;
+import org.diylc.core.IDIYComponent;
+import org.diylc.core.IDrawingObserver;
+import org.diylc.core.Project;
+import org.diylc.core.Theme;
+import org.diylc.core.VisibilityPolicy;
+import org.diylc.core.annotations.ComponentDescriptor;
+import org.diylc.core.annotations.EditableProperty;
+import org.diylc.core.annotations.KeywordPolicy;
+import org.diylc.core.measures.Capacitance;
+import org.diylc.core.measures.Size;
+import org.diylc.core.measures.SizeUnit;
+import org.diylc.utils.Constants;
+
+@ComponentDescriptor(name = "Electrolytic Capacitor (can)", author = "Branislav Stojkovic", category = "Passive",
+ instanceNamePrefix = "C", description = "Multi-section vertically mounted electrolytic capacitor, similar to JJ, CE and others",
+ stretchable = false, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
+public class ElectrolyticCanCapacitor extends AbstractTransparentComponent {
+
+ private static final long serialVersionUID = 1L;
+
+ public static Color BODY_COLOR = Color.decode("#6B6DCE");
+ public static Color BASE_COLOR = Color.decode("#333333");
+ public static Color BORDER_COLOR = BODY_COLOR.darker();
+ public static Color PIN_COLOR = METAL_COLOR;
+ public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
+ public static Color LABEL_COLOR = Color.white;
+ public static Size PIN_SIZE = new Size(0.08d, SizeUnit.in);
+// public static Size PIN_SPACING = new Size(0.05d, SizeUnit.in);
+ public static Size BODY_DIAMETER = new Size(1d, SizeUnit.in);
+ private static double RELATIVE_DIAMETER = 0.6d;
+ private static final Format format = new DecimalFormat("0.#####");
+
+ private Capacitance[] value = new Capacitance[3];
+ private org.diylc.core.measures.Voltage voltage = null;
+
+ private Orientation orientation = Orientation.DEFAULT;
+ private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)};
+ transient private Area[] body;
+ private Color bodyColor = BODY_COLOR;
+ private Color baseColor = BASE_COLOR;
+ private Color borderColor = BORDER_COLOR;
+ private Color labelColor = LABEL_COLOR;
+ protected Display display = Display.NAME;
+// private Size pinSpacing = PIN_SPACING;
+ private Size diameter = BODY_DIAMETER;
+
+ 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 Capacitance[] getValue() {
-// 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;
+// public void setPinSpacing(Size pinSpacing) {
+// this.pinSpacing = pinSpacing;
// 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();
-//// 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);
-// }
-// }
-//}
+
+ @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;
+ }
+}
diff --git a/diylc/diylc-swing/build.xml b/diylc/diylc-swing/build.xml
index 0a3d1c0f..36f630da 100644
--- a/diylc/diylc-swing/build.xml
+++ b/diylc/diylc-swing/build.xml
@@ -7,7 +7,7 @@
-
+
diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar
index 21cf81da..ca3f5281 100644
Binary files a/diylc/diylc-swing/lib/diylc-core.jar and b/diylc/diylc-swing/lib/diylc-core.jar differ
diff --git a/diylc/diylc-swing/lib/swing-framework.jar b/diylc/diylc-swing/lib/swing-framework.jar
index a0518534..8e9d33b0 100644
Binary files a/diylc/diylc-swing/lib/swing-framework.jar and b/diylc/diylc-swing/lib/swing-framework.jar differ
diff --git a/diylc/diylc-swing/library/main.jar b/diylc/diylc-swing/library/main.jar
index 99a59bdd..4a6f83b6 100644
Binary files a/diylc/diylc-swing/library/main.jar and b/diylc/diylc-swing/library/main.jar differ
diff --git a/diylc/diylc-swing/src/org/diylc/swing/gui/editor/MeasureArrayEditor.java b/diylc/diylc-swing/src/org/diylc/swing/gui/editor/MeasureArrayEditor.java
index 67801400..f7ea5e87 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/gui/editor/MeasureArrayEditor.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/gui/editor/MeasureArrayEditor.java
@@ -60,7 +60,7 @@ public class MeasureArrayEditor extends Container {
.getValue());
Double[] values = new Double[measure.length];
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);
oldBg = valueField.getBackground();
@@ -101,7 +101,7 @@ public class MeasureArrayEditor extends Container {
.getGenericSuperclass()).getActualTypeArguments()[0];
Method method = ((Class>) type).getMethod("values");
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());
unitBox.addActionListener(new ActionListener() {