Search in sources :

Example 1 with DFDSName

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);
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) DFDSName(com.ramussoft.idef0.attribute.DFDSName) Row(com.ramussoft.pb.Row)

Example 2 with DFDSName

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);
    }
}
Also used : Function(com.ramussoft.pb.Function) Attribute(com.ramussoft.common.Attribute) Sector(com.ramussoft.pb.Sector) DFDSName(com.ramussoft.idef0.attribute.DFDSName) HashSet(java.util.HashSet)

Example 3 with DFDSName

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);
        }
    }
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) NFunction(com.ramussoft.pb.data.negine.NFunction) Rectangle2D(java.awt.geom.Rectangle2D) Line2D(java.awt.geom.Line2D) Font(java.awt.Font) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) FRectangle(com.dsoft.pb.types.FRectangle) DFDSName(com.ramussoft.idef0.attribute.DFDSName)

Example 4 with DFDSName

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);
    }
}
Also used : DFDSFunction(com.ramussoft.pb.dfds.visual.DFDSFunction) Function(com.ramussoft.pb.Function) DFDFunction(com.ramussoft.pb.dfd.visual.DFDFunction) NFunction(com.ramussoft.pb.data.negine.NFunction) Attribute(com.ramussoft.common.Attribute) NFunction(com.ramussoft.pb.data.negine.NFunction) DFDSName(com.ramussoft.idef0.attribute.DFDSName) DFDObject(com.ramussoft.pb.dfd.visual.DFDObject)

Aggregations

DFDSName (com.ramussoft.idef0.attribute.DFDSName)4 Attribute (com.ramussoft.common.Attribute)3 Function (com.ramussoft.pb.Function)2 NFunction (com.ramussoft.pb.data.negine.NFunction)2 FRectangle (com.dsoft.pb.types.FRectangle)1 FloatPoint (com.dsoft.pb.types.FloatPoint)1 Crosspoint (com.ramussoft.pb.Crosspoint)1 Row (com.ramussoft.pb.Row)1 Sector (com.ramussoft.pb.Sector)1 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)1 DFDObject (com.ramussoft.pb.dfd.visual.DFDObject)1 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)1 BasicStroke (java.awt.BasicStroke)1 Font (java.awt.Font)1 Stroke (java.awt.Stroke)1 Line2D (java.awt.geom.Line2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 HashSet (java.util.HashSet)1