Search in sources :

Example 16 with FloatPoint

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

the class DFDSFunction method getTriangle.

@Override
protected int getTriangle(FloatPoint point) {
    int changingState = getMovingArea().getPointChangingType();
    PaintSector activeSector = getMovingArea().getRefactor().getSector();
    if (activeSector != null)
        if (changingState == SectorRefactor.TYPE_START) {
            Crosspoint crosspoint = activeSector.getStart();
            Function function2 = activeSector.getSector().getStart().getFunction();
            if (crosspoint != null && crosspoint.isDLevel() && function2 != null && function2.getType() == Function.TYPE_DFDS_ROLE)
                return -1;
        } else if (changingState == SectorRefactor.TYPE_END) {
            Crosspoint crosspoint = activeSector.getEnd();
            Function function2 = activeSector.getSector().getEnd().getFunction();
            if (crosspoint != null && crosspoint.isDLevel() && function2 != null && function2.getType() == Function.TYPE_DFDS_ROLE)
                return -1;
        }
    return super.getTriangle(point);
}
Also used : DFDFunction(com.ramussoft.pb.dfd.visual.DFDFunction) NFunction(com.ramussoft.pb.data.negine.NFunction) Function(com.ramussoft.pb.Function) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 17 with FloatPoint

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

the class IDLImporter method addBox.

private void addBox() {
    Function function = getFunction(box.reference);
    int i = box.name.indexOf('}');
    box.function = function;
    function.setName(box.name.substring(i + 1));
    StringTokenizer st = new StringTokenizer(box.name.substring(1, i), " ");
    if (st.hasMoreTokens())
        st.nextElement();
    if (st.hasMoreTokens()) {
        try {
            int font = Integer.parseInt(st.nextToken());
            function.setFont(uniqueFonts.get(font));
        } catch (Exception e) {
        }
    }
    if (st.hasMoreTokens())
        st.nextElement();
    Color bColor = null;
    Color fColor = null;
    if (st.hasMoreTokens()) {
        int tmp = Integer.parseInt(st.nextToken());
        if (tmp < COLORS.length) {
            fColor = COLORS[tmp];
        }
        tmp = Integer.parseInt(st.nextToken());
        if (tmp < COLORS.length) {
            bColor = COLORS[tmp];
        }
    }
    if (bColor != null)
        function.setBackground(bColor);
    if (fColor != null)
        function.setForeground(fColor);
    StringTokenizer tokenizer = new StringTokenizer(box.coordinates, " ()");
    FloatPoint p1 = toPoint(tokenizer.nextToken());
    FloatPoint p2 = toPoint(tokenizer.nextToken());
    FRectangle rectangle = new FRectangle(p1.getX(), p2.getY(), p2.getX() - p1.getX(), p1.getY() - p2.getY());
    function.setBounds(rectangle);
    Status status = new Status(Status.WORKING, "");
    function.setStatus(status);
}
Also used : Status(com.dsoft.pb.idef.elements.Status) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) StringTokenizer(java.util.StringTokenizer) FloatPoint(com.dsoft.pb.types.FloatPoint) FRectangle(com.dsoft.pb.types.FRectangle) Color(java.awt.Color) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) IOException(java.io.IOException)

Example 18 with FloatPoint

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

the class IDLImporter method setSegment.

private void setSegment(Arrowseg seg, MovingArea area) {
    if (seg.seted)
        return;
    List<Arrowseg> source = loadConnected(seg.source);
    List<Arrowseg> sink = loadConnected(seg.sink);
    if (source != null) {
        for (Arrowseg s : source) {
            if (!s.seted)
                setSegment(s, area);
        }
        Crosspoint c = null;
        for (Arrowseg s : source) {
            if (s.sector.getEnd() != null) {
                c = (NCrosspoint) s.sector.getEnd();
            }
        }
        if (c == null)
            c = dataPlugin.createCrosspoint();
        seg.sector.getSector().getStart().setCrosspointA(c);
        seg.sector.getSector().getStart().commit();
        for (Arrowseg s : source) {
            if (s.sector.getEnd() == null) {
                s.sector.getSector().getEnd().setCrosspointA(c);
                s.sector.getSector().getEnd().commit();
            }
        }
    }
    PaintSector ps = seg.sector;
    Point[] points = new Point[seg.pointsList.size()];
    int type = seg.getFirstPinType();
    Ordinate x = null;
    Ordinate y = null;
    if (source != null) {
        for (Arrowseg arrowseg : source) {
            int sType = arrowseg.getLastPinType();
            if (type == sType) {
                if (arrowseg.sector.getLastPin().getType() == Ordinate.TYPE_X) {
                    y = arrowseg.sector.getLastPin().getOrdinate();
                    x = arrowseg.sector.getLastPin().getPOrdinate();
                } else {
                    x = arrowseg.sector.getLastPin().getOrdinate();
                    y = arrowseg.sector.getLastPin().getPOrdinate();
                }
            } else {
                if (arrowseg.sector.getLastPin().getType() == Ordinate.TYPE_Y) {
                    x = arrowseg.sector.getLastPin().getOrdinate();
                    y = arrowseg.sector.getLastPin().getPOrdinate();
                } else {
                    y = arrowseg.sector.getLastPin().getOrdinate();
                    x = arrowseg.sector.getLastPin().getPOrdinate();
                }
            }
        }
    }
    if (x == null) {
        x = new Ordinate(Ordinate.TYPE_X);
        x.setPosition(seg.pointsList.get(0).getX());
    }
    if (y == null) {
        y = new Ordinate(Ordinate.TYPE_Y);
        y.setPosition(seg.pointsList.get(0).getY());
    }
    points[0] = new Point(x, y);
    for (int i = 1; i < seg.pointsList.size(); i++) {
        FloatPoint point = seg.pointsList.get(i);
        type = seg.getPinType(i - 1);
        if (type == Ordinate.TYPE_X) {
            x = new Ordinate(Ordinate.TYPE_X);
            x.setPosition(point.getX());
        } else {
            y = new Ordinate(Ordinate.TYPE_Y);
            y.setPosition(point.getY());
        }
        if ((i == seg.pointsList.size() - 1) && (sink != null) && (sink.size() == 1)) {
            Arrowseg s = sink.get(0);
            List<Arrowseg> list = loadConnected(s.source);
            for (Arrowseg arrowseg : list) {
                if (arrowseg.seted) {
                    Point point2 = arrowseg.sector.getLastPin().getEnd();
                    Ordinate xo = point2.getXOrdinate();
                    for (Point point3 : xo.getPoints()) {
                        point3.setXOrdinate(x);
                    }
                    Ordinate yo = point2.getYOrdinate();
                    for (Point point3 : yo.getPoints()) {
                        point3.setYOrdinate(y);
                    }
                }
            }
        }
        points[i] = new Point(x, y);
    }
    ps.setPoints(points);
    if (source == null)
        initCrosspoint(seg.sector.getSector().getStart(), seg.source, area, seg.sector, true, seg);
    if (sink == null) {
        initCrosspoint(seg.sector.getSector().getEnd(), seg.sink, area, seg.sector, false, seg);
    }
    seg.seted = true;
}
Also used : FloatPoint(com.dsoft.pb.types.FloatPoint) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Ordinate(com.ramussoft.pb.idef.elements.Ordinate)

Example 19 with FloatPoint

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

the class DFDObject 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)

Example 20 with FloatPoint

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

the class DFDObject 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

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