long names are shown below the GenericShape

This commit is contained in:
hneemann 2016-03-24 18:46:58 +01:00
parent 05e6956d2b
commit 6e947da74f
2 changed files with 14 additions and 3 deletions

View File

@ -111,7 +111,7 @@ public class LibrarySelector implements ElementNotFoundNotification {
public Element create(ElementAttributes attributes) {
return new CustomElement(circuit, library);
}
}, circuit.getInputNames(library));
}, circuit.getInputNames(library)).setShortName(createShortName(file));
library.addDescription(description);
customMenu.add(new InsertAction(description.getName(), insertHistory, circuitComponent));
return description;
@ -121,4 +121,10 @@ public class LibrarySelector implements ElementNotFoundNotification {
return null;
}
private String createShortName(File file) {
String name = file.getName();
if (name.endsWith(".dig")) name = name.substring(0, name.length() - 4);
return name;
}
}

View File

@ -120,8 +120,13 @@ public class GenericShape implements Shape {
graphic.drawText(p.getPos().add(-2, 0), p.getPos().add(5, 0), p.getName(), Orientation.RIGHTCENTER, Style.SHAPE_PIN);
}
}
Vector pos = new Vector(SIZE2 * width, -SIZE2 + 2);
graphic.drawText(pos, pos.add(1, 0), name, Orientation.CENTERTOP, Style.NORMAL);
if (name.length() <= 3) {
Vector pos = new Vector(SIZE2 * width, -SIZE2 + 2);
graphic.drawText(pos, pos.add(1, 0), name, Orientation.CENTERTOP, Style.NORMAL);
} else {
Vector pos = new Vector(SIZE2 * width, height + 2);
graphic.drawText(pos, pos.add(1, 0), name, Orientation.CENTERTOP, Style.SHAPE_PIN);
}
}
}