Search in sources :

Example 26 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class SectorNameEditor method selectRows.

protected boolean selectRows() {
    final Stream tmp = getArrowRowsDialog().showModal();
    if (tmp == getStream() || tmp == null)
        return false;
    Stream ls = lowstream;
    setStream(tmp);
    lowstream = ls;
    jTextField.setText(tmp.getName());
    return true;
}
Also used : Stream(com.ramussoft.pb.Stream)

Example 27 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class ArrowOptionstDialog method getSectorNameEditor.

private SectorNameEditor getSectorNameEditor() {
    if (sectorNameEditor == null) {
        sectorNameEditor = new SectorNameEditor(dataPlugin, framework, accessRules) {

            @Override
            protected boolean selectRows() {
                final boolean res = super.selectRows();
                if (res)
                    loadFrom(getStream());
                return res;
            }

            @Override
            public Stream getStream() {
                return sectorRowsEditor.getStream();
            }
        };
        sectorNameEditor.setDialog(this);
        sectorNameEditor.setPreferredSize(new Dimension(100, 100));
    }
    return sectorNameEditor;
}
Also used : Stream(com.ramussoft.pb.Stream) Dimension(java.awt.Dimension)

Example 28 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class AlternativeArrowDialog method getRowFindPanel.

/**
 * This method initializes rowFindPanel
 *
 * @return com.dsoft.pb.frames.elements.RowFindPanel
 */
private RowFindPanel getRowFindPanel() {
    if (rowFindPanel == null) {
        rowFindPanel = new RowFindPanel() {

            @Override
            public boolean find(final String text, final boolean wordsOrder) {
                return find(-1, text, wordsOrder);
            }

            @Override
            public boolean findNext(final String text, final boolean wordsOrder) {
                return find(jList.getSelectedIndex(), text, wordsOrder);
            }

            private boolean find(final int selectedIndex, final String text, final boolean wordsOrder) {
                final Stream[] streams = streamModel.getData();
                for (int i = selectedIndex + 1; i < streams.length; i++) {
                    final Stream stream = streams[i];
                    if (select(text, wordsOrder, i, stream))
                        return true;
                }
                for (int i = 0; i < selectedIndex; i++) {
                    final Stream stream = streams[i];
                    if (select(text, wordsOrder, i, stream))
                        return true;
                }
                return false;
            }

            private boolean select(final String text, final boolean wordsOrder, final int i, final Stream stream) {
                if (RowSetClass.isStartSame(stream, text, wordsOrder)) {
                    jList.setSelectedIndex(i);
                    jList.ensureIndexIsVisible(i);
                    return true;
                }
                return false;
            }

            @Override
            public void setVisible(final boolean aFlag) {
                super.setVisible(aFlag);
                Options.setBoolean("showFindStreamPanel", aFlag);
            }
        };
        boolean v = Options.getBoolean("showFindStreamPanel", true);
        if (!v)
            rowFindPanel.setVisible(false);
        else
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    rowFindPanel.getJTextField().requestFocus();
                }
            });
    }
    return rowFindPanel;
}
Also used : Stream(com.ramussoft.pb.Stream) RowFindPanel(com.ramussoft.pb.frames.components.RowFindPanel)

Example 29 with Stream

use of com.ramussoft.pb.Stream 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 30 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class SectorNameEditor method findStreamByName.

public Stream findStreamByName(final String name) {
    if ("".equals(name))
        return null;
    final Vector<Row> streams = dataPlugin.getRecChilds(dataPlugin.getBaseStream(), true);
    final int l = streams.size();
    for (int i = 0; i < l; i++) {
        final Stream s = (Stream) streams.get(i);
        if (name.equals(s.getName()) && !s.isEmptyName())
            return s;
    }
    return null;
}
Also used : Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

Aggregations

Stream (com.ramussoft.pb.Stream)51 Row (com.ramussoft.pb.Row)30 Function (com.ramussoft.pb.Function)21 Sector (com.ramussoft.pb.Sector)18 ByteArrayOutputStream (java.io.ByteArrayOutputStream)15 NSector (com.ramussoft.pb.data.negine.NSector)14 Vector (java.util.Vector)13 InputStream (java.io.InputStream)11 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)10 ByteArrayInputStream (java.io.ByteArrayInputStream)10 Crosspoint (com.ramussoft.pb.Crosspoint)9 NFunction (com.ramussoft.pb.data.negine.NFunction)9 OutputStream (java.io.OutputStream)7 NStream (com.ramussoft.pb.data.negine.NStream)6 ArrayList (java.util.ArrayList)6 FloatPoint (com.dsoft.pb.types.FloatPoint)4 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)4 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)4 IOException (java.io.IOException)4 FRectangle (com.dsoft.pb.types.FRectangle)3