Search in sources :

Example 11 with PaintSector

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

the class IDEF0Object method onProcessEndBoundsChange.

public void onProcessEndBoundsChange(List<PaintSector> notToMove) {
    final FRectangle oldRec = function.getBounds();
    super.onProcessEndBoundsChange();
    function.setBounds(new FRectangle(myBounds));
    final SectorRefactor refactor = movingArea.getRefactor();
    MemoryData memoryData = new MemoryData();
    List<PaintSector> list = new ArrayList<PaintSector>();
    for (int i = 0; i < refactor.getSectorsCount(); i++) {
        PaintSector sector = refactor.getSector(i);
        boolean con = false;
        if (notToMove != null)
            for (PaintSector ps : notToMove) {
                if (ps.getSector().equals(sector.getSector())) {
                    con = true;
                    break;
                }
            }
        if (con)
            continue;
        setAddedSectorPos(oldRec, sector, list);
    }
    for (PaintSector ps : list) PaintSector.save(ps, memoryData, ((NFunction) function).getEngine());
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) FRectangle(com.dsoft.pb.types.FRectangle) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) NFunction(com.ramussoft.pb.data.negine.NFunction) MemoryData(com.dsoft.utils.DataLoader.MemoryData) ArrayList(java.util.ArrayList) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint)

Example 12 with PaintSector

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

the class MovingArea method setTransparent.

/**
 * Змінює прозорість напису для активного сектора.
 */
public void setTransparent() {
    final PaintSector sector = ((PaintSector.Pin) activeObject).getSector();
    sector.setTransparent(!sector.isTransparent());
    startUserTransaction();
    PaintSector.save(sector, new MemoryData(), dataPlugin.getEngine());
    refactor.setUndoPoint();
}
Also used : Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) MemoryData(com.dsoft.utils.DataLoader.MemoryData)

Example 13 with PaintSector

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

the class MovingArea method joinArrows.

public void joinArrows() {
    List<Row> rows = mouseSelection.getSelectedArrowsAddedRows();
    Row[] array = rows.toArray(new Row[rows.size()]);
    startUserTransaction();
    List<MovingLabel> pss = new ArrayList<MovingLabel>();
    for (int i = 1; i < mouseSelection.getLabels().size(); i++) pss.add(mouseSelection.getLabels().get(i));
    mouseSelection.getLabels().removeAll(pss);
    for (MovingLabel ml : pss) ml.getSector().remove();
    PaintSector sector = mouseSelection.getLabels().get(0).getSector();
    Stream stream = sector.getStream();
    if (stream == null) {
        stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
        stream.setRows(array);
        sector.setStream(stream, ReplaceStreamType.SIMPLE);
    }
    sector.setRows(array);
    sector.createTexts();
    HashSet<PaintSector> hashSet = new HashSet();
    sector.getConnectedSector(hashSet);
    for (PaintSector sp : hashSet) PaintSector.save(sp, new DataLoader.MemoryData(), dataPlugin.getEngine());
    getRefactor().setUndoPoint();
}
Also used : PaintSector(com.ramussoft.pb.idef.elements.PaintSector) MemoryData(com.dsoft.utils.DataLoader.MemoryData) ArrayList(java.util.ArrayList) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) 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) HashSet(java.util.HashSet)

Example 14 with PaintSector

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

the class MovingArea method processMouse.

/**
 * Медод, який обробляє натискання на кнопці миші, якщо стан панелі
 * відображення змінює певні атрибути, то вони змінюються.
 *
 * @param e Пораметри натискання миші.
 */
protected void processMouse(final MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON3)
        return;
    final int x = e.getX();
    final int y = e.getY();
    final double dX = getDoubleOrdinate(x);
    final double dY = getDoubleOrdinate(y);
    int type = Function.TYPE_OPERATION;
    if (getState() == FUNCTION_ADDING_STATE && getActiveObject() == null) {
        if (isOut(dX, LEFT_PART, CLIENT_WIDTH) || isOut(dY, TOP_PART, CLIENT_HEIGHT))
            return;
        if (!canAddOnContext()) {
            JOptionPane.showMessageDialog(this, ResourceLoader.getString("you_can_not_add_more_then_one_f"));
            return;
        }
        addInOutObject(dX, dY, type);
    } else if (getState() == EXTERNAL_REFERENCE_ADDING_STATE && getActiveObject() == null) {
        if (isOut(dX, LEFT_PART, CLIENT_WIDTH) || isOut(dY, TOP_PART, CLIENT_HEIGHT))
            return;
        addInOutObject(dX, dY, Function.TYPE_EXTERNAL_REFERENCE);
    } else if (getState() == DATA_STORE_ADDING_STATE && getActiveObject() == null) {
        if (isOut(dX, LEFT_PART, CLIENT_WIDTH) || isOut(dY, TOP_PART, CLIENT_HEIGHT))
            return;
        addInOutObject(dX, dY, Function.TYPE_DATA_STORE);
    } else if (getState() == DFDS_ROLE_ADDING_STATE && getActiveObject() == null) {
        if (isOut(dX, LEFT_PART, CLIENT_WIDTH) || isOut(dY, TOP_PART, CLIENT_HEIGHT))
            return;
        addInOutObject(dX, dY, Function.TYPE_DFDS_ROLE);
    } else if (getChangingState() == ARROW_CHANGING_STATE) {
        final PaintSector.Pin activePin = getPin(e.getX(), e.getY());
        if (activePin == null)
            addArrowToArea(dX, dY);
        else {
            PaintSector sector = activePin.getSector();
            if ((sector.isPart()) && (sector.isSelEnd() || sector.isSelStart())) {
                if (activeObject instanceof PaintSector.Pin) {
                    final PaintSector.Pin pin = (PaintSector.Pin) activeObject;
                    if (pin.getSector().isSelEnd() || pin.getSector().isSelStart()) {
                        setActiveObject(null);
                        refactor.setSector(pin.getSector());
                        if (pin.getSector().isSelEnd()) {
                            setState(END_POINT_CHANGING_ADD);
                        } else if (pin.getSector().isSelStart()) {
                            setState(START_POINT_CHANGING_ADD);
                        }
                        panel.getFramework().put(CURRENT_MOVING_AREA, this);
                    }
                }
            } else {
                if (getPointChangingType() == SectorRefactor.TYPE_START) {
                    if (sector.isPart() && activePin.getSector().getStart() == null)
                        return;
                } else {
                    if (activePin.getSector().isPart() && activePin.getSector().getEnd() == null)
                        return;
                }
                final SectorRefactor.PerspectivePoint pp = new SectorRefactor.PerspectivePoint();
                pp.type = getPointChangingType();
                pp.pin = activePin;
                pp.x = getDoubleOrdinate(e.getX());
                pp.y = getDoubleOrdinate(e.getY());
                refactor.setPoint(pp);
                doSector();
            }
        }
    } else if (getChangingState() == TILDA_ADDING_STATE) {
        final PaintSector.Pin activePin = getPin(e.getX(), e.getY());
        if (activePin != null) {
            startUserTransaction();
            List<PaintSector> ps = activePin.getSector().setTildaPos(getDoubleOrdinate(e.getX()), getDoubleOrdinate(e.getY()));
            for (PaintSector s : ps) PaintSector.save(s, new MemoryData(), dataPlugin.getEngine());
            refactor.setUndoPoint();
        }
    } else if (getChangingState() == TEXT_ADDING_STATE) {
        final MovingText text = createText();
        cancelAdding();
        refactor.addText(text);
        text.setBounds(dX, dY, text.getBounds().getWidth(), text.getBounds().getHeight());
        text.setFont(Options.getFont("DEFAULT_TEXT_FONT", new Font("Arial", 0, 10)));
        text.setColor(Options.getColor("DEFAULT_TEXT_COLOR", Color.black));
        startUserTransaction();
        refactor.setUndoPoint();
    } else {
        if (activeObject instanceof PaintSector.Pin) {
            final PaintSector.Pin pin = (PaintSector.Pin) activeObject;
            if (pin.getSector().isSelEnd() || pin.getSector().isSelStart()) {
                setActiveObject(null);
                refactor.setSector(pin.getSector());
                if (pin.getSector().isSelEnd()) {
                    setState(END_POINT_CHANGING);
                } else if (pin.getSector().isSelStart()) {
                    setState(START_POINT_CHANGING);
                }
                panel.getFramework().put(CURRENT_MOVING_AREA, this);
            }
        }
    }
}
Also used : Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) PerspectivePoint(com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint) MemoryData(com.dsoft.utils.DataLoader.MemoryData) ArrayList(java.util.ArrayList) EventListenerList(javax.swing.event.EventListenerList) List(java.util.List) 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) Font(java.awt.Font)

Example 15 with PaintSector

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

the class MovingArea method setShowTilda.

/**
 * Робить так, що показується тільда на активному секторі.
 */
public void setShowTilda() {
    startUserTransaction();
    final PaintSector sector = ((PaintSector.Pin) activeObject).getSector();
    sector.setShowTilda(!sector.isShowTilda());
    PaintSector.save(sector, new MemoryData(), getDataPlugin().getEngine());
    refactor.setUndoPoint();
}
Also used : Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) MemoryData(com.dsoft.utils.DataLoader.MemoryData)

Aggregations

PaintSector (com.ramussoft.pb.idef.elements.PaintSector)32 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)15 FloatPoint (com.dsoft.pb.types.FloatPoint)14 Crosspoint (com.ramussoft.pb.Crosspoint)12 Function (com.ramussoft.pb.Function)12 Point (com.ramussoft.pb.idef.elements.Point)12 Row (com.ramussoft.pb.Row)10 MemoryData (com.dsoft.utils.DataLoader.MemoryData)9 MovingArea (com.ramussoft.pb.idef.visual.MovingArea)9 ArrayList (java.util.ArrayList)8 Stream (com.ramussoft.pb.Stream)7 NFunction (com.ramussoft.pb.data.negine.NFunction)7 Pin (com.ramussoft.pb.idef.elements.PaintSector.Pin)6 PerspectivePoint (com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint)5 Sector (com.ramussoft.pb.Sector)4 MovingLabel (com.ramussoft.pb.idef.visual.MovingLabel)4 IOException (java.io.IOException)4 Vector (java.util.Vector)4 FRectangle (com.dsoft.pb.types.FRectangle)3 NSector (com.ramussoft.pb.data.negine.NSector)3