Search in sources :

Example 1 with ProjectOptions

use of com.dsoft.pb.idef.elements.ProjectOptions in project ramus by Vitaliy-Yakovchuk.

the class IDLExporter method export.

public void export(OutputStream out) throws IOException {
    loadFonts();
    writer = new IDLWriter(out, encoding);
    writer.p1("KIT");
    writer.right();
    writer.p1("IDL VERSION 1.2.8");
    writer.p2("TITLE {0}", base.getName());
    final ProjectOptions projectOptions = base.getProjectOptions();
    writer.p2("AUTHOR {0}", projectOptions.getProjectAutor());
    writer.p1("CREATION DATE " + format.format(new Date()));
    writer.p2("PROJECT NAME {0}", projectOptions.getProjectName());
    writer.println();
    writer.println("MODEL {0}", q(base.getName()));
    writer.right();
    writer.println("{LWI");
    printFonts();
    writer.println("D 0 0 0 0 0 1 0 0 2");
    writer.println("G 0 1");
    writer.println("T " + q(Status.STATUS_NAMES[base.getStatus().getType()].toUpperCase()));
    writer.println("R 77");
    writer.println("M 0 }");
    writer.left();
    writer.println(" ;");
    writer.right();
    writer.p2("AUTHOR {0}", projectOptions.getProjectAutor());
    writer.p2("PROJECT NAME {0}", projectOptions.getProjectName());
    rec(new FunctionCallback() {

        @Override
        public void call(Function f) throws IOException {
            String code = MovingFunction.getIDEF0Kod((com.ramussoft.database.common.Row) f);
            writer.p1("DIAGRAM GRAPHIC " + code);
            writer.right();
            writer.p1("CREATION DATE " + format.format(projectOptions.getDateCreateDate()));
            writer.p1("REVISION DATE " + format.format(projectOptions.getDateChangeDate()));
            writer.p2("TITLE {0}", f.getName());
            writer.p2("STATUS " + Status.STATUS_NAMES[f.getStatus().getType()].toUpperCase());
            writer.println();
            for (int i = 0; i < f.getChildCount(); i++) {
                Function child = (Function) f.getChildAt(i);
                int j = i;
                if (!f.equals(base))
                    j++;
                writer.p1("BOX " + j);
                writer.right();
                int textColot = toByteTextIndex(child.getForeground());
                int bkColot = toByteIndex(child.getBackground());
                writer.p2("NAME {0}", "{LWI I " + uniqueFonts.indexOf(child.getFont()) + " " + textColot + " " + bkColot + " " + textColot + "}" + child.getName());
                String lb = toCoortinate(child.getBounds().getLeft(), child.getBounds().getBottom());
                String rt = toCoortinate(child.getBounds().getRight(), child.getBounds().getTop());
                writer.p1("BOX COORDINATES " + lb + " " + rt);
                writer.p1("DETAIL REFERENCE N " + MovingFunction.getIDEF0Kod((com.ramussoft.database.common.Row) child));
                writer.left();
                writer.p1("ENDBOX");
            }
            printSegments(f);
            writer.left();
            writer.p1("ENDDIAGRAM");
        }
    }, true);
    writer.left();
    writer.p1("ENDMODEL");
    writer.left();
    writer.p1("ENDKIT");
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) IOException(java.io.IOException) Row(com.ramussoft.pb.Row) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions) Date(java.util.Date)

Example 2 with ProjectOptions

use of com.dsoft.pb.idef.elements.ProjectOptions in project ramus by Vitaliy-Yakovchuk.

the class ProjectPreferencesPlugin method getAttributeConverter.

@Override
public AttributeConverter getAttributeConverter() {
    return new AbstractAttributeConverter() {

        @Override
        public Object toObject(List<Persistent>[] persistents, long elementId, long attributeId, IEngine engine) {
            ProjectOptions result;
            if (persistents[0].size() == 0)
                return null;
            else
                result = new ProjectOptions((IDEF0ModelPreferencesPersistent) persistents[0].get(0));
            for (Persistent p : persistents[1]) result.getReadedModel().addReaded().setDeligate((ReaderPersistent) p);
            return result;
        }

        @SuppressWarnings("unchecked")
        @Override
        public List<Persistent>[] toPersistens(Object object, long elementId, long attributeId, IEngine engine) {
            ProjectOptions po = (ProjectOptions) object;
            List<Persistent>[] res = new List[2];
            List<Persistent> f = new ArrayList<Persistent>();
            f.add(po.getDeligate());
            res[0] = f;
            List<Persistent> s = new ArrayList<Persistent>();
            for (Readed r : po.getReadedModel().getAllReaded()) {
                s.add(r.getDeligate());
            }
            res[1] = s;
            return res;
        }
    };
}
Also used : IEngine(com.ramussoft.common.IEngine) ArrayList(java.util.ArrayList) Persistent(com.ramussoft.common.persistent.Persistent) List(java.util.List) ArrayList(java.util.ArrayList) AbstractAttributeConverter(com.ramussoft.common.attribute.AbstractAttributeConverter) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions) Readed(com.dsoft.pb.idef.elements.Readed)

Example 3 with ProjectOptions

use of com.dsoft.pb.idef.elements.ProjectOptions in project ramus by Vitaliy-Yakovchuk.

the class NDataPluginFactory method createDataPlugin.

private DataPlugin createDataPlugin() {
    DataPlugin plugin = (DataPlugin) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { DataPlugin.class }, new InvocationHandler() {

        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            try {
                String name = method.getName();
                if ("getBaseFunction".equals(name)) {
                    if (rowBaseFunction == null) {
                        rowBaseFunction = getBaseFunction(dataPlugin, baseFunction);
                    }
                    return rowBaseFunction;
                }
                if ("getBaseFunctionQualifier".equals(name))
                    return baseFunction;
                if ("isReadOnly".equals(name))
                    return !dataPlugin.getAccessRules().canUpdateQualifier(baseFunction.getId());
                if ("createRow".equals(name)) {
                    com.ramussoft.pb.Row parent = (com.ramussoft.pb.Row) args[0];
                    RowSet set = dataPlugin.getRowSet(baseFunction.getId());
                    if (parent instanceof Function) {
                        Row row = set.createRow((Row) parent);
                        ((NFunction) row).setDefaultValues();
                        ((NFunction) row).setDecompositionType(((Function) parent).getDecompositionType());
                        return row;
                    }
                } else if ("createFunction".equals(name)) {
                    com.ramussoft.pb.Function parent = (com.ramussoft.pb.Function) args[0];
                    final Integer type = (Integer) args[1];
                    RowSet set = dataPlugin.getRowSet(baseFunction.getId());
                    if (parent instanceof Function) {
                        Row row = set.createRow((Row) parent, new ElementCreationCallback() {

                            @Override
                            public void created(Element element) {
                                Engine engine = dataPlugin.getEngine();
                                Attribute attribute = IDEF0Plugin.getFunctionTypeAttribute(engine);
                                engine.setAttribute(element, attribute, type);
                            }
                        });
                        ((NFunction) row).setDefaultValues();
                        ((NFunction) row).setDecompositionType(((Function) parent).getDecompositionType());
                        return row;
                    }
                } else if ((("getChilds".equals(name)) || ("getRecChilds".equals(name))) && (args[0] == null) && (((Boolean) args[1]) == false)) {
                    Vector v = (Vector) method.invoke(dataPlugin, args);
                    v.add(0, dataPlugin.getBaseStream());
                    v.add(0, getBaseFunction(dataPlugin, baseFunction));
                    return v;
                }
                if ("getProjectOptions".equals(name))
                    return getProjectOptions();
                if ("setProjectOptions".equals(name))
                    return setProjectOptions((ProjectOptions) args[0]);
                if ("refresh".equals(name)) {
                    fullRefrash((GUIFramework) args[0]);
                    return null;
                }
                return method.invoke(dataPlugin, args);
            } catch (InvocationTargetException e) {
                throw e.getTargetException();
            }
        }

        private Row getBaseFunction(final NDataPlugin dataPlugin, final Qualifier baseFunction) {
            return dataPlugin.getNBaseFunction(baseFunction.getId());
        }

        protected Object setProjectOptions(ProjectOptions projectOptions) {
            getBaseFunction(dataPlugin, baseFunction).setAttribute(IDEF0Plugin.getProjectPreferencesAttrtibute(dataPlugin.getEngine()), projectOptions);
            return null;
        }

        protected Object getProjectOptions() {
            return getBaseFunction(dataPlugin, baseFunction).getAttribute(IDEF0Plugin.getProjectPreferencesAttrtibute(dataPlugin.getEngine()));
        }
    });
    plugin.getBaseFunction();
    return plugin;
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) RowSet(com.ramussoft.database.common.RowSet) Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) ElementCreationCallback(com.ramussoft.database.common.ElementCreationCallback) Qualifier(com.ramussoft.common.Qualifier) Vector(java.util.Vector) Engine(com.ramussoft.common.Engine) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler) InvocationTargetException(java.lang.reflect.InvocationTargetException) Row(com.ramussoft.database.common.Row) DataPlugin(com.ramussoft.pb.DataPlugin) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Example 4 with ProjectOptions

use of com.dsoft.pb.idef.elements.ProjectOptions in project ramus by Vitaliy-Yakovchuk.

the class ModelParaleler method createParalel.

public void createParalel(final Function function, final boolean createAllRows) {
    ModelParaleler.this.function = function;
    if (createAllRows)
        createAllRows();
    Qualifier qualifier = toEngine.createQualifier();
    copyQualifier(function.getQualifier(), qualifier);
    IDEF0Plugin.installFunctionAttributes(qualifier, toEngine);
    Qualifier q = IDEF0Plugin.getModelTree(toEngine);
    Element element = toEngine.createElement(q.getId());
    toEngine.setAttribute(element, StandardAttributesPlugin.getAttributeQualifierId(toEngine), qualifier.getId());
    toEngine.setAttribute(element, StandardAttributesPlugin.getAttributeNameAttribute(toEngine), function.getName());
    toDataPlugin = NDataPluginFactory.getDataPlugin(qualifier, toEngine, toDataPlugin.getAccessRules());
    ModelParaleler.this.base = toDataPlugin.getBaseFunction();
    Vector<Row> childs = fromDataPlugin.getRecChilds(function, true);
    ProjectOptions projectOptions = toDataPlugin.getBaseFunction().getProjectOptions();
    projectOptions.getDeligate().setDiagramSize(function.getProjectOptions().getDeligate().getDiagramSize());
    toDataPlugin.getBaseFunction().setProjectOptions(projectOptions);
    for (Row row : childs) {
        NFunction dest = (NFunction) getRow(row);
        showMessageAnimation(dest.toString());
    }
    NFunction func = null;
    Vector<Row> v = toDataPlugin.getChilds(base, true);
    if (v.size() > 0)
        func = (NFunction) v.get(0);
    createSectorsOnUpperLevel(func);
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Example 5 with ProjectOptions

use of com.dsoft.pb.idef.elements.ProjectOptions in project ramus by Vitaliy-Yakovchuk.

the class ArrowPainter method paintTop.

public void paintTop(final Graphics2D g, final int height, MovingArea area, Font font2, 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);
        }
    }
    int width = movingArea.getIntOrdinate(movingArea.MOVING_AREA_WIDTH);
    width /= hPageCount;
    int left = 0;
    if (partNumber > 0) {
        left = width * partNumber;
        width += 1;
    }
    g.drawLine(left, 0, left, height);
    g.drawLine(left + width - 1, 0, left + width - 1, height);
    g.drawRect(left, 0, width - 1, height - 1);
    final int div = (int) ((width / height) * 0.65d);
    final int x = left + width - width / div;
    g.drawLine(x, 0, x, height - 1);
    g.setFont(movingArea.getFont(font2));
    final int height2 = height - 8 - (int) g.getFont().getStringBounds(CONTEXT_T, g.getFontRenderContext()).getHeight();
    g.drawString(CONTEXT_T, x + 5, 5 + (int) g.getFont().getStringBounds(CONTEXT_T, g.getFontRenderContext()).getHeight());
    final Function activeFunction = movingArea.getActiveFunction();
    if (activeFunction == movingArea.dataPlugin.getBaseFunction()) {
        g.setFont(movingArea.getFont(font2));
        final int textWidth = (int) g.getFont().getStringBounds(TOP_T, g.getFontRenderContext()).getWidth();
        final int textHeight = (int) g.getFont().getStringBounds(TOP_T, g.getFontRenderContext()).getHeight();
        g.drawString(TOP_T, x + (width / div - textWidth) / 2, (height - textHeight) / 2 + textHeight);
    } else {
        final Vector v = movingArea.dataPlugin.getChilds(activeFunction.getParentRow(), true);
        final int width2 = width - x + left;
        for (int i = 0; i < v.size(); i++) {
            final Function f = (Function) v.get(i);
            final int x1 = (int) (f.getBounds().getX() * width2 / movingArea.getDoubleWidth());
            final int y1 = (int) (f.getBounds().getY() * height2 / movingArea.getDoubleHeight());
            final int width1 = (int) (f.getBounds().getWidth() * width2 / movingArea.getDoubleWidth());
            final int height1 = (int) (f.getBounds().getHeight() * height2 / movingArea.getDoubleHeight());
            if (f.equals(activeFunction))
                g.fillRect(x + x1, y1 + height - height2, width1, height1);
            else
                g.drawRect(x + x1, y1 + height - height2, width1, height1);
        }
    }
    g.setFont(movingArea.getFont(font2));
    final int h2 = height - 1;
    final int x2 = left + (int) (width / 2.0);
    g.drawLine(x2, 0, x2, h2);
    final int w = height / 4;
    final int w2 = (x - x2 + w) / 2;
    g.drawLine(x2 + w, 0, x2 + w, h2);
    g.drawLine(x2 + w2, 0, x2 + w2, h2);
    String s;
    int h;
    final ProjectOptions projectOptions = activeFunction.getProjectOptions();
    final Readed[] rs = projectOptions.getReadedModel().getSortReaded(3);
    for (int i = 0; i < 4; i++) {
        if (i == 0) {
            s = READER_B;
            h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
            g.drawString(s, x2 + w2 + 2, (i + 1) * w - (w - h) / 2);
            s = DATE_B;
            h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
            final int ww = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getWidth();
            g.drawString(s, x - 2 - ww, (i + 1) * w - (w - h) / 2);
        } else if (i <= rs.length) {
            s = rs[i - 1].getReader();
            if (s.length() > 13) {
                s = s.substring(0, 10) + "...";
            }
            h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
            g.drawString(s, x2 + w2 + 2, (i + 1) * w - (w - h) / 2);
            s = rs[i - 1].getDate();
            h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
            final int ww = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getWidth();
            g.drawString(s, x - 2 - ww, (i + 1) * w - (w - h) / 2);
        }
        g.drawLine(x2, i * w, x, i * w);
        s = ResourceLoader.getString(Status.STATUS_NAMES[i]);
        h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
        g.drawString(s, x2 + w + 2, (i + 1) * w - (w - h) / 2);
        if (activeFunction.getStatus().getType() == i)
            g.fillRect(x2, i * w, w, w);
    }
    final int x3 = left + width / 6;
    g.drawLine(x3, 0, x3, h2);
    s = AUTOR_T + activeFunction.getAuthor();
    h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
    g.drawString(s, x3 + 2, w - (w - h) / 2);
    s = PROJECT_T + " ";
    final int projectTitileWidth = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getWidth();
    h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
    g.drawString(s, x3 + 2, 2 * w - (w - h) / 2);
    s = TOP_IDEF_NOTES;
    final int t1 = 4 * w - (w - h) / 2;
    g.drawString(s, x3 + 2, t1);
    int wi1 = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getWidth() + 8 + x3;
    for (int i = 1; i <= 10; i++) {
        s = Integer.toString(i);
        g.drawString(s, wi1, t1);
        wi1 += (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getWidth() + 5;
    }
    final String d1 = DATE_T + " ";
    final String d2 = REV_T + " ";
    wi1 = (int) g.getFont().getStringBounds(d1, g.getFontRenderContext()).getWidth();
    final int wi2 = (int) g.getFont().getStringBounds(d2, g.getFontRenderContext()).getWidth();
    final int wi = wi1 > wi2 ? wi1 : wi2;
    String createDate = Readed.dateFormat.format(activeFunction.getCreateDate());
    final int dw = (int) g.getFont().getStringBounds(createDate, g.getFontRenderContext()).getWidth();
    final String pn = projectOptions.getProjectName();
    g.setFont(font2);
    movingArea.paintText(g, pn, movingArea.getFBounds(new Rectangle(x3 + 2 + projectTitileWidth, (int) (1.45 * w - (w - h) / 2), x2 - 4 - wi - dw - (x3 + 2 + projectTitileWidth), height - w)), Line.CENTER_ALIGN, 0, true);
    g.setFont(movingArea.getFont(font2));
    g.drawString(d1, x2 - 2 - wi - dw, w - (w - h) / 2);
    g.drawString(d2, x2 - 2 - wi - dw, 2 * w - (w - h) / 2);
    g.drawString(createDate, x2 - 2 - dw, w - (w - h) / 2);
    String revDate = Readed.dateFormat.format(activeFunction.getRevDate());
    g.drawString(revDate, x2 - 2 - dw, 2 * w - (w - h) / 2);
    s = USED_AT_T;
    h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
    g.drawString(s, left + 5, 5 + h);
    s = projectOptions.getUsedAt();
    g.setFont(font2);
    movingArea.paintText(g, s, movingArea.getFBounds(new Rectangle(left + 5, h + 3, x3 - 11 - left, height - h - 8)), 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) Vector(java.util.Vector) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions) FloatPoint(com.dsoft.pb.types.FloatPoint) Readed(com.dsoft.pb.idef.elements.Readed)

Aggregations

ProjectOptions (com.dsoft.pb.idef.elements.ProjectOptions)10 Function (com.ramussoft.pb.Function)6 Qualifier (com.ramussoft.common.Qualifier)5 NFunction (com.ramussoft.pb.data.negine.NFunction)5 Attribute (com.ramussoft.common.Attribute)3 Element (com.ramussoft.common.Element)3 DataPlugin (com.ramussoft.pb.DataPlugin)3 Row (com.ramussoft.pb.Row)3 Readed (com.dsoft.pb.idef.elements.Readed)2 FRectangle (com.dsoft.pb.types.FRectangle)2 Engine (com.ramussoft.common.Engine)2 Row (com.ramussoft.database.common.Row)2 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)2 Vector (java.util.Vector)2 FloatPoint (com.dsoft.pb.types.FloatPoint)1 AttributeType (com.ramussoft.common.AttributeType)1 IEngine (com.ramussoft.common.IEngine)1 AbstractAttributeConverter (com.ramussoft.common.attribute.AbstractAttributeConverter)1 Journaled (com.ramussoft.common.journal.Journaled)1 Persistent (com.ramussoft.common.persistent.Persistent)1