Search in sources :

Example 1 with Function

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

the class ArrowPainter method paintBottom.

public void paintBottom(final Graphics2D g, final int height, MovingArea area, Font bottomFont, int partNumber, int hPageCount) {
    if (!area.isPrinting()) {
        if (!MovingArea.DISABLE_RENDERING_HINTS) {
            g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
            g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        }
    }
    g.setFont(bottomFont);
    final Font font = bottomFont;
    final Function activeFunction = movingArea.getActiveFunction();
    int width = movingArea.getIntOrdinate(movingArea.MOVING_AREA_WIDTH);
    width /= hPageCount;
    int left = 0;
    if (partNumber > 0) {
        left = width * partNumber;
        width += 1;
    }
    final int x = left + width / 5;
    g.drawLine(left, 0, left, height - 1);
    g.drawLine(width - 1, 0, width - 1, height - 1);
    g.drawRect(left, 0, width - 1, height - 1);
    g.drawLine(x, 0, x, height - 1);
    g.drawLine(left + width / 5 * 4, 0, left + width / 5 * 4, height - 1);
    g.setFont(movingArea.getFont(g.getFont()));
    String number = NUMBER + " " + movingArea.getFunctionNumber();
    if (hPageCount > 1)
        number += "." + (partNumber + 1);
    String node = NODE_B;
    final double nodeWidth = g.getFont().getStringBounds(node, g.getFontRenderContext()).getWidth();
    final int nT = 5 + 4 + (int) g.getFont().getStringBounds(node, g.getFontRenderContext()).getHeight();
    g.drawString(node, left + 5, nT);
    g.drawString(number, left + width / 5 * 4 + 5, nT);
    node = TITLE_B;
    final int titleWidth = (int) g.getFont().getStringBounds(node, g.getFontRenderContext()).getWidth();
    g.drawString(node, x + 5, nT);
    if (activeFunction.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
        node = MovingFunction.getDFDSKod((com.ramussoft.database.common.Row) activeFunction, movingArea.dataPlugin);
    } else
        node = MovingFunction.getIDEF0Kod((com.ramussoft.database.common.Row) activeFunction);
    g.drawString(node, left + (int) nodeWidth + 10, nT);
    node = activeFunction.getName();
    if (activeFunction.equals(movingArea.dataPlugin.getBaseFunction()) && activeFunction.getDecompositionType() != MovingArea.DIAGRAM_TYPE_DFDS) {
        final Vector v = movingArea.dataPlugin.getChilds(activeFunction, true);
        if (v.size() > 0)
            node = ((Row) v.get(0)).getName();
    }
    g.setFont(font);
    movingArea.paintText(g, node, movingArea.getFBounds(new Rectangle(x + 10 + titleWidth, 2, x * 3 - 10 - titleWidth - 3 * left, height)), Line.CENTER_ALIGN, 1, true);
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) Rectangle(java.awt.Rectangle) FRectangle(com.dsoft.pb.types.FRectangle) Row(com.ramussoft.pb.Row) Vector(java.util.Vector) Font(java.awt.Font) FloatPoint(com.dsoft.pb.types.FloatPoint)

Example 2 with Function

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

the class PaintSector method isSelected.

/**
 * Перевіряє, чи являється диний сектор активний.
 *
 * @param area Область відображення.
 * @return true, якщо активний даний сектор або той, що наслідується, false,
 * якщо сектор не активний.
 */
private boolean isSelected(final MovingArea area) {
    if (MovingLabel.getActiveStream() != null && equalsStreams(MovingLabel.getActiveStream(), getStream()))
        return true;
    if (rec)
        return false;
    final PaintSector as = area.getActiveSector();
    if (as == this)
        return true;
    rec = true;
    boolean res = false;
    if (as != null) {
        if (getStart() != null && !getStart().isOne(sector)) {
            if (isSelected(area, getStart()))
                res = true;
        } else if (getEnd() != null && !getEnd().isOne(sector)) {
            if (isSelected(area, getEnd()))
                res = true;
        }
    }
    if (!res && area.getActiveObject() instanceof IDEF0Object) {
        final Function active = ((IDEF0Object) area.getActiveObject()).getFunction();
        if (active == sector.getStart().getFunction() || active == sector.getEnd().getFunction())
            res = true;
    }
    rec = false;
    return res;
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) IDEF0Object(com.ramussoft.pb.idef.visual.IDEF0Object)

Example 3 with Function

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

the class SectorRefactor method changeSector.

/**
 * Змінює сектор переданий методом setSector(Sector sector).
 *
 * @return <code>true</code>, якщо зміна відбулась,<br>
 * <code>false</code>, якщо зміна не відбулась.
 */
public boolean changeSector() {
    Crosspoint crosspoint;
    final PerspectivePoint point = getLastPoint();
    if (point.functionType == -1 && point.borderType == -1) {
        if (point.pin.getSector().getStart() == null || point.pin.getSector().getEnd() == null || point.pin.getSector().equals(sector))
            return false;
    }
    Sector inner = sector.getSector();
    for (PaintSector s : sectors) if (s.getSector().equals(inner)) {
        this.sector = s;
        break;
    }
    lastC = null;
    NSectorBorder sb;
    if (point.type == TYPE_START) {
        sb = sector.getSector().getStart();
        crosspoint = sector.getStart();
        pointB = new PerspectivePoint();
        pointB.x = sector.getEndPoint().getX();
        pointB.y = sector.getEndPoint().getY();
    } else {
        sb = sector.getSector().getEnd();
        crosspoint = sector.getEnd();
        pointA = new PerspectivePoint();
        pointA.x = sector.getStartPoint().getX();
        pointA.y = sector.getStartPoint().getY();
    }
    List<Sector> oldConnectedSectors = new ArrayList<Sector>();
    if (crosspoint != null) {
        for (Sector s : crosspoint.getIns()) if (s != sector.getSector())
            oldConnectedSectors.add(s);
        for (Sector s : crosspoint.getOuts()) if (s != sector.getSector())
            oldConnectedSectors.add(s);
    }
    Sector s = null;
    boolean createMiss = true;
    if (point.function != null) {
        Function oldF = sb.getFunction();
        if (oldF != null && oldF.equals(point.function)) {
            if (function.getDecompositionType() >= 0 || point.function.getType() >= Function.TYPE_EXTERNAL_REFERENCE)
                createMiss = false;
            else {
                createMiss = point.functionType != sb.getFunctionType();
            }
        }
    }
    if (createMiss)
        s = createMiss(point);
    else
        point.crosspoint = sb.getCrosspoint();
    if (s != null)
        s.setVisualAttributes(sector.getSector().getVisualAttributes());
    if (type == TYPE_START) {
        copyToSectorBorder(sb, pointA);
        sector.setStart(point.crosspoint, point.point, createMiss);
        sector.getSector().getStart().commit();
    } else {
        copyToSectorBorder(sector.getSector().getEnd(), pointB);
        sector.setEnd(point.crosspoint, point.point, createMiss);
        sector.getSector().getEnd().commit();
    }
    if (sector.getStream() != null) {
        if (lastC != null)
            lastC.setStream(cloneStream(sector.getStream(), movingArea.dataPlugin, lastC), ReplaceStreamType.CHILDREN);
    }
    sector.setCorrectRows();
    sector.regeneratePoints();
    sector.tryRemovePin(movingArea);
    Hashtable<Long, Sector> sectorHash = movingArea.getDataPlugin().getSectorHash();
    for (Sector sector : oldConnectedSectors) {
        if (sectorHash.get(((NSector) sector).getElementId()) != null) {
            fixOwners(sector, getDataPlugin());
        }
    }
    saveToFunction();
    return true;
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) NSectorBorder(com.ramussoft.pb.data.negine.NSectorBorder) NSector(com.ramussoft.pb.data.negine.NSector) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) ArrayList(java.util.ArrayList) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 4 with Function

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

the class SectorRefactor method fillStartFromOwners.

private static void fillStartFromOwners(Sector sector, HashSet<Row> owners, DataPlugin dataPlugin, boolean[] hasFunctionOwners) {
    Crosspoint crosspoint = sector.getStart().getCrosspoint();
    Function function2 = sector.getStart().getFunction();
    if (function2 != null) {
        if (function2.getType() != Function.TYPE_DFDS_ROLE) {
            Row row = function2.getOwner();
            if (row != null && !owners.contains(row)) {
                owners.add(row);
                hasFunctionOwners[0] = true;
            }
        } else {
            Stream stream = (Stream) dataPlugin.findRowByGlobalId(function2.getLink());
            if (stream != null)
                for (Row row : stream.getAdded()) {
                    if (row != null && !owners.contains(row))
                        owners.add(row);
                }
        }
    }
    if (crosspoint != null)
        for (Sector sector2 : crosspoint.getOppozite(sector)) fillStartFromOwners(sector2, owners, dataPlugin, hasFunctionOwners);
}
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) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 5 with Function

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

the class SectorRefactor method createSectorOnIn.

public Sector createSectorOnIn(final Crosspoint point, final SectorBorder border, final PaintSector sector, boolean start) {
    Function function = border.getFunction();
    int borderType = border.getBorderType();
    if (function != null && function.getType() == Function.TYPE_DFDS_ROLE) {
        function = null;
        borderType = MovingText.getOpposite(border.getFunctionType());
    }
    double pos;
    Sector s;
    Point bPoint;
    Function par = sector.getFunction();
    if (start)
        bPoint = sector.getStartPoint();
    else
        bPoint = sector.getEndPoint();
    if (function != null) {
        if ((border.getFunctionType() == MovingPanel.RIGHT) || (border.getFunctionType() == MovingPanel.LEFT))
            pos = bPoint.getY() / movingArea.CLIENT_HEIGHT * par.getBounds().getHeight() + par.getBounds().getY();
        else
            pos = bPoint.getX() / movingArea.CLIENT_WIDTH * par.getBounds().getWidth() + par.getBounds().getX();
        s = createPartIn(point, function, border.getFunctionType(), pos, !start);
    } else {
        if ((borderType == MovingPanel.RIGHT) || (borderType == MovingPanel.LEFT))
            pos = bPoint.getY() / movingArea.CLIENT_HEIGHT * par.getBounds().getHeight() + par.getBounds().getY();
        else
            pos = sector.getStartPoint().getX() / movingArea.CLIENT_WIDTH * par.getBounds().getWidth() + par.getBounds().getX();
        s = createPartOut(point, this.function, borderType, pos, !start);
    }
    if (s != null) {
        s.setStream(cloneStream(sector.getSector().getStream(), movingArea.dataPlugin, s), ReplaceStreamType.CHILDREN);
        ((NSector) s).storeData();
        s.setVisualAttributes(s.getVisualAttributes());
    }
    return s;
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) NSector(com.ramussoft.pb.data.negine.NSector) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint)

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