fixed the label position in the relay shapes

This commit is contained in:
hneemann 2018-07-19 13:44:32 +02:00
parent 6525256813
commit ded9976b92
3 changed files with 15 additions and 3 deletions

View File

@ -69,6 +69,19 @@ public interface Graphic extends Closeable {
*/ */
void drawText(VectorInterface p1, VectorInterface p2, String text, Orientation orientation, Style style); void drawText(VectorInterface p1, VectorInterface p2, String text, Orientation orientation, Style style);
/**
* Helper to draw a horizontal left to right text
*
* @param g the Graphic instance to draw to
* @param pos the text position
* @param text the text
* @param orientation the text orientation
* @param style the text style
*/
static void drawText(Graphic g, VectorInterface pos, String text, Orientation orientation, Style style) {
g.drawText(pos, pos.add(new Vector(1, 0)), text, orientation, style);
}
/** /**
* opens a new group, used to create SVG grouping * opens a new group, used to create SVG grouping
*/ */
@ -91,7 +104,6 @@ public interface Graphic extends Closeable {
return false; return false;
} }
/** /**
* closes the graphics instance * closes the graphics instance
* *

View File

@ -111,6 +111,6 @@ public class RelayDTShape implements Shape {
graphic.drawLine(new Vector(SIZE + SIZE2, -SIZE * 2), new Vector(SIZE * 2, -SIZE * 2), Style.NORMAL); graphic.drawLine(new Vector(SIZE + SIZE2, -SIZE * 2), new Vector(SIZE * 2, -SIZE * 2), Style.NORMAL);
if (label != null && label.length() > 0) if (label != null && label.length() > 0)
graphic.drawText(new Vector(SIZE, 4), new Vector(SIZE * 2, 4), label, Orientation.CENTERTOP, Style.SHAPE_PIN); Graphic.drawText(graphic, new Vector(SIZE, -SIZE * 3 - 4), label, Orientation.CENTERBOTTOM, Style.SHAPE_PIN);
} }
} }

View File

@ -114,7 +114,7 @@ public class RelayShape implements Shape {
graphic.drawLine(new Vector(SIZE + SIZE2, -SIZE * 2), new Vector(SIZE * 2, -SIZE * 2), Style.NORMAL); graphic.drawLine(new Vector(SIZE + SIZE2, -SIZE * 2), new Vector(SIZE * 2, -SIZE * 2), Style.NORMAL);
if (label != null && label.length() > 0) if (label != null && label.length() > 0)
graphic.drawText(new Vector(SIZE, 4), new Vector(SIZE * 2, 4), label, Orientation.CENTERTOP, Style.SHAPE_PIN); Graphic.drawText(graphic, new Vector(SIZE, -SIZE * 3 - 4), label, Orientation.CENTERBOTTOM, Style.SHAPE_PIN);
} }
} }