mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
outline mode
improved auto-create for pads
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>lastPath</string>
|
<string>lastPath</string>
|
||||||
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop</string>
|
<string>C:\Documents and Settings\Branislav Stojkovic\My Documents\Downloads</string>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>abnormalExit</string>
|
<string>abnormalExit</string>
|
||||||
@@ -31,6 +31,12 @@
|
|||||||
<blue>240</blue>
|
<blue>240</blue>
|
||||||
<alpha>240</alpha>
|
<alpha>240</alpha>
|
||||||
</gridColor>
|
</gridColor>
|
||||||
|
<outlineColor>
|
||||||
|
<red>0</red>
|
||||||
|
<green>0</green>
|
||||||
|
<blue>0</blue>
|
||||||
|
<alpha>255</alpha>
|
||||||
|
</outlineColor>
|
||||||
</org.diylc.core.Theme>
|
</org.diylc.core.Theme>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
@@ -45,6 +51,10 @@
|
|||||||
<string>hiQualityRender</string>
|
<string>hiQualityRender</string>
|
||||||
<boolean>false</boolean>
|
<boolean>false</boolean>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>outline</string>
|
||||||
|
<boolean>true</boolean>
|
||||||
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>exportGrid</string>
|
<string>exportGrid</string>
|
||||||
<boolean>true</boolean>
|
<boolean>true</boolean>
|
||||||
@@ -63,11 +73,11 @@
|
|||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>autoCreatePads</string>
|
<string>autoCreatePads</string>
|
||||||
<boolean>false</boolean>
|
<boolean>true</boolean>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>continuousCreation</string>
|
<string>continuousCreation</string>
|
||||||
<boolean>false</boolean>
|
<boolean>true</boolean>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>showTemplatesAtStartup</string>
|
<string>showTemplatesAtStartup</string>
|
||||||
|
|||||||
Binary file not shown.
+5
-1
@@ -32,5 +32,9 @@ public enum DrawOption {
|
|||||||
/**
|
/**
|
||||||
* Anti-aliasing is used when drawing.
|
* Anti-aliasing is used when drawing.
|
||||||
*/
|
*/
|
||||||
ANTIALIASING;
|
ANTIALIASING,
|
||||||
|
/**
|
||||||
|
* Draw components in outline mode.
|
||||||
|
*/
|
||||||
|
OUTLINE_MODE;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -43,6 +43,8 @@ public interface IPlugInPort {
|
|||||||
public static final String AUTO_EDIT_KEY = "autoEdit";
|
public static final String AUTO_EDIT_KEY = "autoEdit";
|
||||||
public static final String ABNORMAL_EXIT_KEY = "abnormalExit";
|
public static final String ABNORMAL_EXIT_KEY = "abnormalExit";
|
||||||
public static final String WHEEL_ZOOM_KEY = "wheelZoom";
|
public static final String WHEEL_ZOOM_KEY = "wheelZoom";
|
||||||
|
public static final String OUTLINE_KEY = "outline";
|
||||||
|
public static final String THEME_KEY = "theme";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns size of the canvas that takes project dimensions into account as
|
* Returns size of the canvas that takes project dimensions into account as
|
||||||
|
|||||||
+2
-2
@@ -63,8 +63,8 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
if (checkPointsClipped(g2d.getClip())) {
|
if (checkPointsClipped(g2d.getClip())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+83
-39
@@ -13,14 +13,19 @@ import java.awt.geom.Ellipse2D;
|
|||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
import org.diylc.common.Display;
|
import org.diylc.common.Display;
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.Theme;
|
||||||
import org.diylc.core.VisibilityPolicy;
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
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;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all leaded components such as resistors or capacitors. Has two
|
* Base class for all leaded components such as resistors or capacitors. Has two
|
||||||
@@ -45,7 +50,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
protected Color bodyColor = Color.white;
|
protected Color bodyColor = Color.white;
|
||||||
protected Color borderColor = Color.black;
|
protected Color borderColor = Color.black;
|
||||||
protected Color labelColor = LABEL_COLOR;
|
protected Color labelColor = LABEL_COLOR;
|
||||||
protected Display display = Display.NAME;
|
protected Display display = Display.VALUE;
|
||||||
|
|
||||||
protected AbstractLeadedComponent() {
|
protected AbstractLeadedComponent() {
|
||||||
super();
|
super();
|
||||||
@@ -60,8 +65,8 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
double distance = points[0].distance(points[1]);
|
double distance = points[0].distance(points[1]);
|
||||||
Shape shape = getBodyShape();
|
Shape shape = getBodyShape();
|
||||||
// If there's no body, just draw the line connecting the ending points.
|
// If there's no body, just draw the line connecting the ending points.
|
||||||
@@ -74,13 +79,32 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
int width = getClosestOdd(this.width.convertToPixels());
|
int width = getClosestOdd(this.width.convertToPixels());
|
||||||
Shape body = new Ellipse2D.Double(points[0].x - width / 2, points[0].y - width / 2,
|
Shape body = new Ellipse2D.Double(points[0].x - width / 2, points[0].y - width / 2,
|
||||||
width, width);
|
width, width);
|
||||||
g2d.setColor(bodyColor);
|
Composite oldComposite = g2d.getComposite();
|
||||||
|
if (alpha < MAX_ALPHA) {
|
||||||
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||||
|
/ MAX_ALPHA));
|
||||||
|
}
|
||||||
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
|
||||||
g2d.fill(body);
|
g2d.fill(body);
|
||||||
Color finalBorderColor = componentState == ComponentState.SELECTED
|
g2d.setComposite(oldComposite);
|
||||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor;
|
Color finalBorderColor;
|
||||||
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme
|
||||||
|
.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
|
: borderColor;
|
||||||
|
}
|
||||||
|
|
||||||
g2d.setColor(finalBorderColor);
|
g2d.setColor(finalBorderColor);
|
||||||
g2d.draw(body);
|
g2d.draw(body);
|
||||||
drawLead(g2d, componentState);
|
if (!outlineMode) {
|
||||||
|
drawLead(g2d, componentState);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Normal mode with component body in the center and two lead parts.
|
// Normal mode with component body in the center and two lead parts.
|
||||||
Rectangle shapeRect = shape.getBounds();
|
Rectangle shapeRect = shape.getBounds();
|
||||||
@@ -99,23 +123,42 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
}
|
}
|
||||||
if (bodyColor != null) {
|
if (bodyColor != null) {
|
||||||
if (bodyColor != null) {
|
if (bodyColor != null) {
|
||||||
g2d.setColor(bodyColor);
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
|
||||||
g2d.fill(shape);
|
g2d.fill(shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
decorateComponentBody(g2d);
|
decorateComponentBody(g2d, outlineMode);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
Color finalBorderColor = componentState == ComponentState.SELECTED
|
Color finalBorderColor;
|
||||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor;
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme
|
||||||
|
.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
|
: borderColor;
|
||||||
|
}
|
||||||
g2d.setColor(finalBorderColor);
|
g2d.setColor(finalBorderColor);
|
||||||
g2d.draw(shape);
|
g2d.draw(shape);
|
||||||
// Draw label.
|
// Draw label.
|
||||||
g2d.setFont(LABEL_FONT);
|
g2d.setFont(LABEL_FONT);
|
||||||
Color finalLabelFont = componentState == ComponentState.SELECTED
|
Color finalLabelColor;
|
||||||
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
if (outlineMode) {
|
||||||
: labelColor;
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
g2d.setColor(finalLabelFont);
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED : theme
|
||||||
|
.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
|
: labelColor;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalLabelColor);
|
||||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||||
String label = display == Display.NAME ? getName() : getValue().toString();
|
String label = display == Display.NAME ? getName() : getValue().toString();
|
||||||
// Adjust label angle if needed to make sure that it's readable.
|
// Adjust label angle if needed to make sure that it's readable.
|
||||||
@@ -128,30 +171,31 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
calculateLabelYCoordinate(shapeRect, textRect, fontMetrics));
|
calculateLabelYCoordinate(shapeRect, textRect, fontMetrics));
|
||||||
|
|
||||||
// Go back to the original transformation to draw leads.
|
// Go back to the original transformation to draw leads.
|
||||||
g2d.setTransform(oldTransform);
|
if (!outlineMode) {
|
||||||
int leadThickness = getClosestOdd(getLeadThickness());
|
g2d.setTransform(oldTransform);
|
||||||
double leadLength = (distance - shapeRect.width) / 2 - leadThickness / 2;
|
int leadThickness = getClosestOdd(getLeadThickness());
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(leadThickness));
|
double leadLength = (distance - shapeRect.width) / 2 - leadThickness / 2;
|
||||||
Color leadColor = shouldShadeLeads() ? getLeadColor(componentState).darker()
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(leadThickness));
|
||||||
: getLeadColor(componentState);
|
Color leadColor = shouldShadeLeads() ? getLeadColor(componentState).darker()
|
||||||
g2d.setColor(leadColor);
|
: getLeadColor(componentState);
|
||||||
int endX = (int) (points[0].x + Math.cos(theta) * leadLength);
|
|
||||||
int endY = (int) Math.round(points[0].y + Math.sin(theta) * leadLength);
|
|
||||||
g2d.drawLine(points[0].x, points[0].y, endX, endY);
|
|
||||||
endX = (int) (points[1].x + Math.cos(theta - Math.PI) * leadLength);
|
|
||||||
endY = (int) Math.round(points[1].y + Math.sin(theta - Math.PI) * leadLength);
|
|
||||||
g2d.drawLine(points[1].x, points[1].y, endX, endY);
|
|
||||||
if (shouldShadeLeads()) {
|
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(leadThickness - 2));
|
|
||||||
leadColor = getLeadColor(componentState);
|
|
||||||
g2d.setColor(leadColor);
|
g2d.setColor(leadColor);
|
||||||
g2d.drawLine(points[0].x, points[0].y, (int) (points[0].x + Math.cos(theta)
|
int endX = (int) (points[0].x + Math.cos(theta) * leadLength);
|
||||||
* leadLength), (int) (points[0].y + Math.sin(theta) * leadLength));
|
int endY = (int) Math.round(points[0].y + Math.sin(theta) * leadLength);
|
||||||
g2d
|
g2d.drawLine(points[0].x, points[0].y, endX, endY);
|
||||||
.drawLine(points[1].x, points[1].y, (int) (points[1].x + Math.cos(theta
|
endX = (int) (points[1].x + Math.cos(theta - Math.PI) * leadLength);
|
||||||
- Math.PI)
|
endY = (int) Math.round(points[1].y + Math.sin(theta - Math.PI) * leadLength);
|
||||||
* leadLength), (int) (points[1].y + Math.sin(theta - Math.PI)
|
g2d.drawLine(points[1].x, points[1].y, endX, endY);
|
||||||
* leadLength));
|
if (shouldShadeLeads()) {
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(leadThickness - 2));
|
||||||
|
leadColor = getLeadColor(componentState);
|
||||||
|
g2d.setColor(leadColor);
|
||||||
|
g2d.drawLine(points[0].x, points[0].y, (int) (points[0].x + Math.cos(theta)
|
||||||
|
* leadLength), (int) (points[0].y + Math.sin(theta) * leadLength));
|
||||||
|
g2d.drawLine(points[1].x, points[1].y, (int) (points[1].x + Math.cos(theta
|
||||||
|
- Math.PI)
|
||||||
|
* leadLength), (int) (points[1].y + Math.sin(theta - Math.PI)
|
||||||
|
* leadLength));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +214,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void decorateComponentBody(Graphics2D g2d) {
|
protected void decorateComponentBody(Graphics2D g2d, boolean outlineMode) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -103,10 +103,11 @@ public interface IDIYComponent<T> extends Serializable {
|
|||||||
*
|
*
|
||||||
* @param g2d
|
* @param g2d
|
||||||
* @param componentState
|
* @param componentState
|
||||||
|
* @param outlineMode
|
||||||
* @param project
|
* @param project
|
||||||
* @param drawingObserver
|
* @param drawingObserver
|
||||||
*/
|
*/
|
||||||
void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver);
|
IDrawingObserver drawingObserver);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+13
-1
@@ -10,12 +10,14 @@ public class Theme implements Serializable {
|
|||||||
private String name;
|
private String name;
|
||||||
private Color bgColor;
|
private Color bgColor;
|
||||||
private Color gridColor;
|
private Color gridColor;
|
||||||
|
private Color outlineColor;
|
||||||
|
|
||||||
public Theme(String name, Color bgColor, Color gridColor) {
|
public Theme(String name, Color bgColor, Color gridColor, Color outlineColor) {
|
||||||
super();
|
super();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.bgColor = bgColor;
|
this.bgColor = bgColor;
|
||||||
this.gridColor = gridColor;
|
this.gridColor = gridColor;
|
||||||
|
this.outlineColor = outlineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -30,12 +32,17 @@ public class Theme implements Serializable {
|
|||||||
return gridColor;
|
return gridColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Color getOutlineColor() {
|
||||||
|
return outlineColor;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((bgColor == null) ? 0 : bgColor.hashCode());
|
result = prime * result + ((bgColor == null) ? 0 : bgColor.hashCode());
|
||||||
result = prime * result + ((gridColor == null) ? 0 : gridColor.hashCode());
|
result = prime * result + ((gridColor == null) ? 0 : gridColor.hashCode());
|
||||||
|
result = prime * result + ((outlineColor == null) ? 0 : outlineColor.hashCode());
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -59,6 +66,11 @@ public class Theme implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
} else if (!gridColor.equals(other.gridColor))
|
} else if (!gridColor.equals(other.gridColor))
|
||||||
return false;
|
return false;
|
||||||
|
if (outlineColor == null) {
|
||||||
|
if (other.outlineColor != null)
|
||||||
|
return false;
|
||||||
|
} else if (!outlineColor.equals(other.outlineColor))
|
||||||
|
return false;
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
if (other.name != null)
|
if (other.name != null)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+10
-13
@@ -46,14 +46,14 @@ public class DrawingManager {
|
|||||||
public static int CONTROL_POINT_SIZE = 7;
|
public static int CONTROL_POINT_SIZE = 7;
|
||||||
|
|
||||||
public static final String ZOOM_KEY = "zoom";
|
public static final String ZOOM_KEY = "zoom";
|
||||||
public static final String THEME_KEY = "theme";
|
|
||||||
public static String DEBUG_COMPONENT_AREAS = "org.diylc.debugComponentAreas";
|
public static String DEBUG_COMPONENT_AREAS = "org.diylc.debugComponentAreas";
|
||||||
|
|
||||||
public static Color GRID_COLOR = new Color(240, 240, 240);
|
public static Color CONTROL_POINT_COLOR = Color.blue;
|
||||||
public static Color CONTROL_POINT_COLOR = Color.black;
|
|
||||||
public static Color SELECTED_CONTROL_POINT_COLOR = Color.green;
|
public static Color SELECTED_CONTROL_POINT_COLOR = Color.green;
|
||||||
|
|
||||||
private Theme theme = new Theme("Light", Constants.CANVAS_COLOR, GRID_COLOR);
|
private Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
|
||||||
// Keeps Area object of each drawn component.
|
// Keeps Area object of each drawn component.
|
||||||
private Map<IDIYComponent<?>, Area> componentAreaMap;
|
private Map<IDIYComponent<?>, Area> componentAreaMap;
|
||||||
@@ -80,10 +80,6 @@ public class DrawingManager {
|
|||||||
String debugComponentAreasStr = System.getProperty(DEBUG_COMPONENT_AREAS);
|
String debugComponentAreasStr = System.getProperty(DEBUG_COMPONENT_AREAS);
|
||||||
debugComponentAreas = debugComponentAreasStr != null
|
debugComponentAreas = debugComponentAreasStr != null
|
||||||
&& debugComponentAreasStr.equalsIgnoreCase("true");
|
&& debugComponentAreasStr.equalsIgnoreCase("true");
|
||||||
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(THEME_KEY, null);
|
|
||||||
if (theme != null) {
|
|
||||||
this.theme = theme;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,7 +216,8 @@ public class DrawingManager {
|
|||||||
}
|
}
|
||||||
// Draw the component through the g2dWrapper.
|
// Draw the component through the g2dWrapper.
|
||||||
try {
|
try {
|
||||||
component.draw(g2dWrapper, state, project, g2dWrapper);
|
component.draw(g2dWrapper, state, drawOptions.contains(DrawOption.OUTLINE_MODE),
|
||||||
|
project, g2dWrapper);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error drawing " + component.getName(), e);
|
LOG.error("Error drawing " + component.getName(), e);
|
||||||
failedComponents.add(component);
|
failedComponents.add(component);
|
||||||
@@ -235,7 +232,7 @@ public class DrawingManager {
|
|||||||
// Draw control points.
|
// Draw control points.
|
||||||
if (drawOptions.contains(DrawOption.CONTROL_POINTS)) {
|
if (drawOptions.contains(DrawOption.CONTROL_POINTS)) {
|
||||||
// Draw unselected points first to make sure they are below.
|
// Draw unselected points first to make sure they are below.
|
||||||
if (dragInProgress) {
|
if (dragInProgress || drawOptions.contains(DrawOption.OUTLINE_MODE)) {
|
||||||
for (IDIYComponent<?> component : project.getComponents()) {
|
for (IDIYComponent<?> component : project.getComponents()) {
|
||||||
for (int i = 0; i < component.getControlPointCount(); i++) {
|
for (int i = 0; i < component.getControlPointCount(); i++) {
|
||||||
VisibilityPolicy visibilityPolicy = component
|
VisibilityPolicy visibilityPolicy = component
|
||||||
@@ -247,7 +244,6 @@ public class DrawingManager {
|
|||||||
&& !selectedComponents.contains(component) && component
|
&& !selectedComponents.contains(component) && component
|
||||||
.getControlPointVisibilityPolicy(i) == VisibilityPolicy.ALWAYS))) {
|
.getControlPointVisibilityPolicy(i) == VisibilityPolicy.ALWAYS))) {
|
||||||
g2dWrapper.setColor(CONTROL_POINT_COLOR);
|
g2dWrapper.setColor(CONTROL_POINT_COLOR);
|
||||||
|
|
||||||
Point controlPoint = component.getControlPoint(i);
|
Point controlPoint = component.getControlPoint(i);
|
||||||
int pointSize = CONTROL_POINT_SIZE - 2;
|
int pointSize = CONTROL_POINT_SIZE - 2;
|
||||||
g2dWrapper.fillOval(controlPoint.x - pointSize / 2, controlPoint.y
|
g2dWrapper.fillOval(controlPoint.x - pointSize / 2, controlPoint.y
|
||||||
@@ -283,7 +279,8 @@ public class DrawingManager {
|
|||||||
g2dWrapper.startedDrawingComponent();
|
g2dWrapper.startedDrawingComponent();
|
||||||
g2dWrapper.setComposite(slotComposite);
|
g2dWrapper.setComposite(slotComposite);
|
||||||
try {
|
try {
|
||||||
componentSlot.draw(g2dWrapper, ComponentState.NORMAL, project, g2dWrapper);
|
componentSlot.draw(g2dWrapper, ComponentState.NORMAL, drawOptions
|
||||||
|
.contains(DrawOption.OUTLINE_MODE), project, g2dWrapper);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error drawing " + componentSlot.getName(), e);
|
LOG.error("Error drawing " + componentSlot.getName(), e);
|
||||||
failedComponents.add(componentSlot);
|
failedComponents.add(componentSlot);
|
||||||
@@ -393,7 +390,7 @@ public class DrawingManager {
|
|||||||
|
|
||||||
public void setTheme(Theme theme) {
|
public void setTheme(Theme theme) {
|
||||||
this.theme = theme;
|
this.theme = theme;
|
||||||
ConfigurationManager.getInstance().writeValue(THEME_KEY, theme);
|
ConfigurationManager.getInstance().writeValue(IPlugInPort.THEME_KEY, theme);
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-6
@@ -800,7 +800,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
for (int j = i + 1; j < controlPoints.length; j++) {
|
for (int j = i + 1; j < controlPoints.length; j++) {
|
||||||
if (controlPoints[i] != null && controlPoints[j] != null
|
if (controlPoints[i] != null && controlPoints[j] != null
|
||||||
&& controlPoints[i].equals(controlPoints[j])) {
|
&& controlPoints[i].equals(controlPoints[j])) {
|
||||||
// Control points collision detected, cannot make this move.
|
// Control points collision detected, cannot make
|
||||||
|
// this move.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1171,13 +1172,25 @@ public class Presenter implements IPlugInPort {
|
|||||||
currentProject.getComponents().add(component);
|
currentProject.getComponents().add(component);
|
||||||
}
|
}
|
||||||
if (canCreatePads
|
if (canCreatePads
|
||||||
&& ConfigurationManager.getInstance().readBoolean(IPlugInPort.AUTO_PADS_KEY, false)) {
|
&& ConfigurationManager.getInstance().readBoolean(IPlugInPort.AUTO_PADS_KEY, false)
|
||||||
|
&& !(component instanceof SolderPad)) {
|
||||||
|
ComponentType padType = ComponentProcessor.getInstance().extractComponentTypeFrom(
|
||||||
|
SolderPad.class);
|
||||||
for (int i = 0; i < component.getControlPointCount(); i++) {
|
for (int i = 0; i < component.getControlPointCount(); i++) {
|
||||||
if (component.isControlPointSticky(i)) {
|
if (component.isControlPointSticky(i)) {
|
||||||
SolderPad pad = new SolderPad();
|
try {
|
||||||
pad.setControlPoint(component.getControlPoint(i), 0);
|
IDIYComponent<?> pad = instantiationManager.instantiateComponent(padType,
|
||||||
addComponent(pad, ComponentProcessor.getInstance().extractComponentTypeFrom(
|
component.getControlPoint(i), currentProject);
|
||||||
SolderPad.class), false);
|
pad.setControlPoint(component.getControlPoint(i), 0);
|
||||||
|
addComponent(pad, padType, false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.warn("Could not auto-create solder pad", e);
|
||||||
|
}
|
||||||
|
// SolderPad pad = new SolderPad();
|
||||||
|
// pad.setControlPoint(component.getControlPoint(i), 0);
|
||||||
|
// addComponent(pad,
|
||||||
|
// ComponentProcessor.getInstance().extractComponentTypeFrom(
|
||||||
|
// SolderPad.class), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-8
@@ -21,6 +21,7 @@ import java.awt.event.MouseAdapter;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.image.VolatileImage;
|
import java.awt.image.VolatileImage;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
@@ -47,11 +48,11 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
|
|
||||||
private static boolean USE_HARDWARE_ACCELLERATION = false;
|
private static boolean USE_HARDWARE_ACCELLERATION = false;
|
||||||
|
|
||||||
static final EnumSet<DrawOption> DRAW_OPTIONS = EnumSet.of(DrawOption.GRID,
|
// static final EnumSet<DrawOption> DRAW_OPTIONS = EnumSet.of(DrawOption.GRID,
|
||||||
DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.CONTROL_POINTS);
|
// DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.CONTROL_POINTS);
|
||||||
static final EnumSet<DrawOption> DRAW_OPTIONS_ANTI_ALIASING = EnumSet.of(DrawOption.GRID,
|
// static final EnumSet<DrawOption> DRAW_OPTIONS_ANTI_ALIASING = EnumSet.of(DrawOption.GRID,
|
||||||
DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.ANTIALIASING,
|
// DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.ANTIALIASING,
|
||||||
DrawOption.CONTROL_POINTS);
|
// DrawOption.CONTROL_POINTS);
|
||||||
|
|
||||||
public CanvasPanel(IPlugInPort plugInPort) {
|
public CanvasPanel(IPlugInPort plugInPort) {
|
||||||
super();
|
super();
|
||||||
@@ -114,9 +115,15 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
}
|
}
|
||||||
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
||||||
g2d.setClip(getVisibleRect());
|
g2d.setClip(getVisibleRect());
|
||||||
plugInPort.draw(g2d, ConfigurationManager.getInstance().readBoolean(
|
Set<DrawOption> drawOptions = EnumSet.of(DrawOption.GRID, DrawOption.SELECTION,
|
||||||
IPlugInPort.ANTI_ALIASING_KEY, true) ? DRAW_OPTIONS_ANTI_ALIASING : DRAW_OPTIONS,
|
DrawOption.ZOOM, DrawOption.CONTROL_POINTS);
|
||||||
null);
|
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.ANTI_ALIASING_KEY, true)) {
|
||||||
|
drawOptions.add(DrawOption.ANTIALIASING);
|
||||||
|
}
|
||||||
|
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.OUTLINE_KEY, false)) {
|
||||||
|
drawOptions.add(DrawOption.OUTLINE_MODE);
|
||||||
|
}
|
||||||
|
plugInPort.draw(g2d, drawOptions, null);
|
||||||
if (USE_HARDWARE_ACCELLERATION) {
|
if (USE_HARDWARE_ACCELLERATION) {
|
||||||
VolatileImage volatileImage = (VolatileImage) bufferImage;
|
VolatileImage volatileImage = (VolatileImage) bufferImage;
|
||||||
do {
|
do {
|
||||||
|
|||||||
+2
@@ -52,6 +52,8 @@ public class ConfigPlugin implements IPlugIn {
|
|||||||
"Hi-Quality Rendering", IPlugInPort.HI_QUALITY_RENDER_KEY, false), CONFIG_MENU);
|
"Hi-Quality Rendering", IPlugInPort.HI_QUALITY_RENDER_KEY, false), CONFIG_MENU);
|
||||||
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
||||||
"Mouse Wheel Zoom", IPlugInPort.WHEEL_ZOOM_KEY, false), CONFIG_MENU);
|
"Mouse Wheel Zoom", IPlugInPort.WHEEL_ZOOM_KEY, false), CONFIG_MENU);
|
||||||
|
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
||||||
|
"Outline Mode", IPlugInPort.OUTLINE_KEY, false), CONFIG_MENU);
|
||||||
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
||||||
"Snap to Grid", IPlugInPort.SNAP_TO_GRID_KEY, true), CONFIG_MENU);
|
"Snap to Grid", IPlugInPort.SNAP_TO_GRID_KEY, true), CONFIG_MENU);
|
||||||
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
||||||
|
|||||||
+7
-4
@@ -33,16 +33,19 @@ public class ProjectDrawingProvider implements IDrawingProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics g) {
|
public void draw(Graphics g) {
|
||||||
EnumSet<DrawOption> options = EnumSet.of(DrawOption.ANTIALIASING);
|
EnumSet<DrawOption> drawOptions = EnumSet.of(DrawOption.ANTIALIASING);
|
||||||
if (useZoom) {
|
if (useZoom) {
|
||||||
options.add(DrawOption.ZOOM);
|
drawOptions.add(DrawOption.ZOOM);
|
||||||
}
|
}
|
||||||
if (showGridWhenNeeded
|
if (showGridWhenNeeded
|
||||||
&& ConfigurationManager.getInstance().readBoolean(IPlugInPort.EXPORT_GRID_KEY,
|
&& ConfigurationManager.getInstance().readBoolean(IPlugInPort.EXPORT_GRID_KEY,
|
||||||
false)) {
|
false)) {
|
||||||
options.add(DrawOption.GRID);
|
drawOptions.add(DrawOption.GRID);
|
||||||
}
|
}
|
||||||
plugInPort.draw((Graphics2D) g, options, null);
|
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.OUTLINE_KEY, false)) {
|
||||||
|
drawOptions.add(DrawOption.OUTLINE_MODE);
|
||||||
|
}
|
||||||
|
plugInPort.draw((Graphics2D) g, drawOptions, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+7
@@ -5,6 +5,8 @@ import java.awt.Color;
|
|||||||
import java.awt.Stroke;
|
import java.awt.Stroke;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
|
|
||||||
|
import org.diylc.core.Theme;
|
||||||
|
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
public static final int PIXELS_PER_INCH = 200;
|
public static final int PIXELS_PER_INCH = 200;
|
||||||
@@ -15,4 +17,9 @@ public class Constants {
|
|||||||
|
|
||||||
public static final Stroke DASHED_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
|
public static final Stroke DASHED_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
|
||||||
BasicStroke.JOIN_MITER, 10f, new float[] { 2.0f }, 0.0f);
|
BasicStroke.JOIN_MITER, 10f, new float[] { 2.0f }, 0.0f);
|
||||||
|
|
||||||
|
public static final Theme DEFAULT_THEME = new Theme("Light", Constants.CANVAS_COLOR, new Color(
|
||||||
|
240, 240, 240), Color.black);
|
||||||
|
|
||||||
|
public static final Color TRANSPARENT_COLOR = new Color(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -133,8 +133,8 @@ public class MockDIYComponent implements IDIYComponent<Capacitance> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
g2d.setColor(componentState.equals(ComponentState.SELECTED) ? color : color.darker());
|
g2d.setColor(componentState.equals(ComponentState.SELECTED) ? color : color.darker());
|
||||||
g2d.fillRect(leftTopCorner.x, leftTopCorner.y, 200, 50);
|
g2d.fillRect(leftTopCorner.x, leftTopCorner.y, 200, 50);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,4 +12,10 @@
|
|||||||
<blue>193</blue>
|
<blue>193</blue>
|
||||||
<alpha>255</alpha>
|
<alpha>255</alpha>
|
||||||
</gridColor>
|
</gridColor>
|
||||||
|
<outlineColor>
|
||||||
|
<red>255</red>
|
||||||
|
<green>255</green>
|
||||||
|
<blue>255</blue>
|
||||||
|
<alpha>255</alpha>
|
||||||
|
</outlineColor>
|
||||||
</org.diylc.core.Theme>
|
</org.diylc.core.Theme>
|
||||||
@@ -12,4 +12,10 @@
|
|||||||
<blue>40</blue>
|
<blue>40</blue>
|
||||||
<alpha>255</alpha>
|
<alpha>255</alpha>
|
||||||
</gridColor>
|
</gridColor>
|
||||||
|
<outlineColor>
|
||||||
|
<red>255</red>
|
||||||
|
<green>255</green>
|
||||||
|
<blue>255</blue>
|
||||||
|
<alpha>255</alpha>
|
||||||
|
</outlineColor>
|
||||||
</org.diylc.core.Theme>
|
</org.diylc.core.Theme>
|
||||||
@@ -1,15 +1,21 @@
|
|||||||
<org.diylc.core.Theme>
|
<org.diylc.core.Theme>
|
||||||
<name>Light</name>
|
<name>Light</name>
|
||||||
<bgColor>
|
<bgColor>
|
||||||
<red>255</red>
|
<red>255</red>
|
||||||
<green>255</green>
|
<green>255</green>
|
||||||
<blue>255</blue>
|
<blue>255</blue>
|
||||||
<alpha>255</alpha>
|
<alpha>255</alpha>
|
||||||
</bgColor>
|
</bgColor>
|
||||||
<gridColor>
|
<gridColor>
|
||||||
<red>240</red>
|
<red>240</red>
|
||||||
<green>240</green>
|
<green>240</green>
|
||||||
<blue>240</blue>
|
<blue>240</blue>
|
||||||
<alpha>240</alpha>
|
<alpha>240</alpha>
|
||||||
</gridColor>
|
</gridColor>
|
||||||
|
<outlineColor>
|
||||||
|
<red>0</red>
|
||||||
|
<green>0</green>
|
||||||
|
<blue>0</blue>
|
||||||
|
<alpha>255</alpha>
|
||||||
|
</outlineColor>
|
||||||
</org.diylc.core.Theme>
|
</org.diylc.core.Theme>
|
||||||
@@ -309,5 +309,29 @@
|
|||||||
</changes>
|
</changes>
|
||||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||||
</com.diyfever.gui.update.Version>
|
</com.diyfever.gui.update.Version>
|
||||||
|
<com.diyfever.gui.update.Version>
|
||||||
|
<versionNumber>
|
||||||
|
<major>3</major>
|
||||||
|
<minor>0</minor>
|
||||||
|
<build>9</build>
|
||||||
|
</versionNumber>
|
||||||
|
<releaseDate>2011-03-03 20:00:00.000 CET</releaseDate>
|
||||||
|
<name></name>
|
||||||
|
<changes>
|
||||||
|
<com.diyfever.gui.update.Change>
|
||||||
|
<changeType>BUG_FIX</changeType>
|
||||||
|
<description>Auto-created solder pads aren't assigned with default settings and name</description>
|
||||||
|
</com.diyfever.gui.update.Change>
|
||||||
|
<com.diyfever.gui.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description></description>
|
||||||
|
</com.diyfever.gui.update.Change>
|
||||||
|
<com.diyfever.gui.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Outline mode that resembles PCB silkscreen</description>
|
||||||
|
</com.diyfever.gui.update.Change>
|
||||||
|
</changes>
|
||||||
|
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||||
|
</com.diyfever.gui.update.Version>
|
||||||
</a>
|
</a>
|
||||||
</java.util.Arrays_-ArrayList>
|
</java.util.Arrays_-ArrayList>
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="lib" path="lib/xstream-1.3.1.jar"/>
|
<classpathentry kind="lib" path="lib/xstream-1.3.1.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
|
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/bancika-gui-framework.jar"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/DIYLC"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/DIYLC"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
+5
-2
@@ -5,8 +5,8 @@ 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.Shape;
|
|
||||||
|
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
@@ -17,6 +17,9 @@ import org.diylc.core.VisibilityPolicy;
|
|||||||
import org.diylc.core.annotations.EditableProperty;
|
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;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
|
|
||||||
public abstract class AbstractBoard extends AbstractTransparentComponent<String> {
|
public abstract class AbstractBoard extends AbstractTransparentComponent<String> {
|
||||||
|
|
||||||
@@ -38,7 +41,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
protected Color borderColor = BORDER_COLOR;
|
protected Color borderColor = BORDER_COLOR;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
if (componentState != ComponentState.DRAGGING) {
|
if (componentState != ComponentState.DRAGGING) {
|
||||||
|
|||||||
+3
-3
@@ -41,14 +41,14 @@ public class EyeletBoard extends AbstractBoard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.draw(g2d, componentState, project, drawingObserver);
|
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||||
if (componentState != ComponentState.DRAGGING) {
|
if (componentState != ComponentState.DRAGGING) {
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||||
|
|||||||
+3
-3
@@ -37,14 +37,14 @@ public class MarshallPerfBoard extends AbstractBoard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.draw(g2d, componentState, project, drawingObserver);
|
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||||
if (componentState != ComponentState.DRAGGING) {
|
if (componentState != ComponentState.DRAGGING) {
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||||
|
|||||||
+3
-3
@@ -33,14 +33,14 @@ public class PerfBoard extends AbstractBoard {
|
|||||||
protected Color padColor = COPPER_COLOR;
|
protected Color padColor = COPPER_COLOR;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.draw(g2d, componentState, project, drawingObserver);
|
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||||
if (componentState != ComponentState.DRAGGING) {
|
if (componentState != ComponentState.DRAGGING) {
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||||
|
|||||||
+3
-3
@@ -35,14 +35,14 @@ public class VeroBoard extends AbstractBoard {
|
|||||||
protected OrientationHV orientation = OrientationHV.HORIZONTAL;
|
protected OrientationHV orientation = OrientationHV.HORIZONTAL;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.draw(g2d, componentState, project, drawingObserver);
|
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||||
if (componentState != ComponentState.DRAGGING) {
|
if (componentState != ComponentState.DRAGGING) {
|
||||||
Composite oldComposite = g2d.getComposite();
|
Composite oldComposite = g2d.getComposite();
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
|
|||||||
+2
-3
@@ -9,7 +9,6 @@ import org.diylc.core.ComponentState;
|
|||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
import org.diylc.core.Theme;
|
|
||||||
import org.diylc.core.VisibilityPolicy;
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
@@ -33,8 +32,8 @@ public class Eyelet extends AbstractComponent<String> {
|
|||||||
private String value = "";
|
private String value = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
if (checkPointsClipped(g2d.getClip())) {
|
if (checkPointsClipped(g2d.getClip())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -32,8 +32,8 @@ public class SolderPad extends AbstractComponent<Void> {
|
|||||||
private Type type = Type.ROUND;
|
private Type type = Type.ROUND;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
if (checkPointsClipped(g2d.getClip())) {
|
if (checkPointsClipped(g2d.getClip())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -33,8 +33,8 @@ public class TraceCut extends AbstractComponent<Void> {
|
|||||||
protected Point point = new Point(0, 0);
|
protected Point point = new Point(0, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
if (checkPointsClipped(g2d.getClip())) {
|
if (checkPointsClipped(g2d.getClip())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-14
@@ -8,6 +8,7 @@ import java.awt.Point;
|
|||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
@@ -20,6 +21,9 @@ import org.diylc.core.annotations.ComponentDescriptor;
|
|||||||
import org.diylc.core.annotations.EditableProperty;
|
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;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Mini Toggle Switch", category = "Electromechanical", author = "Branislav Stojkovic", description = "Panel mounted mini toggle switch", stretchable = false, zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "SW")
|
@ComponentDescriptor(name = "Mini Toggle Switch", category = "Electromechanical", author = "Branislav Stojkovic", description = "Panel mounted mini toggle switch", stretchable = false, zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "SW")
|
||||||
public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchType> {
|
public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchType> {
|
||||||
@@ -166,8 +170,8 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
if (checkPointsClipped(g2d.getClip())) {
|
if (checkPointsClipped(g2d.getClip())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -179,27 +183,40 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||||
/ MAX_ALPHA));
|
/ MAX_ALPHA));
|
||||||
}
|
}
|
||||||
g2d.setColor(BODY_COLOR);
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : BODY_COLOR);
|
||||||
g2d.fill(body);
|
g2d.fill(body);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED
|
Color finalBorderColor;
|
||||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : BORDER_COLOR);
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme
|
||||||
|
.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
|
: BORDER_COLOR;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalBorderColor);
|
||||||
g2d.draw(body);
|
g2d.draw(body);
|
||||||
}
|
}
|
||||||
// Do not track these changes because the whole switch has been tracked
|
// Do not track these changes because the whole switch has been tracked
|
||||||
// so far.
|
// so far.
|
||||||
drawingObserver.stopTracking();
|
drawingObserver.stopTracking();
|
||||||
// Draw lugs.
|
// Draw lugs.
|
||||||
int circleDiameter = getClosestOdd((int) CIRCLE_SIZE.convertToPixels());
|
if (!outlineMode) {
|
||||||
int lugWidth = getClosestOdd((int) LUG_WIDTH.convertToPixels());
|
int circleDiameter = getClosestOdd((int) CIRCLE_SIZE.convertToPixels());
|
||||||
int lugHeight = getClosestOdd((int) LUG_HEIGHT.convertToPixels());
|
int lugWidth = getClosestOdd((int) LUG_WIDTH.convertToPixels());
|
||||||
for (Point p : controlPoints) {
|
int lugHeight = getClosestOdd((int) LUG_HEIGHT.convertToPixels());
|
||||||
g2d.setColor(CIRCLE_COLOR);
|
for (Point p : controlPoints) {
|
||||||
g2d.fillOval(p.x - circleDiameter / 2, p.y - circleDiameter / 2, circleDiameter,
|
g2d.setColor(CIRCLE_COLOR);
|
||||||
circleDiameter);
|
g2d.fillOval(p.x - circleDiameter / 2, p.y - circleDiameter / 2, circleDiameter,
|
||||||
g2d.setColor(LUG_COLOR);
|
circleDiameter);
|
||||||
g2d.fillRect(p.x - lugWidth / 2, p.y - lugHeight / 2, lugWidth, lugHeight);
|
g2d.setColor(LUG_COLOR);
|
||||||
|
g2d.fillRect(p.x - lugWidth / 2, p.y - lugHeight / 2, lugWidth, lugHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -14,7 +14,6 @@ import org.diylc.core.ComponentState;
|
|||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
import org.diylc.core.Theme;
|
|
||||||
import org.diylc.core.VisibilityPolicy;
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
@@ -37,8 +36,8 @@ public class BOM extends AbstractComponent<Void> {
|
|||||||
private Point point = new Point(0, 0);
|
private Point point = new Point(0, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
List<BomEntry> bom = BomMaker.getInstance().createBom(project.getComponents());
|
List<BomEntry> bom = BomMaker.getInstance().createBom(project.getComponents());
|
||||||
// Cleanup entries that do not have a value set.
|
// Cleanup entries that do not have a value set.
|
||||||
Iterator<BomEntry> iterator = bom.iterator();
|
Iterator<BomEntry> iterator = bom.iterator();
|
||||||
|
|||||||
+2
-3
@@ -13,7 +13,6 @@ import org.diylc.core.ComponentState;
|
|||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
import org.diylc.core.Theme;
|
|
||||||
import org.diylc.core.VisibilityPolicy;
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
@@ -42,8 +41,8 @@ public class Image extends AbstractTransparentComponent<Void> {
|
|||||||
private byte scale = 50;
|
private byte scale = 50;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
double s = 1d * scale / DEFAULT_SCALE;
|
double s = 1d * scale / DEFAULT_SCALE;
|
||||||
Point endPoint = new Point((int) (image.getIconWidth() * s),
|
Point endPoint = new Point((int) (image.getIconWidth() * s),
|
||||||
(int) (image.getIconHeight() * s));
|
(int) (image.getIconHeight() * s));
|
||||||
|
|||||||
+2
-2
@@ -30,8 +30,8 @@ public class Label extends AbstractComponent<Void> {
|
|||||||
private boolean center = true;
|
private boolean center = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED ? LABEL_COLOR_SELECTED : color);
|
g2d.setColor(componentState == ComponentState.SELECTED ? LABEL_COLOR_SELECTED : color);
|
||||||
g2d.setFont(font);
|
g2d.setFont(font);
|
||||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||||
|
|||||||
+20
-7
@@ -5,6 +5,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.components.AbstractLeadedComponent;
|
import org.diylc.components.AbstractLeadedComponent;
|
||||||
import org.diylc.core.CreationMethod;
|
import org.diylc.core.CreationMethod;
|
||||||
@@ -16,6 +17,9 @@ import org.diylc.core.measures.Capacitance;
|
|||||||
import org.diylc.core.measures.CapacitanceUnit;
|
import org.diylc.core.measures.CapacitanceUnit;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Electrolytic Capacitor (axial)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Axial electrolytic capacitor, similar to Sprague Atom, F&T, etc", zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Electrolytic Capacitor (axial)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Axial electrolytic capacitor, similar to Sprague Atom, F&T, etc", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class AxialElectrolyticCapacitor extends AbstractLeadedComponent<Capacitance> {
|
public class AxialElectrolyticCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||||
@@ -118,15 +122,24 @@ public class AxialElectrolyticCapacitor extends AbstractLeadedComponent<Capacita
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decorateComponentBody(Graphics2D g2d) {
|
protected void decorateComponentBody(Graphics2D g2d, boolean outlineMode) {
|
||||||
if (polarized) {
|
if (polarized) {
|
||||||
int markerLength = (int) (getLength().convertToPixels() * 0.2);
|
|
||||||
g2d.setColor(markerColor);
|
|
||||||
int width = getClosestOdd(getWidth().convertToPixels());
|
int width = getClosestOdd(getWidth().convertToPixels());
|
||||||
g2d
|
int markerLength = (int) (getLength().convertToPixels() * 0.2);
|
||||||
.fillRect((int) getLength().convertToPixels() - markerLength, 0, markerLength,
|
if (!outlineMode) {
|
||||||
width);
|
g2d.setColor(markerColor);
|
||||||
g2d.setColor(tickColor);
|
g2d.fillRect((int) getLength().convertToPixels() - markerLength, 0, markerLength,
|
||||||
|
width);
|
||||||
|
}
|
||||||
|
Color finalTickColor;
|
||||||
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalTickColor = theme.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalTickColor = tickColor;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalTickColor);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
||||||
g2d.drawLine((int) getLength().convertToPixels() - markerLength / 2,
|
g2d.drawLine((int) getLength().convertToPixels() - markerLength / 2,
|
||||||
(int) (width / 2 - width * 0.15), (int) getLength().convertToPixels()
|
(int) (width / 2 - width * 0.15), (int) getLength().convertToPixels()
|
||||||
|
|||||||
+1
-1
@@ -87,7 +87,7 @@ public class CapacitorSymbol extends AbstractSchematicLeadedSymbol<Capacitance>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decorateComponentBody(Graphics2D g2d) {
|
protected void decorateComponentBody(Graphics2D g2d, boolean outlineMode) {
|
||||||
if (polarized) {
|
if (polarized) {
|
||||||
// Draw + sign.
|
// Draw + sign.
|
||||||
g2d.setColor(getBorderColor());
|
g2d.setColor(getBorderColor());
|
||||||
|
|||||||
+2
-2
@@ -159,8 +159,8 @@ public class PotentiometerPanel extends AbstractPotentiometer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
for (Area shape : getBody()) {
|
for (Area shape : getBody()) {
|
||||||
if (shape != null) {
|
if (shape != null) {
|
||||||
|
|||||||
+21
-8
@@ -7,6 +7,7 @@ import java.awt.geom.Area;
|
|||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.components.AbstractLeadedComponent;
|
import org.diylc.components.AbstractLeadedComponent;
|
||||||
import org.diylc.core.CreationMethod;
|
import org.diylc.core.CreationMethod;
|
||||||
@@ -18,6 +19,9 @@ import org.diylc.core.measures.Capacitance;
|
|||||||
import org.diylc.core.measures.CapacitanceUnit;
|
import org.diylc.core.measures.CapacitanceUnit;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Electrolytic Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Vertical mounted electrolytic capacitor, polarized or bipolar", zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Electrolytic Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Vertical mounted electrolytic capacitor, polarized or bipolar", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
|
public class RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
|
||||||
@@ -86,16 +90,25 @@ public class RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decorateComponentBody(Graphics2D g2d) {
|
protected void decorateComponentBody(Graphics2D g2d, boolean outlineMode) {
|
||||||
if (polarized) {
|
if (polarized) {
|
||||||
int totalDiameter = getClosestOdd(getLength().convertToPixels());
|
int totalDiameter = getClosestOdd(getLength().convertToPixels());
|
||||||
Area area = new Area(getBodyShape());
|
if (!outlineMode) {
|
||||||
area
|
Area area = new Area(getBodyShape());
|
||||||
.subtract(new Area(new Rectangle2D.Double(0, 0, totalDiameter * 0.8,
|
area.subtract(new Area(new Rectangle2D.Double(0, 0, totalDiameter * 0.8,
|
||||||
totalDiameter)));
|
totalDiameter)));
|
||||||
g2d.setColor(markerColor);
|
g2d.setColor(markerColor);
|
||||||
g2d.fill(area);
|
g2d.fill(area);
|
||||||
g2d.setColor(tickColor);
|
}
|
||||||
|
Color finalTickColor;
|
||||||
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalTickColor = theme.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalTickColor = tickColor;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalTickColor);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
||||||
g2d.drawLine((int) (totalDiameter * 0.9), totalDiameter / 2
|
g2d.drawLine((int) (totalDiameter * 0.9), totalDiameter / 2
|
||||||
- (int) (totalDiameter * 0.05), (int) (totalDiameter * 0.9), totalDiameter / 2
|
- (int) (totalDiameter * 0.05), (int) (totalDiameter * 0.9), totalDiameter / 2
|
||||||
|
|||||||
+2
-2
@@ -104,9 +104,9 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decorateComponentBody(Graphics2D g2d) {
|
protected void decorateComponentBody(Graphics2D g2d, boolean outlineMode) {
|
||||||
// int width = getWidth().convertToPixels();
|
// int width = getWidth().convertToPixels();
|
||||||
if (colorCode == ResistorColorCode.NONE) {
|
if (colorCode == ResistorColorCode.NONE || outlineMode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int height = getClosestOdd(getWidth().convertToPixels());
|
int height = getClosestOdd(getWidth().convertToPixels());
|
||||||
|
|||||||
+2
-2
@@ -241,8 +241,8 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
if (checkPointsClipped(g2d.getClip())) {
|
if (checkPointsClipped(g2d.getClip())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+52
-16
@@ -12,6 +12,7 @@ import java.awt.geom.Ellipse2D;
|
|||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
@@ -19,11 +20,15 @@ import org.diylc.core.ComponentState;
|
|||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.Theme;
|
||||||
import org.diylc.core.VisibilityPolicy;
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
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;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "DIL IC", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "IC", description = "IC with rectangular housing and two parallel rows of pins", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "DIL IC", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "IC", description = "IC with rectangular housing and two parallel rows of pins", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
||||||
public class DIL_IC extends AbstractTransparentComponent<String> {
|
public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||||
@@ -248,38 +253,69 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
if (checkPointsClipped(g2d.getClip())) {
|
if (checkPointsClipped(g2d.getClip())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
|
|
||||||
Area mainArea = getBody()[0];
|
Area mainArea = getBody()[0];
|
||||||
for (Point point : controlPoints) {
|
if (!outlineMode) {
|
||||||
g2d.setColor(PIN_COLOR);
|
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
|
||||||
g2d.fillRect(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
for (Point point : controlPoints) {
|
||||||
g2d.setColor(PIN_BORDER_COLOR);
|
g2d.setColor(PIN_COLOR);
|
||||||
g2d.drawRect(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
g2d.fillRect(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||||
|
g2d.setColor(PIN_BORDER_COLOR);
|
||||||
|
g2d.drawRect(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Composite oldComposite = g2d.getComposite();
|
Composite oldComposite = g2d.getComposite();
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||||
/ MAX_ALPHA));
|
/ MAX_ALPHA));
|
||||||
}
|
}
|
||||||
g2d.setColor(BODY_COLOR);
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : BODY_COLOR);
|
||||||
g2d.fill(mainArea);
|
g2d.fill(mainArea);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED
|
|
||||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : BORDER_COLOR);
|
Color finalBorderColor;
|
||||||
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme
|
||||||
|
.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : BORDER_COLOR;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalBorderColor);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
g2d.draw(mainArea);
|
if (outlineMode) {
|
||||||
if (getBody()[1] != null) {
|
Area area = new Area(mainArea);
|
||||||
g2d.setColor(INDENT_COLOR);
|
area.subtract(getBody()[1]);
|
||||||
g2d.fill(getBody()[1]);
|
g2d.draw(area);
|
||||||
|
} else {
|
||||||
|
g2d.draw(mainArea);
|
||||||
|
if (getBody()[1] != null) {
|
||||||
|
g2d.setColor(INDENT_COLOR);
|
||||||
|
g2d.fill(getBody()[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Draw label.
|
// Draw label.
|
||||||
g2d.setFont(LABEL_FONT);
|
g2d.setFont(LABEL_FONT);
|
||||||
g2d.setColor(LABEL_COLOR);
|
Color finalLabelColor;
|
||||||
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED : theme
|
||||||
|
.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
|
: LABEL_COLOR;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalLabelColor);
|
||||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||||
Rectangle2D rect = fontMetrics.getStringBounds(getName(), g2d);
|
Rectangle2D rect = fontMetrics.getStringBounds(getName(), g2d);
|
||||||
int textHeight = (int) (rect.getHeight());
|
int textHeight = (int) (rect.getHeight());
|
||||||
|
|||||||
+16
-3
@@ -5,13 +5,18 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.components.AbstractLeadedComponent;
|
import org.diylc.components.AbstractLeadedComponent;
|
||||||
import org.diylc.core.CreationMethod;
|
import org.diylc.core.CreationMethod;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
|
import org.diylc.core.Theme;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
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;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Diode (plastic)", author = "Branislav Stojkovic", category = "Semiconductors", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "Plastic diode, like most rectifier, zener, schottky, etc.", zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Diode (plastic)", author = "Branislav Stojkovic", category = "Semiconductors", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "Plastic diode, like most rectifier, zener, schottky, etc.", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class DiodePlastic extends AbstractLeadedComponent<String> {
|
public class DiodePlastic extends AbstractLeadedComponent<String> {
|
||||||
@@ -20,7 +25,7 @@ public class DiodePlastic extends AbstractLeadedComponent<String> {
|
|||||||
|
|
||||||
public static Size DEFAULT_WIDTH = new Size(1d / 4, SizeUnit.in);
|
public static Size DEFAULT_WIDTH = new Size(1d / 4, SizeUnit.in);
|
||||||
public static Size DEFAULT_HEIGHT = new Size(1d / 8, SizeUnit.in);
|
public static Size DEFAULT_HEIGHT = new Size(1d / 8, SizeUnit.in);
|
||||||
public static Size MARKER_WIDTH = new Size(1.5d, SizeUnit.mm);
|
public static Size MARKER_WIDTH = new Size(1d, SizeUnit.mm);
|
||||||
public static Color BODY_COLOR = Color.darkGray;
|
public static Color BODY_COLOR = Color.darkGray;
|
||||||
public static Color MARKER_COLOR = Color.decode("#DDDDDD");
|
public static Color MARKER_COLOR = Color.decode("#DDDDDD");
|
||||||
public static Color LABEL_COLOR = Color.white;
|
public static Color LABEL_COLOR = Color.white;
|
||||||
@@ -80,8 +85,16 @@ public class DiodePlastic extends AbstractLeadedComponent<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decorateComponentBody(Graphics2D g2d) {
|
protected void decorateComponentBody(Graphics2D g2d, boolean outlineMode) {
|
||||||
g2d.setColor(markerColor);
|
Color finalMarkerColor;
|
||||||
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalMarkerColor = theme.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalMarkerColor = markerColor;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalMarkerColor);
|
||||||
int width = (int) getLength().convertToPixels();
|
int width = (int) getLength().convertToPixels();
|
||||||
int markerWidth = (int) MARKER_WIDTH.convertToPixels();
|
int markerWidth = (int) MARKER_WIDTH.convertToPixels();
|
||||||
g2d.fillRect(width - markerWidth, 0, markerWidth, getClosestOdd(getWidth()
|
g2d.fillRect(width - markerWidth, 0, markerWidth, getClosestOdd(getWidth()
|
||||||
|
|||||||
+9
-7
@@ -83,13 +83,15 @@ public class LED extends AbstractLeadedComponent<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decorateComponentBody(Graphics2D g2d) {
|
protected void decorateComponentBody(Graphics2D g2d, boolean outlineMode) {
|
||||||
int size = getClosestOdd((int) (getLength().convertToPixels() * 1.2));
|
if (!outlineMode) {
|
||||||
int innerSize = getClosestOdd(getLength().convertToPixels());
|
int size = getClosestOdd((int) (getLength().convertToPixels() * 1.2));
|
||||||
int x = (size - innerSize) / 2;
|
int innerSize = getClosestOdd(getLength().convertToPixels());
|
||||||
Shape s = new Ellipse2D.Double(x, x, innerSize, innerSize);
|
int x = (size - innerSize) / 2;
|
||||||
g2d.setColor(getBorderColor());
|
Shape s = new Ellipse2D.Double(x, x, innerSize, innerSize);
|
||||||
g2d.draw(s);
|
g2d.setColor(getBorderColor());
|
||||||
|
g2d.draw(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Size")
|
@EditableProperty(name = "Size")
|
||||||
|
|||||||
+54
-16
@@ -10,6 +10,7 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
@@ -23,6 +24,9 @@ import org.diylc.core.annotations.ComponentDescriptor;
|
|||||||
import org.diylc.core.annotations.EditableProperty;
|
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;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Transistor (TO-220 package)", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "Q", description = "Transistors with metal tab for heat sink mounting", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Transistor (TO-220 package)", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "Q", description = "Transistors with metal tab for heat sink mounting", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
||||||
public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
||||||
@@ -40,7 +44,7 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
public static Size PIN_SPACING = new Size(0.1d, SizeUnit.in);
|
public static Size PIN_SPACING = new Size(0.1d, SizeUnit.in);
|
||||||
public static Size BODY_WIDTH = new Size(0.4d, SizeUnit.in);
|
public static Size BODY_WIDTH = new Size(0.4d, SizeUnit.in);
|
||||||
public static Size BODY_HEIGHT = new Size(4.5d, SizeUnit.mm);
|
public static Size BODY_HEIGHT = new Size(4.5d, SizeUnit.mm);
|
||||||
public static Size TAB_THICKNESS = new Size(0.05d, SizeUnit.in);
|
public static Size TAB_THICKNESS = new Size(1d, SizeUnit.mm);
|
||||||
|
|
||||||
private String value = "";
|
private String value = "";
|
||||||
private Orientation orientation = Orientation.DEFAULT;
|
private Orientation orientation = Orientation.DEFAULT;
|
||||||
@@ -173,8 +177,8 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
if (checkPointsClipped(g2d.getClip())) {
|
if (checkPointsClipped(g2d.getClip())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -186,29 +190,63 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||||
/ MAX_ALPHA));
|
/ MAX_ALPHA));
|
||||||
}
|
}
|
||||||
g2d.setColor(bodyColor);
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
|
||||||
g2d.fill(mainArea);
|
g2d.fill(mainArea);
|
||||||
g2d.setColor(tabColor);
|
Color finalTabColor;
|
||||||
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalTabColor = theme.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalTabColor = tabColor;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalTabColor);
|
||||||
g2d.fill(tabArea);
|
g2d.fill(tabArea);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
if (!outlineMode) {
|
||||||
g2d.setColor(tabBorderColor);
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
g2d.draw(tabArea);
|
g2d.setColor(tabBorderColor);
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED
|
g2d.draw(tabArea);
|
||||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
}
|
||||||
|
Color finalBorderColor;
|
||||||
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme
|
||||||
|
.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalBorderColor);
|
||||||
g2d.draw(mainArea);
|
g2d.draw(mainArea);
|
||||||
|
|
||||||
// Draw pins.
|
// Draw pins.
|
||||||
for (Point point : controlPoints) {
|
if (!outlineMode) {
|
||||||
g2d.setColor(PIN_COLOR);
|
for (Point point : controlPoints) {
|
||||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
g2d.setColor(PIN_COLOR);
|
||||||
g2d.setColor(PIN_BORDER_COLOR);
|
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||||
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
g2d.setColor(PIN_BORDER_COLOR);
|
||||||
|
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw label.
|
// Draw label.
|
||||||
g2d.setFont(LABEL_FONT);
|
g2d.setFont(LABEL_FONT);
|
||||||
g2d.setColor(LABEL_COLOR);
|
Color finalLabelColor;
|
||||||
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED : theme
|
||||||
|
.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
|
: LABEL_COLOR;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalLabelColor);
|
||||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||||
Rectangle2D rect = fontMetrics.getStringBounds(getName(), g2d);
|
Rectangle2D rect = fontMetrics.getStringBounds(getName(), g2d);
|
||||||
int textHeight = (int) (rect.getHeight());
|
int textHeight = (int) (rect.getHeight());
|
||||||
|
|||||||
+39
-11
@@ -11,6 +11,7 @@ import java.awt.geom.Area;
|
|||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
@@ -24,6 +25,9 @@ import org.diylc.core.annotations.ComponentDescriptor;
|
|||||||
import org.diylc.core.annotations.EditableProperty;
|
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;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Transistor (TO-92 package)", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "Q", description = "Transistor with small plastic or epoxy body", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Transistor (TO-92 package)", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "Q", description = "Transistor with small plastic or epoxy body", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
||||||
public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
||||||
@@ -165,8 +169,8 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
if (checkPointsClipped(g2d.getClip())) {
|
if (checkPointsClipped(g2d.getClip())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -177,24 +181,48 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
|||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
||||||
/ MAX_ALPHA));
|
/ MAX_ALPHA));
|
||||||
}
|
}
|
||||||
g2d.setColor(bodyColor);
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
|
||||||
g2d.fill(mainArea);
|
g2d.fill(mainArea);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED
|
Color finalBorderColor;
|
||||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme
|
||||||
|
.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalBorderColor);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
g2d.draw(mainArea);
|
g2d.draw(mainArea);
|
||||||
|
|
||||||
for (Point point : controlPoints) {
|
if (!outlineMode) {
|
||||||
g2d.setColor(PIN_COLOR);
|
for (Point point : controlPoints) {
|
||||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
g2d.setColor(PIN_COLOR);
|
||||||
g2d.setColor(PIN_BORDER_COLOR);
|
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||||
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
g2d.setColor(PIN_BORDER_COLOR);
|
||||||
|
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw label.
|
// Draw label.
|
||||||
g2d.setFont(LABEL_FONT);
|
g2d.setFont(LABEL_FONT);
|
||||||
g2d.setColor(LABEL_COLOR);
|
Color finalLabelColor;
|
||||||
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED : theme
|
||||||
|
.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalLabelColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
|
: LABEL_COLOR;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalLabelColor);
|
||||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||||
Rectangle2D rect = fontMetrics.getStringBounds(getName(), g2d);
|
Rectangle2D rect = fontMetrics.getStringBounds(getName(), g2d);
|
||||||
int textHeight = (int) (rect.getHeight());
|
int textHeight = (int) (rect.getHeight());
|
||||||
|
|||||||
+30
-13
@@ -9,6 +9,7 @@ import java.awt.Shape;
|
|||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
|
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
@@ -16,11 +17,15 @@ import org.diylc.core.ComponentState;
|
|||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.Theme;
|
||||||
import org.diylc.core.VisibilityPolicy;
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
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;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Tube Socket", author = "Branislav Stojkovic", category = "Tubes", instanceNamePrefix = "V", description = "Various types of tube/valve sockets", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
@ComponentDescriptor(name = "Tube Socket", author = "Branislav Stojkovic", category = "Tubes", instanceNamePrefix = "V", description = "Various types of tube/valve sockets", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
||||||
public class TubeSocket extends AbstractTransparentComponent<String> {
|
public class TubeSocket extends AbstractTransparentComponent<String> {
|
||||||
@@ -186,8 +191,8 @@ public class TubeSocket extends AbstractTransparentComponent<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
IDrawingObserver drawingObserver) {
|
Project project, IDrawingObserver drawingObserver) {
|
||||||
// g2d.setColor(Color.black);
|
// g2d.setColor(Color.black);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
// for (int i = 0; i < controlPoints.length; i++) {
|
// for (int i = 0; i < controlPoints.length; i++) {
|
||||||
@@ -202,22 +207,34 @@ public class TubeSocket extends AbstractTransparentComponent<String> {
|
|||||||
/ MAX_ALPHA));
|
/ MAX_ALPHA));
|
||||||
}
|
}
|
||||||
if (componentState != ComponentState.DRAGGING) {
|
if (componentState != ComponentState.DRAGGING) {
|
||||||
g2d.setColor(BODY_COLOR);
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : BODY_COLOR);
|
||||||
g2d.fill(body);
|
g2d.fill(body);
|
||||||
}
|
}
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED
|
Color finalBorderColor;
|
||||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : BORDER_COLOR);
|
if (outlineMode) {
|
||||||
|
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
|
||||||
|
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme
|
||||||
|
.getOutlineColor();
|
||||||
|
} else {
|
||||||
|
finalBorderColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : BORDER_COLOR;
|
||||||
|
}
|
||||||
|
g2d.setColor(finalBorderColor);
|
||||||
g2d.draw(body);
|
g2d.draw(body);
|
||||||
// Draw pins
|
// Draw pins
|
||||||
int pinSize = getClosestOdd(PIN_SIZE.convertToPixels());
|
if (!outlineMode) {
|
||||||
for (int i = 1; i < controlPoints.length; i++) {
|
int pinSize = getClosestOdd(PIN_SIZE.convertToPixels());
|
||||||
g2d.setColor(PIN_COLOR);
|
for (int i = 1; i < controlPoints.length; i++) {
|
||||||
g2d.fillOval(controlPoints[i].x - pinSize / 2, controlPoints[i].y - pinSize / 2,
|
g2d.setColor(PIN_COLOR);
|
||||||
pinSize, pinSize);
|
g2d.fillOval(controlPoints[i].x - pinSize / 2, controlPoints[i].y - pinSize / 2,
|
||||||
g2d.setColor(PIN_BORDER_COLOR);
|
pinSize, pinSize);
|
||||||
g2d.drawOval(controlPoints[i].x - pinSize / 2, controlPoints[i].y - pinSize / 2,
|
g2d.setColor(PIN_BORDER_COLOR);
|
||||||
pinSize, pinSize);
|
g2d.drawOval(controlPoints[i].x - pinSize / 2, controlPoints[i].y - pinSize / 2,
|
||||||
|
pinSize, pinSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user