Search in sources :

Example 46 with Function

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

the class IDEFPanel method createParalel.

protected void createParalel() {
    Function f = null;
    try {
        final JFileChooser chooser = new JFileChooser() {

            @Override
            public void approveSelection() {
                if (getSelectedFile().exists()) {
                    if (JOptionPane.showConfirmDialog(framework.getMainFrame(), GlobalResourcesManager.getString("File.Exists"), UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
                        return;
                }
                super.approveSelection();
            }
        };
        if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
            final CreateParalelDialog dialog = new CreateParalelDialog(framework.getMainFrame());
            if (!dialog.showModal())
                return;
            String fn = chooser.getSelectedFile().getAbsolutePath();
            if (!fn.substring(fn.length() - frame.FILE_EX.length()).equalsIgnoreCase(frame.FILE_EX))
                fn += frame.FILE_EX;
            f = ((MovingFunction) movingArea.getActiveObject()).getFunction();
            frame.propertyChange(MChangeListener.FILE_SAVE, null);
            boolean clearFunctionalBlock = dialog.getCreateParalelModel().isClearFunctionalBlock();
            dataPlugin.createParalel(f, dialog.getCreateParalelModel().isCopyAllRows(), clearFunctionalBlock, new File(fn), framework, movingArea.getDataPlugin());
            movingArea.repaint();
        }
    } catch (final IOException e) {
        JOptionPane.showMessageDialog(framework.getMainFrame(), e.getLocalizedMessage());
    }
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) JFileChooser(javax.swing.JFileChooser) IOException(java.io.IOException) File(java.io.File)

Example 47 with Function

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

the class PaintSector method getStartTunnelType.

/**
 * Повертає тип тунеля для початку сектора.
 *
 * @return Crosspoint.TUNNEL_NONE - тунель відсутній;<br>
 * Crosspoint.TUNNEL_HARD - тунель показаний прямими дужками;<br>
 * Crosspoint.TUNNEL_SOFT - тунель показаний заокругленими дужками.
 */
public int getStartTunnelType() {
    if (getStart() == null)
        return Crosspoint.TUNNEL_NONE;
    int res = sector.getStart().getTunnelType();
    Function function = sector.getFunction();
    if ((function.getParentRow() == null) || (function.getParentRow().toString().equals("F_BASE_FUNCTIONS"))) {
        if (sector.getStart().getBorderType() >= 0)
            res = Crosspoint.TUNNEL_NONE;
    }
    if (res != Crosspoint.TUNNEL_NONE)
        if (sector.getStart().getFunction() != null && (sector.getStart().getFunction().getChildCount() == 0 || sector.getStart().getFunction().getType() == Function.TYPE_DFDS_ROLE))
            res = Crosspoint.TUNNEL_NONE;
    return res;
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint)

Example 48 with Function

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

the class SectorRefactor method copyOwnersFrom.

public static void copyOwnersFrom(Function function, DataPlugin dataPlugin) {
    Function par = (Function) function.getParent();
    HashSet<Function> roles = new HashSet<Function>();
    for (Sector sector : par.getSectors()) {
        if (function.equals(sector.getStart().getFunction())) {
            getEndRoles(sector, roles, dataPlugin);
            getStartRoles(sector, roles, dataPlugin);
        }
        if (function.equals(sector.getEnd().getFunction())) {
            getStartRoles(sector, roles, dataPlugin);
            getEndRoles(sector, roles, dataPlugin);
        }
    }
    Stream stream = (Stream) dataPlugin.findRowByGlobalId(function.getLink());
    Row[] owners;
    if (stream == null)
        owners = new Row[] {};
    else
        owners = stream.getAdded();
    for (Function function2 : roles) {
        stream = (Stream) dataPlugin.findRowByGlobalId(function2.getLink());
        if (stream == null) {
            if (owners.length > 0) {
                stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                function2.setLink(stream.getElement().getId());
                stream.setRows(owners);
            }
        } else {
            stream.setRows(owners);
        }
    }
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) HashSet(java.util.HashSet)

Example 49 with Function

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

the class SectorRefactor method createPartOut.

/**
 * Метод свторює сектор зверху на функціональному блоці.
 *
 * @param point        Точка на краю активного функціоналоноко блоку (констук якого
 *                     показується).
 * @param function     Активний функціональний блок.
 * @param functionType Край, на якому знаходиться тока.
 */
private Sector createPartOut(final Crosspoint point, final Function function, final int functionType, final double outPos, boolean start) {
    if (functionType < 0) {
        JOptionPane.showMessageDialog(null, "Не виправлена " + "помилка тунулювання.");
        return null;
    }
    final Function par = (Function) function.getParent();
    if (par == null)
        return null;
    // PerspectivePoint ppPoint = null;
    final Sector sector = getDataPlugin().createSector();
    sector.setFunction(par);
    /*	if (par.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
			ppPoint = new PerspectivePoint();
			ppPoint.x = function.getBounds().getX() + outPos
					/ movingArea.CLIENT_WIDTH * function.getBounds().getWidth();
			ppPoint.y = outPos;
			ppPoint.borderType = functionType;
			createBorderPoints(ppPoint, par);
		}*/
    final Crosspoint op = getDataPlugin().createCrosspoint();
    if (start) {
        sector.getStart().setCrosspointA(point);
        sector.getStart().setFunctionA(function);
        sector.getStart().setFunctionTypeA(functionType);
        sector.getEnd().setCrosspointA(op);
        /*if (par.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
				sector.getEnd().setFunctionA(ppPoint.function);
				sector.getEnd().setFunctionTypeA(
						MovingPanel.getOpposite(functionType));
			} else*/
        sector.getEnd().setBorderTypeA(functionType);
    } else {
        sector.getEnd().setCrosspointA(point);
        sector.getEnd().setFunctionA(function);
        sector.getEnd().setFunctionTypeA(functionType);
        sector.getStart().setCrosspointA(op);
        /*if (par.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
				sector.getStart().setFunctionA(ppPoint.function);
				sector.getStart().setFunctionTypeA(
						MovingPanel.getOpposite(functionType));
			} else*/
        sector.getStart().setBorderTypeA(functionType);
    }
    sector.getStart().commit();
    sector.getEnd().commit();
    PaintSector.save(createOutPaintPart(sector, outPos), new DataLoader.MemoryData(), movingArea.getDataPlugin().getEngine());
    return sector;
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) DataLoader(com.dsoft.utils.DataLoader) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 50 with Function

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

the class PaintSector method paint.

/**
 * Малює сектор, використовуючи параметри movingArea.
 *
 * @param g          Об’єкт для малювання.
 * @param movingArea Об’єкт для завантаження параметрів.
 */
public void paint(final Graphics2D g, final MovingArea movingArea) {
    g.setColor(getColor());
    g.setFont(getFont());
    arrowPainter = new ArrowPainter(movingArea);
    if (movingArea.getMousePin() != null && movingArea.getMousePin().getSector() == this && !selStart && !selEnd || isSelected(movingArea))
        g.setStroke(getBoldStroke());
    else {
        Stroke stroke = getStroke();
        if (stroke instanceof WayStroke) {
            final float arrowWidth = (float) movingArea.getIDoubleOrdinate(ArrowPainter.ARROW_WIDTH);
            WayStroke wayStroke = (WayStroke) stroke;
            if (wayStroke.getType() == 0)
                wayStroke.setArrowWidth(arrowWidth);
            else if (wayStroke.getType() == 1)
                wayStroke.setArrowWidth(arrowWidth / 2);
            else
                wayStroke.setArrowWidth(arrowWidth / 3);
        } else if (stroke instanceof ArrowedStroke) {
            final float arrowWidth = (float) movingArea.getIDoubleOrdinate(ArrowPainter.ARROW_WIDTH);
            final float arrowHeight = (float) movingArea.getIDoubleOrdinate(ArrowPainter.ARROW_HEIGHT);
            g.setStroke(new ArrowedStroke(arrowWidth, arrowHeight));
            ArrowedStroke arrowedStroke = (ArrowedStroke) stroke;
            if (arrowedStroke.getType() == 0) {
                arrowedStroke.setArrowWidth(arrowWidth);
                arrowedStroke.setArrowHeight(arrowHeight);
            } else if (arrowedStroke.getType() == 1) {
                arrowedStroke.setArrowWidth(arrowWidth / 2);
                arrowedStroke.setArrowHeight(arrowHeight / 2);
            } else {
                arrowedStroke.setArrowWidth(arrowWidth / 3);
                arrowedStroke.setArrowHeight(arrowHeight / 3);
            }
        }
        g.setStroke(stroke);
    }
    for (int i = 0; i < getPinCount(); i++) getPin(i).paint(g, movingArea);
    if (showTilda && text != null)
        arrowPainter.paintTilda(g, this);
    switch(getStartTunnelType()) {
        case Crosspoint.TUNNEL_SIMPLE_SOFT:
        case Crosspoint.TUNNEL_SOFT:
            {
                arrowPainter.paintTunnel(g, getStartPoint().getPoint(), getVectorType(SectorRefactor.TYPE_START), true);
            }
            break;
        case Crosspoint.TUNNEL_HARD:
            {
                arrowPainter.paintTunnel(g, getStartPoint().getPoint(), getVectorType(SectorRefactor.TYPE_START), false);
            }
            break;
        case Crosspoint.TUNNEL_NONE:
            {
                int borderType = getSector().getStart().getBorderType();
                NCrosspoint crosspoint = (NCrosspoint) getStart();
                if ((borderType >= 0) && (crosspoint != null) && (crosspoint.isOneInOut())) {
                    NSector in = (NSector) crosspoint.getIn();
                    Function outer = in.getFunction();
                    NSector out = (NSector) crosspoint.getOut();
                    Function inner = out.getFunction();
                    if ((inner != null) && (inner.getParent() != null) && (!inner.getParent().equals(outer))) {
                        arrowPainter.paintLink(g, getStartPoint().getPoint(), getVectorType(SectorRefactor.TYPE_START), inner, outer);
                    }
                }
            }
            break;
    }
    switch(getEndTunnelType()) {
        case Crosspoint.TUNNEL_SIMPLE_SOFT:
        case Crosspoint.TUNNEL_SOFT:
            {
                arrowPainter.paintTunnel(g, getEndPoint().getPoint(), getVectorType(SectorRefactor.TYPE_END), true);
            }
            break;
        case Crosspoint.TUNNEL_HARD:
            {
                arrowPainter.paintTunnel(g, getEndPoint().getPoint(), getVectorType(SectorRefactor.TYPE_END), false);
            }
            break;
        case Crosspoint.TUNNEL_NONE:
            {
                int borderType = getSector().getEnd().getBorderType();
                NCrosspoint crosspoint = (NCrosspoint) getEnd();
                if ((borderType >= 0) && (crosspoint != null) && (crosspoint.isOneInOut())) {
                    Function outer = crosspoint.getOut().getFunction();
                    Function inner = crosspoint.getIn().getFunction();
                    if ((inner != null) && (inner.getParent() != null) && (!inner.getParent().equals(outer))) {
                        arrowPainter.paintLink(g, getEndPoint().getPoint(), getVectorType(SectorRefactor.TYPE_END), inner, outer);
                    }
                }
            }
            break;
    }
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) WayStroke(com.ramussoft.pb.idef.visual.WayStroke) Stroke(java.awt.Stroke) ArrowedStroke(com.ramussoft.pb.idef.visual.ArrowedStroke) BasicStroke(java.awt.BasicStroke) NSector(com.ramussoft.pb.data.negine.NSector) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) WayStroke(com.ramussoft.pb.idef.visual.WayStroke) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint) ArrowedStroke(com.ramussoft.pb.idef.visual.ArrowedStroke)

Aggregations

Function (com.ramussoft.pb.Function)96 NFunction (com.ramussoft.pb.data.negine.NFunction)50 Row (com.ramussoft.pb.Row)36 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)27 Crosspoint (com.ramussoft.pb.Crosspoint)25 Sector (com.ramussoft.pb.Sector)25 Stream (com.ramussoft.pb.Stream)21 FloatPoint (com.dsoft.pb.types.FloatPoint)19 NSector (com.ramussoft.pb.data.negine.NSector)18 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)17 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)17 Vector (java.util.Vector)17 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)15 IOException (java.io.IOException)13 FRectangle (com.dsoft.pb.types.FRectangle)11 Point (com.ramussoft.pb.idef.elements.Point)11 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 ArrayList (java.util.ArrayList)10 MovingArea (com.ramussoft.pb.idef.visual.MovingArea)8