Search in sources :

Example 21 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class HTTPParser method getPinCoords.

private String getPinCoords(final Pin pin, final MovingArea area) {
    final double d = 2;
    final FRectangle bounds = new FRectangle();
    if (pin.getType() == PaintSector.PIN_TYPE_X) {
        double x1 = pin.getStart().getX();
        double x2 = pin.getEnd().getX();
        final double y = pin.getEnd().getY();
        if (x2 < x1) {
            final double x = x1;
            x1 = x2;
            x2 = x;
        }
        bounds.setX(x1);
        bounds.setWidth(x2 - x1);
        bounds.setY(y - d);
        bounds.setHeight(d * 2);
    } else {
        double y1 = pin.getStart().getY();
        double y2 = pin.getEnd().getY();
        final double x = pin.getEnd().getX();
        if (y2 < y1) {
            final double y = y1;
            y1 = y2;
            y2 = y;
        }
        bounds.setY(y1);
        bounds.setHeight(y2 - y1);
        bounds.setX(x - d);
        bounds.setWidth(d * 2);
    }
    return getAreaCoords(bounds, area);
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle)

Example 22 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class FRectanglePlugin method getAttributeConverter.

@Override
public AttributeConverter getAttributeConverter() {
    return new SimpleAttributeConverter() {

        @Override
        protected Object toObject(Persistent persistent) {
            FRectanglePersistent fp = (FRectanglePersistent) persistent;
            return new FRectangle(fp.getX(), fp.getY(), fp.getWidth(), fp.getHeight());
        }

        @Override
        protected Persistent toPersistent(Object value) {
            FRectanglePersistent e = new FRectanglePersistent();
            FRectangle rect = (FRectangle) value;
            e.setX(rect.getX());
            e.setY(rect.getY());
            e.setWidth(rect.getWidth());
            e.setHeight(rect.getHeight());
            return e;
        }
    };
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle) Persistent(com.ramussoft.common.persistent.Persistent) SimpleAttributeConverter(com.ramussoft.core.attribute.simple.SimpleAttributeConverter)

Example 23 with FRectangle

use of com.dsoft.pb.types.FRectangle 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 24 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class DFDSFunction method setAddedRolesPos.

private void setAddedRolesPos(FRectangle oldRec, FRectangle bounds) {
    if (oldRec.getWidth() != bounds.getWidth())
        justifyRoles();
    else {
        double dx = bounds.getX() - oldRec.getX();
        double dy = bounds.getBottom() - oldRec.getBottom();
        for (DFDSRole role : movingArea.getDFDSRoles(this)) {
            FRectangle rectangle = role.getBounds();
            if (oldRec.intersects(rectangle)) {
                rectangle.setX(rectangle.getX() + dx);
                rectangle.setY(rectangle.getY() + dy);
                role.getFunction().setBounds(new FRectangle(rectangle));
            }
        }
    }
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle)

Example 25 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class IDLImporter method addBox.

private void addBox() {
    Function function = getFunction(box.reference);
    int i = box.name.indexOf('}');
    box.function = function;
    function.setName(box.name.substring(i + 1));
    StringTokenizer st = new StringTokenizer(box.name.substring(1, i), " ");
    if (st.hasMoreTokens())
        st.nextElement();
    if (st.hasMoreTokens()) {
        try {
            int font = Integer.parseInt(st.nextToken());
            function.setFont(uniqueFonts.get(font));
        } catch (Exception e) {
        }
    }
    if (st.hasMoreTokens())
        st.nextElement();
    Color bColor = null;
    Color fColor = null;
    if (st.hasMoreTokens()) {
        int tmp = Integer.parseInt(st.nextToken());
        if (tmp < COLORS.length) {
            fColor = COLORS[tmp];
        }
        tmp = Integer.parseInt(st.nextToken());
        if (tmp < COLORS.length) {
            bColor = COLORS[tmp];
        }
    }
    if (bColor != null)
        function.setBackground(bColor);
    if (fColor != null)
        function.setForeground(fColor);
    StringTokenizer tokenizer = new StringTokenizer(box.coordinates, " ()");
    FloatPoint p1 = toPoint(tokenizer.nextToken());
    FloatPoint p2 = toPoint(tokenizer.nextToken());
    FRectangle rectangle = new FRectangle(p1.getX(), p2.getY(), p2.getX() - p1.getX(), p1.getY() - p2.getY());
    function.setBounds(rectangle);
    Status status = new Status(Status.WORKING, "");
    function.setStatus(status);
}
Also used : Status(com.dsoft.pb.idef.elements.Status) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) StringTokenizer(java.util.StringTokenizer) FloatPoint(com.dsoft.pb.types.FloatPoint) FRectangle(com.dsoft.pb.types.FRectangle) Color(java.awt.Color) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) IOException(java.io.IOException)

Aggregations

FRectangle (com.dsoft.pb.types.FRectangle)39 FloatPoint (com.dsoft.pb.types.FloatPoint)11 NFunction (com.ramussoft.pb.data.negine.NFunction)11 Rectangle2D (java.awt.geom.Rectangle2D)10 Function (com.ramussoft.pb.Function)9 Point (com.ramussoft.pb.idef.elements.Point)7 BasicStroke (java.awt.BasicStroke)6 Stroke (java.awt.Stroke)6 Line2D (java.awt.geom.Line2D)6 ArrayList (java.util.ArrayList)6 Crosspoint (com.ramussoft.pb.Crosspoint)5 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)5 Row (com.ramussoft.pb.Row)4 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)4 Font (java.awt.Font)4 MemoryData (com.dsoft.utils.DataLoader.MemoryData)3 Stream (com.ramussoft.pb.Stream)3 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)3 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)3 Status (com.dsoft.pb.idef.elements.Status)2