Search in sources :

Example 1 with FRectangle

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

the class DFDFunctionEllipse method paint.

@Override
public void paint(Graphics2D g) {
    g.setColor(function.getBackground());
    final Rectangle2D rect = movingArea.getBounds(getBounds());
    Ellipse2D ellipse = new Ellipse2D.Double(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
    g.fill(ellipse);
    g.setFont(function.getFont());
    paintText(g);
    paintBorder(g);
    final Stroke tmp = g.getStroke();
    g.draw(ellipse);
    if (!function.isHaveChilds()) {
        FRectangle fr = new FRectangle(rect);
        double y1 = rect.getY() + rect.getHeight() / 2.5;
        double x1 = getX(rect.getY() + rect.getHeight() / 2.5, true, fr);
        double x2 = rect.getX() + rect.getWidth() / 2.5;
        double y2 = getY(x2, true, fr);
        g.draw(new Line2D.Double(x1, y1, x2, y2));
    }
    g.setStroke(new BasicStroke(2));
    final String string = Integer.toString(function.getId());
    g.setFont(function.getFont());
    double h = MovingArea.getWidth(0) + MovingArea.getWidth((int) function.getFont().getStringBounds(string, g.getFontRenderContext()).getHeight());
    h = h * 0.7;
    paintTringle(g);
    g.setStroke(tmp);
    movingArea.paintText(g, string, new FRectangle(getBounds().getX(), getBounds().getBottom() - h, getBounds().getWidth(), h), com.ramussoft.pb.print.old.Line.RIGHT_ALIGN, 1, true);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) FRectangle(com.dsoft.pb.types.FRectangle) Rectangle2D(java.awt.geom.Rectangle2D) Line2D(java.awt.geom.Line2D) Ellipse2D(java.awt.geom.Ellipse2D)

Example 2 with FRectangle

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

the class External method paint.

@Override
public void paint(Graphics2D g) {
    DataPlugin dp = ((NFunction) function).getDataPlugin();
    Row row = dp.findRowByGlobalId(function.getLink());
    final class PolygonD extends Polygon {

        /**
         */
        private static final long serialVersionUID = 113232131232134523L;

        public void addPoint(final double x, final double y) {
            super.addPoint((int) x, (int) y);
        }
    }
    g.setColor(function.getBackground());
    final Rectangle2D rect = movingArea.getBounds(getBounds());
    g.fill(rect);
    g.setFont(function.getFont());
    paintText(g);
    if (row != null) {
        String string = row.getKod();
        movingArea.paintText(g, string, new FRectangle(myBounds.getX() + 3, myBounds.getY() + 3, myBounds.getWidth() - 3, myBounds.getHeight() - 3), Line.LEFT_ALIGN, 0, true);
    }
    paintBorder(g);
    final Stroke tmp = g.getStroke();
    g.draw(rect);
    double zm = movingArea.getIDoubleOrdinate(2);
    g.draw(new Line2D.Double(rect.getX() + zm, rect.getY() + zm, rect.getX() + zm, rect.getY() + rect.getHeight()));
    g.draw(new Line2D.Double(rect.getX() + zm, rect.getY() + zm, rect.getX() + rect.getWidth(), rect.getY() + zm));
    if (paintTriangle >= 0) {
        final PolygonD p = new PolygonD();
        p.addPoint(rect.getX() + rect.getWidth() / 2, rect.getY() + rect.getHeight() / 2);
        int standoff2 = -1;
        switch(paintTriangle) {
            case Point.TOP:
                {
                    p.addPoint(rect.getX() + standoff2, rect.getY() + standoff2);
                    p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + standoff2);
                }
                break;
            case Point.LEFT:
                {
                    p.addPoint(rect.getX() + standoff2, rect.getY() + standoff2);
                    p.addPoint(rect.getX() + standoff2, rect.getY() + rect.getHeight() - standoff2);
                }
                break;
            case Point.RIGHT:
                {
                    p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + standoff2);
                    p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + rect.getHeight() - standoff2);
                }
                break;
            case Point.BOTTOM:
                {
                    p.addPoint(rect.getX() + standoff2, rect.getY() + rect.getHeight() - standoff2);
                    p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + rect.getHeight() - standoff2);
                }
                break;
        }
        if (p.npoints > 1)
            g.fillPolygon(p);
    }
    g.setStroke(tmp);
}
Also used : Stroke(java.awt.Stroke) NFunction(com.ramussoft.pb.data.negine.NFunction) Rectangle2D(java.awt.geom.Rectangle2D) Line2D(java.awt.geom.Line2D) Point(com.ramussoft.pb.idef.elements.Point) FRectangle(com.dsoft.pb.types.FRectangle) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin) Polygon(java.awt.Polygon)

Example 3 with FRectangle

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

the class DFDSFunction method onProcessEndBoundsChange.

@Override
public void onProcessEndBoundsChange() {
    FRectangle oldRec = function.getBounds();
    myBounds.setTransformNetBounds(MovingArea.NET_LENGTH);
    FRectangle newRect = new FRectangle(myBounds);
    function.setBounds(newRect);
    final SectorRefactor refactor = movingArea.getRefactor();
    MemoryData memoryData = new MemoryData();
    List<PaintSector> list = new ArrayList<PaintSector>();
    for (int i = 0; i < refactor.getSectorsCount(); i++) {
        PaintSector sector = refactor.getSector(i);
        try {
            setAddedSectorPos(oldRec, sector, list);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    for (PaintSector ps : list) PaintSector.save(ps, memoryData, ((NFunction) function).getEngine());
    setAddedRolesPos(oldRec, newRect);
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) FRectangle(com.dsoft.pb.types.FRectangle) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) NFunction(com.ramussoft.pb.data.negine.NFunction) MemoryData(com.dsoft.utils.DataLoader.MemoryData) ArrayList(java.util.ArrayList) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 4 with FRectangle

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

the class DFDSFunction method justifyRoles.

public void justifyRoles(List<Function> roles1) {
    FRectangle bounds = getBounds();
    List<Function> roles = new ArrayList<Function>();
    for (Function role : roles1) if (bounds.intersects(role.getBounds()))
        roles.add(role);
    List<List<FRectangle>> lines = new ArrayList<List<FRectangle>>();
    lines.add(new ArrayList<FRectangle>());
    List<double[]> maxHights = new ArrayList<double[]>();
    maxHights.add(new double[] { 0 });
    int line = 0;
    double x = bounds.getX() + 2;
    double maxX = bounds.getX() + bounds.getWidth() * ROLES_PERCENT;
    for (Function role : roles) {
        FRectangle rectangle = role.getBounds();
        if (x + rectangle.getWidth() > maxX) {
            line++;
            lines.add(new ArrayList<FRectangle>());
            x = bounds.getX() + 2;
            maxHights.add(new double[] { 0 });
        }
        List<FRectangle> list = lines.get(line);
        FRectangle rect = role.getBounds();
        list.add(rect);
        rect.setX(x);
        if (rect.getHeight() > maxHights.get(line)[0])
            maxHights.get(line)[0] = rect.getHeight();
        x += rect.getWidth() + 3;
    }
    double d = maxHights.get(line)[0];
    double y = bounds.getBottom() - d - 2;
    for (int i = line; i >= 0; --i) {
        List<FRectangle> rectangles = lines.get(i);
        for (FRectangle rectangle : rectangles) rectangle.setY(y);
        if (i > 0)
            y -= maxHights.get(i - 1)[0];
    }
    int i = 0;
    for (List<FRectangle> list : lines) for (FRectangle rectangle : list) {
        roles.get(i).setBounds(new FRectangle(rectangle));
        i++;
    }
}
Also used : DFDFunction(com.ramussoft.pb.dfd.visual.DFDFunction) NFunction(com.ramussoft.pb.data.negine.NFunction) Function(com.ramussoft.pb.Function) FRectangle(com.dsoft.pb.types.FRectangle) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 5 with FRectangle

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

the class DFDSFunction method justifyByDFDSRoles.

public void justifyByDFDSRoles(List<DFDSRole> roles1) {
    FRectangle bounds = getBounds();
    List<DFDSRole> roles = new ArrayList<DFDSRole>();
    for (DFDSRole role : roles1) if (bounds.intersects(role.getBounds()))
        roles.add(role);
    List<List<FRectangle>> lines = new ArrayList<List<FRectangle>>();
    lines.add(new ArrayList<FRectangle>());
    List<double[]> maxHights = new ArrayList<double[]>();
    maxHights.add(new double[] { 0 });
    int line = 0;
    double x = bounds.getX() + 2;
    double maxX = bounds.getX() + bounds.getWidth() * ROLES_PERCENT;
    for (DFDSRole role : roles) {
        FRectangle rectangle = role.getBounds();
        if (x + rectangle.getWidth() > maxX) {
            line++;
            lines.add(new ArrayList<FRectangle>());
            x = bounds.getX() + 2;
            maxHights.add(new double[] { 0 });
        }
        List<FRectangle> list = lines.get(line);
        FRectangle rect = role.getBounds();
        list.add(rect);
        rect.setX(x);
        if (rect.getHeight() > maxHights.get(line)[0])
            maxHights.get(line)[0] = rect.getHeight();
        x += rect.getWidth() + 3;
    }
    double d = maxHights.get(line)[0];
    double y = bounds.getBottom() - d - 2;
    for (int i = line; i >= 0; --i) {
        List<FRectangle> rectangles = lines.get(i);
        for (FRectangle rectangle : rectangles) rectangle.setY(y);
        if (i > 0)
            y -= maxHights.get(i - 1)[0];
    }
    int i = 0;
    for (List<FRectangle> list : lines) for (FRectangle rectangle : list) {
        roles.get(i).getFunction().setBounds(new FRectangle(rectangle));
        i++;
    }
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint)

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