mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
Next (#663)
* flatpak file updated * add sha generator * fix mail * remove mail * Mini Toggle Switch - lugs do not get rotated when changing orientation; rotate from the context menu doesn't work * Added 'SVG Image' component * Fixed the issue with Perf Board, Vero Board and TriPad Board sometimes rendering an extra row with pads when there's no space for them * release 4.18 * Keep grouped components together when pasting * Added 'Dial Scale' component for designing device face-plates * dial scale updates * dial scale tweaks * release * release * release * release
This commit is contained in:
+32
-13
@@ -19,16 +19,16 @@
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.swing.plugins.edit;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
package org.diylc.clipboard;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
/**
|
||||
@@ -37,18 +37,29 @@ import org.diylc.core.IDIYComponent;
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class ComponentTransferable extends ArrayList<IDIYComponent<?>> implements Transferable {
|
||||
public class ComponentTransferable implements Transferable, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final DataFlavor listFlavor = new DataFlavor(ComponentTransferable.class, "application/diylc");
|
||||
public static final DataFlavor listFlavor = new DataFlavor(ComponentTransferable.class, "application/diylc");
|
||||
|
||||
private List<IDIYComponent<?>> components;
|
||||
private Set<Set<IDIYComponent<?>>> groups;
|
||||
|
||||
public ComponentTransferable() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ComponentTransferable(List<IDIYComponent<?>> components) {
|
||||
super();
|
||||
this.components = components;
|
||||
this.groups = null;
|
||||
}
|
||||
|
||||
public ComponentTransferable(Collection<IDIYComponent<?>> selectedComponents) {
|
||||
super(selectedComponents);
|
||||
public ComponentTransferable(List<IDIYComponent<?>> components, Set<Set<IDIYComponent<?>>> groups) {
|
||||
super();
|
||||
this.components = components;
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,5 +78,13 @@ public class ComponentTransferable extends ArrayList<IDIYComponent<?>> implement
|
||||
@Override
|
||||
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
||||
return flavor.equals(listFlavor);
|
||||
}
|
||||
|
||||
public List<IDIYComponent<?>> getComponents() {
|
||||
return components;
|
||||
}
|
||||
|
||||
public Set<Set<IDIYComponent<?>>> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
*
|
||||
* 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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.diylc.clipboard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public class ComponentTransferableFactory {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(ComponentTransferableFactory.class);
|
||||
|
||||
private static ComponentTransferableFactory instance;
|
||||
|
||||
public static ComponentTransferableFactory getInstance() {
|
||||
if (instance == null)
|
||||
instance = new ComponentTransferableFactory();
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ComponentTransferable build(Collection<IDIYComponent<?>> selectedComponents, Set<Set<IDIYComponent<?>>> groups) {
|
||||
Set<IDIYComponent<?>> originalComponentSet = new HashSet<IDIYComponent<?>>(selectedComponents);
|
||||
List<IDIYComponent<?>> originalComponents = new ArrayList<IDIYComponent<?>>(selectedComponents);
|
||||
List<IDIYComponent<?>> clonedComponents = originalComponents.stream(
|
||||
).map(x -> {
|
||||
try {
|
||||
return x.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
Set<Set<IDIYComponent<?>>> clonedGroups = new HashSet<Set<IDIYComponent<?>>>();
|
||||
|
||||
for (Set<IDIYComponent<?>> group : groups) {
|
||||
if (group.isEmpty())
|
||||
continue;
|
||||
|
||||
if (originalComponentSet.contains(group.iterator().next())) {
|
||||
Set<IDIYComponent<?>> clonedGroup = new HashSet<IDIYComponent<?>>();
|
||||
clonedGroups.add(clonedGroup);
|
||||
for (int i = 0; i < originalComponents.size(); i++) {
|
||||
if (group.contains(originalComponents.get(i))) {
|
||||
clonedGroup.add(clonedComponents.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ComponentTransferable(clonedComponents, clonedGroups);
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import java.awt.Point;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -37,6 +36,7 @@ import org.diylc.appframework.simplemq.IMessageListener;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.appframework.update.Version;
|
||||
import org.diylc.appframework.update.VersionNumber;
|
||||
import org.diylc.clipboard.ComponentTransferable;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Template;
|
||||
@@ -242,11 +242,11 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
/**
|
||||
* Adds a list of components to the project.
|
||||
*
|
||||
* @param components
|
||||
* @param componentTransferable
|
||||
* @param autoGroup
|
||||
* @param assignNewNames
|
||||
*/
|
||||
void pasteComponents(Collection<IDIYComponent<?>> components, boolean autoGroup, boolean assignNewNames);
|
||||
void pasteComponents(ComponentTransferable componentTransferable, boolean autoGroup, boolean assignNewNames);
|
||||
|
||||
/**
|
||||
* Duplicates selected components and places them nearby.
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ObjectCache {
|
||||
}
|
||||
|
||||
public Stroke fetchStroke(float width, float[] dash, float phase, int cap) {
|
||||
String key = width + "|" + Arrays.toString(dash) + "|" + phase + "|" + phase;
|
||||
String key = width + "|" + Arrays.toString(dash) + "|" + phase + "|" + cap;
|
||||
if (dashStrokeMap.containsKey(key)) {
|
||||
return dashStrokeMap.get(key);
|
||||
}
|
||||
@@ -73,4 +73,14 @@ public class ObjectCache {
|
||||
dashStrokeMap.put(key, stroke);
|
||||
return stroke;
|
||||
}
|
||||
|
||||
public Stroke fetchStroke(float width, int cap) {
|
||||
String key = width + "|" + cap;
|
||||
if (dashStrokeMap.containsKey(key)) {
|
||||
return dashStrokeMap.get(key);
|
||||
}
|
||||
Stroke stroke = new BasicStroke(width, cap, BasicStroke.JOIN_ROUND);
|
||||
dashStrokeMap.put(key, stroke);
|
||||
return stroke;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.awt.geom.Point2D;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -34,6 +33,7 @@ import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.clipboard.ComponentTransferable;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.Orientation;
|
||||
@@ -142,7 +142,7 @@ public class InstantiationManager {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void pasteComponents(Collection<IDIYComponent<?>> components, Point2D scaledPoint, boolean snapToGrid,
|
||||
public void pasteComponents(ComponentTransferable componentTransferable, Point2D scaledPoint, boolean snapToGrid,
|
||||
Size gridSpacing, boolean autoGroup, Project currentProject, boolean assignNewNames) {
|
||||
// Adjust location of components so they are centered under the mouse
|
||||
// cursor
|
||||
@@ -156,6 +156,8 @@ public class InstantiationManager {
|
||||
existingNames.add(c.getName());
|
||||
|
||||
List<IDIYComponent<?>> allComponents = new ArrayList<IDIYComponent<?>>(currentProject.getComponents());
|
||||
|
||||
List<IDIYComponent<?>> components = componentTransferable.getComponents();
|
||||
|
||||
for (IDIYComponent<?> component : components) {
|
||||
// assign a new name if it already exists in the project
|
||||
@@ -210,7 +212,12 @@ public class InstantiationManager {
|
||||
CalcUtils.snapPointToGrid(scaledPoint, gridSpacing);
|
||||
}
|
||||
// Update the location according to mouse location
|
||||
updateSingleClick(scaledPoint, snapToGrid, gridSpacing);
|
||||
updateSingleClick(scaledPoint, snapToGrid, gridSpacing);
|
||||
|
||||
// copy group information if available
|
||||
if (componentTransferable.getGroups() != null) {
|
||||
currentProject.getGroups().addAll(componentTransferable.getGroups());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,6 +57,7 @@ import org.diylc.appframework.miscutils.Utils;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.appframework.update.Version;
|
||||
import org.diylc.appframework.update.VersionNumber;
|
||||
import org.diylc.clipboard.ComponentTransferable;
|
||||
import org.diylc.common.BuildingBlockPackage;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.DrawOption;
|
||||
@@ -1699,9 +1700,9 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pasteComponents(Collection<IDIYComponent<?>> components, boolean autoGroup, boolean assignNewNames) {
|
||||
LOG.info(String.format("pasteComponents(%s, %s, %s)", components, autoGroup, assignNewNames));
|
||||
instantiationManager.pasteComponents(components, this.previousScaledPoint, isSnapToGrid(),
|
||||
public void pasteComponents(ComponentTransferable componentTransferable, boolean autoGroup, boolean assignNewNames) {
|
||||
LOG.info(String.format("pasteComponents(%s, %s, %s)", componentTransferable, autoGroup, assignNewNames));
|
||||
instantiationManager.pasteComponents(componentTransferable, this.previousScaledPoint, isSnapToGrid(),
|
||||
currentProject.getGridSpacing(), autoGroup, this.currentProject, assignNewNames);
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
messageDispatcher.dispatchMessage(EventType.SLOT_CHANGED, instantiationManager.getComponentTypeSlot(),
|
||||
@@ -2975,7 +2976,7 @@ public class Presenter implements IPlugInPort {
|
||||
LOG.error("Could not clone component: " + c);
|
||||
}
|
||||
// paste them to the project
|
||||
pasteComponents(clones, true, true);
|
||||
pasteComponents(new ComponentTransferable(clones), true, true);
|
||||
} else
|
||||
throw new InvalidBlockException();
|
||||
}
|
||||
|
||||
@@ -3569,5 +3569,25 @@
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>4</major>
|
||||
<minor>19</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2021-08-21 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Dial Scale' component for designing device face-plates</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Keep grouped components together when pasting</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
</a>
|
||||
</java.util.Arrays_-ArrayList>
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
*
|
||||
* 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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.diylc.components.chassis;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.awt.StringUtils;
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.components.transform.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
import com.sun.prism.BasicStroke;
|
||||
|
||||
@ComponentDescriptor(name = "Dial Scale", author = "Branislav Stojkovic", category = "Misc",
|
||||
instanceNamePrefix = "DS", description = "Control panel dial scale", zOrder = IDIYComponent.CHASSIS + 0.1,
|
||||
bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
|
||||
public class DialScale extends AbstractComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Size DIAMETER = new Size(1d, SizeUnit.in);
|
||||
public static Size MARKER_SIZE = new Size(0.1d, SizeUnit.in);
|
||||
public static Size TICK_WIDTH = new Size(0.5d, SizeUnit.mm);
|
||||
public static Color COLOR = Color.black;
|
||||
|
||||
private Size diameter = DIAMETER;
|
||||
private Size markerSize = MARKER_SIZE;
|
||||
private Size tickWidth = TICK_WIDTH;
|
||||
private Color color = COLOR;
|
||||
private Point2D.Double point = new Point2D.Double(0, 0);
|
||||
private String value = "";
|
||||
private DialScaleType type = DialScaleType.Ticks;
|
||||
private Font font = LABEL_FONT;
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
if (checkPointsClipped(g2d.getClip())) {
|
||||
return;
|
||||
}
|
||||
|
||||
double x0 = point.getX();
|
||||
double y0 = point.getY();
|
||||
|
||||
double r = diameter.convertToPixels() / 2;
|
||||
double marker = markerSize.convertToPixels();
|
||||
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||
|
||||
g2d.drawLine((int)(x0 - r / 6), (int)y0, (int)(x0 + r / 6), (int)y0);
|
||||
g2d.drawLine((int)x0, (int)(y0 - r / 6), (int)x0, (int)(y0 + r / 6));
|
||||
|
||||
|
||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR : color);
|
||||
g2d.setFont(font.deriveFont((float)marker));
|
||||
|
||||
Stroke tickStroke = ObjectCache.getInstance().fetchStroke((float)tickWidth.convertToPixels(), BasicStroke.CAP_BUTT);
|
||||
|
||||
double x1;
|
||||
double y1;
|
||||
|
||||
int segments;
|
||||
if (type == DialScaleType.Numeric_1_10) {
|
||||
segments = 10;
|
||||
} else if (type == DialScaleType.Numeric_1_12) {
|
||||
segments = 12;
|
||||
} else {
|
||||
segments = 11;
|
||||
}
|
||||
|
||||
double shift = (5 * Math.PI / 3) / (segments - 1);
|
||||
|
||||
double alpha = 4 * Math.PI / 6;
|
||||
|
||||
for (int i = 0; i < segments; i++) {
|
||||
double x = x0 + Math.cos(alpha) * r;
|
||||
double y = y0 + Math.sin(alpha) * r;
|
||||
|
||||
switch (type) {
|
||||
case Dots:
|
||||
g2d.fillOval((int)(x - marker / 2), (int)(y - marker / 2), (int)marker, (int)marker);
|
||||
break;
|
||||
case Numeric_0_10:
|
||||
StringUtils.drawCenteredText(g2d, Integer.toString(i), x, y, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
break;
|
||||
case Numeric_1_12:
|
||||
case Numeric_1_11:
|
||||
case Numeric_1_10:
|
||||
StringUtils.drawCenteredText(g2d, Integer.toString(i + 1), x, y, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
break;
|
||||
case Ticks:
|
||||
x1 = x0 + Math.cos(alpha) * (r - marker);
|
||||
y1 = y0 + Math.sin(alpha) * (r - marker);
|
||||
g2d.setStroke(tickStroke);
|
||||
g2d.drawLine((int)x, (int)y, (int)x1, (int)y1);
|
||||
break;
|
||||
case Numeric_Even:
|
||||
if (i % 2 == 0) {
|
||||
StringUtils.drawCenteredText(g2d, Integer.toString(i), x, y, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
}
|
||||
break;
|
||||
case Numeric_Even_Ticks:
|
||||
if (i % 2 == 0) {
|
||||
StringUtils.drawCenteredText(g2d, Integer.toString(i), x, y, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
} else {
|
||||
x1 = x0 + Math.cos(alpha) * (r - marker);
|
||||
y1 = y0 + Math.sin(alpha) * (r - marker);
|
||||
g2d.setStroke(tickStroke);
|
||||
g2d.drawLine((int)x, (int)y, (int)x1, (int)y1);
|
||||
}
|
||||
break;
|
||||
case Dots_Gradual: {
|
||||
double currentMarker = marker * (i + 5) / 15;
|
||||
g2d.fillOval((int)(x - currentMarker / 2), (int)(y - currentMarker / 2), (int)currentMarker, (int)currentMarker);
|
||||
}
|
||||
}
|
||||
|
||||
alpha += shift;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
double r = getClosestOdd(width * 2d / 3) - 2;
|
||||
double mark = 4d * width / 32;
|
||||
double alpha = 5 * Math.PI / 6;
|
||||
double x0 = width * 2d / 3;
|
||||
double y0 = height * 2d / 3;
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||
g2d.setColor(Color.black);
|
||||
for (int i = 0; i < 7; i++) {
|
||||
g2d.drawLine((int)(x0 + Math.cos(alpha) * r), (int)(y0 + Math.sin(alpha) * r),
|
||||
(int)(x0 + Math.cos(alpha) * (r - mark)), (int)(y0 + Math.sin(alpha) * (r - mark)));
|
||||
alpha += Math.PI / 6;
|
||||
}
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Size getDiameter() {
|
||||
return diameter;
|
||||
}
|
||||
|
||||
public void setDiameter(Size diameter) {
|
||||
this.diameter = diameter;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Marker Size")
|
||||
public Size getMarkerSize() {
|
||||
return markerSize;
|
||||
}
|
||||
|
||||
public void setMarkerSize(Size markerSize) {
|
||||
this.markerSize = markerSize;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Tick Width")
|
||||
public Size getTickWidth() {
|
||||
return tickWidth;
|
||||
}
|
||||
|
||||
public void setTickWidth(Size tickWidth) {
|
||||
this.tickWidth = tickWidth;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Font getFont() {
|
||||
return font;
|
||||
}
|
||||
|
||||
public void setFont(Font font) {
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public DialScaleType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(DialScaleType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return super.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.NEVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2D getControlPoint(int index) {
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point2D point, int index) {
|
||||
this.point.setLocation(point);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Color")
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
@EditableProperty
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
double size = getDiameter().convertToPixels();
|
||||
return new Rectangle2D.Double(point.getX() - size, point.getY() - size, size * 2, size * 2);
|
||||
}
|
||||
|
||||
public enum DialScaleType {
|
||||
Ticks("Ticks"), Dots("Dots (Uniform)"), Dots_Gradual("Dots (Gradual)"), Numeric_0_10("Numeric (0-10)"), Numeric_1_11("Numeric (1-11)"),
|
||||
Numeric_1_10("Numeric (1-10)"), Numeric_1_12("Numeric (1-12)"), Numeric_Even("Numeric (Even, No Ticks)"), Numeric_Even_Ticks("Numeric (Even, With Ticks)");
|
||||
|
||||
private String label;
|
||||
|
||||
private DialScaleType(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
<property name="jar.dir" value="${build.dir}/jar" />
|
||||
<property name="report.dir" value="${build.dir}/junitreport" />
|
||||
<property name="main.class" value="org.diylc.DIYLCStarter" />
|
||||
<property name="diylc.version" value="4.18.0" />
|
||||
<property name="diylc.version" value="4.19.0" />
|
||||
|
||||
<property name="osx.jre8.path" value="jre\osx\jdk8u275-b01-jre\Contents\Home\" />
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -31,7 +31,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
@@ -52,6 +51,8 @@ import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.IConfigListener;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.clipboard.ComponentTransferable;
|
||||
import org.diylc.clipboard.ComponentTransferableFactory;
|
||||
import org.diylc.common.BuildingBlockPackage;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
@@ -84,7 +85,6 @@ import org.diylc.swing.gui.DialogFactory;
|
||||
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
||||
import org.diylc.swing.images.IconLoader;
|
||||
import org.diylc.swing.plugins.config.ConfigPlugin;
|
||||
import org.diylc.swing.plugins.edit.ComponentTransferable;
|
||||
import org.diylc.swing.plugins.edit.FindDialog;
|
||||
import org.diylc.swing.plugins.file.BomDialog;
|
||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||
@@ -463,7 +463,8 @@ public class ActionFactory {
|
||||
presenter.loadProjectFromFile(file.getAbsolutePath());
|
||||
// Grab all components and paste them into the main
|
||||
// presenter
|
||||
plugInPort.pasteComponents(presenter.getCurrentProject().getComponents(), false, false);
|
||||
plugInPort.pasteComponents(ComponentTransferableFactory.getInstance()
|
||||
.build(presenter.getCurrentProject().getComponents(), presenter.getCurrentProject().getGroups()), false, false);
|
||||
// Cleanup components in the temp presenter, don't need
|
||||
// them anymore
|
||||
presenter.selectAll(0);
|
||||
@@ -565,7 +566,7 @@ public class ActionFactory {
|
||||
List<IDIYComponent<?>> components = parser.generateComponents(parsedComponents, outputWarnings);
|
||||
if (!outputWarnings.isEmpty())
|
||||
LOG.warn("Component creation produced warnings:\n" + String.join("\n", outputWarnings));
|
||||
plugInPort.pasteComponents(components, false, false);
|
||||
plugInPort.pasteComponents(new ComponentTransferable(components), false, false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
swingUI.showMessage("Could not import netlist file: " + e.getMessage(), "Error",
|
||||
@@ -1245,7 +1246,7 @@ public class ActionFactory {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Cut triggered");
|
||||
clipboard.setContents(
|
||||
new ComponentTransferable(cloneComponents(plugInPort.getSelectedComponents())),
|
||||
ComponentTransferableFactory.getInstance().build(plugInPort.getSelectedComponents(), plugInPort.getCurrentProject().getGroups()),
|
||||
clipboardOwner);
|
||||
plugInPort.deleteSelectedComponents();
|
||||
}
|
||||
@@ -1268,14 +1269,13 @@ public class ActionFactory {
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Paste.getIcon());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Paste triggered");
|
||||
try {
|
||||
List<IDIYComponent<?>> components =
|
||||
(List<IDIYComponent<?>>) clipboard.getData(ComponentTransferable.listFlavor);
|
||||
plugInPort.pasteComponents(cloneComponents(components), false,
|
||||
ComponentTransferable componentTransferable =
|
||||
(ComponentTransferable) clipboard.getData(ComponentTransferable.listFlavor);
|
||||
plugInPort.pasteComponents(componentTransferable, false,
|
||||
ConfigurationManager.getInstance().readBoolean(Presenter.RENUMBER_ON_PASTE_KEY, true));
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Coule not paste.", ex);
|
||||
@@ -1306,7 +1306,7 @@ public class ActionFactory {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Copy triggered");
|
||||
clipboard.setContents(
|
||||
new ComponentTransferable(cloneComponents(plugInPort.getSelectedComponents())),
|
||||
ComponentTransferableFactory.getInstance().build(plugInPort.getSelectedComponents(), plugInPort.getCurrentProject().getGroups()),
|
||||
clipboardOwner);
|
||||
}
|
||||
}
|
||||
@@ -1338,18 +1338,6 @@ public class ActionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<IDIYComponent<?>> cloneComponents(Collection<IDIYComponent<?>> components) {
|
||||
List<IDIYComponent<?>> result = new ArrayList<IDIYComponent<?>>(components.size());
|
||||
for (IDIYComponent<?> component : components) {
|
||||
try {
|
||||
result.add(component.clone());
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static class SelectAllAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.IConfigListener;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.Utils;
|
||||
import org.diylc.clipboard.ComponentTransferable;
|
||||
import org.diylc.common.BadPositionException;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
@@ -68,7 +69,6 @@ import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.swing.gui.TranslatedMenu;
|
||||
import org.diylc.swing.gui.TranslatedPopupMenu;
|
||||
import org.diylc.swing.images.IconLoader;
|
||||
import org.diylc.swing.plugins.edit.ComponentTransferable;
|
||||
import org.diylc.swing.plugins.file.ProjectDrawingProvider;
|
||||
import org.diylc.swingframework.ruler.IRulerListener;
|
||||
import org.diylc.swingframework.ruler.Ruler.InchSubdivision;
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.util.EnumSet;
|
||||
|
||||
import org.diylc.appframework.undo.IUndoListener;
|
||||
import org.diylc.appframework.undo.UndoHandler;
|
||||
import org.diylc.clipboard.ComponentTransferable;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.common.IPlugIn;
|
||||
|
||||
Reference in New Issue
Block a user