Search in sources :

Example 1 with NFunction

use of com.ramussoft.pb.data.negine.NFunction 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 2 with NFunction

use of com.ramussoft.pb.data.negine.NFunction 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 3 with NFunction

use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.

the class DFDSRole method onProcessEndBoundsChange.

@Override
public void onProcessEndBoundsChange() {
    final FRectangle oldRec = function.getBounds();
    myBounds.setTransformNetBounds(MovingArea.NET_LENGTH);
    List<PaintSector> list = new ArrayList<PaintSector>();
    final SectorRefactor refactor = movingArea.getRefactor();
    boolean sectorReplaced = false;
    DFDSFunction function = movingArea.findDFDSFunction(this.getBounds());
    if (function != null) {
        getFunction().setOwner(function.getFunction());
        for (int i = 0; i < refactor.getSectorsCount(); i++) {
            PaintSector ps = refactor.getSector(i);
            Function function2 = ps.getSector().getStart().getFunction();
            if (function2 != null && function2.equals(this.function)) {
                replaceFunction(ps.getSector().getStart(), ps, list, ps.getStartPoint(), ps.getSector().getStart().getFunctionType(), function, refactor, true);
            }
            Function function3 = ps.getSector().getEnd().getFunction();
            if (function3 != null && function3.equals(this.function)) {
                replaceFunction(ps.getSector().getEnd(), ps, list, ps.getEndPoint(), ps.getSector().getEnd().getFunctionType(), function, refactor, false);
            }
        }
        function.justifyRoles();
        sectorReplaced = true;
    } else {
        if (this.getFunction().getOwner() != null) {
            DFDSFunction function2 = movingArea.findDFDSFunction(this.getFunction().getOwner());
            if (function2 != null && function2.getBounds().intersects(this.getBounds())) {
                function2.justifyRoles();
            } else
                this.function.setBounds(new FRectangle(myBounds));
        } else
            this.function.setBounds(new FRectangle(myBounds));
    }
    MemoryData memoryData = new MemoryData();
    if (!sectorReplaced) {
        for (int i = 0; i < refactor.getSectorsCount(); i++) {
            PaintSector sector = refactor.getSector(i);
            setAddedSectorPos(oldRec, sector, list);
        }
    }
    for (PaintSector ps : list) PaintSector.save(ps, memoryData, ((NFunction) this.function).getEngine());
    long l = this.function.getLink();
    if (l >= 0l) {
        Stream stream = (Stream) movingArea.getDataPlugin().findRowByGlobalId(l);
        if (stream != null) {
            Row[] rows = stream.getAdded();
            RectangleVisualOptions ops = new RectangleVisualOptions();
            ops.bounds = this.function.getBounds();
            ops.background = this.function.getBackground();
            ops.font = this.function.getFont();
            ops.foreground = this.function.getForeground();
            for (Row row : rows) if (row != null) {
                IDEF0Plugin.setDefaultRectangleVisualOptions(movingArea.getDataPlugin().getEngine(), row.getElement(), ops);
            }
        }
    }
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) NFunction(com.ramussoft.pb.data.negine.NFunction) ArrayList(java.util.ArrayList) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) FRectangle(com.dsoft.pb.types.FRectangle) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) MemoryData(com.dsoft.utils.DataLoader.MemoryData) RectangleVisualOptions(com.ramussoft.idef0.attribute.RectangleVisualOptions) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

Example 4 with NFunction

use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.

the class AbstractDataPlugin method indexOfFunction.

public int indexOfFunction(final Function function) {
    if (((NFunction) function).isBase())
        return 0;
    class X {

        private int count = 0;

        private Function f;

        public int getIndex(final Function f) {
            this.f = f;
            calc(getBaseFunction(f));
            return count;
        }

        private boolean calc(final Function base) {
            final Enumeration cs = base.children();
            while (cs.hasMoreElements()) {
                final Function c = (Function) cs.nextElement();
                if (c.getType() >= Function.TYPE_EXTERNAL_REFERENCE)
                    continue;
                if (c.equals(f)) {
                    count++;
                    return true;
                }
                if (c.isHaveRealChilds()) {
                    count++;
                    if (calc(c))
                        return true;
                }
            }
            return false;
        }
    }
    return new X().getIndex(function);
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) Enumeration(java.util.Enumeration) NFunction(com.ramussoft.pb.data.negine.NFunction)

Example 5 with NFunction

use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.

the class DataStore method paint.

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

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

            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());
        Rectangle2D r2d = null;
        if (row != null) {
            String string = row.getKod();
            r2d = function.getFont().getStringBounds(string, g.getFontRenderContext());
            left = movingArea.getIDoubleOrdinate(r2d.getWidth()) + 1;
        } else {
            left = EMPTY_LEFT;
        }
        g.fill(rect);
        g.setFont(function.getFont());
        paintText(g);
        if (row != null) {
            String string = row.getKod();
            movingArea.paintText(g, string, new FRectangle(myBounds.getX() + 0.5, myBounds.getY(), left - 0.5, myBounds.getHeight()), Line.LEFT_ALIGN, 1, true);
        }
        g.draw(new Line2D.Double(rect.getX() + left, rect.getMaxY(), rect.getX() + left, rect.getY()));
        paintBorder(g);
        g.draw(new Line2D.Double(rect.getX(), rect.getY(), rect.getMaxX(), rect.getY()));
        g.draw(new Line2D.Double(rect.getX(), rect.getMaxY(), rect.getX(), rect.getY()));
        g.draw(new Line2D.Double(rect.getMaxX(), rect.getMaxY(), rect.getX(), rect.getMaxY()));
        g.setStroke(new BasicStroke(2));
        /*
             * g.draw(new Line2D.Double(rect.getX() + rect.getWidth() - 1,
			 * rect.getY() + 1, rect.getX() + rect.getWidth() - 1, rect.getY() +
			 * rect.getHeight() - 1)); g.draw(new Line2D.Double(rect.getX() + 1,
			 * rect.getY() + rect.getHeight() - 1, rect.getX() + rect.getWidth()
			 * - 1, rect .getY() + rect.getHeight() - 1));
			 */
        final String string = getIDEF0Kod();
        g.setFont(function.getFont());
        double h = MovingArea.getWidth(0) + MovingArea.getWidth((int) function.getFont().getStringBounds(string, g.getFontRenderContext()).getHeight());
        h = h * 0.7;
        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);
        }
    } catch (NullPointerException e) {
    }
    g.setStroke(tmp);
}
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) 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)

Aggregations

NFunction (com.ramussoft.pb.data.negine.NFunction)24 Function (com.ramussoft.pb.Function)10 Row (com.ramussoft.pb.Row)9 FloatPoint (com.dsoft.pb.types.FloatPoint)8 FRectangle (com.dsoft.pb.types.FRectangle)7 Attribute (com.ramussoft.common.Attribute)7 Qualifier (com.ramussoft.common.Qualifier)7 Point (com.ramussoft.pb.idef.elements.Point)7 Crosspoint (com.ramussoft.pb.Crosspoint)6 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)6 NSector (com.ramussoft.pb.data.negine.NSector)5 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)5 Element (com.ramussoft.common.Element)4 Sector (com.ramussoft.pb.Sector)4 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)4 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)4 MemoryData (com.dsoft.utils.DataLoader.MemoryData)3 Engine (com.ramussoft.common.Engine)3 DataPlugin (com.ramussoft.pb.DataPlugin)3 PerspectivePoint (com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint)3