mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
"cut line" added
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
|
||||
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.connectivity;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.common.OrientationHV;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.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;
|
||||
|
||||
@ComponentDescriptor(name = "Cut Line", category = "Connectivity", author = "Branislav Stojkovic", description = "Cut line", instanceNamePrefix = "CL", stretchable = false, zOrder = IDIYComponent.COMPONENT, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
|
||||
public class CutLine extends AbstractTransparentComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Size WIDTH = new Size(0.125d, SizeUnit.in);
|
||||
public static Size LENGTH = new Size(3.125d, SizeUnit.in);
|
||||
public static Color COLOR = Color.black;
|
||||
|
||||
private Size width = WIDTH;
|
||||
private Size length = LENGTH;
|
||||
private Color color = COLOR;
|
||||
private Point point = new Point(0, 0);
|
||||
private OrientationHV orientation = OrientationHV.VERTICAL;
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState,
|
||||
boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
if (checkPointsClipped(g2d.getClip())) {
|
||||
return;
|
||||
}
|
||||
int w = getClosestOdd((int) getWidth().convertToPixels());
|
||||
int l = getClosestOdd((int) getLength().convertToPixels());
|
||||
g2d.setColor(componentState == ComponentState.SELECTED
|
||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: color);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(w));
|
||||
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
|
||||
if (getOrientation() == OrientationHV.HORIZONTAL)
|
||||
g2d.drawLine(point.x, point.y, point.x + l, point.y);
|
||||
else
|
||||
g2d.drawLine(point.x, point.y, point.x, point.y + l);
|
||||
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
||||
g2d.setColor(COLOR);
|
||||
g2d.drawLine(width / 2, height - 2, width / 2, 1);
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Size getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(Size width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Size getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public void setLength(Size length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public OrientationHV getOrientation() {
|
||||
return orientation;
|
||||
}
|
||||
|
||||
public void setOrientation(OrientationHV orientation) {
|
||||
this.orientation = orientation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return super.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.NEVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getControlPoint(int index) {
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point point, int index) {
|
||||
this.point.setLocation(point);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Color")
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Void value) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
//package org.diylc.components.transform;
|
||||
//
|
||||
//import java.awt.Point;
|
||||
//import java.awt.geom.AffineTransform;
|
||||
//
|
||||
//import org.diylc.common.IComponentTransformer;
|
||||
//import org.diylc.common.Orientation;
|
||||
//import org.diylc.components.passive.TrimmerPotentiometer;
|
||||
//import org.diylc.core.IDIYComponent;
|
||||
//
|
||||
//public class TrimmerTransformer implements IComponentTransformer {
|
||||
//
|
||||
// @Override
|
||||
// public boolean canRotate(IDIYComponent<?> component) {
|
||||
// return component.getClass().equals(TrimmerPotentiometer.class);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canMirror(IDIYComponent<?> component) {
|
||||
// return component.getClass().equals(TrimmerPotentiometer.class);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean mirroringChangesCircuit() {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void rotate(IDIYComponent<?> component, Point center, int direction) {
|
||||
// AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.x, center.y);
|
||||
// for (int index = 0; index < component.getControlPointCount(); index++) {
|
||||
// Point p = new Point(component.getControlPoint(index));
|
||||
// rotate.transform(p, p);
|
||||
// component.setControlPoint(p, index);
|
||||
// }
|
||||
//
|
||||
// TrimmerPotentiometer potentiometer = (TrimmerPotentiometer) component;
|
||||
// Orientation o = potentiometer.getOrientation();
|
||||
// int oValue = o.ordinal();
|
||||
// oValue += direction;
|
||||
// if (oValue < 0)
|
||||
// oValue = Orientation.values().length - 1;
|
||||
// if (oValue >= Orientation.values().length)
|
||||
// oValue = 0;
|
||||
// o = Orientation.values()[oValue];
|
||||
// potentiometer.setOrientation(o);
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings("incomplete-switch")
|
||||
// @Override
|
||||
// public void mirror(IDIYComponent<?> component, Point center, int direction) {
|
||||
// TrimmerPotentiometer potentiometer = (TrimmerPotentiometer) component;
|
||||
// int dx = center.x - potentiometer.getControlPoint(1).x;
|
||||
// int dy = center.y - potentiometer.getControlPoint(1).y;
|
||||
// if (direction == IComponentTransformer.HORIZONTAL) {
|
||||
// Orientation o = potentiometer.getOrientation();
|
||||
// switch (o) {
|
||||
// case _90:
|
||||
// o = Orientation._270;
|
||||
// break;
|
||||
// case _270:
|
||||
// o = Orientation._90;
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < potentiometer.getControlPointCount(); i++) {
|
||||
// Point p = potentiometer.getControlPoint(i);
|
||||
// potentiometer
|
||||
// .setControlPoint(
|
||||
// new Point(p.x + 2 * dx, p.y + (potentiometer.getControlPoint(2).y - potentiometer.getControlPoint(0).y)),
|
||||
// i);
|
||||
// }
|
||||
//
|
||||
// potentiometer.setOrientation(o);
|
||||
// } else {
|
||||
// Orientation o = potentiometer.getOrientation();
|
||||
// switch (o) {
|
||||
// case DEFAULT:
|
||||
// o = Orientation._180;
|
||||
// break;
|
||||
// case _180:
|
||||
// o = Orientation.DEFAULT;
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < potentiometer.getControlPointCount(); i++) {
|
||||
// Point p = potentiometer.getControlPoint(i);
|
||||
// potentiometer
|
||||
// .setControlPoint(new Point(p.x + (potentiometer.getControlPoint(2).x - potentiometer.getControlPoint(0).x),
|
||||
// p.y + 2 * dy), i);
|
||||
// }
|
||||
//
|
||||
// potentiometer.setOrientation(o);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -14,7 +14,7 @@
|
||||
<classpathentry kind="lib" path="lib/jep-2.4.1.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/diylc-core"/>
|
||||
<classpathentry kind="lib" path="lib/xstream-1.4.3.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_121"/>
|
||||
<classpathentry kind="lib" path="lib/java-http-proxy.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;Library&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;DIYLC&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;diylc-core&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;diylc-library&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_121"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.diylc.DIYLCStarter"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="diylc-swing"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-splash:splash.png -Xms256m -Xmx512m -Dorg.diylc.scriptRun=true -Ddorg.diylc.debugComponentAreas=true"/>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1822,6 +1822,10 @@
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Using right click to draw a selection rectangle doesn't move objects under the cursor (useful for selecting multiple components that have a big board below)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>"Cut Line" component added to designate where a custom eyelet/turret boards needs to be cut</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Increased padding between schematic symbols and their labels</description>
|
||||
|
||||
Reference in New Issue
Block a user