Search in sources :

Example 6 with FloatPoint

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

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

Example 7 with FloatPoint

use of com.dsoft.pb.types.FloatPoint 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 8 with FloatPoint

use of com.dsoft.pb.types.FloatPoint 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 FloatPoint

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

the class MovingPanel method mouseMoved.

public int mouseMoved(final FloatPoint point) {
    final int type = getPressType(point);
    if (type != mouseType) {
        mouseType = type;
        if (movingArea.getVisualCopyCursor() != null)
            movingArea.setCursor(movingArea.getVisualCopyCursor());
        else if (type == -1)
            movingArea.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        else if (type == STATE_MOVE)
            movingArea.setCursor(new Cursor(Cursor.MOVE_CURSOR));
        else if (type == STATE_STOP)
            movingArea.setCursor(new Cursor(Cursor.MOVE_CURSOR));
        else if (type == STATE_RESIZE_LEFT)
            movingArea.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR));
        else if (type == STATE_RESIZE_RIGHT)
            movingArea.setCursor(new Cursor(Cursor.E_RESIZE_CURSOR));
        else if (type == STATE_RESIZE_TOP)
            movingArea.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR));
        else if (type == STATE_RESIZE_BOTTOM)
            movingArea.setCursor(new Cursor(Cursor.S_RESIZE_CURSOR));
        else if (type == STATE_RESIZE_BOTTOM_LEFT)
            movingArea.setCursor(new Cursor(Cursor.SW_RESIZE_CURSOR));
        else if (type == STATE_RESIZE_RIGHT_BOTTOM)
            movingArea.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR));
        else if (type == STATE_RESIZE_TOP_RIGHT)
            movingArea.setCursor(new Cursor(Cursor.NE_RESIZE_CURSOR));
        else if (type == STATE_RESIZE_LEFT_TOP)
            movingArea.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR));
    }
    movingArea.repaint();
    return -1;
}
Also used : Cursor(java.awt.Cursor) FloatPoint(com.dsoft.pb.types.FloatPoint)

Example 10 with FloatPoint

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

the class SectorRefactor method createMiss.

private Sector createMiss(final PerspectivePoint point) {
    if (point.functionType >= 0) {
        point.crosspoint = getDataPlugin().createCrosspoint();
        double inPos;
        if (point.functionType == MovingPanel.LEFT || point.functionType == MovingPanel.RIGHT)
            inPos = point.point.getY();
        else
            inPos = point.point.getX();
        return createPartIn(point.crosspoint, point.function, point.functionType, inPos, point.type == TYPE_END);
    } else if (point.borderType == -1) {
        // Tochka na inshomu sektory
        final PaintSector.Pin pin = point.pin;
        final double x = point.x;
        final double y = point.y;
        double oX;
        double oY;
        double opX;
        double opY;
        final boolean start = point.type == TYPE_START;
        if (start) {
            oX = pointA.x;
            oY = pointA.y;
            opX = pointB.getX();
            opY = pointB.getY();
        } else {
            opX = pointA.getX();
            opY = pointA.getY();
            oX = pointB.x;
            oY = pointB.y;
        }
        final Point p = new Point();
        if (pin.isNearStart(x, y) && pin.isFirst()) {
            final Crosspoint crosspoint = pin.getSector().getStart();
            if (crosspoint.isCanAddOut() && point.type == TYPE_START || crosspoint.isCanAddIn() && point.type == TYPE_END) {
                final int type = pin.getStart().isCanConnected(opX, opY);
                if (type >= 0) {
                    p.setType(type);
                    p.setXOrdinate(pin.getStart().getXOrdinate());
                    p.setYOrdinate(pin.getStart().getYOrdinate());
                    point.crosspoint = crosspoint;
                    point.point = p;
                    return null;
                }
            }
        } else if (pin.isNearEnd(x, y) && pin.isEnd()) {
            final Crosspoint crosspoint = pin.getSector().getEnd();
            if (crosspoint.isCanAddOut() && point.type == TYPE_START || crosspoint.isCanAddIn() && point.type == TYPE_END) {
                final int type = pin.getEnd().isCanConnected(opX, opY);
                if (type >= 0) {
                    p.setType(type);
                    p.setXOrdinate(pin.getEnd().getXOrdinate());
                    p.setYOrdinate(pin.getEnd().getYOrdinate());
                    point.crosspoint = crosspoint;
                    point.point = p;
                    return null;
                }
            }
        }
        final PaintSector sector = pin.getSector();
        final SplitSectorType sst = sector.splitSector(pin, new FloatPoint(point.x, point.y), oX, oY, opX, opY, start);
        final PaintSector aSector = sst.paintSector;
        point.crosspoint = sector.getEnd();
        point.point = new Point(sector.getEndPoint().getXOrdinate(), sector.getEndPoint().getYOrdinate());
        point.point.setType(sst.type);
        tryRemoveText(aSector);
        tryRemoveText(sector);
        addSector(aSector);
    } else {
        // TOCHKA NA KRAU
        createBorderPoints(point, function);
    }
    return null;
}
Also used : FloatPoint(com.dsoft.pb.types.FloatPoint) SplitSectorType(com.ramussoft.pb.idef.elements.PaintSector.SplitSectorType) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint)

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