change project font

This commit is contained in:
bancika
2017-04-18 17:41:36 +02:00
parent 8e6f7a07e5
commit beb574c38f
33 changed files with 59 additions and 30 deletions
@@ -230,7 +230,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
// } // }
// Draw label. // Draw label.
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
if (useShapeRectAsPosition()) { if (useShapeRectAsPosition()) {
g2d.translate(shapeRect.x, shapeRect.y); g2d.translate(shapeRect.x, shapeRect.y);
} }
@@ -1,5 +1,6 @@
package org.diylc.core; package org.diylc.core;
import java.awt.Font;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@@ -31,6 +32,7 @@ public class Project implements Serializable {
public static Size DEFAULT_WIDTH = new Size(29d, SizeUnit.cm); public static Size DEFAULT_WIDTH = new Size(29d, SizeUnit.cm);
public static Size DEFAULT_HEIGHT = new Size(21d, SizeUnit.cm); public static Size DEFAULT_HEIGHT = new Size(21d, SizeUnit.cm);
public static Size DEFAULT_GRID_SPACING = new Size(0.1d, SizeUnit.in); public static Size DEFAULT_GRID_SPACING = new Size(0.1d, SizeUnit.in);
public static Font DEFAULT_FONT = new Font("Tahoma", Font.PLAIN, 14);
private VersionNumber fileVersion; private VersionNumber fileVersion;
@@ -43,6 +45,7 @@ public class Project implements Serializable {
private List<IDIYComponent<?>> components; private List<IDIYComponent<?>> components;
private Set<Set<IDIYComponent<?>>> groups; private Set<Set<IDIYComponent<?>>> groups;
private Set<Integer> lockedLayers; private Set<Integer> lockedLayers;
private Font font = DEFAULT_FONT;
public Project() { public Project() {
components = new ArrayList<IDIYComponent<?>>(); components = new ArrayList<IDIYComponent<?>>();
@@ -140,6 +143,28 @@ public class Project implements Serializable {
this.fileVersion = fileVersion; this.fileVersion = fileVersion;
} }
@EditableProperty(name = "Default Font")
public Font getFont() {
if (font == null)
font = DEFAULT_FONT;
return font;
}
public void setFont(Font font) {
this.font = font;
}
@EditableProperty(name = "Default Font Size")
public int getFontSize() {
if (font == null)
font = DEFAULT_FONT;
return font.getSize();
}
public void setFontSize(int size) {
font = font.deriveFont((float) size);
}
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
Binary file not shown.
@@ -93,7 +93,7 @@ public abstract class Abstract3LegSymbol extends AbstractComponent<String> {
g2d.setTransform(old); g2d.setTransform(old);
// Draw label // Draw label
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
Theme theme = Theme theme =
@@ -61,12 +61,12 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
g2d.drawRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y); g2d.drawRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
} }
protected void drawCoordinates(Graphics2D g2d, int spacing) { protected void drawCoordinates(Graphics2D g2d, int spacing, Project project) {
if (!getDrawCoordinates()) if (!getDrawCoordinates())
return; return;
Point p = new Point(firstPoint); Point p = new Point(firstPoint);
g2d.setColor(coordinateColor); g2d.setColor(coordinateColor);
g2d.setFont(LABEL_FONT.deriveFont(COORDINATE_FONT_SIZE)); g2d.setFont(project.getFont().deriveFont(COORDINATE_FONT_SIZE));
int t = 1; int t = 1;
while (p.y < secondPoint.y - spacing) { while (p.y < secondPoint.y - spacing) {
@@ -78,7 +78,7 @@ public class EyeletBoard extends AbstractBoard {
g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter); g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter);
} }
} }
super.drawCoordinates(g2d, spacing); super.drawCoordinates(g2d, spacing, project);
} }
} }
@@ -70,7 +70,7 @@ public class MarshallPerfBoard extends AbstractBoard {
g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter); g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter);
} }
} }
super.drawCoordinates(g2d, spacing); super.drawCoordinates(g2d, spacing, project);
} }
} }
@@ -70,7 +70,7 @@ public class PerfBoard extends AbstractBoard {
g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter); g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter);
} }
} }
super.drawCoordinates(g2d, spacing); super.drawCoordinates(g2d, spacing, project);
} }
} }
@@ -133,7 +133,7 @@ public class TriPadBoard extends AbstractBoard {
} }
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
super.drawCoordinates(g2d, spacing); super.drawCoordinates(g2d, spacing, project);
} }
} }
@@ -93,7 +93,7 @@ public class VeroBoard extends AbstractBoard {
} }
} }
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
super.drawCoordinates(g2d, spacing); super.drawCoordinates(g2d, spacing, project);
} }
} }
@@ -228,7 +228,7 @@ public class CliffJack1_4 extends AbstractTransparentComponent<String> {
: LABEL_COLOR; : LABEL_COLOR;
} }
g2d.setColor(finalLabelColor); g2d.setColor(finalLabelColor);
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
int centerX = (controlPoints[0].x + controlPoints[3].x) / 2; int centerX = (controlPoints[0].x + controlPoints[3].x) / 2;
int centerY = (controlPoints[0].y + controlPoints[3].y) / 2; int centerY = (controlPoints[0].y + controlPoints[3].y) / 2;
drawCenteredText(g2d, name, centerX, centerY, HorizontalAlignment.CENTER, VerticalAlignment.CENTER); drawCenteredText(g2d, name, centerX, centerY, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
@@ -248,7 +248,7 @@ public class ClosedJack1_4 extends AbstractTransparentComponent<String> {
: LABEL_COLOR; : LABEL_COLOR;
} }
g2d.setColor(finalLabelColor); g2d.setColor(finalLabelColor);
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Rectangle bounds = body[0].getBounds(); Rectangle bounds = body[0].getBounds();
int centerX = bounds.x + bounds.width / 2; int centerX = bounds.x + bounds.width / 2;
int centerY = bounds.y + bounds.height / 2; int centerY = bounds.y + bounds.height / 2;
@@ -318,7 +318,7 @@ public class MiniRelay extends AbstractTransparentComponent<String> {
} }
} }
// Draw label. // Draw label.
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
finalLabelColor = finalLabelColor =
@@ -130,7 +130,7 @@ public class OpenJack1_4 extends AbstractTransparentComponent<String> {
// draw labels // draw labels
if (showLabels) { if (showLabels) {
g2d.setColor(BASE_COLOR.darker()); g2d.setColor(BASE_COLOR.darker());
g2d.setFont(LABEL_FONT.deriveFont(LABEL_FONT.getSize2D() * 0.8f)); g2d.setFont(project.getFont().deriveFont(project.getFont().getSize2D() * 0.8f));
int springLength = (int) SPRING_LENGTH.convertToPixels(); int springLength = (int) SPRING_LENGTH.convertToPixels();
int holeToEdge = (int) HOLE_TO_EDGE.convertToPixels(); int holeToEdge = (int) HOLE_TO_EDGE.convertToPixels();
int centerY = controlPoints[0].y + springLength - holeToEdge; int centerY = controlPoints[0].y + springLength - holeToEdge;
@@ -159,7 +159,7 @@ public class PlasticDCJack extends AbstractTransparentComponent<String> {
if (!outlineMode && getPolarity() != DCPolarity.NONE) { if (!outlineMode && getPolarity() != DCPolarity.NONE) {
int spacing = (int) SPACING.convertToPixels(); int spacing = (int) SPACING.convertToPixels();
g2d.setColor(MARKING_COLOR); g2d.setColor(MARKING_COLOR);
g2d.setFont(LABEL_FONT.deriveFont(12f)); g2d.setFont(project.getFont().deriveFont(12f));
drawCenteredText(g2d, getPolarity() == DCPolarity.CENTER_NEGATIVE ? "+" : "-", controlPoints[0].x, drawCenteredText(g2d, getPolarity() == DCPolarity.CENTER_NEGATIVE ? "+" : "-", controlPoints[0].x,
controlPoints[0].y - spacing * 7 / 16, HorizontalAlignment.CENTER, VerticalAlignment.CENTER); controlPoints[0].y - spacing * 7 / 16, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
drawCenteredText(g2d, getPolarity() == DCPolarity.CENTER_NEGATIVE ? "_" : "+", controlPoints[2].x, drawCenteredText(g2d, getPolarity() == DCPolarity.CENTER_NEGATIVE ? "_" : "+", controlPoints[2].x,
@@ -145,7 +145,7 @@ public class HumbuckerPickup extends AbstractTransparentComponent<String> {
: LABEL_COLOR; : LABEL_COLOR;
} }
g2d.setColor(finalLabelColor); g2d.setColor(finalLabelColor);
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Rectangle bounds = body[0].getBounds(); Rectangle bounds = body[0].getBounds();
drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER, drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
VerticalAlignment.CENTER); VerticalAlignment.CENTER);
@@ -128,7 +128,7 @@ public class P90Pickup extends AbstractTransparentComponent<String> {
: LABEL_COLOR; : LABEL_COLOR;
} }
g2d.setColor(finalLabelColor); g2d.setColor(finalLabelColor);
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Rectangle bounds = body[0].getBounds(); Rectangle bounds = body[0].getBounds();
drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER, drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
VerticalAlignment.CENTER); VerticalAlignment.CENTER);
@@ -160,7 +160,7 @@ public class SingleCoilPickup extends AbstractTransparentComponent<String> {
: LABEL_COLOR; : LABEL_COLOR;
} }
g2d.setColor(finalLabelColor); g2d.setColor(finalLabelColor);
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Rectangle bounds = body[3].getBounds(); Rectangle bounds = body[3].getBounds();
drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER, drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
VerticalAlignment.CENTER); VerticalAlignment.CENTER);
@@ -51,7 +51,7 @@ public class BOM extends AbstractComponent<Void> {
iterator.remove(); iterator.remove();
} }
} }
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
g2d.setColor(componentState == ComponentState.DRAGGING || componentState == ComponentState.SELECTED ? SELECTION_COLOR g2d.setColor(componentState == ComponentState.DRAGGING || componentState == ComponentState.SELECTED ? SELECTION_COLOR
: getColor()); : getColor());
// Determine maximum name length and maximum value length to calculate // Determine maximum name length and maximum value length to calculate
@@ -196,7 +196,7 @@ public class PotentiometerPanel extends AbstractPotentiometer {
} }
} }
// Draw caption. // Draw caption.
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
finalLabelColor = finalLabelColor =
@@ -327,7 +327,7 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
} }
// Draw label. // Draw label.
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
finalLabelColor = finalLabelColor =
@@ -331,7 +331,7 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
} }
} }
// Draw label. // Draw label.
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
Theme theme = Theme theme =
@@ -393,7 +393,7 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
textY2 = textY2 - pinSize; textY2 = textY2 - pinSize;
} }
g2d.setFont(LABEL_FONT.deriveFont((float) (Label.LABEL_FONT.getSize2D() * 0.66))); g2d.setFont(project.getFont().deriveFont((float) (project.getFont().getSize2D() * 0.66)));
if (displayNumbers == DisplayNumbers.DIP) { if (displayNumbers == DisplayNumbers.DIP) {
if (pinNo > pinCount.getValue() / 2) { if (pinNo > pinCount.getValue() / 2) {
g2d.drawString(Integer.toString(pinCount.getValue() - j), textX1, textY1); g2d.drawString(Integer.toString(pinCount.getValue() - j), textX1, textY1);
@@ -89,7 +89,7 @@ public class ICSymbol extends AbstractTransparentComponent<String> {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2)); g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
g2d.draw(body[0]); g2d.draw(body[0]);
// Draw label // Draw label
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
Theme theme = Theme theme =
@@ -304,7 +304,7 @@ public class SIL_IC extends AbstractTransparentComponent<String> {
} }
} }
// Draw label. // Draw label.
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
Theme theme = Theme theme =
@@ -227,7 +227,7 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
} }
// Draw label. // Draw label.
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
finalLabelColor = finalLabelColor =
@@ -349,7 +349,7 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
} }
// Draw label. // Draw label.
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
finalLabelColor = finalLabelColor =
@@ -264,7 +264,7 @@ public class TransistorTO3 extends AbstractTransparentComponent<String> {
} }
// Draw label. // Draw label.
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
finalLabelColor = finalLabelColor =
@@ -262,7 +262,7 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
} }
// Draw label. // Draw label.
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
Theme theme = Theme theme =
@@ -269,7 +269,7 @@ public abstract class PassiveSMDComponent<T> extends AbstractTransparentComponen
g2d.draw(contactArea); g2d.draw(contactArea);
// Draw label. // Draw label.
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
Theme theme = Theme theme =
@@ -75,7 +75,7 @@ public abstract class AbstractTubeSymbol extends AbstractComponent<String> {
} }
// Draw label // Draw label
g2d.setFont(LABEL_FONT); g2d.setFont(project.getFont());
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
Theme theme = Theme theme =
Binary file not shown.
Binary file not shown.
+4
View File
@@ -1650,6 +1650,10 @@
<changeType>NEW_FEATURE</changeType> <changeType>NEW_FEATURE</changeType>
<description>Hold Control key to zoom with mouse wheel. Zooming tracks mouse cursor position.</description> <description>Hold Control key to zoom with mouse wheel. Zooming tracks mouse cursor position.</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Ability to set project-wide default font through 'Edit Project Settings' dialog.</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Hookup wire can be sent to back behind boards</description> <description>Hookup wire can be sent to back behind boards</description>