board improvements

show point for non-stretchable components too
This commit is contained in:
bancika
2011-01-17 00:19:47 +00:00
parent c02b37bcba
commit 6dba12eab8
7 changed files with 34 additions and 14 deletions
@@ -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) {
@@ -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);
}
}
@@ -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);
}
}
@@ -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);