mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
boards don't disappear when points are flipped
This commit is contained in:
Binary file not shown.
+10
-4
@@ -28,6 +28,8 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
protected String value = "";
|
protected String value = "";
|
||||||
protected Point[] controlPoints = new Point[] { new Point(0, 0),
|
protected Point[] controlPoints = new Point[] { new Point(0, 0),
|
||||||
new Point(DEFAULT_WIDTH.convertToPixels(), DEFAULT_HEIGHT.convertToPixels()) };
|
new Point(DEFAULT_WIDTH.convertToPixels(), DEFAULT_HEIGHT.convertToPixels()) };
|
||||||
|
protected Point firstPoint = new Point();
|
||||||
|
protected Point secondPoint = new Point();
|
||||||
|
|
||||||
protected Color boardColor = BOARD_COLOR;
|
protected Color boardColor = BOARD_COLOR;
|
||||||
protected Color borderColor = BORDER_COLOR;
|
protected Color borderColor = BORDER_COLOR;
|
||||||
@@ -43,14 +45,14 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
/ MAX_ALPHA));
|
/ MAX_ALPHA));
|
||||||
}
|
}
|
||||||
g2d.setColor(boardColor);
|
g2d.setColor(boardColor);
|
||||||
g2d.fillRect(controlPoints[0].x, controlPoints[0].y, controlPoints[1].x
|
g2d.fillRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y
|
||||||
- controlPoints[0].x, controlPoints[1].y - controlPoints[0].y);
|
- firstPoint.y);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
}
|
}
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED
|
g2d.setColor(componentState == ComponentState.SELECTED
|
||||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
||||||
g2d.drawRect(controlPoints[0].x, controlPoints[0].y, controlPoints[1].x
|
g2d.drawRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y
|
||||||
- controlPoints[0].x, controlPoints[1].y - controlPoints[0].y);
|
- firstPoint.y);
|
||||||
// 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();
|
||||||
@@ -97,6 +99,10 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
@Override
|
@Override
|
||||||
public void setControlPoint(Point point, int index) {
|
public void setControlPoint(Point point, int index) {
|
||||||
controlPoints[index].setLocation(point);
|
controlPoints[index].setLocation(point);
|
||||||
|
firstPoint.setLocation(Math.min(controlPoints[0].x, controlPoints[1].x), Math.min(
|
||||||
|
controlPoints[0].y, controlPoints[1].y));
|
||||||
|
secondPoint.setLocation(Math.max(controlPoints[0].x, controlPoints[1].x), Math.max(
|
||||||
|
controlPoints[0].y, controlPoints[1].y));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
|
|||||||
+4
-4
@@ -39,15 +39,15 @@ public class PerfBoard extends AbstractBoard {
|
|||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||||
/ MAX_ALPHA));
|
/ MAX_ALPHA));
|
||||||
}
|
}
|
||||||
Point p = new Point(controlPoints[0]);
|
Point p = new Point(firstPoint);
|
||||||
int diameter = getClosestOdd(PAD_SIZE.convertToPixels());
|
int diameter = getClosestOdd(PAD_SIZE.convertToPixels());
|
||||||
int holeDiameter = getClosestOdd(HOLE_SIZE.convertToPixels());
|
int holeDiameter = getClosestOdd(HOLE_SIZE.convertToPixels());
|
||||||
int spacing = this.spacing.convertToPixels();
|
int spacing = this.spacing.convertToPixels();
|
||||||
|
|
||||||
while (p.y < controlPoints[1].y - spacing) {
|
while (p.y < secondPoint.y - spacing) {
|
||||||
p.x = controlPoints[0].x;
|
p.x = firstPoint.x;
|
||||||
p.y += spacing;
|
p.y += spacing;
|
||||||
while (p.x < controlPoints[1].x - spacing) {
|
while (p.x < secondPoint.x - spacing) {
|
||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
g2d.setColor(padColor);
|
g2d.setColor(padColor);
|
||||||
g2d.fillOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter);
|
g2d.fillOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter);
|
||||||
|
|||||||
+4
-4
@@ -42,13 +42,13 @@ public class VeroBoard extends AbstractBoard {
|
|||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||||
/ MAX_ALPHA));
|
/ MAX_ALPHA));
|
||||||
}
|
}
|
||||||
Point p = new Point(controlPoints[0]);
|
Point p = new Point(firstPoint);
|
||||||
int stripSize = getClosestOdd(STRIP_SIZE.convertToPixels());
|
int stripSize = getClosestOdd(STRIP_SIZE.convertToPixels());
|
||||||
int holeSize = getClosestOdd(HOLE_SIZE.convertToPixels());
|
int holeSize = getClosestOdd(HOLE_SIZE.convertToPixels());
|
||||||
int spacing = this.spacing.convertToPixels();
|
int spacing = this.spacing.convertToPixels();
|
||||||
|
|
||||||
while (p.y < controlPoints[1].y - spacing) {
|
while (p.y < secondPoint.y - spacing) {
|
||||||
p.x = controlPoints[0].x;
|
p.x = firstPoint.x;
|
||||||
p.y += spacing;
|
p.y += spacing;
|
||||||
g2d.setColor(padColor);
|
g2d.setColor(padColor);
|
||||||
g2d.fillRect(p.x + SPACING.convertToPixels() / 2, p.y - stripSize / 2,
|
g2d.fillRect(p.x + SPACING.convertToPixels() / 2, p.y - stripSize / 2,
|
||||||
@@ -56,7 +56,7 @@ public class VeroBoard extends AbstractBoard {
|
|||||||
g2d.setColor(padColor.darker());
|
g2d.setColor(padColor.darker());
|
||||||
g2d.drawRect(p.x + SPACING.convertToPixels() / 2, p.y - stripSize / 2,
|
g2d.drawRect(p.x + SPACING.convertToPixels() / 2, p.y - stripSize / 2,
|
||||||
controlPoints[1].x - spacing - p.x, stripSize);
|
controlPoints[1].x - spacing - p.x, stripSize);
|
||||||
while (p.x < controlPoints[1].x - spacing) {
|
while (p.x < secondPoint.x - spacing) {
|
||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
||||||
|
|||||||
+1
-1
@@ -277,7 +277,7 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum PinCount {
|
public static enum PinCount {
|
||||||
|
|
||||||
_4, _8, _10, _12, _14, _16, _24, _32;
|
_4, _8, _10, _12, _14, _16, _24, _32;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user