Search in sources :

Example 1 with IDEF0Object

use of com.ramussoft.pb.idef.visual.IDEF0Object in project ramus by Vitaliy-Yakovchuk.

the class PaintSector method isSelected.

/**
 * Перевіряє, чи являється диний сектор активний.
 *
 * @param area Область відображення.
 * @return true, якщо активний даний сектор або той, що наслідується, false,
 * якщо сектор не активний.
 */
private boolean isSelected(final MovingArea area) {
    if (MovingLabel.getActiveStream() != null && equalsStreams(MovingLabel.getActiveStream(), getStream()))
        return true;
    if (rec)
        return false;
    final PaintSector as = area.getActiveSector();
    if (as == this)
        return true;
    rec = true;
    boolean res = false;
    if (as != null) {
        if (getStart() != null && !getStart().isOne(sector)) {
            if (isSelected(area, getStart()))
                res = true;
        } else if (getEnd() != null && !getEnd().isOne(sector)) {
            if (isSelected(area, getEnd()))
                res = true;
        }
    }
    if (!res && area.getActiveObject() instanceof IDEF0Object) {
        final Function active = ((IDEF0Object) area.getActiveObject()).getFunction();
        if (active == sector.getStart().getFunction() || active == sector.getEnd().getFunction())
            res = true;
    }
    rec = false;
    return res;
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) IDEF0Object(com.ramussoft.pb.idef.visual.IDEF0Object)

Example 2 with IDEF0Object

use of com.ramussoft.pb.idef.visual.IDEF0Object in project ramus by Vitaliy-Yakovchuk.

the class SectorRefactor method updatePageSize.

public void updatePageSize(boolean updateFonts, boolean updateZoom, double percent, Function function) {
    if (updateZoom) {
        function.setBounds(function.getBounds().zoom(percent));
    }
    if (updateFonts) {
        Font font = function.getFont();
        if (font != null) {
            function.setFont(new Font(font.getName(), font.getStyle(), (int) (font.getSize() * percent)));
        }
    }
    if (function.getChildCount() == 0)
        return;
    if (updateZoom) {
        loadFromFunction(function, false);
        for (MovingText text : texts) {
            if (text instanceof IDEF0Object) {
            } else {
            // text.setBounds(text.getBounds().zoom(percent));
            }
        }
        HashSet<Ordinate> ordinates = new HashSet<Ordinate>();
        for (PaintSector paintSector : sectors) {
            for (int i = 0; i < paintSector.getPointCount(); i++) {
                Point point = paintSector.getPoint(i);
                if (!ordinates.contains(point.getXOrdinate()))
                    ordinates.add(point.getXOrdinate());
                if (!ordinates.contains(point.getYOrdinate()))
                    ordinates.add(point.getYOrdinate());
            }
            MovingLabel movingLabel = paintSector.getText();
            if (movingLabel != null) {
                movingLabel.setBounds(movingLabel.getBounds().zoom(percent));
                Font font = movingLabel.getFont();
                movingLabel.setFont(new Font(font.getName(), font.getStyle(), (int) (font.getSize() * percent)));
            }
            Font font = paintSector.getFont();
            if (font != null) {
                paintSector.setFont(new Font(font.getName(), font.getStyle(), (int) (font.getSize() * percent)));
                paintSector.saveVisual();
            }
        }
        for (Ordinate o : ordinates) {
            o.setPosition(percent * o.getPosition());
        }
        for (PaintSector paintSector : sectors) {
            for (int i = 0; i < paintSector.getPointCount(); i++) {
                if (paintSector.getSector().getEnd().getBorderType() == Point.BOTTOM) {
                    Point point = paintSector.getEndPoint();
                    point.getYOrdinate().setPosition(movingArea.CLIENT_HEIGHT - 7);
                } else if (paintSector.getSector().getStart().getBorderType() == Point.BOTTOM) {
                    Point point = paintSector.getStartPoint();
                    point.getYOrdinate().setPosition(movingArea.CLIENT_HEIGHT - 7);
                }
                if (paintSector.getSector().getEnd().getBorderType() == Point.TOP) {
                    Point point = paintSector.getEndPoint();
                    point.getYOrdinate().setPosition(7);
                } else if (paintSector.getSector().getStart().getBorderType() == Point.TOP) {
                    Point point = paintSector.getStartPoint();
                    point.getYOrdinate().setPosition(7);
                }
                if (paintSector.getSector().getEnd().getBorderType() == Point.LEFT) {
                    Point point = paintSector.getEndPoint();
                    point.getXOrdinate().setPosition(7);
                } else if (paintSector.getSector().getStart().getBorderType() == Point.LEFT) {
                    Point point = paintSector.getStartPoint();
                    point.getXOrdinate().setPosition(7);
                }
                if (paintSector.getSector().getEnd().getBorderType() == Point.RIGHT) {
                    Point point = paintSector.getEndPoint();
                    point.getXOrdinate().setPosition(movingArea.CLIENT_WIDTH - 7);
                } else if (paintSector.getSector().getStart().getBorderType() == Point.RIGHT) {
                    Point point = paintSector.getStartPoint();
                    point.getXOrdinate().setPosition(movingArea.CLIENT_WIDTH - 7);
                }
            }
        }
        saveToFunction();
    }
}
Also used : MovingLabel(com.ramussoft.pb.idef.visual.MovingLabel) FloatPoint(com.dsoft.pb.types.FloatPoint) Font(java.awt.Font) IDEF0Object(com.ramussoft.pb.idef.visual.IDEF0Object) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint) MovingText(com.ramussoft.pb.idef.visual.MovingText) HashSet(java.util.HashSet)

Example 3 with IDEF0Object

use of com.ramussoft.pb.idef.visual.IDEF0Object in project ramus by Vitaliy-Yakovchuk.

the class Point method isMoveableFunctionPoint.

/**
 * Метод перевіряє, чи можливе переміщення саме цієї точки, якщо точка
 * розташована на краю функціонального блоку.
 *
 * @param position Нова позиція координати.
 * @param type     Тип координати, переміщення якої має відбуватись.
 * @return true, якщо перміщення можливе, false, якщо переміщення не
 * можливе.
 */
private boolean isMoveableFunctionPoint(final double position, final int type) {
    int funType;
    Function fun;
    if (isStart()) {
        funType = sector.getSector().getStart().getFunctionType();
        fun = sector.getSector().getStart().getFunction();
    } else {
        funType = sector.getSector().getEnd().getFunctionType();
        fun = sector.getSector().getEnd().getFunction();
    }
    if (isMoveableDFDSRow(fun))
        return true;
    IDEF0Object function = sector.getMovingArea().getIDEF0Object(fun);
    if (funType == MovingPanel.LEFT || funType == MovingPanel.RIGHT) {
        if (type == Ordinate.TYPE_Y)
            return position >= function.getBounds().getTop() && position <= function.getBounds().getBottom();
        else {
            if (funType == MovingPanel.LEFT)
                return position > sector.getPoint(sector.getPointCount() - 2).getX();
            else
                return position < sector.getPoint(1).getX();
        }
    } else {
        if (type == Ordinate.TYPE_X)
            return position >= function.getBounds().getLeft() && position <= function.getBounds().getRight();
        else {
            if (funType == MovingPanel.TOP)
                return position > sector.getPoint(sector.getPointCount() - 2).getY();
            else
                return position < sector.getPoint(sector.getPointCount() - 2).getY();
        }
    }
}
Also used : Function(com.ramussoft.pb.Function) FloatPoint(com.dsoft.pb.types.FloatPoint) IDEF0Object(com.ramussoft.pb.idef.visual.IDEF0Object)

Aggregations

IDEF0Object (com.ramussoft.pb.idef.visual.IDEF0Object)3 FloatPoint (com.dsoft.pb.types.FloatPoint)2 Function (com.ramussoft.pb.Function)2 Crosspoint (com.ramussoft.pb.Crosspoint)1 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)1 MovingLabel (com.ramussoft.pb.idef.visual.MovingLabel)1 MovingText (com.ramussoft.pb.idef.visual.MovingText)1 Font (java.awt.Font)1 HashSet (java.util.HashSet)1