Search in sources :

Example 16 with PaintSector

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

the class ArrowOptionstDialog method showModal.

public void showModal(final PaintSector sector, MovingArea movingArea) {
    isOk = false;
    Options.loadOptions("select_row", this);
    Options.saveOptions("select_row", this);
    sectorRowsEditor.setSector(sector.getSector());
    sectorNameEditor.setSector(sector.getSector());
    sectorRowsEditor.setSectorNameEditor(sectorNameEditor);
    getColorChooser16().setColor(sector.getColor());
    getJFontChooser().setSelFont(sector.getFont());
    final Stream s = sector.getStream();
    loadFrom(s);
    lineStyleChooser.setStroke(sector.getStroke());
    sectorNameEditor.beforeShow();
    Options.loadOptions("select_row", this);
    setVisible(true);
    if (isOk) {
        ((NSector) sector.getSector()).getDataPlugin().startUserTransaction();
        sector.setFont(getJFontChooser().getSelFont());
        sector.setColor(getColorChooser16().getColor());
        sector.setStroke(lineStyleChooser.getStroke());
        if (lineStyleChooser.isDefaultArrowStyle()) {
            Options.setStroke("DEFAULT_ARROW_STROKE", lineStyleChooser.getStroke());
        }
        sector.copyVisual(Sector.VISUAL_COPY_ADDED);
        sector.setShowText(sectorNameEditor.getBox().isSelected());
        sector.setAlternativeText(sectorNameEditor.getAlternativeTextField().getText());
        sector.getSector().setTextAligment(sectorNameEditor.getTextAligment());
        Stream stream = sectorRowsEditor.getStream();
        if (stream == null) {
            stream = sectorNameEditor.findStreamByName();
            if (stream == null) {
                stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
            }
        }
        final String t = sectorNameEditor.getArrowName();
        if (!t.equals("")) {
            if (!t.equals(stream.getName()) && sectorNameEditor.findStreamByName(stream.getName()) != null) {
                stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
            }
        }
        if (t.equals("")) {
            if (!stream.isEmptyName()) {
                stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                stream.setEmptyName(true);
            }
        } else {
            stream.setName(t);
        }
        final Row[] added = stream.getAdded();
        stream.setRows(sectorRowsEditor.getRows());
        sector.setStream(stream, sectorNameEditor.getReplaceStreamType());
        stream = sector.getStream();
        stream.setRows(added);
        saveTo(stream);
        // sector.setStreamAddedByRefactor(false);
        final Row[] rs = sectorRowsEditor.getRows();
        sector.setRows(rs);
        sector.createTexts();
        HashSet<PaintSector> hashSet = new HashSet();
        sector.getConnectedSector(hashSet);
        for (PaintSector sp : hashSet) PaintSector.save(sp, new DataLoader.MemoryData(), dataPlugin.getEngine());
        movingArea.getRefactor().setUndoPoint();
    }
    saveOption();
}
Also used : PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) HashSet(java.util.HashSet)

Example 17 with PaintSector

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

the class ModelParaleler method createSectorsOnUpperLevel.

private void createSectorsOnUpperLevel(NFunction func) {
    if (func != null) {
        MovingArea area = new MovingArea(toDataPlugin, func);
        area.setDataPlugin(toDataPlugin);
        SectorRefactor sr = area.getRefactor();
        sr.loadFromFunction(func, false);
        for (int i = 0; i < sr.getSectorsCount(); i++) {
            PaintSector ps = sr.getSector(i);
            if (ps.getSector().getStart().getBorderType() >= 0)
                sr.createSectorOnIn(ps, true);
            if (ps.getSector().getEnd().getBorderType() >= 0)
                sr.createSectorOnIn(ps, false);
        }
        sr.loadFromFunction((NFunction) func.getParentRow(), true);
        sr.saveToFunction();
    }
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) PaintSector(com.ramussoft.pb.idef.elements.PaintSector)

Example 18 with PaintSector

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

the class ModelParaleler method copyFunction.

private void copyFunction(NFunction source, NFunction destination) {
    long l = source.getLink();
    if (l >= 0) {
        Row row = fromDataPlugin.findRowByGlobalId(l);
        if (row != null) {
            l = getRow(row).getElement().getId();
            destination.setLink(l);
        }
    }
    // destination.setName(source.getName());
    if (source.getChildCount() > 0) {
        SectorRefactor sr = new SectorRefactor(new MovingArea(fromDataPlugin));
        sr.loadFromFunction(source, false);
        for (int i = 0; i < sr.getSectorsCount(); i++) {
            PaintSector ps = sr.getSector(i);
            PaintSector.save(ps, new DataLoader.MemoryData(), fromEngine);
            ps.setSector(getSector((NSector) ps.getSector()));
        }
    // sr.saveToFunction(destination);
    }
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) DataLoader(com.dsoft.utils.DataLoader) NSector(com.ramussoft.pb.data.negine.NSector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Row(com.ramussoft.pb.Row)

Example 19 with PaintSector

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

the class SectorColorAttributePlugin method apply.

public void apply(Color color, PaintSector.Pin pin) {
    PaintSector sector = pin.getSector();
    sector.setColor(color);
    sector.copyVisual(Sector.VISUAL_COPY_ADDED);
    pin.getSector().getMovingArea().getRefactor().setUndoPoint();
}
Also used : PaintSector(com.ramussoft.pb.idef.elements.PaintSector)

Example 20 with PaintSector

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

the class StreamAttributePlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
    if (old != null)
        old.close();
    return new AbstractAttributeEditor() {

        private SectorRowsEditor sectorRowsEditor;

        private SectorNameEditor sectorNameEditor;

        private PaintSector.Pin pin;

        private DataPlugin dataPlugin;

        private PaintSector sector;

        private JTabbedPane component;

        {
            dataPlugin = NDataPluginFactory.getDataPlugin(null, engine, rules);
            Sector sector = dataPlugin.findSectorByGlobalId(GlobalId.create(element.getId()));
            if (sector != null) {
                dataPlugin = NDataPluginFactory.getDataPlugin(engine.getQualifier(sector.getFunction().getElement().getQualifierId()), engine, rules);
                component = new JTabbedPane();
                sectorRowsEditor = new SectorRowsEditor(dataPlugin, framework, rules);
                sectorNameEditor = new SectorNameEditor(dataPlugin, framework, rules) {

                    @Override
                    public Stream getStream() {
                        return sectorRowsEditor.getStream();
                    }
                };
                sectorRowsEditor.setSectorNameEditor(sectorNameEditor);
                component.addTab(ResourceLoader.getString("stream"), null, sectorRowsEditor, null);
                component.addTab(ResourceLoader.getString("name"), null, sectorNameEditor, null);
                ResourceLoader.setJComponentsText(sectorRowsEditor);
                ResourceLoader.setJComponentsText(sectorNameEditor);
            }
        }

        @Override
        public Object setValue(Object value) {
            this.pin = (PaintSector.Pin) value;
            sector = pin.getSector();
            sectorNameEditor.setSector(sector.getSector());
            sectorRowsEditor.setSector(sector.getSector());
            return value;
        }

        @Override
        public Object getValue() {
            return pin;
        }

        @Override
        public JComponent getComponent() {
            if (component == null)
                return new JPanel();
            return component;
        }

        @Override
        public JComponent getLastComponent() {
            return component;
        }

        @Override
        public void apply(Engine engine, Element element, Attribute attribute, Object value) {
            sector.setShowText(sectorNameEditor.getBox().isSelected());
            sector.setAlternativeText(sectorNameEditor.getAlternativeTextField().getText());
            Stream stream = sectorRowsEditor.getStream();
            if (stream == null) {
                stream = sectorNameEditor.findStreamByName();
                if (stream == null) {
                    stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                }
            }
            final String t = sectorNameEditor.getArrowName();
            if (!t.equals("")) {
                if (!t.equals(stream.getName()) && sectorNameEditor.findStreamByName(stream.getName()) != null) {
                    stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                }
            }
            if (t.equals("")) {
                if (!stream.isEmptyName()) {
                    stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                    stream.setEmptyName(true);
                }
            } else
                stream.setName(t);
            final Row[] added = stream.getAdded();
            stream.setRows(sectorRowsEditor.getRows());
            sector.setStream(stream, sectorNameEditor.getReplaceStreamType());
            stream = sector.getStream();
            stream.setRows(added);
            // sector.setStreamAddedByRefactor(false);
            final Row[] rs = sectorRowsEditor.getRows();
            sector.setRows(rs);
            sector.createTexts();
            PaintSector.save(sector, new DataLoader.MemoryData(), engine);
            sector.getMovingArea().getRefactor().setUndoPoint();
            sectorNameEditor.setChanged(false);
        }

        @Override
        public boolean canApply() {
            final boolean b = isSave();
            if (b) {
                if (!isOkStreamName()) {
                    if (JOptionPane.showConfirmDialog(component, ResourceLoader.getString("you_entered_exists_stream_continue"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
                        return false;
                }
            } else {
                JOptionPane.showMessageDialog(component, ResourceLoader.getString("you_should_enter_name_or_at_least_on_added_elemen"));
                return false;
            }
            return b;
        }

        private boolean isSave() {
            final Row[] rs = sectorRowsEditor.getRows();
            final boolean b = rs.length > 0 || !sectorNameEditor.getArrowName().equals("");
            return b;
        }

        private boolean isOkStreamName() {
            final Stream stream = sectorNameEditor.findStreamByName();
            if (stream != null)
                return stream.equals(sectorNameEditor.getNullStream());
            return true;
        }

        @Override
        public boolean isSaveAnyway() {
            return sectorRowsEditor.isChanged() || sectorNameEditor.isChanged();
        }

        @Override
        public void close() {
            super.close();
            sectorRowsEditor.dispose();
        }
    };
}
Also used : JPanel(javax.swing.JPanel) Attribute(com.ramussoft.common.Attribute) Sector(com.ramussoft.pb.Sector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) JTabbedPane(javax.swing.JTabbedPane) Element(com.ramussoft.common.Element) SectorNameEditor(com.ramussoft.pb.idef.frames.SectorNameEditor) DataLoader(com.dsoft.utils.DataLoader) AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) SectorRowsEditor(com.ramussoft.pb.idef.frames.SectorRowsEditor) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin) Engine(com.ramussoft.common.Engine)

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