mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 15:26:52 -04:00
text is ignored if the visual elements bounding box is calculated
This commit is contained in:
parent
5f70789ec5
commit
f33554b64d
@ -14,7 +14,7 @@
|
||||
<string>1,1,1,1,1,1,1,1</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="380" y="160"/>
|
||||
<pos x="340" y="160"/>
|
||||
<rotate>0</rotate>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
@ -60,7 +60,7 @@
|
||||
<string>1,1,1,1,1,1,1,1</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="380" y="380"/>
|
||||
<pos x="340" y="380"/>
|
||||
<rotate>0</rotate>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
@ -112,17 +112,6 @@
|
||||
<pos x="820" y="220"/>
|
||||
<rotate>0</rotate>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Clock</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>Takt</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="480" y="120"/>
|
||||
<rotate>0</rotate>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Out</elementName>
|
||||
<elementAttributes>
|
||||
@ -134,132 +123,247 @@
|
||||
<pos x="820" y="440"/>
|
||||
<rotate>0</rotate>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>In</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>C_i-1</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="300" y="100"/>
|
||||
<rotate>0</rotate>
|
||||
</visualElement>
|
||||
</visualElements>
|
||||
<wires>
|
||||
<wire>
|
||||
<p1 x="640" y="140"/>
|
||||
<p2 x="760" y="220"/>
|
||||
<p1 x="660" y="140"/>
|
||||
<p2 x="740" y="220"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="160"/>
|
||||
<p2 x="760" y="240"/>
|
||||
<p1 x="660" y="160"/>
|
||||
<p2 x="740" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="180"/>
|
||||
<p2 x="760" y="260"/>
|
||||
<p1 x="660" y="180"/>
|
||||
<p2 x="740" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="200"/>
|
||||
<p2 x="760" y="280"/>
|
||||
<p1 x="660" y="200"/>
|
||||
<p2 x="740" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="360"/>
|
||||
<p2 x="760" y="300"/>
|
||||
<p1 x="660" y="360"/>
|
||||
<p2 x="740" y="300"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="380"/>
|
||||
<p2 x="760" y="320"/>
|
||||
<p1 x="660" y="380"/>
|
||||
<p2 x="740" y="320"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="400"/>
|
||||
<p2 x="760" y="340"/>
|
||||
<p1 x="660" y="400"/>
|
||||
<p2 x="740" y="340"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="420"/>
|
||||
<p2 x="760" y="360"/>
|
||||
<p1 x="660" y="420"/>
|
||||
<p2 x="740" y="360"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="480" y="120"/>
|
||||
<p2 x="540" y="140"/>
|
||||
<p1 x="380" y="380"/>
|
||||
<p2 x="500" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="380"/>
|
||||
<p2 x="540" y="240"/>
|
||||
<p1 x="380" y="400"/>
|
||||
<p2 x="500" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="400"/>
|
||||
<p2 x="540" y="260"/>
|
||||
<p1 x="500" y="280"/>
|
||||
<p2 x="380" y="420"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="540" y="280"/>
|
||||
<p2 x="400" y="420"/>
|
||||
<p1 x="380" y="440"/>
|
||||
<p2 x="500" y="300"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="440"/>
|
||||
<p2 x="540" y="300"/>
|
||||
<p1 x="380" y="260"/>
|
||||
<p2 x="500" y="400"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="380" y="240"/>
|
||||
<p2 x="500" y="380"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="380" y="300"/>
|
||||
<p2 x="500" y="440"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="380" y="280"/>
|
||||
<p2 x="500" y="420"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="300" y="160"/>
|
||||
<p2 x="380" y="160"/>
|
||||
<p2 x="340" y="160"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="160"/>
|
||||
<p1 x="360" y="160"/>
|
||||
<p2 x="540" y="160"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="480"/>
|
||||
<p1 x="640" y="160"/>
|
||||
<p2 x="660" y="160"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="360" y="480"/>
|
||||
<p2 x="540" y="480"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="260"/>
|
||||
<p2 x="480" y="260"/>
|
||||
<p1 x="740" y="320"/>
|
||||
<p2 x="760" y="320"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="460" y="420"/>
|
||||
<p1 x="360" y="260"/>
|
||||
<p2 x="380" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="500" y="260"/>
|
||||
<p2 x="540" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="740" y="260"/>
|
||||
<p2 x="760" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="500" y="420"/>
|
||||
<p2 x="540" y="420"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="520"/>
|
||||
<p1 x="360" y="420"/>
|
||||
<p2 x="380" y="420"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="420"/>
|
||||
<p2 x="660" y="420"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="300" y="100"/>
|
||||
<p2 x="440" y="100"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="360" y="520"/>
|
||||
<p2 x="540" y="520"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="200"/>
|
||||
<p1 x="360" y="200"/>
|
||||
<p2 x="540" y="200"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="200"/>
|
||||
<p2 x="660" y="200"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="520" y="360"/>
|
||||
<p2 x="540" y="360"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="460"/>
|
||||
<p1 x="640" y="360"/>
|
||||
<p2 x="660" y="360"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="740" y="360"/>
|
||||
<p2 x="760" y="360"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="440" y="140"/>
|
||||
<p2 x="540" y="140"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="140"/>
|
||||
<p2 x="660" y="140"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="360" y="460"/>
|
||||
<p2 x="540" y="460"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="300"/>
|
||||
<p2 x="440" y="300"/>
|
||||
<p1 x="360" y="300"/>
|
||||
<p2 x="380" y="300"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="480" y="400"/>
|
||||
<p1 x="500" y="300"/>
|
||||
<p2 x="540" y="300"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="740" y="300"/>
|
||||
<p2 x="760" y="300"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="500" y="400"/>
|
||||
<p2 x="540" y="400"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="240"/>
|
||||
<p2 x="500" y="240"/>
|
||||
<p1 x="360" y="400"/>
|
||||
<p2 x="380" y="400"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="400"/>
|
||||
<p2 x="660" y="400"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="360" y="240"/>
|
||||
<p2 x="380" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="500" y="240"/>
|
||||
<p2 x="540" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="740" y="240"/>
|
||||
<p2 x="760" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="520" y="340"/>
|
||||
<p2 x="660" y="340"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="180"/>
|
||||
<p1 x="740" y="340"/>
|
||||
<p2 x="760" y="340"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="360" y="180"/>
|
||||
<p2 x="540" y="180"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="500"/>
|
||||
<p1 x="640" y="180"/>
|
||||
<p2 x="660" y="180"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="360" y="500"/>
|
||||
<p2 x="540" y="500"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="280"/>
|
||||
<p2 x="460" y="280"/>
|
||||
<p1 x="360" y="280"/>
|
||||
<p2 x="380" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="500" y="280"/>
|
||||
<p2 x="540" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="740" y="280"/>
|
||||
<p2 x="760" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="440"/>
|
||||
<p2 x="820" y="440"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="440" y="440"/>
|
||||
<p1 x="500" y="440"/>
|
||||
<p2 x="540" y="440"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="360" y="440"/>
|
||||
<p2 x="380" y="440"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="220"/>
|
||||
<p2 x="660" y="220"/>
|
||||
@ -269,40 +373,40 @@
|
||||
<p2 x="820" y="220"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="400" y="220"/>
|
||||
<p1 x="360" y="220"/>
|
||||
<p2 x="540" y="220"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="740" y="220"/>
|
||||
<p2 x="760" y="220"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="300" y="380"/>
|
||||
<p2 x="380" y="380"/>
|
||||
<p2 x="340" y="380"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="500" y="380"/>
|
||||
<p2 x="540" y="380"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="480" y="260"/>
|
||||
<p2 x="480" y="400"/>
|
||||
<p1 x="360" y="380"/>
|
||||
<p2 x="380" y="380"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="640" y="380"/>
|
||||
<p2 x="660" y="380"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="660" y="220"/>
|
||||
<p2 x="660" y="340"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="500" y="240"/>
|
||||
<p2 x="500" y="380"/>
|
||||
<p1 x="440" y="100"/>
|
||||
<p2 x="440" y="140"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="520" y="340"/>
|
||||
<p2 x="520" y="360"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="440" y="300"/>
|
||||
<p2 x="440" y="440"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="460" y="280"/>
|
||||
<p2 x="460" y="420"/>
|
||||
</wire>
|
||||
</wires>
|
||||
</circuit>
|
@ -183,11 +183,11 @@ public class VisualElement implements Drawable, Moveable, AttributeListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bounding box of the shape of this element
|
||||
* @return the bounding box of the shape of this element, text is ignored
|
||||
*/
|
||||
public GraphicMinMax getMinMax() {
|
||||
if (minMax == null) {
|
||||
GraphicMinMax mm = new GraphicMinMax();
|
||||
GraphicMinMax mm = new GraphicMinMax(false);
|
||||
drawShape(mm, false);
|
||||
minMax = mm;
|
||||
}
|
||||
@ -205,10 +205,11 @@ public class VisualElement implements Drawable, Moveable, AttributeListener {
|
||||
* Is used to create the icons in the element menu
|
||||
*
|
||||
* @param maxHeight the maximum height
|
||||
* @return the icon or null if the maximum height is exceeded.
|
||||
* @return the created icon
|
||||
*/
|
||||
public ImageIcon createIcon(int maxHeight) {
|
||||
GraphicMinMax mm = getMinMax();
|
||||
GraphicMinMax mm = new GraphicMinMax();
|
||||
drawShape(mm, false);
|
||||
|
||||
double scale = 0.5;
|
||||
if (mm.getMax().y - mm.getMin().y > maxHeight / scale)
|
||||
|
@ -4,16 +4,33 @@ import static de.neemann.digital.core.element.ElementAttributes.cleanLabel;
|
||||
|
||||
/**
|
||||
* This class is used to determine the size of shapes or the whole circuit.
|
||||
* You can draw the items to a instance of this class an then obtain the size
|
||||
* You can draw the items to an instance of this class and then obtain the size
|
||||
* by the getters getMin() and getMax().
|
||||
*
|
||||
* @author hneemann
|
||||
*/
|
||||
public class GraphicMinMax implements Graphic {
|
||||
|
||||
private final boolean includeText;
|
||||
private Vector min;
|
||||
private Vector max;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*/
|
||||
public GraphicMinMax() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param includeText true if text is included in measurement
|
||||
*/
|
||||
public GraphicMinMax(boolean includeText) {
|
||||
this.includeText = includeText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLine(Vector p1, Vector p2, Style style) {
|
||||
check(p1);
|
||||
@ -44,6 +61,7 @@ public class GraphicMinMax implements Graphic {
|
||||
|
||||
@Override
|
||||
public void drawText(Vector p1, Vector p2, String text, Orientation orientation, Style style) {
|
||||
if (includeText)
|
||||
approxTextSize(this, p1, p2, text, orientation, style);
|
||||
}
|
||||
|
||||
@ -64,7 +82,7 @@ public class GraphicMinMax implements Graphic {
|
||||
Vector height = new Vector(delta.y, -delta.x).mul(style.getFontSize()).div(128);
|
||||
|
||||
int div = 190;
|
||||
if (text.length() > 15) div = 240;
|
||||
if (text.length() > 2) div = 220;
|
||||
Vector width = delta.mul(text.length() * style.getFontSize()).div(div);
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user