mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
don't group pasted components
fix: click twice on a building block makes components jump to top-left various minor updates
This commit is contained in:
@@ -202,9 +202,10 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
|||||||
/**
|
/**
|
||||||
* Adds a list of components to the project.
|
* Adds a list of components to the project.
|
||||||
*
|
*
|
||||||
* @param components
|
* @param components
|
||||||
|
* @param autoGroup
|
||||||
*/
|
*/
|
||||||
void pasteComponents(Collection<IDIYComponent<?>> components);
|
void pasteComponents(Collection<IDIYComponent<?>> components, boolean autoGroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicates selected components and places them nearby.
|
* Duplicates selected components and places them nearby.
|
||||||
|
|||||||
@@ -117,21 +117,7 @@ public class ComponentProcessor {
|
|||||||
keywordTag = annotation.keywordTag();
|
keywordTag = annotation.keywordTag();
|
||||||
continuity = annotation.continuity();
|
continuity = annotation.continuity();
|
||||||
} else { // default
|
} else { // default
|
||||||
name = clazz.getSimpleName();
|
return null;
|
||||||
description = "";
|
|
||||||
creationMethod = CreationMethod.SINGLE_CLICK;
|
|
||||||
category = "Uncategorized";
|
|
||||||
namePrefix = "Unknown";
|
|
||||||
author = "Unknown";
|
|
||||||
zOrder = IDIYComponent.COMPONENT;
|
|
||||||
flexibleZOrder = false;
|
|
||||||
stretchable = true;
|
|
||||||
bomPolicy = BomPolicy.SHOW_ALL_NAMES;
|
|
||||||
autoEdit = true;
|
|
||||||
transformer = null;
|
|
||||||
keywordPolicy = KeywordPolicy.NEVER_SHOW;
|
|
||||||
keywordTag = null;
|
|
||||||
continuity = false;
|
|
||||||
}
|
}
|
||||||
icon = null;
|
icon = null;
|
||||||
// Draw component icon.
|
// Draw component icon.
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import java.util.Collection;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.common.ComponentType;
|
import org.diylc.common.ComponentType;
|
||||||
@@ -61,9 +61,12 @@ public class InstantiationManager {
|
|||||||
private Point firstControlPoint;
|
private Point firstControlPoint;
|
||||||
private Point potentialControlPoint;
|
private Point potentialControlPoint;
|
||||||
|
|
||||||
private static final ComponentType clipboardType = new ComponentType("Clipboard contents",
|
public static final ComponentType clipboardType = new ComponentType("Clipboard contents",
|
||||||
"Components from the clipboard", CreationMethod.SINGLE_CLICK, "Multi", "", "", null, null, 0, false, false, null,
|
"Components from the clipboard", CreationMethod.SINGLE_CLICK, "Multi", "", "", null, null, 0, false, false, null,
|
||||||
false, null, KeywordPolicy.NEVER_SHOW, null, false);
|
false, null, KeywordPolicy.NEVER_SHOW, null, false);
|
||||||
|
public static final ComponentType blockType = new ComponentType("Building block",
|
||||||
|
"Components from the building block", CreationMethod.SINGLE_CLICK, "Multi", "", "", null, null, 0, false, false, null,
|
||||||
|
false, null, KeywordPolicy.NEVER_SHOW, null, false);
|
||||||
|
|
||||||
public InstantiationManager() {}
|
public InstantiationManager() {}
|
||||||
|
|
||||||
@@ -85,7 +88,11 @@ public class InstantiationManager {
|
|||||||
|
|
||||||
public Point getPotentialControlPoint() {
|
public Point getPotentialControlPoint() {
|
||||||
return potentialControlPoint;
|
return potentialControlPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPotentialControlPoint(Point potentialControlPoint) {
|
||||||
|
this.potentialControlPoint = potentialControlPoint;
|
||||||
|
}
|
||||||
|
|
||||||
public void setComponentTypeSlot(ComponentType componentTypeSlot, Template template, Project currentProject)
|
public void setComponentTypeSlot(ComponentType componentTypeSlot, Template template, Project currentProject)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
@@ -133,7 +140,7 @@ public class InstantiationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void pasteComponents(Collection<IDIYComponent<?>> components, Point scaledPoint, boolean snapToGrid,
|
public void pasteComponents(Collection<IDIYComponent<?>> components, Point scaledPoint, boolean snapToGrid,
|
||||||
Size gridSpacing) {
|
Size gridSpacing, boolean autoGroup) {
|
||||||
// Adjust location of components so they are centered under the mouse
|
// Adjust location of components so they are centered under the mouse
|
||||||
// cursor
|
// cursor
|
||||||
int minX = Integer.MAX_VALUE;
|
int minX = Integer.MAX_VALUE;
|
||||||
@@ -176,7 +183,7 @@ public class InstantiationManager {
|
|||||||
|
|
||||||
// Update the component type slot so the app knows that something's
|
// Update the component type slot so the app knows that something's
|
||||||
// being instantiated.
|
// being instantiated.
|
||||||
this.componentTypeSlot = clipboardType;
|
this.componentTypeSlot = autoGroup ? blockType : clipboardType;
|
||||||
|
|
||||||
if (snapToGrid) {
|
if (snapToGrid) {
|
||||||
scaledPoint = new Point(scaledPoint);
|
scaledPoint = new Point(scaledPoint);
|
||||||
|
|||||||
@@ -356,6 +356,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
if (!Modifier.isAbstract(clazz.getModifiers()) && IDIYComponent.class.isAssignableFrom(clazz)) {
|
if (!Modifier.isAbstract(clazz.getModifiers()) && IDIYComponent.class.isAssignableFrom(clazz)) {
|
||||||
ComponentType componentType =
|
ComponentType componentType =
|
||||||
ComponentProcessor.getInstance().extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) clazz);
|
ComponentProcessor.getInstance().extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) clazz);
|
||||||
|
if (componentType == null)
|
||||||
|
continue;
|
||||||
List<ComponentType> nestedList;
|
List<ComponentType> nestedList;
|
||||||
if (componentTypes.containsKey(componentType.getCategory())) {
|
if (componentTypes.containsKey(componentType.getCategory())) {
|
||||||
nestedList = componentTypes.get(componentType.getCategory());
|
nestedList = componentTypes.get(componentType.getCategory());
|
||||||
@@ -517,8 +519,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
addComponent(component, true);
|
addComponent(component, true);
|
||||||
newSelection.add(component);
|
newSelection.add(component);
|
||||||
}
|
}
|
||||||
// group components if there's more than one, e.g. building blocks
|
// group components if there's more than one, e.g. building blocks, but not clipboard contents
|
||||||
if (componentSlot.size() > 1) {
|
if (componentSlot.size() > 1 && !componentTypeSlot.getName().toLowerCase().contains("clipboard")) {
|
||||||
this.currentProject.getGroups().add(new HashSet<IDIYComponent<?>>(componentSlot));
|
this.currentProject.getGroups().add(new HashSet<IDIYComponent<?>>(componentSlot));
|
||||||
}
|
}
|
||||||
// Select the new component
|
// Select the new component
|
||||||
@@ -1452,10 +1454,10 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pasteComponents(Collection<IDIYComponent<?>> components) {
|
public void pasteComponents(Collection<IDIYComponent<?>> components, boolean autoGroup) {
|
||||||
LOG.info(String.format("pasteComponents(%s)", components));
|
LOG.info(String.format("pasteComponents(%s, %s)", components, autoGroup));
|
||||||
instantiationManager.pasteComponents(components, this.previousScaledPoint, isSnapToGrid(),
|
instantiationManager.pasteComponents(components, this.previousScaledPoint, isSnapToGrid(),
|
||||||
currentProject.getGridSpacing());
|
currentProject.getGridSpacing(), autoGroup);
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
messageDispatcher.dispatchMessage(EventType.SLOT_CHANGED, instantiationManager.getComponentTypeSlot(),
|
messageDispatcher.dispatchMessage(EventType.SLOT_CHANGED, instantiationManager.getComponentTypeSlot(),
|
||||||
instantiationManager.getFirstControlPoint());
|
instantiationManager.getFirstControlPoint());
|
||||||
@@ -2327,6 +2329,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
Collection<IDIYComponent<?>> components = blocks.get(blockName);
|
Collection<IDIYComponent<?>> components = blocks.get(blockName);
|
||||||
if (components == null)
|
if (components == null)
|
||||||
throw new InvalidBlockException();
|
throw new InvalidBlockException();
|
||||||
|
// clear potential control point every time!
|
||||||
|
instantiationManager.setPotentialControlPoint(null);
|
||||||
// clone components
|
// clone components
|
||||||
List<IDIYComponent<?>> clones = new ArrayList<IDIYComponent<?>>();
|
List<IDIYComponent<?>> clones = new ArrayList<IDIYComponent<?>>();
|
||||||
List<IDIYComponent<?>> testComponents = new ArrayList<IDIYComponent<?>>(currentProject.getComponents());
|
List<IDIYComponent<?>> testComponents = new ArrayList<IDIYComponent<?>>(currentProject.getComponents());
|
||||||
@@ -2341,7 +2345,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
LOG.error("Could not clone component: " + c);
|
LOG.error("Could not clone component: " + c);
|
||||||
}
|
}
|
||||||
// paste them to the project
|
// paste them to the project
|
||||||
pasteComponents(clones);
|
pasteComponents(clones, true);
|
||||||
} else
|
} else
|
||||||
throw new InvalidBlockException();
|
throw new InvalidBlockException();
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -38,7 +38,7 @@ 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;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Chassis Panel", author = "Branislav Stojkovic", category = "Electromechanical",
|
@ComponentDescriptor(name = "Chassis Panel", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||||
instanceNamePrefix = "CP", description = "One side of a chassis, with or withouth rounded edges",
|
instanceNamePrefix = "CP", description = "One side of a chassis, with or withouth rounded edges",
|
||||||
zOrder = IDIYComponent.CHASSIS, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
|
zOrder = IDIYComponent.CHASSIS, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
|
||||||
transformer = SimpleComponentTransformer.class)
|
transformer = SimpleComponentTransformer.class)
|
||||||
|
|||||||
@@ -1,75 +1,75 @@
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
|
* DIY Layout Creator (DIYLC). 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 it under the terms of the GNU
|
* 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
|
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* 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
|
* 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
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
* Public License for more details.
|
* Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||||
* <http://www.gnu.org/licenses/>.
|
* <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.diylc.components.chassis;
|
package org.diylc.components.chassis;
|
||||||
|
|
||||||
import java.awt.AlphaComposite;
|
import java.awt.AlphaComposite;
|
||||||
import java.awt.Composite;
|
import java.awt.Composite;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.SimpleComponentTransformer;
|
import org.diylc.common.SimpleComponentTransformer;
|
||||||
import org.diylc.components.shapes.AbstractShape;
|
import org.diylc.components.shapes.AbstractShape;
|
||||||
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.annotations.BomPolicy;
|
import org.diylc.core.annotations.BomPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Elliptical Cutout", author = "Branislav Stojkovic", category = "Electromechanical",
|
@ComponentDescriptor(name = "Elliptical Cutout", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||||
instanceNamePrefix = "ELC", description = "Elliptical chassis cutout", zOrder = IDIYComponent.CHASSIS + 0.1,
|
instanceNamePrefix = "ELC", description = "Elliptical chassis cutout", zOrder = IDIYComponent.CHASSIS + 0.1,
|
||||||
bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
|
bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
|
||||||
public class EllipticalCutout extends AbstractShape {
|
public class EllipticalCutout extends AbstractShape {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public EllipticalCutout() {
|
public EllipticalCutout() {
|
||||||
this.borderColor = LIGHT_METAL_COLOR.darker();
|
this.borderColor = LIGHT_METAL_COLOR.darker();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
||||||
|
|
||||||
if (componentState != ComponentState.DRAGGING) {
|
if (componentState != ComponentState.DRAGGING) {
|
||||||
Composite oldComposite = g2d.getComposite();
|
Composite oldComposite = g2d.getComposite();
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
}
|
}
|
||||||
g2d.setColor(color);
|
g2d.setColor(color);
|
||||||
g2d.fillOval(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
|
g2d.fillOval(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
}
|
}
|
||||||
// Do not track any changes that follow because the whole oval has been
|
// Do not track any changes that follow because the whole oval has been
|
||||||
// tracked so far.
|
// tracked so far.
|
||||||
drawingObserver.stopTracking();
|
drawingObserver.stopTracking();
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
: borderColor);
|
: borderColor);
|
||||||
g2d.drawOval(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
|
g2d.drawOval(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
int factor = 32 / width;
|
int factor = 32 / width;
|
||||||
g2d.setColor(COLOR);
|
g2d.setColor(COLOR);
|
||||||
g2d.fillOval(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
g2d.fillOval(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||||
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
||||||
g2d.drawOval(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
g2d.drawOval(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,125 +1,125 @@
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
|
* DIY Layout Creator (DIYLC). 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 it under the terms of the GNU
|
* 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
|
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* 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
|
* 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
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
* Public License for more details.
|
* Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||||
* <http://www.gnu.org/licenses/>.
|
* <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.diylc.components.chassis;
|
package org.diylc.components.chassis;
|
||||||
|
|
||||||
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.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.SimpleComponentTransformer;
|
import org.diylc.common.SimpleComponentTransformer;
|
||||||
import org.diylc.components.shapes.AbstractShape;
|
import org.diylc.components.shapes.AbstractShape;
|
||||||
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.annotations.BomPolicy;
|
import org.diylc.core.annotations.BomPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Polygonal Cutout", author = "Branislav Stojkovic", category = "Electromechanical",
|
@ComponentDescriptor(name = "Polygonal Cutout", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||||
instanceNamePrefix = "POLYC", description = "Polygonal chassis cutout", zOrder = IDIYComponent.CHASSIS + 0.1,
|
instanceNamePrefix = "POLYC", description = "Polygonal chassis cutout", zOrder = IDIYComponent.CHASSIS + 0.1,
|
||||||
bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
|
bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
|
||||||
public class PolygonalCutout extends AbstractShape {
|
public class PolygonalCutout extends AbstractShape {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
protected PointCount pointCount = PointCount._4;
|
protected PointCount pointCount = PointCount._4;
|
||||||
|
|
||||||
public PolygonalCutout() {
|
public PolygonalCutout() {
|
||||||
super();
|
super();
|
||||||
this.borderColor = LIGHT_METAL_COLOR.darker();
|
this.borderColor = LIGHT_METAL_COLOR.darker();
|
||||||
this.controlPoints =
|
this.controlPoints =
|
||||||
new Point[] {new Point(0, 0), new Point(0, (int) DEFAULT_HEIGHT.convertToPixels()),
|
new Point[] {new Point(0, 0), new Point(0, (int) DEFAULT_HEIGHT.convertToPixels()),
|
||||||
new Point((int) DEFAULT_WIDTH.convertToPixels(), (int) DEFAULT_HEIGHT.convertToPixels()),
|
new Point((int) DEFAULT_WIDTH.convertToPixels(), (int) DEFAULT_HEIGHT.convertToPixels()),
|
||||||
new Point((int) DEFAULT_WIDTH.convertToPixels(), 0)};
|
new Point((int) DEFAULT_WIDTH.convertToPixels(), 0)};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
||||||
g2d.setColor(color);
|
g2d.setColor(color);
|
||||||
int[] xPoints = new int[controlPoints.length];
|
int[] xPoints = new int[controlPoints.length];
|
||||||
int[] yPoints = new int[controlPoints.length];
|
int[] yPoints = new int[controlPoints.length];
|
||||||
for (int i = 0; i < controlPoints.length; i++) {
|
for (int i = 0; i < controlPoints.length; i++) {
|
||||||
xPoints[i] = controlPoints[i].x;
|
xPoints[i] = controlPoints[i].x;
|
||||||
yPoints[i] = controlPoints[i].y;
|
yPoints[i] = controlPoints[i].y;
|
||||||
}
|
}
|
||||||
|
|
||||||
Composite oldComposite = g2d.getComposite();
|
Composite oldComposite = g2d.getComposite();
|
||||||
if (this.alpha < MAX_ALPHA) {
|
if (this.alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(3, 1.0F * this.alpha / MAX_ALPHA));
|
g2d.setComposite(AlphaComposite.getInstance(3, 1.0F * this.alpha / MAX_ALPHA));
|
||||||
}
|
}
|
||||||
g2d.fillPolygon(xPoints, yPoints, controlPoints.length);
|
g2d.fillPolygon(xPoints, yPoints, controlPoints.length);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
|
|
||||||
// Do not track any changes that follow because the whole board has been
|
// Do not track any changes that follow because the whole board has been
|
||||||
// tracked so far.
|
// tracked so far.
|
||||||
drawingObserver.stopTracking();
|
drawingObserver.stopTracking();
|
||||||
Color lineColor =
|
Color lineColor =
|
||||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
: borderColor;
|
: borderColor;
|
||||||
g2d.setColor(lineColor);
|
g2d.setColor(lineColor);
|
||||||
g2d.drawPolygon(xPoints, yPoints, controlPoints.length);
|
g2d.drawPolygon(xPoints, yPoints, controlPoints.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Edges")
|
@EditableProperty(name = "Edges")
|
||||||
public PointCount getPointCount() {
|
public PointCount getPointCount() {
|
||||||
return pointCount;
|
return pointCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPointCount(PointCount pointCount) {
|
public void setPointCount(PointCount pointCount) {
|
||||||
if (this.pointCount == pointCount)
|
if (this.pointCount == pointCount)
|
||||||
return;
|
return;
|
||||||
int oldPointCount = Integer.parseInt(this.pointCount.toString());
|
int oldPointCount = Integer.parseInt(this.pointCount.toString());
|
||||||
int newPointCount = Integer.parseInt(pointCount.toString());
|
int newPointCount = Integer.parseInt(pointCount.toString());
|
||||||
this.controlPoints = Arrays.copyOf(this.controlPoints, newPointCount);
|
this.controlPoints = Arrays.copyOf(this.controlPoints, newPointCount);
|
||||||
if (oldPointCount < newPointCount) {
|
if (oldPointCount < newPointCount) {
|
||||||
this.controlPoints[newPointCount - 1] = this.controlPoints[oldPointCount - 1];
|
this.controlPoints[newPointCount - 1] = this.controlPoints[oldPointCount - 1];
|
||||||
for (int i = oldPointCount - 1; i < newPointCount - 1; i++) {
|
for (int i = oldPointCount - 1; i < newPointCount - 1; i++) {
|
||||||
this.controlPoints[i] =
|
this.controlPoints[i] =
|
||||||
new Point((this.controlPoints[i - 1].x + this.controlPoints[newPointCount - 1].x) / 2,
|
new Point((this.controlPoints[i - 1].x + this.controlPoints[newPointCount - 1].x) / 2,
|
||||||
(this.controlPoints[i - 1].y + this.controlPoints[newPointCount - 1].y) / 2);
|
(this.controlPoints[i - 1].y + this.controlPoints[newPointCount - 1].y) / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.pointCount = pointCount;
|
this.pointCount = pointCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
int factor = 32 / width;
|
int factor = 32 / width;
|
||||||
g2d.setColor(COLOR);
|
g2d.setColor(COLOR);
|
||||||
int[] x = {2 / factor, width - 2 / factor, width - 4 / factor, 3 / factor};
|
int[] x = {2 / factor, width - 2 / factor, width - 4 / factor, 3 / factor};
|
||||||
int[] y = {4 / factor, 2 / factor, height - 5 / factor, height - 2 / factor};
|
int[] y = {4 / factor, 2 / factor, height - 5 / factor, height - 2 / factor};
|
||||||
g2d.fillPolygon(x, y, 4);
|
g2d.fillPolygon(x, y, 4);
|
||||||
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
||||||
g2d.drawPolygon(x, y, 4);
|
g2d.drawPolygon(x, y, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PointCount {
|
public enum PointCount {
|
||||||
_3, _4, _5, _6, _7, _8;
|
_3, _4, _5, _6, _7, _8;
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name().substring(1);
|
return name().substring(1);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,92 +1,92 @@
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
|
* DIY Layout Creator (DIYLC). 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 it under the terms of the GNU
|
* 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
|
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* 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
|
* 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
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
* Public License for more details.
|
* Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||||
* <http://www.gnu.org/licenses/>.
|
* <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.diylc.components.chassis;
|
package org.diylc.components.chassis;
|
||||||
|
|
||||||
import java.awt.AlphaComposite;
|
import java.awt.AlphaComposite;
|
||||||
import java.awt.Composite;
|
import java.awt.Composite;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.SimpleComponentTransformer;
|
import org.diylc.common.SimpleComponentTransformer;
|
||||||
import org.diylc.components.shapes.AbstractShape;
|
import org.diylc.components.shapes.AbstractShape;
|
||||||
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.annotations.BomPolicy;
|
import org.diylc.core.annotations.BomPolicy;
|
||||||
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;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Rectangular Cutout", author = "Branislav Stojkovic", category = "Electromechanical",
|
@ComponentDescriptor(name = "Rectangular Cutout", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||||
instanceNamePrefix = "RECTC", description = "Rectangular chassis cutout, with or without rounded edges",
|
instanceNamePrefix = "RECTC", description = "Rectangular chassis cutout, with or without rounded edges",
|
||||||
zOrder = IDIYComponent.CHASSIS + 0.1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
zOrder = IDIYComponent.CHASSIS + 0.1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
||||||
transformer = SimpleComponentTransformer.class)
|
transformer = SimpleComponentTransformer.class)
|
||||||
public class RectangularCutout extends AbstractShape {
|
public class RectangularCutout extends AbstractShape {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
protected Size edgeRadius = new Size(0d, SizeUnit.mm);
|
protected Size edgeRadius = new Size(0d, SizeUnit.mm);
|
||||||
|
|
||||||
public RectangularCutout() {
|
public RectangularCutout() {
|
||||||
this.borderColor = LIGHT_METAL_COLOR.darker();
|
this.borderColor = LIGHT_METAL_COLOR.darker();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
||||||
int radius = (int) edgeRadius.convertToPixels();
|
int radius = (int) edgeRadius.convertToPixels();
|
||||||
if (componentState != ComponentState.DRAGGING) {
|
if (componentState != ComponentState.DRAGGING) {
|
||||||
Composite oldComposite = g2d.getComposite();
|
Composite oldComposite = g2d.getComposite();
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
}
|
}
|
||||||
g2d.setColor(color);
|
g2d.setColor(color);
|
||||||
g2d.fillRoundRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y, radius,
|
g2d.fillRoundRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y, radius,
|
||||||
radius);
|
radius);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
}
|
}
|
||||||
// Do not track any changes that follow because the whole rect has been
|
// Do not track any changes that follow because the whole rect has been
|
||||||
// tracked so far.
|
// tracked so far.
|
||||||
drawingObserver.stopTracking();
|
drawingObserver.stopTracking();
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
: borderColor);
|
: borderColor);
|
||||||
g2d.drawRoundRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y, radius,
|
g2d.drawRoundRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y, radius,
|
||||||
radius);
|
radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Radius")
|
@EditableProperty(name = "Radius")
|
||||||
public Size getEdgeRadius() {
|
public Size getEdgeRadius() {
|
||||||
return edgeRadius;
|
return edgeRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEdgeRadius(Size edgeRadius) {
|
public void setEdgeRadius(Size edgeRadius) {
|
||||||
this.edgeRadius = edgeRadius;
|
this.edgeRadius = edgeRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
int factor = 32 / width;
|
int factor = 32 / width;
|
||||||
g2d.setColor(COLOR);
|
g2d.setColor(COLOR);
|
||||||
g2d.fillRect(2 / factor, 4 / factor, width - 4 / factor, height - 8 / factor);
|
g2d.fillRect(2 / factor, 4 / factor, width - 4 / factor, height - 8 / factor);
|
||||||
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
||||||
g2d.drawRect(2 / factor, 4 / factor, width - 4 / factor, height - 8 / factor);
|
g2d.drawRect(2 / factor, 4 / factor, width - 4 / factor, height - 8 / factor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ 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 = "9V Battery Snap", category = "Electromechanical", author = "Branislav Stojkovic",
|
@ComponentDescriptor(name = "9V Battery Snap", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||||
description = "", stretchable = false, zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "BTR",
|
description = "", stretchable = false, zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "BTR",
|
||||||
autoEdit = false, transformer = BatterySnapTransformer.class)
|
autoEdit = false, transformer = BatterySnapTransformer.class)
|
||||||
public class BatterySnap9V extends AbstractTransparentComponent<String> {
|
public class BatterySnap9V extends AbstractTransparentComponent<String> {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ 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 = "Cliff 1/4\" Jack", category = "Electromechanical", author = "Branislav Stojkovic",
|
@ComponentDescriptor(name = "Cliff 1/4\" Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||||
description = "Cliff-style closed panel mount 1/4\" phono jack", stretchable = false,
|
description = "Cliff-style closed panel mount 1/4\" phono jack", stretchable = false,
|
||||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J", autoEdit = false, transformer = CliffJackTransformer.class)
|
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J", autoEdit = false, transformer = CliffJackTransformer.class)
|
||||||
public class CliffJack1_4 extends AbstractTransparentComponent<String> {
|
public class CliffJack1_4 extends AbstractTransparentComponent<String> {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ 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 = "Closed 1/4\" Jack", category = "Electromechanical", author = "Branislav Stojkovic",
|
@ComponentDescriptor(name = "Closed 1/4\" Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||||
description = "Enclosed panel mount 1/4\" phono jack", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
description = "Enclosed panel mount 1/4\" phono jack", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
||||||
instanceNamePrefix = "J", autoEdit = false, transformer = ClosedJackTransformer.class)
|
instanceNamePrefix = "J", autoEdit = false, transformer = ClosedJackTransformer.class)
|
||||||
public class ClosedJack1_4 extends AbstractTransparentComponent<String> {
|
public class ClosedJack1_4 extends AbstractTransparentComponent<String> {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ import org.diylc.core.measures.Voltage;
|
|||||||
import org.diylc.core.measures.VoltageUnit;
|
import org.diylc.core.measures.VoltageUnit;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Mini Relay", author = "Branislav Stojkovic", category = "Electromechanical",
|
@ComponentDescriptor(name = "Mini Relay", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||||
instanceNamePrefix = "RY", description = "Miniature PCB mount relay, like Omron G5V-1 or G5V-2",
|
instanceNamePrefix = "RY", description = "Miniature PCB mount relay, like Omron G5V-1 or G5V-2",
|
||||||
stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
||||||
public class MiniRelay extends AbstractTransparentComponent<String> {
|
public class MiniRelay extends AbstractTransparentComponent<String> {
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ 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 = "Mini Toggle Switch", category = "Electromechanical", author = "Branislav Stojkovic",
|
@ComponentDescriptor(name = "Mini Toggle Switch", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||||
description = "Panel mounted mini toggle switch", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
description = "Panel mounted mini toggle switch", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
||||||
instanceNamePrefix = "SW", autoEdit = false)
|
instanceNamePrefix = "SW", autoEdit = false)
|
||||||
public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchType> {
|
public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchType> {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ 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 = "Open 1/4\" Jack", category = "Electromechanical", author = "Branislav Stojkovic",
|
@ComponentDescriptor(name = "Open 1/4\" Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||||
description = "Switchcraft-style open panel mount 1/4\" phono jack, stereo and mono", stretchable = false,
|
description = "Switchcraft-style open panel mount 1/4\" phono jack, stereo and mono", stretchable = false,
|
||||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J")
|
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J")
|
||||||
public class OpenJack1_4 extends AbstractTransparentComponent<String> {
|
public class OpenJack1_4 extends AbstractTransparentComponent<String> {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ 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 = "Plastic DC Jack", category = "Electromechanical", author = "Branislav Stojkovic",
|
@ComponentDescriptor(name = "Plastic DC Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||||
description = "Panel mount plastic DC jack", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
description = "Panel mount plastic DC jack", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
||||||
instanceNamePrefix = "J", autoEdit = false)
|
instanceNamePrefix = "J", autoEdit = false)
|
||||||
public class PlasticDCJack extends AbstractTransparentComponent<String> {
|
public class PlasticDCJack extends AbstractTransparentComponent<String> {
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
|||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Pin spacing")
|
@EditableProperty(name = "Pin Spacing")
|
||||||
public Size getPinSpacing() {
|
public Size getPinSpacing() {
|
||||||
return pinSpacing;
|
return pinSpacing;
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
|||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Row spacing")
|
@EditableProperty(name = "Row Spacing")
|
||||||
public Size getRowSpacing() {
|
public Size getRowSpacing() {
|
||||||
return rowSpacing;
|
return rowSpacing;
|
||||||
}
|
}
|
||||||
@@ -527,7 +527,7 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
|||||||
this.indentColor = indentColor;
|
this.indentColor = indentColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Display pin numbers")
|
@EditableProperty(name = "Display Pin #s")
|
||||||
public DisplayNumbers getDisplayNumbers() {
|
public DisplayNumbers getDisplayNumbers() {
|
||||||
return displayNumbers;
|
return displayNumbers;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public class SIL_IC extends AbstractTransparentComponent<String> {
|
|||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Pin spacing")
|
@EditableProperty(name = "Pin Spacing")
|
||||||
public Size getPinSpacing() {
|
public Size getPinSpacing() {
|
||||||
return pinSpacing;
|
return pinSpacing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
this.body = null;
|
this.body = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Lead length")
|
@EditableProperty(name = "Lead Length")
|
||||||
public Size getLeadLength() {
|
public Size getLeadLength() {
|
||||||
if (leadLength == null) {
|
if (leadLength == null) {
|
||||||
leadLength = LEAD_LENGTH;
|
leadLength = LEAD_LENGTH;
|
||||||
@@ -477,7 +477,7 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
this.body = null;
|
this.body = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Tab border")
|
@EditableProperty(name = "Tab Border")
|
||||||
public Color getTabBorderColor() {
|
public Color getTabBorderColor() {
|
||||||
return tabBorderColor;
|
return tabBorderColor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,623 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
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.tube;
|
||||||
|
|
||||||
|
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.Shape;
|
||||||
|
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.components.transform.TO220Transformer;
|
||||||
|
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.Size;
|
||||||
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
|
//@ComponentDescriptor(name = "Sub-Mini Tube", author = "Branislav Stojkovic", category = "Tubes", instanceNamePrefix = "V", description = "Sub-miniature (pencil) vacuum tube", stretchable = false, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO220Transformer.class)
|
||||||
|
public class SubminiTube extends AbstractTransparentComponent<String> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public static Color BODY_COLOR = Color.lightGray;
|
||||||
|
public static Color BORDER_COLOR = Color.gray;
|
||||||
|
public static Color PIN_COLOR = Color.decode("#00B2EE");
|
||||||
|
public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
|
||||||
|
public static Color LABEL_COLOR = Color.white;
|
||||||
|
public static Size PIN_SIZE = new Size(0.03d, SizeUnit.in);
|
||||||
|
public static Size PIN_SPACING = new Size(0.1d, SizeUnit.in);
|
||||||
|
public static Size BODY_WIDTH = new Size(0.4d, SizeUnit.in);
|
||||||
|
public static Size BODY_THICKNESS = new Size(4.5d, SizeUnit.mm);
|
||||||
|
public static Size BODY_HEIGHT = new Size(9d, SizeUnit.mm);
|
||||||
|
public static Size DIAMETER = new Size(0.4d, SizeUnit.in);
|
||||||
|
public static Size LENGTH = new Size(1.375d, SizeUnit.in);
|
||||||
|
public static Size LEAD_LENGTH = new Size(0.2d, SizeUnit.in);
|
||||||
|
public static Size LEAD_THICKNESS = new Size(0.8d, SizeUnit.mm);
|
||||||
|
|
||||||
|
private String value = "";
|
||||||
|
private Orientation orientation = Orientation.DEFAULT;
|
||||||
|
private Point[] controlPoints = new Point[] { new Point(0, 0),
|
||||||
|
new Point(0, 0), new Point(0, 0) };
|
||||||
|
transient private Shape[] body;
|
||||||
|
private Color bodyColor = BODY_COLOR;
|
||||||
|
private Color borderColor = BORDER_COLOR;
|
||||||
|
private Display display = Display.NAME;
|
||||||
|
private boolean folded = false;
|
||||||
|
private Size leadLength = LEAD_LENGTH;
|
||||||
|
private PinArrangement leadArrangement = PinArrangement.Circular;
|
||||||
|
private boolean topLead = false;
|
||||||
|
private Size diameter = DIAMETER;
|
||||||
|
private Size length = LENGTH;
|
||||||
|
private PinCount pinCount = PinCount._8;
|
||||||
|
private Size leadSpacing = PIN_SPACING;
|
||||||
|
|
||||||
|
public SubminiTube() {
|
||||||
|
super();
|
||||||
|
updateControlPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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) PIN_SPACING.convertToPixels();
|
||||||
|
// Update control points.
|
||||||
|
int x = controlPoints[0].x;
|
||||||
|
int y = controlPoints[0].y;
|
||||||
|
int newPointCount = getPinCount().getValue();
|
||||||
|
// Need a new array
|
||||||
|
if (newPointCount != controlPoints.length) {
|
||||||
|
controlPoints = new Point[newPointCount];
|
||||||
|
for (int i = 0; i < controlPoints.length; i++) {
|
||||||
|
controlPoints[i] = new Point(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int dx;
|
||||||
|
int dy;
|
||||||
|
if (folded) {
|
||||||
|
switch (orientation) {
|
||||||
|
case DEFAULT:
|
||||||
|
dx = 0;
|
||||||
|
dy = pinSpacing;
|
||||||
|
break;
|
||||||
|
case _90:
|
||||||
|
dx = -pinSpacing;
|
||||||
|
dy = 0;
|
||||||
|
break;
|
||||||
|
case _180:
|
||||||
|
dx = 0;
|
||||||
|
dy = -pinSpacing;
|
||||||
|
break;
|
||||||
|
case _270:
|
||||||
|
dx = pinSpacing;
|
||||||
|
dy = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("Unexpected orientation: "
|
||||||
|
+ orientation);
|
||||||
|
}
|
||||||
|
for (int i = 1; i < controlPoints.length; i++) {
|
||||||
|
controlPoints[i].setLocation(controlPoints[0].x + i * dx, controlPoints[0].y + i * dy);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (orientation) {
|
||||||
|
case DEFAULT:
|
||||||
|
controlPoints[1].setLocation(x, y + pinSpacing);
|
||||||
|
controlPoints[2].setLocation(x, y + 2 * pinSpacing);
|
||||||
|
break;
|
||||||
|
case _90:
|
||||||
|
controlPoints[1].setLocation(x - pinSpacing, y);
|
||||||
|
controlPoints[2].setLocation(x - 2 * pinSpacing, y);
|
||||||
|
break;
|
||||||
|
case _180:
|
||||||
|
controlPoints[1].setLocation(x, y - pinSpacing);
|
||||||
|
controlPoints[2].setLocation(x, y - 2 * pinSpacing);
|
||||||
|
break;
|
||||||
|
case _270:
|
||||||
|
controlPoints[1].setLocation(x + pinSpacing, y);
|
||||||
|
controlPoints[2].setLocation(x + 2 * pinSpacing, y);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("Unexpected orientation: "
|
||||||
|
+ orientation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shape[] getBody() {
|
||||||
|
if (body == null) {
|
||||||
|
body = new Shape[2];
|
||||||
|
int x = controlPoints[0].x;
|
||||||
|
int y = controlPoints[0].y;
|
||||||
|
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||||
|
int bodyWidth = getClosestOdd(BODY_WIDTH.convertToPixels());
|
||||||
|
int bodyThickness = getClosestOdd(BODY_THICKNESS.convertToPixels());
|
||||||
|
int bodyHeight = getClosestOdd(BODY_HEIGHT.convertToPixels());
|
||||||
|
int tabThickness = 0; // (int) TAB_THICKNESS.convertToPixels();
|
||||||
|
int tabHeight = 0;// (int) TAB_HEIGHT.convertToPixels();
|
||||||
|
int tabHoleDiameter = 0;// (int)
|
||||||
|
// TAB_HOLE_DIAMETER.convertToPixels();
|
||||||
|
double leadLength = getLeadLength().convertToPixels();
|
||||||
|
|
||||||
|
switch (orientation) {
|
||||||
|
case DEFAULT:
|
||||||
|
if (folded) {
|
||||||
|
body[0] = new Rectangle2D.Double(x + leadLength, y
|
||||||
|
+ pinSpacing - bodyWidth / 2, bodyHeight, bodyWidth);
|
||||||
|
body[1] = new Area(new Rectangle2D.Double(x + leadLength
|
||||||
|
+ bodyHeight, y + pinSpacing - bodyWidth / 2,
|
||||||
|
tabHeight, bodyWidth));
|
||||||
|
((Area) body[1]).subtract(new Area(new Ellipse2D.Double(x
|
||||||
|
+ leadLength + bodyHeight + tabHeight / 2
|
||||||
|
- tabHoleDiameter / 2, y + pinSpacing
|
||||||
|
- tabHoleDiameter / 2, tabHoleDiameter,
|
||||||
|
tabHoleDiameter)));
|
||||||
|
} else {
|
||||||
|
body[0] = new Rectangle2D.Double(x - bodyThickness / 2, y
|
||||||
|
+ pinSpacing - bodyWidth / 2, bodyThickness,
|
||||||
|
bodyWidth);
|
||||||
|
body[1] = new Rectangle2D.Double(x + bodyThickness / 2
|
||||||
|
- tabThickness, y + pinSpacing - bodyWidth / 2,
|
||||||
|
tabThickness, bodyWidth);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case _90:
|
||||||
|
if (folded) {
|
||||||
|
body[0] = new Rectangle2D.Double(x - pinSpacing - bodyWidth
|
||||||
|
/ 2, y + leadLength, bodyWidth, bodyHeight);
|
||||||
|
body[1] = new Area(new Rectangle2D.Double(x - pinSpacing
|
||||||
|
- bodyWidth / 2, y + leadLength + bodyHeight,
|
||||||
|
bodyWidth, tabHeight));
|
||||||
|
((Area) body[1]).subtract(new Area(new Ellipse2D.Double(x
|
||||||
|
- pinSpacing - tabHoleDiameter / 2, y + leadLength
|
||||||
|
+ bodyHeight + tabHeight / 2 - tabHoleDiameter / 2,
|
||||||
|
tabHoleDiameter, tabHoleDiameter)));
|
||||||
|
} else {
|
||||||
|
body[0] = new Rectangle2D.Double(x - pinSpacing - bodyWidth
|
||||||
|
/ 2, y - bodyThickness / 2, bodyWidth,
|
||||||
|
bodyThickness);
|
||||||
|
body[1] = new Rectangle2D.Double(x - pinSpacing - bodyWidth
|
||||||
|
/ 2, y + bodyThickness / 2 - tabThickness,
|
||||||
|
bodyWidth, tabThickness);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case _180:
|
||||||
|
if (folded) {
|
||||||
|
body[0] = new Rectangle2D.Double(x - leadLength
|
||||||
|
- bodyHeight, y - pinSpacing - bodyWidth / 2,
|
||||||
|
bodyHeight, bodyWidth);
|
||||||
|
body[1] = new Area(new Rectangle2D.Double(x - leadLength
|
||||||
|
- bodyHeight - tabHeight, y - pinSpacing
|
||||||
|
- bodyWidth / 2, tabHeight, bodyWidth));
|
||||||
|
((Area) body[1]).subtract(new Area(new Ellipse2D.Double(x
|
||||||
|
- leadLength - bodyHeight - tabHeight / 2
|
||||||
|
- tabHoleDiameter / 2, y - pinSpacing
|
||||||
|
- tabHoleDiameter / 2, tabHoleDiameter,
|
||||||
|
tabHoleDiameter)));
|
||||||
|
} else {
|
||||||
|
body[0] = new Rectangle2D.Double(x - bodyThickness / 2, y
|
||||||
|
- pinSpacing - bodyWidth / 2, bodyThickness,
|
||||||
|
bodyWidth);
|
||||||
|
body[1] = new Rectangle2D.Double(x - bodyThickness / 2, y
|
||||||
|
- pinSpacing - bodyWidth / 2, tabThickness,
|
||||||
|
bodyWidth);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case _270:
|
||||||
|
if (folded) {
|
||||||
|
body[0] = new Rectangle2D.Double(x + pinSpacing - bodyWidth
|
||||||
|
/ 2, y - leadLength - bodyHeight, bodyWidth,
|
||||||
|
bodyHeight);
|
||||||
|
body[1] = new Area(new Rectangle2D.Double(x + pinSpacing
|
||||||
|
- bodyWidth / 2, y - leadLength - bodyHeight
|
||||||
|
- tabHeight, bodyWidth, tabHeight));
|
||||||
|
((Area) body[1]).subtract(new Area(new Ellipse2D.Double(x
|
||||||
|
+ pinSpacing - tabHoleDiameter / 2, y - leadLength
|
||||||
|
- bodyHeight - tabHeight / 2 - tabHoleDiameter / 2,
|
||||||
|
tabHoleDiameter, tabHoleDiameter)));
|
||||||
|
} else {
|
||||||
|
body[0] = new Rectangle2D.Double(x + pinSpacing - bodyWidth
|
||||||
|
/ 2, y - bodyThickness / 2, bodyWidth,
|
||||||
|
bodyThickness);
|
||||||
|
body[1] = new Rectangle2D.Double(x + pinSpacing - bodyWidth
|
||||||
|
/ 2, y - bodyThickness / 2, bodyWidth, tabThickness);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("Unexpected orientation: "
|
||||||
|
+ orientation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
Shape mainArea = getBody()[0];
|
||||||
|
Shape tabArea = getBody()[1];
|
||||||
|
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);
|
||||||
|
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
|
||||||
|
// Draw pins.
|
||||||
|
|
||||||
|
if (folded) {
|
||||||
|
int leadThickness = getClosestOdd(LEAD_THICKNESS.convertToPixels());
|
||||||
|
int leadLength = (int) getLeadLength().convertToPixels();
|
||||||
|
Color finalPinColor;
|
||||||
|
Color finalPinBorderColor;
|
||||||
|
if (outlineMode) {
|
||||||
|
finalPinColor = new Color(0, 0, 0, 0);
|
||||||
|
finalPinBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
|
: theme.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalPinColor = METAL_COLOR;
|
||||||
|
finalPinBorderColor = METAL_COLOR.darker();
|
||||||
|
}
|
||||||
|
for (Point point : controlPoints) {
|
||||||
|
switch (orientation) {
|
||||||
|
case DEFAULT:
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness));
|
||||||
|
g2d.setColor(finalPinBorderColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x + leadLength
|
||||||
|
- leadThickness / 2, point.y);
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness - 2));
|
||||||
|
g2d.setColor(finalPinColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x + leadLength
|
||||||
|
- leadThickness / 2, point.y);
|
||||||
|
break;
|
||||||
|
case _90:
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness));
|
||||||
|
g2d.setColor(finalPinBorderColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x, point.y
|
||||||
|
+ leadLength - leadThickness / 2);
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness - 2));
|
||||||
|
g2d.setColor(finalPinColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x, point.y
|
||||||
|
+ leadLength - leadThickness / 2);
|
||||||
|
break;
|
||||||
|
case _180:
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness));
|
||||||
|
g2d.setColor(finalPinBorderColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x - leadLength
|
||||||
|
- leadThickness / 2, point.y);
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness - 2));
|
||||||
|
g2d.setColor(finalPinColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x - leadLength
|
||||||
|
- leadThickness / 2, point.y);
|
||||||
|
break;
|
||||||
|
case _270:
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness));
|
||||||
|
g2d.setColor(finalPinBorderColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x, point.y
|
||||||
|
- leadLength);
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
|
||||||
|
leadThickness - 2));
|
||||||
|
g2d.setColor(finalPinColor);
|
||||||
|
g2d.drawLine(point.x, point.y, point.x, point.y
|
||||||
|
- leadLength);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!outlineMode) {
|
||||||
|
for (Point point : controlPoints) {
|
||||||
|
|
||||||
|
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
|
||||||
|
: LABEL_COLOR;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalLabelColor);
|
||||||
|
String label = "";
|
||||||
|
label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||||
|
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;
|
||||||
|
int bodySize = width * 5 / 10;
|
||||||
|
int tabSize = bodySize * 6 / 10;
|
||||||
|
int holeSize = 5 * width / 32;
|
||||||
|
Area a = new Area(new Rectangle2D.Double((width - bodySize) / 2,
|
||||||
|
margin, bodySize, tabSize));
|
||||||
|
a.subtract(new Area(new Ellipse2D.Double(width / 2 - holeSize / 2,
|
||||||
|
margin + tabSize / 2 - holeSize / 2, holeSize, holeSize)));
|
||||||
|
g2d.setColor(BORDER_COLOR);
|
||||||
|
g2d.draw(a);
|
||||||
|
g2d.setColor(BODY_COLOR);
|
||||||
|
g2d.fillRect((width - bodySize) / 2, margin + tabSize, bodySize,
|
||||||
|
bodySize);
|
||||||
|
g2d.setColor(BORDER_COLOR);
|
||||||
|
g2d.drawRect((width - bodySize) / 2, margin + tabSize, bodySize,
|
||||||
|
bodySize);
|
||||||
|
g2d.setColor(METAL_COLOR);
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
||||||
|
g2d.drawLine(width / 2, margin + tabSize + bodySize, width / 2, height
|
||||||
|
- margin);
|
||||||
|
g2d.drawLine(width / 2 - bodySize / 3, margin + tabSize + bodySize,
|
||||||
|
width / 2 - bodySize / 3, height - margin);
|
||||||
|
g2d.drawLine(width / 2 + bodySize / 3, margin + tabSize + bodySize,
|
||||||
|
width / 2 + bodySize / 3, height - margin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Body")
|
||||||
|
public Color getBodyColor() {
|
||||||
|
return bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBodyColor(Color bodyColor) {
|
||||||
|
this.bodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Border")
|
||||||
|
public Color getBorderColor() {
|
||||||
|
return borderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBorderColor(Color borderColor) {
|
||||||
|
this.borderColor = borderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public boolean getFolded() {
|
||||||
|
return folded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFolded(boolean folded) {
|
||||||
|
this.folded = folded;
|
||||||
|
// Invalidate the body
|
||||||
|
this.body = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Lead Length")
|
||||||
|
public Size getLeadLength() {
|
||||||
|
if (leadLength == null) {
|
||||||
|
leadLength = LEAD_LENGTH;
|
||||||
|
}
|
||||||
|
return leadLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeadLength(Size leadLength) {
|
||||||
|
this.leadLength = leadLength;
|
||||||
|
// Invalidate the body
|
||||||
|
this.body = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public Display getDisplay() {
|
||||||
|
if (display == null) {
|
||||||
|
display = Display.NAME;
|
||||||
|
}
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplay(Display display) {
|
||||||
|
this.display = display;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Pin Arrangement")
|
||||||
|
public PinArrangement getPinArrangement() {
|
||||||
|
return leadArrangement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPinArrangement(PinArrangement pinArrangement) {
|
||||||
|
this.leadArrangement = pinArrangement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Top Lead")
|
||||||
|
public boolean getTopLead() {
|
||||||
|
return topLead;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTopLead(boolean topLead) {
|
||||||
|
this.topLead = topLead;
|
||||||
|
updateControlPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public Size getDiameter() {
|
||||||
|
return diameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiameter(Size diameter) {
|
||||||
|
this.diameter = diameter;
|
||||||
|
updateControlPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public Size getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLength(Size length) {
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Lead Count")
|
||||||
|
public PinCount getPinCount() {
|
||||||
|
return pinCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPinCount(PinCount pinCount) {
|
||||||
|
this.pinCount = pinCount;
|
||||||
|
updateControlPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Lead Spacing")
|
||||||
|
public Size getLeadSpacing() {
|
||||||
|
return leadSpacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeadSpacing(Size leadSpacing) {
|
||||||
|
this.leadSpacing = leadSpacing;
|
||||||
|
updateControlPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum PinArrangement {
|
||||||
|
Inline("In-line"), Circular("Circular");
|
||||||
|
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
private PinArrangement(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum PinCount {
|
||||||
|
_3, _4, _5, _6, _7, _8, _9, _10;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name().replace("_", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return Integer.parseInt(toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -2042,9 +2042,17 @@
|
|||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Vastly improve performance of selection aree calculations, especially with bigger layouts</description>
|
<description>Vastly improve performance of selection aree calculations, especially with bigger layouts</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Do not group multiple components automatically after being pasted</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Better error handing in V2 file importer</description>
|
<description>Better error handing in V2 file importer</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>BUG_FIX</changeType>
|
||||||
|
<description>Clicking on a building block twice in a row inside the component tree would make the components go back to the top-left corner of the layout</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
|
|||||||
Reference in New Issue
Block a user