mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
board improvements
show point for non-stretchable components too
This commit is contained in:
Binary file not shown.
+2
-1
@@ -418,7 +418,8 @@ public class Presenter implements IPlugInPort {
|
||||
Map<IDIYComponent<?>, Set<Integer>> components = new HashMap<IDIYComponent<?>, Set<Integer>>();
|
||||
Point scaledPoint = scalePoint(point);
|
||||
if (componentSlot != null
|
||||
&& componentSlot.getCreationMethod() == CreationMethod.POINT_BY_POINT) {
|
||||
&& (componentSlot.getCreationMethod() == CreationMethod.POINT_BY_POINT || !componentSlot
|
||||
.isStretchable())) {
|
||||
potentialControlPoint = scaledPoint;
|
||||
snapPointToGrid(potentialControlPoint);
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.awt.Stroke;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final int PIXELS_PER_INCH = 120;//Toolkit.getDefaultToolkit().getScreenResolution();
|
||||
public static final int PIXELS_PER_INCH = 150;//Toolkit.getDefaultToolkit().getScreenResolution();
|
||||
public static int GRIDS_PER_INCH = 8;
|
||||
// public static Size GRID_SIZE = new Size(1d / GRIDS_PER_INCH, SizeUnit.in);
|
||||
// public static final int GRID = 20;
|
||||
|
||||
+2
-2
@@ -1,7 +1,6 @@
|
||||
package org.diylc.components.boards;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
@@ -14,6 +13,7 @@ import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
public abstract class AbstractBoard extends AbstractTransparentComponent<String> {
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setStroke(new BasicStroke());
|
||||
g2d.setStroke(Constants.BASIC_STROKE);
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
|
||||
+10
-1
@@ -51,9 +51,14 @@ public class PerfBoard extends AbstractBoard {
|
||||
p.x += spacing;
|
||||
g2d.setColor(padColor);
|
||||
g2d.fillOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter);
|
||||
g2d.setColor(padColor.darker());
|
||||
g2d.drawOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter);
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter,
|
||||
holeDiameter);
|
||||
g2d.setColor(padColor.darker());
|
||||
g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter,
|
||||
holeDiameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +90,11 @@ public class PerfBoard extends AbstractBoard {
|
||||
g2d.drawRect(2, 2, width - 4, height - 4);
|
||||
g2d.setColor(PAD_COLOR);
|
||||
g2d.fillOval(width / 4, width / 4, width / 2, width / 2);
|
||||
g2d.setColor(PAD_COLOR.darker());
|
||||
g2d.drawOval(width / 4, width / 4, width / 2, width / 2);
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval(width / 2 - 1, width / 2 - 1, 2, 2);
|
||||
g2d.fillOval(width / 2 - 2, width / 2 - 2, 5, 5);
|
||||
g2d.setColor(PAD_COLOR.darker());
|
||||
g2d.drawOval(width / 2 - 2, width / 2 - 2, 5, 5);
|
||||
}
|
||||
}
|
||||
|
||||
+13
-3
@@ -25,7 +25,7 @@ public class VeroBoard extends AbstractBoard {
|
||||
public static Color BORDER_COLOR = BOARD_COLOR.darker();
|
||||
|
||||
public static Size SPACING = new Size(0.1d, SizeUnit.in);
|
||||
public static Size STRIP_SIZE = new Size(0.085d, SizeUnit.in);
|
||||
public static Size STRIP_SIZE = new Size(0.07d, SizeUnit.in);
|
||||
public static Size HOLE_SIZE = new Size(0.7d, SizeUnit.mm);
|
||||
|
||||
protected Size spacing = SPACING;
|
||||
@@ -53,10 +53,15 @@ public class VeroBoard extends AbstractBoard {
|
||||
g2d.setColor(padColor);
|
||||
g2d.fillRect(p.x + SPACING.convertToPixels() / 2, p.y - stripSize / 2,
|
||||
controlPoints[1].x - spacing - p.x, stripSize);
|
||||
g2d.setColor(padColor.darker());
|
||||
g2d.drawRect(p.x + SPACING.convertToPixels() / 2, p.y - stripSize / 2,
|
||||
controlPoints[1].x - spacing - p.x, stripSize);
|
||||
while (p.x < controlPoints[1].x - spacing) {
|
||||
p.x += spacing;
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
||||
g2d.setColor(padColor.darker());
|
||||
g2d.drawOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
||||
}
|
||||
}
|
||||
g2d.setComposite(oldComposite);
|
||||
@@ -89,8 +94,13 @@ public class VeroBoard extends AbstractBoard {
|
||||
g2d.drawRect(2, 2, width - 4, height - 4);
|
||||
g2d.setColor(PAD_COLOR);
|
||||
g2d.fillRect(4, width / 4, width - 8, width / 2);
|
||||
g2d.setColor(PAD_COLOR.darker());
|
||||
g2d.drawRect(4, width / 4, width - 8, width / 2);
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval(width / 3 - 1, width / 2 - 1, 3, 3);
|
||||
g2d.fillOval(2 * width / 3 - 1, width / 2 - 1, 3, 3);
|
||||
g2d.fillOval(width / 3 - 2, width / 2 - 2, 5, 5);
|
||||
g2d.fillOval(2 * width / 3 - 2, width / 2 - 2, 5, 5);
|
||||
g2d.setColor(PAD_COLOR.darker());
|
||||
g2d.drawOval(width / 3 - 2, width / 2 - 2, 5, 5);
|
||||
g2d.drawOval(2 * width / 3 - 2, width / 2 - 2, 5, 5);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -1,6 +1,5 @@
|
||||
package org.diylc.components.connectivity;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
@@ -13,13 +12,14 @@ import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Trace Cut", category = "Connectivity", author = "Branislav Stojkovic", description = "test", instanceNamePrefix = "Cut", stretchable = false, zOrder = IDIYComponent.ABOVE_BOARD)
|
||||
public class TraceCut extends AbstractSinglePointComponent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Size SIZE = new Size(0.085d, SizeUnit.in);
|
||||
public static Size SIZE = new Size(0.07d, SizeUnit.in);
|
||||
public static Color FILL_COLOR = Color.white;
|
||||
public static Color BORDER_COLOR = Color.red;
|
||||
public static Color SELECTION_COLOR = Color.blue;
|
||||
@@ -31,13 +31,13 @@ public class TraceCut extends AbstractSinglePointComponent {
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
int size = this.size.convertToPixels() / 2 * 2;
|
||||
int dotDiameter = (size / 3 * 2) / 2 * 2 + 1;
|
||||
int size = getClosestOdd(this.size.convertToPixels());
|
||||
int dotDiameter = size - 6;
|
||||
g2d.setColor(fillColor);
|
||||
g2d.fillRect(point.x - size / 2, point.y - size / 2, size, size);
|
||||
g2d.setColor(componentState == ComponentState.SELECTED
|
||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
||||
g2d.setStroke(new BasicStroke(1));
|
||||
g2d.setStroke(Constants.BASIC_STROKE);
|
||||
g2d.drawRect(point.x - size / 2, point.y - size / 2, size, size);
|
||||
g2d
|
||||
.fillOval(point.x - dotDiameter / 2, point.y - dotDiameter / 2, dotDiameter,
|
||||
@@ -51,7 +51,7 @@ public class TraceCut extends AbstractSinglePointComponent {
|
||||
g2d.setColor(FILL_COLOR);
|
||||
g2d.fillRect((width - size) / 2, (height - size) / 2, size, size);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.setStroke(new BasicStroke(1));
|
||||
g2d.setStroke(Constants.BASIC_STROKE);
|
||||
g2d.drawRect((width - size) / 2, (height - size) / 2, size, size);
|
||||
g2d.fillOval((width - dotDiameter) / 2, (height - dotDiameter) / 2, dotDiameter,
|
||||
dotDiameter);
|
||||
|
||||
Reference in New Issue
Block a user