Search in sources :

Example 6 with NSector

use of com.ramussoft.pb.data.negine.NSector in project ramus by Vitaliy-Yakovchuk.

the class AbstractCrosspoint method addSector.

/**
 * Метод додає сектор в кінець масива секторів і повертає новостворений
 * масив секторів. Перевірка на те чи сектор вже присутній в масиві не
 * робиться.
 *
 * @param array  Вхідний масив секторів.
 * @param sector Сектор, який буде доданий до масиву.
 * @return Вихідний масив секторів, який включає всі сектори вхідного масиву
 * і додає елемент в кінець.
 */
protected Sector[] addSector(final Sector[] array, final Sector sector) {
    for (Sector s : array) if (((NSector) s).getElementId() == ((NSector) sector).getElementId())
        return array;
    final Sector[] tmp = new Sector[array.length + 1];
    for (int i = 0; i < array.length; i++) tmp[i] = array[i];
    tmp[array.length] = sector;
    return tmp;
}
Also used : NSector(com.ramussoft.pb.data.negine.NSector) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 7 with NSector

use of com.ramussoft.pb.data.negine.NSector 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)

Example 8 with NSector

use of com.ramussoft.pb.data.negine.NSector 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 9 with NSector

use of com.ramussoft.pb.data.negine.NSector in project ramus by Vitaliy-Yakovchuk.

the class ModelParaleler method getSector.

private Sector getSector(NSector sector) {
    NSector res = sectorsHash.get(sector.getElementId());
    if (res == null) {
        res = (NSector) toDataPlugin.createSector();
        sectorsHash.put(sector.getElementId(), res);
        copyAttributes(IDEF0Plugin.getBaseSectorQualifier(fromEngine).getSystemAttributes(), sector.getElement(), res.getElement());
        copy(sector.getStart(), res.getStart());
        copy(sector.getEnd(), res.getEnd());
    }
    return res;
}
Also used : NSector(com.ramussoft.pb.data.negine.NSector)

Example 10 with NSector

use of com.ramussoft.pb.data.negine.NSector in project ramus by Vitaliy-Yakovchuk.

the class MovingArea method setActiveObject.

public void setActiveObject(final Object activeObject, boolean silent) {
    this.prevActiveObject = this.getActiveObject();
    if (activeObject instanceof MovingText)
        this.activeMovingTextIndex = refactor.getTexts().indexOf(activeObject);
    else
        this.activeMovingTextIndex = -1;
    if (activeObject instanceof MovingFunction) {
        NFunction function = (NFunction) ((MovingFunction) activeObject).getFunction();
        if (!silent) {
            panel.getFramework().propertyChanged(Commands.ACTIVATE_ELEMENT, function.getElement());
            long id = dataPlugin.getBaseFunctionQualifier().getAttributeForName();
            for (Attribute attr : dataPlugin.getBaseFunctionQualifier().getAttributes()) if (attr.getId() == id) {
                panel.getFramework().propertyChanged(Commands.ACTIVATE_ATTRIBUTE, new AttributeEditorView.ElementAttribute(function.getElement(), attr));
            }
        }
        Enumeration e = ((MovingFunction) activeObject).getFunction().children();
        while (e.hasMoreElements()) ((Function) e.nextElement()).getSectors();
    }
    final Object o = this.activeObject;
    if ((activeObject == null) && (!silent)) {
        panel.getFramework().propertyChanged(Commands.ACTIVATE_ATTRIBUTE, null);
    }
    this.activeObject = activeObject;
    if (o != activeObject)
        panel.getFrame().refreshActions(panel);
    if (activeObject instanceof PaintSector.Pin) {
        final PaintSector.Pin pin = (PaintSector.Pin) activeObject;
        panel.getFrame().getJCheckBoxMenuItemShowTilda().setSelected(pin.getSector().isShowTilda());
        panel.getFrame().getJCheckBoxMenuItemTransparentText().setSelected(pin.getSector().isTransparent());
        if (!silent) {
            panel.getFramework().propertyChanged(Commands.ACTIVATE_ELEMENT, ((NSector) pin.getSector().getSector()).getElement(), pin);
            panel.getFramework().propertyChanged(Commands.ACTIVATE_ATTRIBUTE, new AttributeEditorView.ElementAttribute(((NSector) pin.getSector().getSector()).getElement(), IDEF0Plugin.getStreamAttribute(dataPlugin.getEngine())), pin);
        }
    }
    repaintAsync();
}
Also used : Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) Enumeration(java.util.Enumeration) NFunction(com.ramussoft.pb.data.negine.NFunction) Attribute(com.ramussoft.common.Attribute) NSector(com.ramussoft.pb.data.negine.NSector) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) AttributeEditorView(com.ramussoft.gui.attribute.AttributeEditorView) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) DFDObject(com.ramussoft.pb.dfd.visual.DFDObject)

Aggregations

NSector (com.ramussoft.pb.data.negine.NSector)11 Crosspoint (com.ramussoft.pb.Crosspoint)6 Sector (com.ramussoft.pb.Sector)6 Function (com.ramussoft.pb.Function)4 NFunction (com.ramussoft.pb.data.negine.NFunction)4 FloatPoint (com.dsoft.pb.types.FloatPoint)3 Row (com.ramussoft.pb.Row)3 Stream (com.ramussoft.pb.Stream)3 NCrosspoint (com.ramussoft.pb.data.negine.NCrosspoint)3 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)3 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)2 MovingArea (com.ramussoft.pb.idef.visual.MovingArea)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ArrayList (java.util.ArrayList)2 DataLoader (com.dsoft.utils.DataLoader)1 MemoryData (com.dsoft.utils.DataLoader.MemoryData)1 Attribute (com.ramussoft.common.Attribute)1 AttributeEditorView (com.ramussoft.gui.attribute.AttributeEditorView)1 SectorPointPersistent (com.ramussoft.idef0.attribute.SectorPointPersistent)1