Created
March 15, 2017 17:31
-
-
Save pholser/d534fb980671728fd9bac511f7deaa93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void drawInfo(Graphics g) { | |
if (ClosetApp.ref.getFloorView() == null) { | |
return; | |
} | |
Drawing drawing = ClosetApp.ref.getFloorView().drawing(); | |
Optional<Customer> customer = ofNullable((Customer) drawing.getUserData()); | |
g.setColor(Color.black); | |
Font bfont = new Font("Tahoma", Font.BOLD, 12); | |
Font font = new Font("Tahoma", Font.PLAIN, 12); | |
g.setFont(bfont); | |
FontMetrics fm = g.getFontMetrics(); | |
Point p = new Point(g.getClipBounds().width / 2, 0); | |
String designerHeading = "Designer: "; | |
int length = fm.stringWidth(designerHeading) + 5; | |
int height = fm.getAscent(); | |
p.y += height; | |
g.drawString(designerHeading, p.x, p.y); | |
g.setFont(font); | |
g.drawString(PrintUtil.getPlanner(drawing), p.x + length, p.y); | |
p.y += height; | |
g.setFont(bfont); | |
g.drawString("Customer:", p.x, p.y); | |
g.setFont(font); | |
customer.ifPresent(c -> | |
g.drawString( | |
c.firstName + " " + c.lastName, | |
p.x + length, | |
p.y)); | |
p.x += 200; | |
g.setFont(bfont); | |
String dateHeading = "Date: "; | |
g.drawString(dateHeading, p.x, p.y); | |
g.setFont(font); | |
customer.ifPresent(c -> | |
ofNullable(customer.get().create_date).ifPresent(d -> { | |
String date = PrintUtil.getPlannedDate(); | |
g.drawString(date, p.x + fm.stringWidth(dateHeading), p.y); | |
}) | |
); | |
p.x -= 200; | |
p.y += height; | |
g.setFont(bfont); | |
g.drawString("Email:", p.x, p.y); | |
g.setFont(font); | |
customer.ifPresent(c -> | |
ofNullable(customer.get().email).ifPresent(e -> | |
g.drawString(customer.get().email, p.x + length, p.y) | |
)); | |
p.y += height; | |
g.setFont(bfont); | |
g.drawString("Project (File):", p.x, p.y); | |
g.setFont(font); | |
customer.ifPresent(c -> { | |
String str = "(" + getFileName() + ") " + c.spaceName; | |
g.drawString(str, p.x + length, p.y); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment