mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 23:36:27 -04:00
added some more options to the rectangle layout
This commit is contained in:
parent
d22eb92100
commit
67cea2db82
@ -717,4 +717,16 @@ public final class Keys {
|
||||
= new Key.KeyInteger("RectHeight", 3)
|
||||
.setMin(2);
|
||||
|
||||
/**
|
||||
* the position of the text in the rectangle
|
||||
*/
|
||||
public static final Key<Boolean> RECT_INSIDE
|
||||
= new Key<>("RectInside", false).setSecondary();
|
||||
|
||||
/**
|
||||
* the position of the text in the rectangle
|
||||
*/
|
||||
public static final Key<Boolean> RECT_BOTTOM
|
||||
= new Key<>("RectBottom", false).setSecondary();
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ public class RectShape implements Shape, DecoratingShape {
|
||||
private final String label;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final boolean inside;
|
||||
private final boolean bottom;
|
||||
private final Integer fontSize;
|
||||
|
||||
/**
|
||||
* Create a new instance
|
||||
@ -42,6 +45,9 @@ public class RectShape implements Shape, DecoratingShape {
|
||||
|
||||
width = attr.get(Keys.RECT_WIDTH);
|
||||
height = attr.get(Keys.RECT_HEIGHT);
|
||||
inside = attr.get(Keys.RECT_INSIDE);
|
||||
bottom = attr.get(Keys.RECT_BOTTOM);
|
||||
fontSize = attr.get(Keys.FONT_SIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,10 +62,21 @@ public class RectShape implements Shape, DecoratingShape {
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
Vector pos = new Vector(0, -2);
|
||||
Style style = Style.NORMAL;
|
||||
|
||||
int ofs = -3;
|
||||
Orientation orientation = Orientation.LEFTBOTTOM;
|
||||
if (inside ^ bottom) {
|
||||
ofs = -ofs;
|
||||
orientation = Orientation.LEFTTOP;
|
||||
}
|
||||
|
||||
Vector pos = new Vector(0, ofs);
|
||||
if (bottom)
|
||||
pos = pos.add(0, height * SIZE);
|
||||
|
||||
Style style = Style.NORMAL.deriveFontStyle(fontSize, true);
|
||||
if (!label.isEmpty())
|
||||
graphic.drawText(pos, pos.add(1, 0), label, Orientation.LEFTBOTTOM, style);
|
||||
graphic.drawText(pos, pos.add(1, 0), label, orientation, style);
|
||||
|
||||
graphic.drawPolygon(new Polygon(true)
|
||||
.add(0, 0)
|
||||
|
@ -41,7 +41,10 @@ public class DummyElement implements Element {
|
||||
public static final ElementTypeDescription RECTDESCRIPTION = new ElementTypeDescription("Rectangle", DummyElement.class)
|
||||
.addAttribute(Keys.LABEL)
|
||||
.addAttribute(Keys.RECT_WIDTH)
|
||||
.addAttribute(Keys.RECT_HEIGHT);
|
||||
.addAttribute(Keys.RECT_HEIGHT)
|
||||
.addAttribute(Keys.RECT_INSIDE)
|
||||
.addAttribute(Keys.RECT_BOTTOM)
|
||||
.addAttribute(Keys.FONT_SIZE);
|
||||
|
||||
/**
|
||||
* Creates a new dummy element
|
||||
|
@ -1254,6 +1254,10 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
||||
<string name="key_RectWidth_tt">Breite in Rastereinheiten</string>
|
||||
<string name="key_RectHeight">Höhe</string>
|
||||
<string name="key_RectHeight_tt">Höhe in Rastereinheiten</string>
|
||||
<string name="key_RectInside">Text innen</string>
|
||||
<string name="key_RectInside_tt">Text ins Innere des Rechtecks setzen.</string>
|
||||
<string name="key_RectBottom">Text unten</string>
|
||||
<string name="key_RectBottom_tt">Text unten ans Rechteck setzen.</string>
|
||||
|
||||
<string name="key_wideShape">Breites Symbol</string>
|
||||
<string name="key_wideShape_tt">Verwendet ein breiteres Symbol zur Darstellung des Gatters.</string>
|
||||
|
@ -1243,6 +1243,10 @@
|
||||
<string name="key_RectWidth_tt">Width in grid units</string>
|
||||
<string name="key_RectHeight">Height</string>
|
||||
<string name="key_RectHeight_tt">Height in grid units</string>
|
||||
<string name="key_RectInside">Text Inside</string>
|
||||
<string name="key_RectInside_tt">Place text inside the rectangle.</string>
|
||||
<string name="key_RectBottom">Text at Bottom</string>
|
||||
<string name="key_RectBottom_tt">Place text at the bottom of the rectangle.</string>
|
||||
|
||||
<string name="key_wideShape">Wide Shape</string>
|
||||
<string name="key_wideShape_tt">Uses a wider shape to visualize the gate.</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user