Search in sources :

Example 26 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class DFDFunction method paint.

@Override
public void paint(Graphics2D g) {
    g.setColor(function.getBackground());
    final Rectangle2D rect = movingArea.getBounds(getBounds());
    RoundRectangle2D rectangle2d = new RoundRectangle2D.Double(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight(), movingArea.getIDoubleOrdinate(20), movingArea.getIDoubleOrdinate(20));
    g.fill(rectangle2d);
    g.setFont(function.getFont());
    paintText(g);
    paintBorder(g);
    final Stroke tmp = g.getStroke();
    g.draw(rectangle2d);
    if (!function.isHaveChilds()) {
        g.draw(new Line2D.Double(rect.getX() + Math.round(movingArea.getIDoubleOrdinate(15)), rect.getY(), rect.getX(), rect.getY() + Math.round(movingArea.getIDoubleOrdinate(15))));
    }
    g.setStroke(new BasicStroke(2));
    final String string = Integer.toString(function.getId());
    g.setFont(function.getFont());
    double h = MovingArea.getWidth((int) function.getFont().getStringBounds(string, g.getFontRenderContext()).getHeight());
    paintTringle(g);
    g.setStroke(tmp);
    movingArea.paintText(g, string, new FRectangle(getBounds().getX(), getBounds().getBottom() - h, getBounds().getWidth() - 3, h), com.ramussoft.pb.print.old.Line.RIGHT_ALIGN, 1, true);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) FRectangle(com.dsoft.pb.types.FRectangle) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Rectangle2D(java.awt.geom.Rectangle2D) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Line2D(java.awt.geom.Line2D)

Example 27 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class MovingArea method createFunctionalObject.

public Function createFunctionalObject(final double dX, final double dY, int type, Function activeFunction) {
    final Function function = (Function) dataPlugin.createFunction(activeFunction, type);
    function.setBounds(new FRectangle(dX, dY, function.getBounds().getWidth(), function.getBounds().getHeight()));
    function.setCreateDate(new Date());
    function.setSystemRevDate(new Date());
    if (type == Function.TYPE_DATA_STORE) {
        FRectangle rect = function.getBounds();
        rect.setHeight(rect.getHeight() / 2);
        function.setBounds(rect);
        function.setFont(Options.getFont("DEFAULT_DATA_STORE_FONT", new Font("Dialog", Font.BOLD, 8)));
        function.setBackground(Options.getColor("DEFAULT_DATA_STORE_COLOR", Color.white));
        function.setForeground(Options.getColor("DEFAULT_DATA_STORE_TEXT_COLOR", Color.black));
    } else if (type == Function.TYPE_EXTERNAL_REFERENCE) {
        FRectangle rect = function.getBounds();
        rect.setHeight(12);
        rect.setWidth(20);
        function.setBounds(rect);
        function.setFont(Options.getFont("DEFAULT_EXTERNAL_REFERENCE_FONT", new Font("Dialog", Font.BOLD, 8)));
        function.setBackground(Options.getColor("DEFAULT_EXTERNAL_COLOR", Color.white));
        function.setForeground(Options.getColor("DEFAULT_EXTERNAL_TEXT_COLOR", Color.black));
    } else if (type == Function.TYPE_DFDS_ROLE) {
        FRectangle rect = function.getBounds();
        rect.setHeight(Options.getInteger("DEFAULT_DFDS_ROLE_HEIGHT", 12));
        rect.setWidth(Options.getInteger("DEFAULT_DFDS_ROLE_WIDTH", 20));
        function.setBounds(rect);
        function.setFont(Options.getFont("DEFAULT_DFDS_ROLE_FONT", new Font("Dialog", Font.BOLD, 8)));
        function.setBackground(Options.getColor("DEFAULT_DFDS_ROLE_COLOR", Color.white));
        function.setForeground(Options.getColor("DEFAULT_DFDS_ROLE_TEXT_COLOR", Color.black));
    } else {
        function.setFont(Options.getFont("DEFAULT_FUNCTIONAL_BLOCK_FONT", new Font("Dialog", 0, 12)));
        function.setBackground(Options.getColor("DEFAULD_FUNCTIONAL_BLOCK_COLOR", Color.white));
        function.setForeground(Options.getColor("DEFAULD_FUNCTIONAL_BLOCK_TEXT_COLOR", Color.black));
    }
    return function;
}
Also used : DFDSFunction(com.ramussoft.pb.dfds.visual.DFDSFunction) Function(com.ramussoft.pb.Function) DFDFunction(com.ramussoft.pb.dfd.visual.DFDFunction) NFunction(com.ramussoft.pb.data.negine.NFunction) FRectangle(com.dsoft.pb.types.FRectangle) Date(java.util.Date) Font(java.awt.Font)

Example 28 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class MovingArea method setActiveFunction.

/**
 * Задає значення активного на блоку (того який являється базовим для
 * решти).
 *
 * @param activeFunction Значення активної функції.
 */
public void setActiveFunction(final Function activeFunction) {
    synchronized (backgroundPaintlock) {
        bImage = null;
    }
    String size = activeFunction.getPageSize();
    initSize(size);
    if (panel != null) {
        cancelAdding();
        panel.setMovingAreaSize(zoom);
    }
    if (activeFunction.getType() >= Function.TYPE_EXTERNAL_REFERENCE)
        return;
    textPaintCache.clear();
    if (activeFunction.getDecompositionType() == DIAGRAM_TYPE_DFDS) {
        DropTarget dropTarget = new DropTarget();
        this.setDropTarget(dropTarget);
        try {
            dropTarget.addDropTargetListener(new DropTargetAdapter() {

                @Override
                public void drop(DropTargetDropEvent event) {
                    if (event.getTransferable().isDataFlavorSupported(RowTreeTable.rowsListFlavor)) {
                        try {
                            event.acceptDrop(event.getSourceActions());
                            Rows rows = (Rows) event.getTransferable().getTransferData(RowTreeTable.rowsListFlavor);
                            FloatPoint point = toPoint(event.getLocation().x, event.getLocation().y);
                            Function owner = null;
                            for (MovingPanel panel : panels) if (panel instanceof DFDSFunction && panel.contain(point)) {
                                owner = ((DFDSFunction) panel).getFunction();
                            }
                            startUserTransaction();
                            Function function = createFunctionalObject(getDoubleOrdinate(event.getLocation().getX()), getDoubleOrdinate(event.getLocation().getY()), Function.TYPE_DFDS_ROLE, activeFunction);
                            RectangleVisualOptions ops = IDEF0Plugin.getDefaultRectangleVisualOptions(dataPlugin.getEngine(), rows.get(0).getElement());
                            if (ops != null) {
                                FRectangle rect = function.getBounds();
                                rect.setHeight(ops.bounds.getHeight());
                                rect.setWidth(ops.bounds.getWidth());
                                function.setBounds(rect);
                                function.setFont(ops.font);
                                function.setBackground(ops.background);
                                function.setForeground(ops.foreground);
                            }
                            Stream stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                            Row[] rows2 = new Row[rows.size()];
                            for (int i = 0; i < rows2.length; i++) rows2[i] = dataPlugin.findRowByGlobalId(rows.get(i).getElementId());
                            stream.setRows(rows2);
                            function.setLink(stream.getElement().getId());
                            if (owner != null) {
                                function.setOwner(owner);
                                DFDSFunction function2 = findDFDSFunction(owner);
                                List<Function> roles = getRoles(function2);
                                if (!roles.contains(function))
                                    roles.add(function);
                                if (function2 != null)
                                    function2.justifyRoles(roles);
                            }
                            commitUserTransaction();
                            panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, activeFunction);
                        } catch (UnsupportedFlavorException e) {
                            e.printStackTrace();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    } else
                        event.rejectDrop();
                }
            });
        } catch (TooManyListenersException e) {
            e.printStackTrace();
        }
    } else
        this.setDropTarget(null);
    if (rec)
        return;
    rec = true;
    if (panel != null) {
        boolean locked;
        if (activeFunction.equals(lockedFunction))
            locked = true;
        else
            locked = activeFunction.lock();
        refactor.loadFromFunction(activeFunction, false);
        if (!activeFunction.equals(lockedFunction)) {
            if (lockedFunction != null)
                lockedFunction.unlock();
            if (locked)
                lockedFunction = activeFunction;
            else
                lockedFunction = null;
        }
        panel.setMovingActiveFunction(activeFunction);
        if (getState() == END_POINT_ADDING)
            setState(START_POINT_ADDING);
        if ((getState() == END_POINT_CHANGING) || (getState() == START_POINT_CHANGING) || (getState() == FUNCTION_ADDING_STATE) || (getState() == TEXT_ADDING_STATE))
            cancelAdding();
    } else
        refactor.loadFromFunction(activeFunction, false);
    boolean updateListeneres = this.activeFunction != activeFunction;
    this.activeFunction = activeFunction;
    if (panel != null) {
        panel.getFrame().propertyChange(MChangeListener.REFRESH_FUNCTION_IN_TREE, activeFunction);
    }
    setPanels();
    if (panel != null) {
        setActiveObject(null);
        final java.awt.Point mp = getMousePosition();
        if (mp != null)
            moveMoveListener.mouseMoved(new MouseEvent(this, 0, 0, 0, mp.x, mp.y, 0, false));
    }
    functionIndex = dataPlugin.indexOfFunction(activeFunction);
    if (functionIndex < 0)
        functionIndex = 0;
    rec = false;
    if (updateListeneres) {
        ActiveFunctionEvent event = new ActiveFunctionEvent(activeFunction);
        for (ActiveFunctionListener l : getActiveFunctionListeners()) l.activeFunctionChanged(event);
    }
    if (panel != null) {
        panel.getFrame().refreshActions(panel);
    }
}
Also used : MouseEvent(java.awt.event.MouseEvent) ActiveFunctionListener(com.ramussoft.pb.idef.visual.event.ActiveFunctionListener) IOException(java.io.IOException) ActiveFunctionEvent(com.ramussoft.pb.idef.visual.event.ActiveFunctionEvent) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) DropTargetAdapter(java.awt.dnd.DropTargetAdapter) DFDSFunction(com.ramussoft.pb.dfds.visual.DFDSFunction) Function(com.ramussoft.pb.Function) DFDFunction(com.ramussoft.pb.dfd.visual.DFDFunction) NFunction(com.ramussoft.pb.data.negine.NFunction) TooManyListenersException(java.util.TooManyListenersException) FloatPoint(com.dsoft.pb.types.FloatPoint) FRectangle(com.dsoft.pb.types.FRectangle) RectangleVisualOptions(com.ramussoft.idef0.attribute.RectangleVisualOptions) Stream(com.ramussoft.pb.Stream) ArrayList(java.util.ArrayList) EventListenerList(javax.swing.event.EventListenerList) List(java.util.List) DropTarget(java.awt.dnd.DropTarget) DropTargetDropEvent(java.awt.dnd.DropTargetDropEvent) DFDSFunction(com.ramussoft.pb.dfds.visual.DFDSFunction) Rows(com.ramussoft.gui.qualifier.table.Rows)

Example 29 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class MovingLabel method resetBoundsX.

public void resetBoundsX() {
    String s = sector.getAlternativeText();
    if ("".equals(s))
        s = sector.getSector().getName();
    setText(s);
    double t;
    boolean b = false;
    movingArea.stringBounder.setFont(getFont());
    double width = getBounds().getWidth();
    double height = getBounds().getHeight();
    if (width < (t = getMinWidth())) {
        width = t;
        b = true;
    }
    if (height < (t = getMinHeight())) {
        height = t;
        b = true;
    }
    if (b) {
        final FRectangle old = getBounds();
        final FRectangle n = new FRectangle(old);
        if (height > width) {
            width = height;
        }
        if (width > movingArea.getDoubleWidth() / 4)
            width = movingArea.getDoubleWidth() / 4;
        n.setWidth(width);
        n.setHeight(height);
        setBounds(n);
        final Rectangle2D r = getResetsBounds(n);
        setBounds(old.getX() - (r.getWidth() - old.getWidth()) / 2, old.getY() - (r.getHeight() - old.getHeight()) / 2, r.getWidth(), r.getHeight());
    } else
        resetBounds();
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle) Rectangle2D(java.awt.geom.Rectangle2D)

Example 30 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class VisualPanelImpl method copyTo.

public void copyTo(VisualPanel dest, boolean copyBackground, boolean copyForeground, boolean copyFont, boolean copySize) {
    if (copyBackground)
        dest.setBackgroundA(background);
    if (copyFont)
        dest.setFontA(font);
    if (copyForeground)
        dest.setForegroundA(foreground);
    if (copySize) {
        FRectangle bds = new FRectangle();
        bds.setX(dest.getBoundsA().getX());
        bds.setY(dest.getBoundsA().getY());
        bds.setWidth(bounds.getWidth());
        bds.setHeight(bounds.getHeight());
        dest.setBoundsA(bds);
    }
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle)

Aggregations

FRectangle (com.dsoft.pb.types.FRectangle)39 FloatPoint (com.dsoft.pb.types.FloatPoint)11 NFunction (com.ramussoft.pb.data.negine.NFunction)11 Rectangle2D (java.awt.geom.Rectangle2D)10 Function (com.ramussoft.pb.Function)9 Point (com.ramussoft.pb.idef.elements.Point)7 BasicStroke (java.awt.BasicStroke)6 Stroke (java.awt.Stroke)6 Line2D (java.awt.geom.Line2D)6 ArrayList (java.util.ArrayList)6 Crosspoint (com.ramussoft.pb.Crosspoint)5 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)5 Row (com.ramussoft.pb.Row)4 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)4 Font (java.awt.Font)4 MemoryData (com.dsoft.utils.DataLoader.MemoryData)3 Stream (com.ramussoft.pb.Stream)3 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)3 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)3 Status (com.dsoft.pb.idef.elements.Status)2