use of com.ramussoft.idef0.attribute.DFDSName in project ramus by Vitaliy-Yakovchuk.
the class NFunction method setName.
@Override
public void setName(String name) {
Row row = dataPlugin.findRowByGlobalId(getLink());
if (row != null)
row.setName(name);
else {
Attribute attribute = engine.getAttribute(rowSet.getQualifier().getAttributeForName());
if (attribute.getAttributeType().toString().equals("IDEF0.DFDSName")) {
DFDSName dfdsName = new DFDSName();
int r = name.indexOf('\n');
if (r >= 0) {
dfdsName.setShortName(name.substring(0, r));
dfdsName.setLongName(name.substring(r + 1));
} else {
dfdsName.setShortName(name);
dfdsName.setLongName("");
}
setNameObject(dfdsName);
} else
super.setName(name);
}
}
use of com.ramussoft.idef0.attribute.DFDSName in project ramus by Vitaliy-Yakovchuk.
the class NFunction method setOwner.
public void setOwner(final Row owner) {
Function ow = null;
if (getType() == Function.TYPE_DFDS_ROLE) {
ow = (Function) owner;
if (ow == null)
ow = (Function) getOwner();
}
if (owner == null) {
setObject(OWNER_ID, null);
} else {
setObject(OWNER_ID, ((NRow) owner).getElementId());
}
Function function = (Function) getParent();
if (function.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
HashSet<Sector> toUpdate = new HashSet<Sector>();
if (getType() == Function.TYPE_DFDS_ROLE) {
if (ow != null) {
for (Sector sector : function.getSectors()) {
if (ow.equals(sector.getStart().getFunction()) || ow.equals(sector.getEnd().getFunction()))
if (!toUpdate.contains(sector))
toUpdate.add(sector);
}
}
} else {
for (Sector sector : function.getSectors()) {
if (this.equals(sector.getStart().getFunction()) || this.equals(sector.getEnd().getFunction()))
if (!toUpdate.contains(sector))
toUpdate.add(sector);
}
}
for (Sector sector : toUpdate) SectorRefactor.fixOwners(sector, getDataPlugin());
}
for (Attribute attribute : engine.getQualifier(getElement().getQualifierId()).getAttributes()) if (attribute.getAttributeType().equals(DFDSNamePlugin.type)) {
DFDSName dfdsName = (DFDSName) engine.getAttribute(getElement(), attribute);
if (dfdsName != null)
dataPlugin.compileDFDSName(dfdsName, this);
}
}
use of com.ramussoft.idef0.attribute.DFDSName in project ramus by Vitaliy-Yakovchuk.
the class DFDSFunction method paint.
@Override
public void paint(Graphics2D g) {
g.setColor(function.getBackground());
final Rectangle2D rect = movingArea.getBounds(getBounds());
g.fill(rect);
g.setFont(function.getFont());
Object nameObject = ((NFunction) function).getNameObject();
if (!(nameObject instanceof DFDSName)) {
DFDSName dfdsName = new DFDSName();
if (nameObject == null)
nameObject = "";
dfdsName.setShortName(String.valueOf(nameObject));
dfdsName.setLongName("");
nameObject = dfdsName;
}
DFDSName name = (DFDSName) nameObject;
if (!transparent && !movingArea.isPrinting() || isNegative()) {
final Rectangle2D rec = movingArea.getBounds(getBounds());
g.setColor(fiterColor(movingArea.getBackground()));
g.fill(rec);
}
Font font = getFont();
g.setFont(font);
g.setColor(fiterColor(getColor()));
FRectangle textBounds = getTextBounds();
FRectangle p = movingArea.paintText(g, // string + ". " +
name.getShortName(), textBounds, Line.CENTER_ALIGN, 0, true);
textBounds.setY(textBounds.getY() + p.getHeight() + 2);
textBounds.setHeight(textBounds.getHeight() - p.getHeight() - 2);
String term = function.getTerm();
if (term != null && term.length() > 0) {
double y = movingArea.getIDoubleOrdinate(p.getBottom()) + 1;
Stroke stroke = g.getStroke();
g.setStroke(new BasicStroke(1, 1, 1, 2, new float[] { (float) movingArea.getIDoubleOrdinate(1), (float) movingArea.getIDoubleOrdinate(2) }, (float) movingArea.getIDoubleOrdinate(2)));
g.draw(new Line2D.Double(rect.getX(), y, rect.getMaxX(), y));
y++;
g.setStroke(stroke);
int size = font.getSize() - movingArea.secondNamePartMinus;
if (size < 1)
size = 1;
g.setFont(new Font(font.getName(), font.getStyle(), size));
FRectangle fr = movingArea.paintText(g, TERMS, textBounds, Line.LEFT_ALIGN, 0, true);
FRectangle r = new FRectangle(textBounds);
r.setX(textBounds.getX() + fr.getWidth() + 2);
r.setWidth(textBounds.getWidth() - fr.getWidth() - 2);
p = movingArea.paintText(g, term, r, Line.LEFT_ALIGN, 0, true);
textBounds.setY(textBounds.getY() + p.getHeight() + 2);
textBounds.setHeight(textBounds.getHeight() - p.getHeight() - 2);
}
if (name.getLongName() != null && name.getLongName().length() > 0) {
double y = movingArea.getIDoubleOrdinate(p.getBottom()) + 1;
Stroke stroke = g.getStroke();
g.setStroke(new BasicStroke(1, 1, 1, 2, new float[] { (float) movingArea.getIDoubleOrdinate(1), (float) movingArea.getIDoubleOrdinate(2) }, (float) movingArea.getIDoubleOrdinate(2)));
g.draw(new Line2D.Double(rect.getX(), y, rect.getMaxX(), y));
y++;
g.setStroke(stroke);
int size = font.getSize() - movingArea.secondNamePartMinus;
if (size < 1)
size = 1;
g.setFont(new Font(font.getName(), font.getStyle(), size));
movingArea.paintText(g, name.getLongName(), textBounds, Line.LEFT_ALIGN, 0, true);
}
paintBorder(g);
final Stroke tmp = g.getStroke();
g.draw(rect);
if (!function.isHaveRealChilds()) {
g.draw(new Line2D.Double(rect.getMaxX() - Math.round(movingArea.getIDoubleOrdinate(4)), rect.getY(), rect.getMaxX(), rect.getY() + Math.round(movingArea.getIDoubleOrdinate(4))));
}
g.setStroke(new BasicStroke(2));
g.setFont(function.getFont());
paintTringle(g);
g.setStroke(tmp);
List<DFDSRole> roles = movingArea.getDFDSRoles(this);
double xc = rect.getCenterX();
double yc = rect.getCenterY();
for (DFDSRole role : roles) {
Rectangle2D r = movingArea.getBounds(role.getBounds());
if (!rect.intersects(r)) {
double x = r.getCenterX();
double y = r.getCenterY();
double dx = Math.abs(xc - x);
double dy = Math.abs(yc - y);
if (dx > dy) {
if (xc < x)
x = r.getX();
else
x = r.getMaxX();
} else {
if (yc < y)
y = r.getY();
else
y = r.getMaxY();
}
ArrowPainter.paintTilda(g, x, y, rect.getX(), rect.getY(), rect.getMaxX(), rect.getMaxY(), 4, movingArea);
}
}
}
use of com.ramussoft.idef0.attribute.DFDSName in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method createBlocks.
public void createBlocks(String[] names) {
double fromX = 20;
double fromY = 20;
double x = fromX;
double y = fromY;
Attribute attribute = null;
for (String name : names) {
Function function = createFunctionalObject(x, y, Function.TYPE_FUNCTION, activeFunction);
x += 110;
if (x + 110 + 20 > CLIENT_WIDTH) {
x = fromX;
y += 60;
}
if (attribute == null)
attribute = getDataPlugin().getEngine().getAttribute(getDataPlugin().getEngine().getQualifier(((NFunction) function).getQualifierId()).getAttributeForName());
Object object;
if (attribute.getAttributeType().getTypeName().equals("DFDSName")) {
DFDSName dfdsName = new DFDSName();
dfdsName.setShortName(name);
dfdsName.setLongName("");
object = dfdsName;
} else
object = name;
((NFunction) function).setAttribute(attribute, object);
}
}
Aggregations