mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
hotspot tracking optimization
This commit is contained in:
+6
-1
@@ -9,6 +9,7 @@ import java.awt.Point;
|
||||
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
@@ -32,7 +33,8 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
protected Color borderColor = BORDER_COLOR;
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setStroke(new BasicStroke());
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
@@ -49,6 +51,9 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
||||
g2d.drawRect(controlPoints[0].x, controlPoints[0].y, controlPoints[1].x
|
||||
- controlPoints[0].x, controlPoints[1].y - controlPoints[0].y);
|
||||
// Do not track any changes that follow because the whole board has been
|
||||
// tracked so far.
|
||||
drawingObserver.stopTracking();
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Color")
|
||||
|
||||
+4
-3
@@ -7,6 +7,7 @@ import java.awt.Point;
|
||||
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -30,9 +31,9 @@ public class PerfBoard extends AbstractBoard {
|
||||
protected Color padColor = PAD_COLOR;
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
||||
super.draw(g2d, componentState, project);
|
||||
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
super.draw(g2d, componentState, project, drawingObserver);
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||
|
||||
+4
-2
@@ -8,6 +8,7 @@ import java.awt.Point;
|
||||
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -32,8 +33,9 @@ public class VeroBoard extends AbstractBoard {
|
||||
protected Color padColor = PAD_COLOR;
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
||||
super.draw(g2d, componentState, project);
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
super.draw(g2d, componentState, project, drawingObserver);
|
||||
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
|
||||
+4
-2
@@ -7,6 +7,7 @@ import java.awt.Point;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -28,7 +29,8 @@ public class SolderPad extends AbstractComponent<Void> {
|
||||
private Point point = new Point(0, 0);
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
int diameter = getClosestOdd(size.convertToPixels());
|
||||
int holeDiameter = getClosestOdd(HOLE_SIZE.convertToPixels());
|
||||
g2d.setColor(componentState == ComponentState.SELECTED
|
||||
@@ -94,7 +96,7 @@ public class SolderPad extends AbstractComponent<Void> {
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setValue(Void value) {
|
||||
}
|
||||
|
||||
+3
-1
@@ -7,6 +7,7 @@ import java.awt.Graphics2D;
|
||||
import org.diylc.components.AbstractSinglePointComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -28,7 +29,8 @@ public class TraceCut extends AbstractSinglePointComponent {
|
||||
private Color borderColor = BORDER_COLOR;
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
||||
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;
|
||||
g2d.setColor(fillColor);
|
||||
|
||||
+6
-1
@@ -12,6 +12,7 @@ import java.awt.geom.RoundRectangle2D;
|
||||
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.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -153,7 +154,8 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
Shape body = getBody();
|
||||
// Draw body if available.
|
||||
if (body != null) {
|
||||
@@ -170,6 +172,9 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : BORDER_COLOR);
|
||||
g2d.draw(body);
|
||||
}
|
||||
// Do not track these changes because the whole switch has been tracked
|
||||
// so far.
|
||||
drawingObserver.stopTracking();
|
||||
// Draw lugs.
|
||||
int circleDiameter = getClosestOdd(CIRCLE_SIZE.convertToPixels());
|
||||
int lugWidth = getClosestOdd(LUG_WIDTH.convertToPixels());
|
||||
|
||||
+3
-1
@@ -12,6 +12,7 @@ import java.util.List;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -35,7 +36,8 @@ public class BOM extends AbstractComponent<Void> {
|
||||
private Point point = new Point(0, 0);
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
List<BomEntry> bom = BomMaker.getInstance().createBom(project.getComponents());
|
||||
// Cleanup entries that do not have a value set.
|
||||
Iterator<BomEntry> iterator = bom.iterator();
|
||||
|
||||
+3
-1
@@ -10,6 +10,7 @@ import java.awt.geom.Rectangle2D;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.measures.Size;
|
||||
@@ -28,7 +29,8 @@ public class ProjectInformation extends AbstractComponent<Void> {
|
||||
private Point point = new Point(0, 0);
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setFont(Constants.LABEL_FONT);
|
||||
g2d.setColor(componentState == ComponentState.DRAGGING
|
||||
|| componentState == ComponentState.SELECTED ? SELECTION_COLOR : COLOR);
|
||||
|
||||
+13
-8
@@ -16,6 +16,7 @@ import org.diylc.common.Orientation;
|
||||
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.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -44,13 +45,16 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
private Size pinSpacing = new Size(0.1d, SizeUnit.in);
|
||||
private Size rowSpacing = new Size(0.3d, SizeUnit.in);
|
||||
private Point[] controlPoints = new Point[] { new Point(0, 0) };
|
||||
// new Point(0, pinSpacing.convertToPixels()),
|
||||
// new Point(0, 2 * pinSpacing.convertToPixels()),
|
||||
// new Point(0, 3 * pinSpacing.convertToPixels()),
|
||||
// new Point(3 * pinSpacing.convertToPixels(), 0),
|
||||
// new Point(3 * pinSpacing.convertToPixels(), pinSpacing.convertToPixels()),
|
||||
// new Point(3 * pinSpacing.convertToPixels(), 2 * pinSpacing.convertToPixels()),
|
||||
// new Point(3 * pinSpacing.convertToPixels(), 3 * pinSpacing.convertToPixels()) };
|
||||
// new Point(0, pinSpacing.convertToPixels()),
|
||||
// new Point(0, 2 * pinSpacing.convertToPixels()),
|
||||
// new Point(0, 3 * pinSpacing.convertToPixels()),
|
||||
// new Point(3 * pinSpacing.convertToPixels(), 0),
|
||||
// new Point(3 * pinSpacing.convertToPixels(),
|
||||
// pinSpacing.convertToPixels()),
|
||||
// new Point(3 * pinSpacing.convertToPixels(), 2 *
|
||||
// pinSpacing.convertToPixels()),
|
||||
// new Point(3 * pinSpacing.convertToPixels(), 3 *
|
||||
// pinSpacing.convertToPixels()) };
|
||||
private Shape body;
|
||||
|
||||
public DIL_IC() {
|
||||
@@ -212,7 +216,8 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
int pinSize = PIN_SIZE.convertToPixels() / 2 * 2;
|
||||
for (Point point : controlPoints) {
|
||||
g2d.setColor(PIN_COLOR);
|
||||
|
||||
Reference in New Issue
Block a user