Search in sources :

Example 1 with FloatPoint

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

the class ArrowPainter method paintTilda.

public void paintTilda(final Graphics2D g, final PaintSector sector) {
    g.setStroke(ArrowPainter.THIN_STROKE);
    final MovingText movingText = sector.getText();
    final FloatPoint t = sector.getTildaPoint();
    final double x1 = movingArea.getIDoubleOrdinate(t.getX());
    final double y1 = movingArea.getIDoubleOrdinate(t.getY());
    final double x2 = movingArea.getIDoubleOrdinate(movingText.getBounds().getLocation().getX());
    final double y2 = movingArea.getIDoubleOrdinate(movingText.getBounds().getLocation().getY());
    final double x3 = x2 + movingArea.getIDoubleOrdinate(movingText.getRealWidth());
    final double y3 = y2 + movingArea.getIDoubleOrdinate(movingText.getRealHeight());
    double lw = 1;
    if (sector.getStroke() instanceof BasicStroke)
        lw = ((BasicStroke) sector.getStroke()).getLineWidth();
    double w = movingArea.getIDoubleOrdinate(lw * 1.5);
    double minW = movingArea.getIDoubleOrdinate(2);
    if (w < minW)
        w = minW;
    paintTilda(g, x1, y1, x2, y2, x3, y3, w, movingArea);
}
Also used : BasicStroke(java.awt.BasicStroke) FloatPoint(com.dsoft.pb.types.FloatPoint) MovingText(com.ramussoft.pb.idef.visual.MovingText)

Example 2 with FloatPoint

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

the class PaintSector method getTildaOPoint.

public FloatPoint getTildaOPoint() {
    final MovingText movingText = getText();
    final double x2 = movingArea.getIDoubleOrdinate(movingText.getBounds().getLocation().getX());
    final double y2 = movingArea.getIDoubleOrdinate(movingText.getBounds().getLocation().getY());
    final double x3 = x2 + movingArea.getIDoubleOrdinate(movingText.getBounds().getWidth());
    final double y3 = y2 + movingArea.getIDoubleOrdinate(movingText.getBounds().getHeight());
    double x = getTildaPoint().getX();
    double y = getTildaPoint().getY();
    if (x3 < x)
        x = x3;
    else if (x2 > x)
        x = x2;
    if (y3 < y)
        y = y3;
    else if (y2 > y)
        y = y2;
    final FloatPoint fp = new FloatPoint(x, y);
    return fp;
}
Also used : FloatPoint(com.dsoft.pb.types.FloatPoint) MovingText(com.ramussoft.pb.idef.visual.MovingText)

Example 3 with FloatPoint

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

the class PaintSector method splitSector.

/**
 * Відщеплює сектор від поточного, поточний сектор урізається, а створений
 * сектор буде іти відразу після поточного, додає його на то й же
 * функціональний блок.
 *
 * @param pin        Частина, яка буде розбита на дві.
 * @param point      Точка на частині, яка буде точкою розбиття.
 * @param oX         Координата x точки секотра, який є відщеплювачем.
 * @param oY         Координата y точки секотра, який є відщеплювачем.
 * @param startPoint <code>true</code>, якщо під’єднується початок
 *                   <code>false</code>, якщо під’єднується кінець.
 * @return Новостворений сектор зверху.
 */
public SplitSectorType splitSector(final Pin pin, final FloatPoint point, final double oX, final double oY, final double opX, final double opY, final boolean startPoint) {
    final int start = pin.getPos();
    boolean nstart = false;
    final int pinType = pin.getType();
    // Point ep = getEndPoint();
    final PaintSector sector = new PaintSector(movingArea);
    saveVisual();
    sector.setSector(this.sector.splitSector());
    // новий кінець цього сектора
    final Point p = new Point();
    // початок новоствореного сектора
    final Point p2 = new Point();
    p.setSector(this);
    p2.setSector(sector);
    // Частина створення точок.
    Point cross = null;
    if (pin.isNearPinStart(point.getX(), point.getY()) && start > 0) {
        nstart = true;
        cross = pin.getStart();
    } else if (pin.isNearPinEnd(point.getX(), point.getY()) && start < getPinCount() - 1) {
        cross = pin.getEnd();
        nstart = false;
    }
    int moreLengthM = 2;
    int moreLengthN = 2;
    /**
     * New Point Type = напрямок нової точки.
     */
    int ct = -1;
    if ((ct = isCrossed(cross, opX, opY, startPoint)) != -1) {
        int st = start;
        if (nstart) {
            moreLengthM = 1;
            moreLengthN = 2;
        } else {
            moreLengthM = 2;
            moreLengthN = 1;
            st = start + 1;
        }
        p.setXOrdinate(points[st].getXOrdinate());
        p.setYOrdinate(points[st].getYOrdinate());
        p.setType(points[st].getType());
        p2.setXOrdinate(p.getXOrdinate());
        p2.setYOrdinate(p.getYOrdinate());
        p2.setType(getPin(st).getType());
        points[st].remove();
    } else {
        if (pinType == Ordinate.TYPE_Y) {
            p.setXOrdinate(points[start].getXOrdinate());
            p.setYOrdinate(new Ordinate(Ordinate.TYPE_Y));
            p.setY(point.getY());
            p.setType(Ordinate.TYPE_Y);
            p2.setType(Ordinate.TYPE_Y);
        } else {
            p.setYOrdinate(points[start].getYOrdinate());
            p.setXOrdinate(new Ordinate(Ordinate.TYPE_X));
            p.setX(point.getX());
            p.setType(Ordinate.TYPE_X);
            p2.setType(Ordinate.TYPE_X);
        }
    }
    p2.setXOrdinate(p.getXOrdinate());
    p2.setYOrdinate(p.getYOrdinate());
    /* поточні точки */
    final Point[] tmp = new Point[start + moreLengthM];
    for (int i = 0; i <= start; i++) tmp[i] = points[i];
    tmp[tmp.length - 1] = p;
    /* точки новоствореного сектора */
    final Point[] tmp2 = new Point[points.length - start - 2 + moreLengthN];
    for (int i = points.length - 1; i - start - 2 + moreLengthN > 0; i--) tmp2[i - start - 2 + moreLengthN] = points[i];
    tmp2[0] = p2;
    // кінець частини створення точок.
    points = tmp;
    sector.points = tmp2;
    sector.setSectorPoints();
    setSectorPoints();
    if (ct == -1) {
        if (sector.getStartPoint().getType() == Ordinate.TYPE_X)
            ct = Ordinate.TYPE_Y;
        else
            ct = Ordinate.TYPE_X;
    }
    return new SplitSectorType(sector, ct);
}
Also used : FloatPoint(com.dsoft.pb.types.FloatPoint) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint)

Example 4 with FloatPoint

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

the class DFDSRole method mouseClicked.

@Override
public void mouseClicked(FloatPoint point) {
    Row owner = getFunction().getOwner();
    if (owner == null)
        super.mouseClicked(point);
    else {
        DFDSFunction function = movingArea.findDFDSFunction(owner);
        if (function == null)
            super.mouseClicked(point);
        else {
            final Ordinate x = new Ordinate(Ordinate.TYPE_X);
            final Ordinate y = new Ordinate(Ordinate.TYPE_Y);
            final Point p = new Point(x, y);
            final SectorRefactor.PerspectivePoint pp = new SectorRefactor.PerspectivePoint();
            pp.point = p;
            pp.setFunction(function.getFunction(), BOTTOM);
            x.setPosition(function.getBounds().getX() + point.getX());
            y.setPosition(getY(x.getPosition(), false, function.getBounds()));
            if (movingArea.getPointChangingType() == SectorRefactor.TYPE_START) {
                pp.type = SectorRefactor.TYPE_START;
                movingArea.getRefactor().setPoint(pp);
                movingArea.doSector();
            } else if (movingArea.getPointChangingType() == SectorRefactor.TYPE_END) {
                pp.type = SectorRefactor.TYPE_END;
                movingArea.getRefactor().setPoint(pp);
                movingArea.doSector();
            }
        }
    }
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Row(com.ramussoft.pb.Row) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Ordinate(com.ramussoft.pb.idef.elements.Ordinate)

Example 5 with FloatPoint

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

the class DFDFunction method mouseClicked.

public void mouseClicked(final FloatPoint point) {
    if (movingArea.getChangingState() == MovingArea.ARROW_CHANGING_STATE) {
        final int type = getTriangle(point);
        final Ordinate x = new Ordinate(Ordinate.TYPE_X);
        final Ordinate y = new Ordinate(Ordinate.TYPE_Y);
        final Point p = new Point(x, y);
        final SectorRefactor.PerspectivePoint pp = new SectorRefactor.PerspectivePoint();
        pp.point = p;
        switch(type) {
            case LEFT:
                {
                    pp.setFunction(getFunction(), LEFT);
                    y.setPosition(getBounds().getY() + point.getY());
                    x.setPosition(getX(y.getPosition(), true, getBounds()));
                }
                break;
            case TOP:
                {
                    pp.setFunction(getFunction(), TOP);
                    x.setPosition(getBounds().getX() + point.getX());
                    y.setPosition(getY(x.getPosition(), true, getBounds()));
                }
                break;
            case BOTTOM:
                {
                    pp.setFunction(getFunction(), BOTTOM);
                    x.setPosition(getBounds().getX() + point.getX());
                    y.setPosition(getY(x.getPosition(), false, getBounds()));
                }
                break;
            case RIGHT:
                {
                    pp.setFunction(getFunction(), RIGHT);
                    y.setPosition(getBounds().getY() + point.getY());
                    x.setPosition(getX(y.getPosition(), false, getBounds()));
                }
                break;
            default:
                return;
        }
        if (movingArea.getPointChangingType() == SectorRefactor.TYPE_START) {
            pp.type = SectorRefactor.TYPE_START;
            movingArea.getRefactor().setPoint(pp);
            movingArea.doSector();
        } else if (movingArea.getPointChangingType() == SectorRefactor.TYPE_END) {
            pp.type = SectorRefactor.TYPE_END;
            movingArea.getRefactor().setPoint(pp);
            movingArea.doSector();
        }
    }
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) FloatPoint(com.dsoft.pb.types.FloatPoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Point(com.ramussoft.pb.idef.elements.Point) Ordinate(com.ramussoft.pb.idef.elements.Ordinate)

Aggregations

FloatPoint (com.dsoft.pb.types.FloatPoint)25 Point (com.ramussoft.pb.idef.elements.Point)14 Crosspoint (com.ramussoft.pb.Crosspoint)8 Ordinate (com.ramussoft.pb.idef.elements.Ordinate)7 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)6 Function (com.ramussoft.pb.Function)5 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)4 GeneralPath (java.awt.geom.GeneralPath)4 Point2D (java.awt.geom.Point2D)4 FRectangle (com.dsoft.pb.types.FRectangle)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 NFunction (com.ramussoft.pb.data.negine.NFunction)2 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)2 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)2 MovingText (com.ramussoft.pb.idef.visual.MovingText)2 StringTokenizer (java.util.StringTokenizer)2 Status (com.dsoft.pb.idef.elements.Status)1 MemoryData (com.dsoft.utils.DataLoader.MemoryData)1 Rows (com.ramussoft.gui.qualifier.table.Rows)1