Search in sources :

Example 6 with Point

use of com.ramussoft.pb.idef.elements.Point in project ramus by Vitaliy-Yakovchuk.

the class IDLImporter method createSegment.

private void createSegment(Arrowseg seg, MovingArea area) {
    SectorRefactor sr = area.getRefactor();
    Sector s = plugin.createSector();
    Function f = getFunction();
    s.setFunction(f);
    PaintSector ps = new PaintSector();
    ps.setSector(s);
    ps.setMovingArea(area);
    sr.addSector(ps);
    seg.sector = ps;
    ArrayList<FloatPoint> list = new ArrayList<FloatPoint>();
    StringTokenizer st = new StringTokenizer(seg.path, "() ");
    while (st.hasMoreElements()) list.add(toPoint(st.nextToken()));
    seg.pointsList = list;
    String text = seg.getText();
    if ((text != null) && (text.length() > 0)) {
        s.setStream(getStream(text), ReplaceStreamType.CHILDREN);
        if (seg.coordinates != null) {
            MovingLabel label = new MovingLabel(area);
            StringTokenizer st2 = new StringTokenizer(seg.coordinates, "()");
            FloatPoint point = toPoint(st2.nextToken());
            label.getBounds().setX(point.getX());
            label.getBounds().setY(point.getY() - 10);
            label.setText(text);
            ps.setText(label);
            if (seg.squiggleCoordinates != null) {
                ps.setShowTilda(true);
            }
        }
        if (seg.label.startsWith("{")) {
            StringTokenizer st2 = new StringTokenizer(seg.label, " ");
            st2.nextElement();
            st2.nextElement();
            try {
                int font = Integer.parseInt(st2.nextToken());
                if (font < uniqueFonts.size())
                    ps.setFont(uniqueFonts.get(font));
            } catch (Exception e) {
            }
            int color = Integer.parseInt(st2.nextToken());
            if (color < COLORS.length)
                ps.setColor(COLORS[color]);
        }
    }
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) StringTokenizer(java.util.StringTokenizer) MovingLabel(com.ramussoft.pb.idef.visual.MovingLabel) FloatPoint(com.dsoft.pb.types.FloatPoint) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Sector(com.ramussoft.pb.Sector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) ArrayList(java.util.ArrayList) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) IOException(java.io.IOException)

Example 7 with Point

use of com.ramussoft.pb.idef.elements.Point 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 8 with Point

use of com.ramussoft.pb.idef.elements.Point in project ramus by Vitaliy-Yakovchuk.

the class IDEF0Object method mouseMoved.

/*
     * (non-Javadoc)
     *
     * @seecom.jason.clasificators.frames.idf.MovingPanel#mouseMoved(com.jason.
     * clasificators.frames.idf.FloatPoint)
     */
@Override
public int mouseMoved(final FloatPoint point) {
    super.mouseMoved(point);
    int res;
    if ((movingArea.getChangingState() == MovingArea.ARROW_CHANGING_STATE) && (movingArea.isOkForCross()))
        res = getTriangle(point);
    else
        res = -1;
    if (res != paintTriangle) {
        paintTriangle = res;
        movingArea.repaintAsync();
    }
    return paintTriangle;
}
Also used : Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint)

Example 9 with Point

use of com.ramussoft.pb.idef.elements.Point in project ramus by Vitaliy-Yakovchuk.

the class MovingArea method fillMovingArea.

private void fillMovingArea() {
    final SectorRefactor.PerspectivePoint pp = new SectorRefactor.PerspectivePoint();
    pp.x = mp.x;
    pp.y = mp.y;
    if (getPointChangingType() == SectorRefactor.TYPE_END) {
        pp.borderType = MovingFunction.RIGHT;
        PerspectivePoint point = refactor.getPoint(SectorRefactor.TYPE_START);
        if (point != null)
            pp.y = point.y;
    } else {
        pp.borderType = MovingFunction.LEFT;
        PerspectivePoint point = refactor.getPoint(SectorRefactor.TYPE_END);
        if (point != null)
            pp.y = point.y;
    }
    int pointChangingType = getPointChangingType();
    pp.type = pointChangingType;
    refactor.setPoint(pp);
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) PerspectivePoint(com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint) PerspectivePoint(com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint) PerspectivePoint(com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point)

Example 10 with Point

use of com.ramussoft.pb.idef.elements.Point in project ramus by Vitaliy-Yakovchuk.

the class DFDFunctionEllipse method getTriangle.

protected int getTriangle(final FloatPoint point) {
    int res = -1;
    FloatPoint l = getLocation();
    for (int type = MovingPanel.RIGHT; type <= MovingPanel.TOP; type++) {
        GeneralPath gp = getTrianglePath(type);
        double y = point.getY() + l.getY();
        double x = point.getX() + l.getX();
        if (gp.contains(new Point2D.Double(x, y))) {
            res = type;
            break;
        }
    }
    return res;
}
Also used : FloatPoint(com.dsoft.pb.types.FloatPoint) GeneralPath(java.awt.geom.GeneralPath) Point2D(java.awt.geom.Point2D) FloatPoint(com.dsoft.pb.types.FloatPoint) Point(com.ramussoft.pb.idef.elements.Point)

Aggregations

Point (com.ramussoft.pb.idef.elements.Point)21 FloatPoint (com.dsoft.pb.types.FloatPoint)19 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)12 Ordinate (com.ramussoft.pb.idef.elements.Ordinate)11 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)6 Crosspoint (com.ramussoft.pb.Crosspoint)5 GeneralPath (java.awt.geom.GeneralPath)4 Point2D (java.awt.geom.Point2D)4 Function (com.ramussoft.pb.Function)3 FRectangle (com.dsoft.pb.types.FRectangle)2 Row (com.ramussoft.pb.Row)2 Sector (com.ramussoft.pb.Sector)2 PerspectivePoint (com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint)2 MovingLabel (com.ramussoft.pb.idef.visual.MovingLabel)2 ArrayList (java.util.ArrayList)2 Vector (java.util.Vector)2 MemoryData (com.dsoft.utils.DataLoader.MemoryData)1 AbstractSector (com.ramussoft.pb.data.AbstractSector)1 NFunction (com.ramussoft.pb.data.negine.NFunction)1 NSector (com.ramussoft.pb.data.negine.NSector)1