Search in sources :

Example 16 with Crosspoint

use of com.ramussoft.pb.Crosspoint in project ramus by Vitaliy-Yakovchuk.

the class PaintSector method getRemoved.

private void getRemoved(final Sector sector, final Vector<PaintSector> resRemove) {
    final PaintSector ps = movingArea.getRefactor().getPaintSector(sector);
    if (ps == null || resRemove.indexOf(ps) >= 0)
        return;
    resRemove.add(ps);
    Crosspoint c;
    c = sector.getStart().getCrosspoint();
    if (c != null && c.isOne(sector)) {
        final Sector[] sectors = c.getIns();
        for (final Sector s : sectors) getRemoved(s, resRemove);
    }
    c = sector.getEnd().getCrosspoint();
    if (c != null && c.isOne(sector)) {
        final Sector[] sectors = c.getOuts();
        for (final Sector s : sectors) getRemoved(s, resRemove);
    }
}
Also used : Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) AbstractSector(com.ramussoft.pb.data.AbstractSector) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 17 with Crosspoint

use of com.ramussoft.pb.Crosspoint in project ramus by Vitaliy-Yakovchuk.

the class PaintSector method paint.

/**
 * Малює сектор, використовуючи параметри movingArea.
 *
 * @param g          Об’єкт для малювання.
 * @param movingArea Об’єкт для завантаження параметрів.
 */
public void paint(final Graphics2D g, final MovingArea movingArea) {
    g.setColor(getColor());
    g.setFont(getFont());
    arrowPainter = new ArrowPainter(movingArea);
    if (movingArea.getMousePin() != null && movingArea.getMousePin().getSector() == this && !selStart && !selEnd || isSelected(movingArea))
        g.setStroke(getBoldStroke());
    else {
        Stroke stroke = getStroke();
        if (stroke instanceof WayStroke) {
            final float arrowWidth = (float) movingArea.getIDoubleOrdinate(ArrowPainter.ARROW_WIDTH);
            WayStroke wayStroke = (WayStroke) stroke;
            if (wayStroke.getType() == 0)
                wayStroke.setArrowWidth(arrowWidth);
            else if (wayStroke.getType() == 1)
                wayStroke.setArrowWidth(arrowWidth / 2);
            else
                wayStroke.setArrowWidth(arrowWidth / 3);
        } else if (stroke instanceof ArrowedStroke) {
            final float arrowWidth = (float) movingArea.getIDoubleOrdinate(ArrowPainter.ARROW_WIDTH);
            final float arrowHeight = (float) movingArea.getIDoubleOrdinate(ArrowPainter.ARROW_HEIGHT);
            g.setStroke(new ArrowedStroke(arrowWidth, arrowHeight));
            ArrowedStroke arrowedStroke = (ArrowedStroke) stroke;
            if (arrowedStroke.getType() == 0) {
                arrowedStroke.setArrowWidth(arrowWidth);
                arrowedStroke.setArrowHeight(arrowHeight);
            } else if (arrowedStroke.getType() == 1) {
                arrowedStroke.setArrowWidth(arrowWidth / 2);
                arrowedStroke.setArrowHeight(arrowHeight / 2);
            } else {
                arrowedStroke.setArrowWidth(arrowWidth / 3);
                arrowedStroke.setArrowHeight(arrowHeight / 3);
            }
        }
        g.setStroke(stroke);
    }
    for (int i = 0; i < getPinCount(); i++) getPin(i).paint(g, movingArea);
    if (showTilda && text != null)
        arrowPainter.paintTilda(g, this);
    switch(getStartTunnelType()) {
        case Crosspoint.TUNNEL_SIMPLE_SOFT:
        case Crosspoint.TUNNEL_SOFT:
            {
                arrowPainter.paintTunnel(g, getStartPoint().getPoint(), getVectorType(SectorRefactor.TYPE_START), true);
            }
            break;
        case Crosspoint.TUNNEL_HARD:
            {
                arrowPainter.paintTunnel(g, getStartPoint().getPoint(), getVectorType(SectorRefactor.TYPE_START), false);
            }
            break;
        case Crosspoint.TUNNEL_NONE:
            {
                int borderType = getSector().getStart().getBorderType();
                NCrosspoint crosspoint = (NCrosspoint) getStart();
                if ((borderType >= 0) && (crosspoint != null) && (crosspoint.isOneInOut())) {
                    NSector in = (NSector) crosspoint.getIn();
                    Function outer = in.getFunction();
                    NSector out = (NSector) crosspoint.getOut();
                    Function inner = out.getFunction();
                    if ((inner != null) && (inner.getParent() != null) && (!inner.getParent().equals(outer))) {
                        arrowPainter.paintLink(g, getStartPoint().getPoint(), getVectorType(SectorRefactor.TYPE_START), inner, outer);
                    }
                }
            }
            break;
    }
    switch(getEndTunnelType()) {
        case Crosspoint.TUNNEL_SIMPLE_SOFT:
        case Crosspoint.TUNNEL_SOFT:
            {
                arrowPainter.paintTunnel(g, getEndPoint().getPoint(), getVectorType(SectorRefactor.TYPE_END), true);
            }
            break;
        case Crosspoint.TUNNEL_HARD:
            {
                arrowPainter.paintTunnel(g, getEndPoint().getPoint(), getVectorType(SectorRefactor.TYPE_END), false);
            }
            break;
        case Crosspoint.TUNNEL_NONE:
            {
                int borderType = getSector().getEnd().getBorderType();
                NCrosspoint crosspoint = (NCrosspoint) getEnd();
                if ((borderType >= 0) && (crosspoint != null) && (crosspoint.isOneInOut())) {
                    Function outer = crosspoint.getOut().getFunction();
                    Function inner = crosspoint.getIn().getFunction();
                    if ((inner != null) && (inner.getParent() != null) && (!inner.getParent().equals(outer))) {
                        arrowPainter.paintLink(g, getEndPoint().getPoint(), getVectorType(SectorRefactor.TYPE_END), inner, outer);
                    }
                }
            }
            break;
    }
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) WayStroke(com.ramussoft.pb.idef.visual.WayStroke) Stroke(java.awt.Stroke) ArrowedStroke(com.ramussoft.pb.idef.visual.ArrowedStroke) BasicStroke(java.awt.BasicStroke) NSector(com.ramussoft.pb.data.negine.NSector) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) WayStroke(com.ramussoft.pb.idef.visual.WayStroke) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint) ArrowedStroke(com.ramussoft.pb.idef.visual.ArrowedStroke)

Example 18 with Crosspoint

use of com.ramussoft.pb.Crosspoint in project ramus by Vitaliy-Yakovchuk.

the class PaintSector method setEnd.

/**
 * Змінює кінцеве значення сектора, забирає сектор з необхідної точки і
 * додає сектор до всіх необхідних точок.
 *
 * @param crosspoint Кінцева точка.
 * @param point      Кінцева точка відображення.
 */
public void setEnd(final Crosspoint crosspoint, final Point point, boolean rem) {
    Crosspoint c = getEnd();
    if (rem) {
        sector.getEnd().setCrosspointA(crosspoint);
        removeAther(c);
    }
    for (int i = 1; i < points.length; i++) points[i].remove();
    points = new PointBuilder(getStartPoint(), point, sector).getPoints();
    // sector.getEnd().setCrosspoint(crosspoint);
    setChangeOptions(point);
    setSectorPoints();
    resetArrowPoints(getStartPoint());
    createTexts();
    sector.reload();
    loadVisuals();
}
Also used : NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint)

Example 19 with Crosspoint

use of com.ramussoft.pb.Crosspoint in project ramus by Vitaliy-Yakovchuk.

the class PaintSector method setStart.

/**
 * Змінює початкове значення сектора, забирає сектор з необхідної точки і
 * додає сектор до всіх необхідних точок.
 *
 * @param crosspoint Початкова точка.
 * @param point      Початкова точка відображення.
 */
public void setStart(final Crosspoint crosspoint, final Point point, boolean rem) {
    Crosspoint c = getStart();
    if (rem) {
        sector.getStart().setCrosspointA(crosspoint);
        removeAther(c);
    }
    for (int i = 0; i < points.length - 1; i++) points[i].remove();
    points = new PointBuilder(point, getEndPoint(), sector).getPoints();
    // sector.getStart().setCrosspoint(crosspoint);
    setChangeOptions(point);
    setSectorPoints();
    resetArrowPoints(getEndPoint());
    createTexts();
    // sector.reload();
    loadVisuals();
}
Also used : NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint)

Example 20 with Crosspoint

use of com.ramussoft.pb.Crosspoint in project ramus by Vitaliy-Yakovchuk.

the class PaintSector method remove.

/**
 * Метод який видаляє сектор.
 */
public void remove() {
    List<Sector> sectors = new ArrayList<Sector>();
    Crosspoint start = getStart();
    if (start != null) {
        for (Sector s : start.getIns()) if (s != getSector())
            sectors.add(s);
        for (Sector s : start.getOuts()) if (s != getSector())
            sectors.add(s);
    }
    Crosspoint end = getEnd();
    if (end != null) {
        for (Sector s : end.getIns()) if (s != getSector())
            sectors.add(s);
        for (Sector s : end.getOuts()) if (s != getSector())
            sectors.add(s);
    }
    final Vector<PaintSector> resRemove = new Vector<PaintSector>();
    getRemoved(getSector(), resRemove);
    if (!resRemove.contains(this))
        resRemove.add(this);
    for (int i = 0; i < resRemove.size(); i++) resRemove.get(i).removeX();
    for (Sector sector : sectors) SectorRefactor.fixOwners(sector, movingArea.dataPlugin);
}
Also used : Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) AbstractSector(com.ramussoft.pb.data.AbstractSector) ArrayList(java.util.ArrayList) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) Vector(java.util.Vector) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint)

Aggregations

Crosspoint (com.ramussoft.pb.Crosspoint)29 NSector (com.ramussoft.pb.data.negine.NSector)18 Sector (com.ramussoft.pb.Sector)16 FloatPoint (com.dsoft.pb.types.FloatPoint)15 Function (com.ramussoft.pb.Function)12 NFunction (com.ramussoft.pb.data.negine.NFunction)11 NCrosspoint (com.ramussoft.pb.data.negine.NCrosspoint)9 Row (com.ramussoft.pb.Row)6 Vector (java.util.Vector)6 AbstractSector (com.ramussoft.pb.data.AbstractSector)5 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)5 Stream (com.ramussoft.pb.Stream)4 Point (com.ramussoft.pb.idef.elements.Point)4 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ArrayList (java.util.ArrayList)3 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)2 Ordinate (com.ramussoft.pb.idef.elements.Ordinate)2 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)2