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.
g2d.setFont(LABEL_FONT);
g2d.setFont(project.getFont());
if (useShapeRectAsPosition()) {
g2d.translate(shapeRect.x, shapeRect.y);
}
@@ -1,5 +1,6 @@
package org.diylc.core;
import java.awt.Font;
import java.io.Serializable;
import java.util.ArrayList;
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_HEIGHT = new Size(21d, SizeUnit.cm);
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;
@@ -43,6 +45,7 @@ public class Project implements Serializable {
private List<IDIYComponent<?>> components;
private Set<Set<IDIYComponent<?>>> groups;
private Set<Integer> lockedLayers;
private Font font = DEFAULT_FONT;
public Project() {
components = new ArrayList<IDIYComponent<?>>();
@@ -139,6 +142,28 @@ public class Project implements Serializable {
public void setFileVersion(VersionNumber 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
public int hashCode() {