Search in sources :

Example 1 with Pin

use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.

the class SectorColorAttributePlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
    if (old != null)
        old.close();
    return new AbstractAttributeEditor() {

        private PaintSector.Pin pin;

        private JColorChooser component;

        private Color color;

        {
            component = new JColorChooser();
        }

        @Override
        public Object setValue(Object value) {
            this.pin = (PaintSector.Pin) value;
            color = pin.getSector().getColor();
            component.setColor(color);
            return value;
        }

        @Override
        public Object getValue() {
            return pin;
        }

        @Override
        public void apply(Engine engine, Element element, Attribute attribute, Object value) {
            SectorColorAttributePlugin.this.apply(component.getColor(), pin);
        }

        @Override
        public JComponent getComponent() {
            return component;
        }

        @Override
        public boolean isSaveAnyway() {
            return !color.equals(component.getColor());
        }
    };
}
Also used : AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Attribute(com.ramussoft.common.Attribute) Color(java.awt.Color) Element(com.ramussoft.common.Element) JColorChooser(javax.swing.JColorChooser) Engine(com.ramussoft.common.Engine)

Example 2 with Pin

use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.

the class HTTPParser method printIDEF0Model.

private void printIDEF0Model() throws IOException {
    int imageWidth = IMAGE_WIDTH;
    String s = (String) params.get("w");
    if (s != null) {
        try {
            imageWidth = new Integer(s).intValue();
        } catch (final Exception e) {
        }
    }
    int imageHeight = IMAGE_HEIGHT;
    s = (String) params.get("h");
    if (s != null) {
        try {
            imageHeight = new Integer(s).intValue();
        } catch (final Exception e) {
        }
    }
    Row row = loadRowById();
    Row old = row;
    if (row == null || !(row instanceof Function)) {
        printIDEF0Error();
        return;
    }
    row = replaceIDEF0Row(row);
    final Function function = (Function) row;
    String functionType;
    String name = function.getName();
    int iFunctionType = function.getType();
    Row ouner = null;
    if (function.getParent() == null) {
        final Enumeration e = function.children();
        while (e.hasMoreElements()) {
            final Function f = (Function) e.nextElement();
            ouner = f.getOwner();
            iFunctionType = f.getType();
            name = f.getName();
            if (ouner != null)
                break;
        }
    } else
        ouner = function.getOwner();
    switch(iFunctionType) {
        case Function.TYPE_PROCESS_KOMPLEX:
            functionType = RES.getString("functionProcessKomplex");
            break;
        case Function.TYPE_PROCESS:
            functionType = RES.getString("functionProcess");
            break;
        case Function.TYPE_PROCESS_PART:
            functionType = RES.getString("functionProcessPart");
            break;
        case Function.TYPE_ACTION:
            functionType = RES.getString("functionAction");
            break;
        case Function.TYPE_OPERATION:
            functionType = RES.getString("functionOperation");
            break;
        default:
            functionType = "";
            break;
    }
    htmlTitle = functionType + " " + name;
    printStartD();
    if (printVersion) {
    } else {
        if (imageWidth != 800) {
            htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=800&h=600\" style=\"color:rgb(0,0,0);\">");
            htmlStream.print("800x600");
            htmlStream.println("</a>");
        }
        if (imageWidth != 905) {
            htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=905&h=700\" style=\"color:rgb(0,0,0);\">");
            htmlStream.print("905x700");
            htmlStream.println("</a>");
        }
        if (imageWidth != 1024) {
            htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=1024&h=768\" style=\"color:rgb(0,0,0);\">");
            htmlStream.print("1024x768");
            htmlStream.println("</a>");
        }
        if (imageWidth != 1152) {
            htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=1152&h=864\" style=\"color:rgb(0,0,0);\">");
            htmlStream.print("1152x864");
            htmlStream.println("</a>");
        }
        if (imageWidth != 1300) {
            htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=1300&h=1000\" style=\"color:rgb(0,0,0);\">");
            htmlStream.print("1300x1000");
            htmlStream.println("</a>");
        }
        if (imageWidth != 1600) {
            htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=1600&h=1200\" style=\"color:rgb(0,0,0);\">");
            htmlStream.print("1600x1200");
            htmlStream.println("</a>");
        }
        final Row parent = function.getParentRow();
        htmlStream.println(RES.getString("functionType") + ": <b>" + functionType + "</b>");
        if (parent != null) {
            printStartATeg("idef0/index.html?id=" + parent.getGlobalId().toString());
            htmlStream.println(RES.getString("oneLevelTop"));
            printEndATeg();
            // printStartATeg("idef0/index.html?id="
            // + dataPlugin.getBaseFunction().getGlobalId().toString());
            htmlStream.println(RES.getString("contents"));
            printEndATeg();
        }
        if (ouner != null) {
            printStartATeg("rows/index.html?id=" + ouner.getGlobalId().toString());
            htmlStream.println(RES.getString("ouner") + ": " + ouner.getKod() + ". " + ouner.getName());
            printEndATeg();
        }
        if (old == row) {
            printStartATeg("rows/index.html?id=" + function.getGlobalId().toString());
            htmlStream.println(RES.getString("element"));
            printEndATeg();
        }
        Row top = row;
        while (top.getParentRow() != null) {
            top = top.getParentRow();
        }
        printStartATeg("fullmodel/index.html?id=" + top.getElement().getId());
        htmlStream.println(RES.getString("ExpandedModel"));
        printEndATeg();
    }
    htmlStream.print("<br>");
    htmlStream.println("<img border=0 src=\"" + fromLink + "idef0/" + "model." + getImagesFormatName() + "?id=" + function.getGlobalId().toString() + "&w=" + imageWidth + "&h=" + imageHeight + "\" useMap=#M" + function.getGlobalId().toString() + ">");
    htmlStream.println("<map name=M" + function.getGlobalId().toString() + ">");
    final Vector childs = dataPlugin.getChilds(function, true);
    final MovingArea area = PIDEF0painter.createMovingArea(new Dimension(imageWidth, imageHeight), dataPlugin, function);
    final SectorRefactor refactor = area.getRefactor();
    for (int i = 0; i < childs.size(); i++) {
        final Function fun = (Function) childs.get(i);
        Row row2 = dataPlugin.findRowByGlobalId(fun.getLink());
        String where = "rows";
        if ((row2 == null) && (fun.getType() < Function.TYPE_EXTERNAL_REFERENCE)) {
            row2 = fun;
            if (!fun.isLeaf())
                where = "idef0";
        }
        if (row2 != null) {
            htmlStream.print("<area shape=RECT coords=" + getAreaCoords(fun.getBounds(), area) + " href=\"" + fromLink + where + "/index.html?id=" + row2.getElement().getId() + "&w=" + imageWidth + "&h=" + imageHeight + (printVersion ? "&printVersion=true" : "") + "\"");
            htmlStream.println(">");
        }
    }
    refactor.loadFromFunction(function, false);
    final int sc = refactor.getSectorsCount();
    for (int i = 0; i < sc; i++) {
        final PaintSector sector = refactor.getSector(i);
        final Stream stream = sector.getStream();
        final MovingLabel text = refactor.getSector(i).getText();
        if (text != null && stream != null) {
            htmlStream.print("<area shape=RECT coords=" + getAreaCoords(text.getBounds(), area) + " href=\"" + fromLink + "rows/index.html?id=" + stream.getGlobalId().toString() + "&sectorId=" + sector.getSector().getGlobalId() + "&w=" + imageWidth + "&h=" + imageHeight + "\"");
            htmlStream.println(">");
        }
        final int l = sector.getPinCount();
        for (int j = 0; j < l; j++) if (stream != null) {
            final Pin pin = sector.getPin(j);
            htmlStream.print("<area shape=RECT coords=" + getPinCoords(pin, area) + " href=\"" + fromLink + "rows/index.html?id=" + stream.getGlobalId().toString() + "&sectorId=" + sector.getSector().getGlobalId() + "&w=" + imageWidth + "&h=" + imageHeight + "\"");
            htmlStream.println(">");
        }
    }
    htmlStream.println("<map>");
    printEndD();
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Enumeration(java.util.Enumeration) Dimension(java.awt.Dimension) DataException(com.ramussoft.report.data.DataException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SQLException(java.sql.SQLException) IOException(java.io.IOException) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) MovingLabel(com.ramussoft.pb.idef.visual.MovingLabel) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream) Row(com.ramussoft.pb.Row) NRow(com.ramussoft.pb.data.negine.NRow) Vector(java.util.Vector)

Example 3 with Pin

use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.

the class LineStyleAttributePlugin method getTableCellEditor.

@Override
public TableCellEditor getTableCellEditor(final Engine engine, final AccessRules rules, final Attribute attribute) {
    final JComboBox box = new JComboBox();
    box.setRenderer(comboBoxRenderer);
    for (Stroke stroke : LineStyleChooser.getStrokes()) {
        box.addItem(stroke);
    }
    return new DefaultCellEditor(box) {

        private Pin pin;

        @Override
        public boolean stopCellEditing() {
            if (box.getSelectedItem() instanceof Stroke) {
                ((Journaled) engine).startUserTransaction();
                apply((BasicStroke) box.getSelectedItem(), pin);
                return super.stopCellEditing();
            }
            return false;
        }

        @Override
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
            pin = (Pin) ((MetadataGetter) table).getMetadata();
            return super.getTableCellEditorComponent(table, value, isSelected, row, column);
        }
    };
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) JComboBox(javax.swing.JComboBox) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) MetadataGetter(com.ramussoft.gui.qualifier.table.MetadataGetter) JTable(javax.swing.JTable) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 4 with Pin

use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.

the class MovingArea method arrowCopyVisual.

public void arrowCopyVisual() {
    startUserTransaction();
    PaintSector.Pin pin = (PaintSector.Pin) activeObject;
    Stream stream = pin.getSector().getStream();
    Row[] oRows = stream.getAdded();
    byte[] bs = pin.getSector().getSector().getVisualAttributes();
    for (Sector f : dataPlugin.getAllSectors()) if (f.getStream() != null && f.getStream().getAdded() != null) {
        Row[] rows = f.getStream().getAdded();
        boolean b = false;
        for (Row row2 : rows) if (row2 != null) {
            if (b)
                break;
            for (Row row3 : oRows) if (row3.equals(row2)) {
                f.setVisualAttributes(bs);
                b = true;
                break;
            }
        }
    }
    refactor.setUndoPoint();
}
Also used : Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) AbstractSector(com.ramussoft.pb.data.AbstractSector) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

Example 5 with Pin

use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.

the class MovingArea method processMouse.

/**
 * Медод, який обробляє натискання на кнопці миші, якщо стан панелі
 * відображення змінює певні атрибути, то вони змінюються.
 *
 * @param e Пораметри натискання миші.
 */
protected void processMouse(final MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON3)
        return;
    final int x = e.getX();
    final int y = e.getY();
    final double dX = getDoubleOrdinate(x);
    final double dY = getDoubleOrdinate(y);
    int type = Function.TYPE_OPERATION;
    if (getState() == FUNCTION_ADDING_STATE && getActiveObject() == null) {
        if (isOut(dX, LEFT_PART, CLIENT_WIDTH) || isOut(dY, TOP_PART, CLIENT_HEIGHT))
            return;
        if (!canAddOnContext()) {
            JOptionPane.showMessageDialog(this, ResourceLoader.getString("you_can_not_add_more_then_one_f"));
            return;
        }
        addInOutObject(dX, dY, type);
    } else if (getState() == EXTERNAL_REFERENCE_ADDING_STATE && getActiveObject() == null) {
        if (isOut(dX, LEFT_PART, CLIENT_WIDTH) || isOut(dY, TOP_PART, CLIENT_HEIGHT))
            return;
        addInOutObject(dX, dY, Function.TYPE_EXTERNAL_REFERENCE);
    } else if (getState() == DATA_STORE_ADDING_STATE && getActiveObject() == null) {
        if (isOut(dX, LEFT_PART, CLIENT_WIDTH) || isOut(dY, TOP_PART, CLIENT_HEIGHT))
            return;
        addInOutObject(dX, dY, Function.TYPE_DATA_STORE);
    } else if (getState() == DFDS_ROLE_ADDING_STATE && getActiveObject() == null) {
        if (isOut(dX, LEFT_PART, CLIENT_WIDTH) || isOut(dY, TOP_PART, CLIENT_HEIGHT))
            return;
        addInOutObject(dX, dY, Function.TYPE_DFDS_ROLE);
    } else if (getChangingState() == ARROW_CHANGING_STATE) {
        final PaintSector.Pin activePin = getPin(e.getX(), e.getY());
        if (activePin == null)
            addArrowToArea(dX, dY);
        else {
            PaintSector sector = activePin.getSector();
            if ((sector.isPart()) && (sector.isSelEnd() || sector.isSelStart())) {
                if (activeObject instanceof PaintSector.Pin) {
                    final PaintSector.Pin pin = (PaintSector.Pin) activeObject;
                    if (pin.getSector().isSelEnd() || pin.getSector().isSelStart()) {
                        setActiveObject(null);
                        refactor.setSector(pin.getSector());
                        if (pin.getSector().isSelEnd()) {
                            setState(END_POINT_CHANGING_ADD);
                        } else if (pin.getSector().isSelStart()) {
                            setState(START_POINT_CHANGING_ADD);
                        }
                        panel.getFramework().put(CURRENT_MOVING_AREA, this);
                    }
                }
            } else {
                if (getPointChangingType() == SectorRefactor.TYPE_START) {
                    if (sector.isPart() && activePin.getSector().getStart() == null)
                        return;
                } else {
                    if (activePin.getSector().isPart() && activePin.getSector().getEnd() == null)
                        return;
                }
                final SectorRefactor.PerspectivePoint pp = new SectorRefactor.PerspectivePoint();
                pp.type = getPointChangingType();
                pp.pin = activePin;
                pp.x = getDoubleOrdinate(e.getX());
                pp.y = getDoubleOrdinate(e.getY());
                refactor.setPoint(pp);
                doSector();
            }
        }
    } else if (getChangingState() == TILDA_ADDING_STATE) {
        final PaintSector.Pin activePin = getPin(e.getX(), e.getY());
        if (activePin != null) {
            startUserTransaction();
            List<PaintSector> ps = activePin.getSector().setTildaPos(getDoubleOrdinate(e.getX()), getDoubleOrdinate(e.getY()));
            for (PaintSector s : ps) PaintSector.save(s, new MemoryData(), dataPlugin.getEngine());
            refactor.setUndoPoint();
        }
    } else if (getChangingState() == TEXT_ADDING_STATE) {
        final MovingText text = createText();
        cancelAdding();
        refactor.addText(text);
        text.setBounds(dX, dY, text.getBounds().getWidth(), text.getBounds().getHeight());
        text.setFont(Options.getFont("DEFAULT_TEXT_FONT", new Font("Arial", 0, 10)));
        text.setColor(Options.getColor("DEFAULT_TEXT_COLOR", Color.black));
        startUserTransaction();
        refactor.setUndoPoint();
    } else {
        if (activeObject instanceof PaintSector.Pin) {
            final PaintSector.Pin pin = (PaintSector.Pin) activeObject;
            if (pin.getSector().isSelEnd() || pin.getSector().isSelStart()) {
                setActiveObject(null);
                refactor.setSector(pin.getSector());
                if (pin.getSector().isSelEnd()) {
                    setState(END_POINT_CHANGING);
                } else if (pin.getSector().isSelStart()) {
                    setState(START_POINT_CHANGING);
                }
                panel.getFramework().put(CURRENT_MOVING_AREA, this);
            }
        }
    }
}
Also used : Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) PerspectivePoint(com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint) MemoryData(com.dsoft.utils.DataLoader.MemoryData) ArrayList(java.util.ArrayList) EventListenerList(javax.swing.event.EventListenerList) List(java.util.List) PerspectivePoint(com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint) PerspectivePoint(com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point) Font(java.awt.Font)

Aggregations

Pin (com.ramussoft.pb.idef.elements.PaintSector.Pin)12 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)7 FloatPoint (com.dsoft.pb.types.FloatPoint)4 Attribute (com.ramussoft.common.Attribute)3 Row (com.ramussoft.pb.Row)3 Stream (com.ramussoft.pb.Stream)3 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)3 BasicStroke (java.awt.BasicStroke)3 Element (com.ramussoft.common.Element)2 Engine (com.ramussoft.common.Engine)2 Journaled (com.ramussoft.common.journal.Journaled)2 AbstractAttributeEditor (com.ramussoft.gui.common.AbstractAttributeEditor)2 MetadataGetter (com.ramussoft.gui.qualifier.table.MetadataGetter)2 Crosspoint (com.ramussoft.pb.Crosspoint)2 Function (com.ramussoft.pb.Function)2 NSector (com.ramussoft.pb.data.negine.NSector)2 Point (com.ramussoft.pb.idef.elements.Point)2 PerspectivePoint (com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint)2 MovingArea (com.ramussoft.pb.idef.visual.MovingArea)2 MovingLabel (com.ramussoft.pb.idef.visual.MovingLabel)2