loadline work

This commit is contained in:
Branislav Stojkovic
2020-05-01 18:56:28 +02:00
parent 1c591bb9f5
commit 308a0346a9
11 changed files with 448 additions and 153 deletions
@@ -0,0 +1,53 @@
package org.diylc.components.misc;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Point;
import org.diylc.awt.StringUtils;
import org.diylc.common.HorizontalAlignment;
import org.diylc.common.VerticalAlignment;
import org.diylc.components.connectivity.CurvedTrace;
import org.diylc.core.ComponentState;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.Project;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.core.measures.Voltage;
public class LoadlineCurve extends CurvedTrace {
private static final long serialVersionUID = 1L;
private static final Size LABEL_SPACING = new Size(1d, SizeUnit.mm);
private Voltage voltage;
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
Project project, IDrawingObserver drawingObserver) {
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
if (getVoltage() == null)
return;
g2d.setColor(Color.black);
Font oldFont = g2d.getFont();
g2d.setFont(project.getFont().deriveFont(12f).deriveFont(Font.BOLD));
Point lastPoint = getControlPoint(getControlPointCount() - 1);
int spacing = (int) LABEL_SPACING.convertToPixels();
int x = lastPoint.x + spacing;
int y = lastPoint.y - spacing;
StringUtils.drawCenteredText(g2d, getVoltage().toString(), x, y, HorizontalAlignment.LEFT, VerticalAlignment.TOP);
g2d.setFont(oldFont);
}
@EditableProperty
public Voltage getVoltage() {
return voltage;
}
public void setVoltage(Voltage voltage) {
this.voltage = voltage;
}
}
@@ -25,10 +25,6 @@ import java.awt.geom.Point2D;
import java.io.Serializable;
import java.util.List;
import org.diylc.core.measures.Current;
import org.diylc.core.measures.Power;
import org.diylc.core.measures.Voltage;
/**
* Represents a complete load characteristics, used for tubes and transistors.
*
@@ -39,9 +35,9 @@ public class LoadlineEntity implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private Power maxDissipation;
private Voltage maxVoltage;
private Current maxCurrent;
private double maxDissipation;
private double maxVoltage;
private double maxCurrent;
private List<Line> lines;
public LoadlineEntity() {
@@ -55,27 +51,27 @@ public class LoadlineEntity implements Serializable {
this.name = name;
}
public Power getMaxDissipation() {
public double getMaxDissipation() {
return maxDissipation;
}
public void setMaxDissipation(Power maxDissipation) {
public void setMaxDissipation(double maxDissipation) {
this.maxDissipation = maxDissipation;
}
public Voltage getMaxVoltage() {
public double getMaxVoltage() {
return maxVoltage;
}
public void setMaxVoltage(Voltage maxVoltage) {
public void setMaxVoltage(double maxVoltage) {
this.maxVoltage = maxVoltage;
}
public Current getMaxCurrent() {
public double getMaxCurrent() {
return maxCurrent;
}
public void setMaxCurrent(Current maxCurrent) {
public void setMaxCurrent(double maxCurrent) {
this.maxCurrent = maxCurrent;
}
@@ -89,14 +85,14 @@ public class LoadlineEntity implements Serializable {
// Individual load line, tied to the grid voltage
public static class Line {
private Voltage voltage;
private double voltage;
private Point2D[] controlPoints;
public Voltage getVoltage() {
public double getVoltage() {
return voltage;
}
public void setVoltage(Voltage voltage) {
public void setVoltage(double voltage) {
this.voltage = voltage;
}