use of com.centurylink.mdw.designer.display.Label in project mdw-designer by CenturyLinkCloud.
the class Icon method drawLabel.
private static void drawLabel(Graphics g, Node node, String desc) {
node.label = new Label(g, desc);
node.lx = node.x + node.w / 2 - node.label.width / 2;
node.ly = node.y + node.h;
g.setColor(Color.BLACK);
node.label.draw(g, node.lx, node.ly);
}
use of com.centurylink.mdw.designer.display.Label in project mdw-designer by CenturyLinkCloud.
the class Icon method drawBox.
public static void drawBox(Graphics g, Node node, Object icon, boolean drawImageAlso) {
int image_h = 0;
if (icon instanceof ImageIcon) {
if (node.isNew())
g.setColor(Color.MAGENTA);
else
g.setColor(Color.DARK_GRAY);
g.drawRoundRect(node.x, node.y, node.w, node.h, 12, 12);
if (drawImageAlso) {
ImageIcon imageIcon = (ImageIcon) icon;
int w = imageIcon.getIconWidth();
image_h = imageIcon.getIconHeight();
g.drawImage(imageIcon.getImage(), node.x + node.w / 2 - w / 2, node.y + 4, null);
}
} else {
((Icon) icon).draw(g, node.x, node.y, node.w, node.h);
if (node.isNew()) {
g.setColor(Color.red);
g.drawRoundRect(node.x - 2, node.y - 2, node.w + 4, node.h + 4, 12, 12);
}
}
String nodeIdType = node.getMainGraph().getNodeIdType();
if (Node.ID_DATABASE.equals(nodeIdType)) {
drawId(g, node.getId().toString(), node.x + 2, node.y - 2, Color.GRAY);
} else if (Node.ID_LOGICAL.equals(nodeIdType)) {
drawId(g, node.getLogicalId(), node.x + 2, node.y - 2, Color.GRAY);
} else if (Node.ID_REFERENCE.equals(nodeIdType)) {
drawId(g, node.getReferenceId(), node.x + 2, node.y - 2, Color.GRAY);
} else if (Node.ID_SEQUENCE.equals(nodeIdType)) {
drawId(g, String.valueOf(node.getSequenceId()), node.x + 2, node.y - 2, Color.GRAY);
}
String desc = node.getName();
if (desc != null) {
if (node.isDeleted())
g.setColor(Color.LIGHT_GRAY);
else if (node.isNew())
g.setColor(Color.MAGENTA);
else
g.setColor(Color.BLACK);
node.label = new Label(g, desc);
node.lx = node.x + node.w / 2 - node.label.width / 2;
if (image_h > 0)
node.ly = node.y + 8 + image_h;
else if (node.label.height > node.h - 8)
node.ly = node.y + 4;
else
node.ly = node.y + (node.h - node.label.height) / 2;
node.label.draw(g, node.lx, node.ly);
}
}
use of com.centurylink.mdw.designer.display.Label in project mdw-designer by CenturyLinkCloud.
the class CanvasCommon method drawConnector.
protected void drawConnector(Graphics g, Graph process, Link conn) {
Graphics2D g2 = (Graphics2D) g;
int n = conn.getNumberOfControlPoints();
if (n < 2)
conn.calcLinkPosition(0, process.arrowstyle);
String labelOrEventType = conn.getLabelAndEventType();
if (conn.isNew())
g.setColor(NEW_COLOR);
else
g.setColor(conn.color);
if (labelOrEventType != null && labelOrEventType.length() == 0)
labelOrEventType = null;
if (conn.isDeleted())
g2.setStroke(dash_stroke);
else
g2.setStroke(line_stroke);
g2.draw(conn.getShape());
if (conn.from != conn.to)
g2.fill(conn.getArrow(process.arrowstyle));
g2.setStroke(normal_stroke);
if (labelOrEventType != null) {
conn.label = new Label(g, labelOrEventType);
if (conn.color != Color.LIGHT_GRAY)
g.setColor(Color.DARK_GRAY);
conn.label.draw(g, conn.lx, conn.ly);
g.setColor(conn.color);
} else
conn.label = null;
}
use of com.centurylink.mdw.designer.display.Label in project mdw-designer by CenturyLinkCloud.
the class CanvasCommon method paintDraggingAndSelection.
protected void paintDraggingAndSelection(Graphics g) {
if (dragging && drag_to_create_link) {
if (selected_obj instanceof Node) {
g.setColor(Color.GREEN);
g.drawLine(((Node) selected_obj).x + delta_x, ((Node) selected_obj).y + delta_y, drag_x, drag_y);
}
} else if (selected_obj != null) {
if (selected_obj instanceof Node) {
drawSelectionBox(g, (Node) selected_obj);
} else if (selected_obj instanceof Link) {
drawSelectionBox(g, (Link) selected_obj);
} else if (selected_obj instanceof SubGraph) {
drawSelectionBox(g, (SubGraph) selected_obj);
} else if (selected_obj instanceof Graph) {
drawSelectionBox(g, (Graph) selected_obj);
} else if (selected_obj instanceof GraphFragment) {
drawSelectionBox(g, (GraphFragment) selected_obj);
} else if (selected_obj instanceof TextNote) {
drawSelectionBox(g, (TextNote) selected_obj);
}
}
if (useLabelEditor && selected_obj != null) /*&& at_anchor==-2 */
{
if (labelEditor.isVisible()) {
Rectangle rect = labelEditor.getBounds();
g.drawRect(rect.x - 1, rect.y - 1, rect.width + 2, rect.height + 2);
} else {
Label label;
int lx, ly;
if (selected_obj instanceof Node) {
// label = ((Node)selected_obj).label;
// lx = ((Node)selected_obj).lx;
// ly = ((Node)selected_obj).ly;
// g.drawRect(lx-1, ly-1, label.width+2, label.height+2);
} else if (selected_obj instanceof Link) {
label = ((Link) selected_obj).label;
if (label != null) {
lx = ((Link) selected_obj).lx;
ly = ((Link) selected_obj).ly;
g.drawRect(lx - 1, ly - 1, label.width + 2, label.height + 2);
}
} else if (selected_obj instanceof TextNote) {
JTextArea textarea = ((TextNote) selected_obj).textarea;
lx = ((TextNote) selected_obj).x;
ly = ((TextNote) selected_obj).y;
g.drawRect(lx - 1, ly - 1, textarea.getWidth() + 2, textarea.getHeight() + 2);
}
// else GraphSegment
}
}
}
Aggregations