fix cut line disappearing

This commit is contained in:
Branislav Stojkovic
2018-12-14 10:01:07 +01:00
parent bc5fc23f38
commit ed6792800b
5 changed files with 130 additions and 122 deletions
Binary file not shown.
@@ -1,23 +1,19 @@
/* /*
*
DIY Layout Creator (DIYLC). * DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
Copyright (c) 2009-2018 held jointly by the individual authors. *
* This file is part of DIYLC.
This file is part of DIYLC. *
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
DIYLC is free software: you can redistribute it and/or modify * General Public License as published by the Free Software Foundation, either version 3 of the
it under the terms of the GNU General Public License as published by * License, or (at your option) any later version.
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
DIYLC is distributed in the hope that it will be useful, * Public License for more details.
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * You should have received a copy of the GNU General Public License along with DIYLC. If not, see
GNU General Public License for more details. * <http://www.gnu.org/licenses/>.
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; package org.diylc.components.connectivity;
@@ -26,11 +22,11 @@ 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.awt.geom.Rectangle2D;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.common.OrientationHV; import org.diylc.common.OrientationHV;
import org.diylc.components.AbstractComponent; import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractTransparentComponent; import org.diylc.components.AbstractTransparentComponent;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -43,127 +39,123 @@ 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 = "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) @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> { public class CutLine extends AbstractTransparentComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static Size WIDTH = new Size(0.125d, SizeUnit.in); public static Size WIDTH = new Size(0.125d, SizeUnit.in);
public static Size LENGTH = new Size(3.125d, SizeUnit.in); public static Size LENGTH = new Size(3.125d, SizeUnit.in);
public static Color COLOR = Color.black; public static Color COLOR = Color.black;
private Size width = WIDTH; private Size width = WIDTH;
private Size length = LENGTH; private Size length = LENGTH;
private Color color = COLOR; private Color color = COLOR;
private Point point = new Point(0, 0); private Point point = new Point(0, 0);
private OrientationHV orientation = OrientationHV.VERTICAL; private OrientationHV orientation = OrientationHV.VERTICAL;
@Override @Override
public void draw(Graphics2D g2d, ComponentState componentState, public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
boolean outlineMode, Project project, IDrawingObserver drawingObserver) {
IDrawingObserver drawingObserver) { int w = getClosestOdd((int) getWidth().convertToPixels());
if (checkPointsClipped(g2d.getClip())) { int l = getClosestOdd((int) getLength().convertToPixels());
return; g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
} : color);
int w = getClosestOdd((int) getWidth().convertToPixels()); g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(w));
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 Composite oldComposite = g2d.getComposite();
public void drawIcon(Graphics2D g2d, int width, int height) { if (alpha < MAX_ALPHA) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2)); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
g2d.setColor(COLOR); }
g2d.drawLine(width / 2, height - 2, width / 2, 1);
}
@EditableProperty if (getOrientation() == OrientationHV.HORIZONTAL)
public Size getWidth() { g2d.drawLine(point.x, point.y, point.x + l, point.y);
return width; else
} g2d.drawLine(point.x, point.y, point.x, point.y + l);
public void setWidth(Size width) { g2d.setComposite(oldComposite);
this.width = width; }
}
@EditableProperty @Override
public Size getLength() { public void drawIcon(Graphics2D g2d, int width, int height) {
return length; g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
} g2d.setColor(COLOR);
g2d.drawLine(width / 2, height - 2, width / 2, 1);
}
public void setLength(Size length) { @EditableProperty
this.length = length; public Size getWidth() {
} return width;
}
@EditableProperty public void setWidth(Size width) {
public OrientationHV getOrientation() { this.width = width;
return orientation; }
}
public void setOrientation(OrientationHV orientation) { @EditableProperty
this.orientation = orientation; public Size getLength() {
} return length;
}
@Override public void setLength(Size length) {
public String getName() { this.length = length;
return super.getName(); }
}
@Override @EditableProperty
public int getControlPointCount() { public OrientationHV getOrientation() {
return 1; return orientation;
} }
@Override public void setOrientation(OrientationHV orientation) {
public boolean isControlPointSticky(int index) { this.orientation = orientation;
return false; }
}
@Override @Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) { public String getName() {
return VisibilityPolicy.NEVER; return super.getName();
} }
@Override @Override
public Point getControlPoint(int index) { public int getControlPointCount() {
return point; return 1;
} }
@Override @Override
public void setControlPoint(Point point, int index) { public boolean isControlPointSticky(int index) {
this.point.setLocation(point); return false;
} }
@EditableProperty(name = "Color") @Override
public Color getColor() { public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return color; return VisibilityPolicy.NEVER;
} }
public void setColor(Color color) { @Override
this.color = color; public Point getControlPoint(int index) {
} return point;
}
@Override @Override
public Void getValue() { public void setControlPoint(Point point, int index) {
return null; this.point.setLocation(point);
} }
@Override @EditableProperty(name = "Color")
public void setValue(Void value) { 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) {}
} }
Binary file not shown.
Binary file not shown.
+16
View File
@@ -1864,6 +1864,22 @@
</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>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>3</major>
<minor>41</minor>
<build>2</build>
</versionNumber>
<releaseDate>2018-12-11 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>"Cut Line" component sometimes disappears</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version> </org.diylc.appframework.update.Version>
</a> </a>
</java.util.Arrays_-ArrayList> </java.util.Arrays_-ArrayList>