Search in sources :

Example 11 with FRectangle

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

Example 12 with FRectangle

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

the class IDEF0Object method setAddedSectorPosWC.

/**
 * Метод організовує зміни в секторі, що виходить або входить в
 * функціональний блок.
 *
 * @param oldRec Старі властивості розмірів функціонального блоку.
 * @param sector Сектор прив’язаний до функціонального блоку.
 */
public boolean setAddedSectorPosWC(final FRectangle oldRec, final PaintSector sector, List<Ordinate> ordinates) {
    boolean res = false;
    final FRectangle currRec = function.getBounds();
    if (function.equals(sector.getSector().getStart().getFunction())) {
        final Point p = sector.getStartPoint();
        if (!p.isMoveable(currRec.getRight(), Ordinate.TYPE_X)) {
            sector.regeneratePoints();
            addOrdinates(sector, ordinates);
        }
        double t = currRec.getY() + currRec.getHeight() * (p.getY() - oldRec.getY()) / oldRec.getHeight();
        if (!p.isMoveable(t, Ordinate.TYPE_Y)) {
            if (sector.getPinCount() == 1)
                p.setYOrdinate(new Ordinate(Ordinate.TYPE_Y));
            p.setY(t);
            sector.regeneratePoints();
            addOrdinates(sector, ordinates);
        } else {
            p.setY(t);
            addOrdinate(ordinates, p.getYOrdinate());
        }
        if (sector.getSector().getStart().getFunctionType() == MovingPanel.RIGHT) {
            p.setX(getX(t, false, currRec));
            addOrdinate(ordinates, p.getXOrdinate());
        } else if (sector.getSector().getStart().getFunctionType() == MovingPanel.LEFT) {
            p.setX(getX(t, true, currRec));
            addOrdinate(ordinates, p.getXOrdinate());
        } else {
            t = currRec.getX() + currRec.getWidth() * (p.getX() - oldRec.getX()) / oldRec.getWidth();
            if (sector.getSector().getStart().getFunctionType() == MovingPanel.TOP) {
                p.setY(getY(t, true, currRec));
            } else {
                p.setY(getY(t, false, currRec));
            }
            addOrdinate(ordinates, p.getYOrdinate());
            if (!p.isMoveable(t, Ordinate.TYPE_X)) {
                p.setXOrdinate(new Ordinate(Ordinate.TYPE_X));
                p.setX(t);
                sector.regeneratePoints();
                addOrdinates(sector, ordinates);
            } else {
                p.setX(t);
                addOrdinate(ordinates, p.getXOrdinate());
            }
            fixCuttedEnd(sector);
            return true;
        }
        res = true;
        fixCuttedEnd(sector);
    }
    if (function.equals(sector.getSector().getEnd().getFunction())) {
        final Point p = sector.getEndPoint();
        if (sector.getSector().getEnd().getFunctionType() == MovingPanel.LEFT) {
            if (!p.isMoveable(currRec.getLeft(), Ordinate.TYPE_X)) {
                sector.regeneratePoints();
                addOrdinates(sector, ordinates);
            }
            final double t = currRec.getY() + currRec.getHeight() * (p.getY() - oldRec.getY()) / oldRec.getHeight();
            p.setX(getX(t, true, currRec));
            addOrdinate(ordinates, p.getXOrdinate());
            if (!p.isMoveable(t, Ordinate.TYPE_Y)) {
                if (sector.getPinCount() == 1)
                    p.setYOrdinate(new Ordinate(Ordinate.TYPE_Y));
                p.setY(t);
                sector.regeneratePoints();
                addOrdinates(sector, ordinates);
            } else {
                p.setY(t);
                addOrdinate(ordinates, p.getYOrdinate());
            }
        } else if (sector.getSector().getEnd().getFunctionType() == MovingPanel.RIGHT) {
            if (!p.isMoveable(currRec.getLeft(), Ordinate.TYPE_X)) {
                sector.regeneratePoints();
                addOrdinates(sector, ordinates);
            }
            final double t = currRec.getY() + currRec.getHeight() * (p.getY() - oldRec.getY()) / oldRec.getHeight();
            p.setX(getX(t, false, currRec));
            addOrdinate(ordinates, p.getXOrdinate());
            if (!p.isMoveable(t, Ordinate.TYPE_Y)) {
                if (sector.getPinCount() == 1)
                    p.setYOrdinate(new Ordinate(Ordinate.TYPE_Y));
                p.setY(t);
                sector.regeneratePoints();
                addOrdinates(sector, ordinates);
            } else {
                p.setY(t);
                addOrdinate(ordinates, p.getYOrdinate());
            }
        } else {
            final double t = currRec.getX() + currRec.getWidth() * (p.getX() - oldRec.getX()) / oldRec.getWidth();
            if (sector.getSector().getEnd().getFunctionType() == MovingPanel.TOP) {
                p.setY(getY(t, true, currRec));
                if (!p.isMoveable(currRec.getTop(), Ordinate.TYPE_Y)) {
                    sector.regeneratePoints();
                    addOrdinates(sector, ordinates);
                } else
                    addOrdinate(ordinates, p.getYOrdinate());
            } else {
                p.setY(getY(t, false, currRec));
                if (!p.isMoveable(currRec.getBottom(), Ordinate.TYPE_Y)) {
                    sector.regeneratePoints();
                    addOrdinates(sector, ordinates);
                } else
                    addOrdinate(ordinates, p.getYOrdinate());
            }
            if (!p.isMoveable(t, Ordinate.TYPE_X)) {
                p.setXOrdinate(new Ordinate(Ordinate.TYPE_X));
                p.setX(t);
                sector.regeneratePoints();
                addOrdinates(sector, ordinates);
            } else {
                p.setX(t);
                addOrdinate(ordinates, p.getXOrdinate());
            }
        }
        res = true;
        fixCuttedStart(sector);
    }
    sector.tryRemovePin(movingArea);
    return res;
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Ordinate(com.ramussoft.pb.idef.elements.Ordinate)

Example 13 with FRectangle

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

the class IDEF0Object method paint.

@Override
public void paint(final Graphics2D g) {
    g.setColor(function.getBackground());
    final Rectangle2D rect = movingArea.getBounds(getBounds());
    g.fill(rect);
    g.setFont(function.getFont());
    // g.setColor(function.getForeground());
    super.paint(g);
    final Stroke tmp = g.getStroke();
    g.draw(rect);
    if (!function.isHaveChilds()) {
        g.draw(new Line2D.Double(rect.getX() + Math.round(movingArea.getIDoubleOrdinate(4)), rect.getY(), rect.getX(), rect.getY() + Math.round(movingArea.getIDoubleOrdinate(4))));
    }
    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;
    movingArea.paintText(g, string, new FRectangle(getBounds().getX(), getBounds().getBottom() - h - 3, getBounds().getWidth() - 3, h), com.ramussoft.pb.print.old.Line.RIGHT_ALIGN, 1, true);
    g.setStroke(tmp);
    paintTringle(g);
}
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)

Example 14 with FRectangle

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

the class IDEF0Object method onProcessEndBoundsChange.

public void onProcessEndBoundsChange(List<PaintSector> notToMove) {
    final FRectangle oldRec = function.getBounds();
    super.onProcessEndBoundsChange();
    function.setBounds(new FRectangle(myBounds));
    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);
        boolean con = false;
        if (notToMove != null)
            for (PaintSector ps : notToMove) {
                if (ps.getSector().equals(sector.getSector())) {
                    con = true;
                    break;
                }
            }
        if (con)
            continue;
        setAddedSectorPos(oldRec, sector, list);
    }
    for (PaintSector ps : list) PaintSector.save(ps, memoryData, ((NFunction) function).getEngine());
}
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) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint)

Example 15 with FRectangle

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

the class MovingArea method copyDFDSVisual.

protected void copyDFDSVisual() {
    startUserTransaction();
    DFDSRole role = (DFDSRole) activeObject;
    VisualPanelImpl panelImpl = new VisualPanelImpl(role);
    Stream stream = role.getStream();
    Row[] oRows = stream.getAdded();
    for (Row row : dataPlugin.getRecChilds(dataPlugin.getBaseFunction(), true)) if (row instanceof Function) {
        final Function f = (Function) row;
        if (f.getType() == Function.TYPE_DFDS_ROLE && f.getElement().getId() != role.getFunction().getElement().getId()) {
            long l = f.getLink();
            if (l >= 0) {
                Stream s = (Stream) dataPlugin.findRowByGlobalId(l);
                if (s != null && s.getAdded() != null) {
                    Row[] rows = s.getAdded();
                    boolean b = false;
                    for (Row row2 : rows) if (row2 != null) {
                        if (b)
                            break;
                        for (Row row3 : oRows) if (row3.equals(row2)) {
                            panelImpl.copyTo(new VisualPanel() {

                                @Override
                                public void setForegroundA(Color foreground) {
                                    f.setForeground(foreground);
                                }

                                @Override
                                public void setFontA(Font font) {
                                    f.setFont(font);
                                }

                                @Override
                                public void setBoundsA(FRectangle bounds) {
                                    f.setBounds(bounds);
                                }

                                @Override
                                public void setBackgroundA(Color background) {
                                    f.setBackground(background);
                                }

                                @Override
                                public Color getForegroundA() {
                                    return f.getForeground();
                                }

                                @Override
                                public Font getFontA() {
                                    return f.getFont();
                                }

                                @Override
                                public FRectangle getBoundsA() {
                                    return f.getBounds();
                                }

                                @Override
                                public Color getBackgroundA() {
                                    return f.getBackground();
                                }
                            }, copyOptions.copyBK, copyOptions.copyFK, copyOptions.copyFont, copyOptions.copySize);
                            b = true;
                            break;
                        }
                    }
                }
            }
        }
    }
    commitUserTransaction();
}
Also used : DFDSRole(com.ramussoft.pb.dfds.visual.DFDSRole) 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) FRectangle(com.dsoft.pb.types.FRectangle) Color(java.awt.Color) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) Font(java.awt.Font)

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