EOS 2  1.1.0
Einfache Objektbasierte Sprache
Diamond.java
gehe zur Dokumentation dieser Datei
1 package de.lathanda.eos.gui.flowchart;
2 
3 import de.lathanda.eos.gui.diagram.Drawing;
4 
16 public class Diamond extends ConnectedUnit {
17  private float textx;
18  private float texty;
19  private final String label;
20  private final float[] borderX = new float[4];
21  private final float[] borderY = new float[4];
22 
23  public Diamond(String label) {
24  this.label = label;
26  }
27 
28  @Override
29  public void drawUnit(Drawing d) {
30  d.drawPolygon(borderX, borderY, 4);
31  d.drawString(label, textx, texty);
32  }
33 
34  @Override
35  public void layoutUnit(Drawing d) {
36  float labelwidth = d.stringWidth(label);
37 
38  width = (labelwidth + 2 * BORDER) * 1.5f;
39  height = (2 * d.getHeight()) + 2 * BORDER;
40  textx = 0.5f * (width - labelwidth);
41  texty = BORDER + d.getHeight() / 2 + d.getAscent();
42  borderX[0] = 0;
43  borderX[1] = width / 2;
44  borderX[2] = width;
45  borderX[3] = width / 2;
46  borderY[0] = height / 2;
47  borderY[1] = 0;
48  borderY[2] = height / 2;
49  borderY[3] = height;
50  }
51 
52  float getX(int nr) {
53  return borderX[nr] + getOffsetX();
54  }
55 
56  float getY(int nr) {
57  return borderY[nr] + getOffsetY();
58  }
59 }
float stringWidth(String text)
Definition: Drawing.java:111
void drawPolygon(float[] x, float[] y, int n)
Definition: Drawing.java:246
void drawString(String text, float x, float y)
Definition: Drawing.java:148
static final float BORDER
Definition: Unit.java:13
Impressum