Search in sources :

Example 1 with Readed

use of com.dsoft.pb.idef.elements.Readed 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 2 with Readed

use of com.dsoft.pb.idef.elements.Readed 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)

Example 3 with Readed

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

the class ReadedModel method setValueAt.

/**
 * @see javax.swing.table.AbstractTableModel#setValueAt(java.lang.Object,
 * int, int)
 */
public void setValueAt(final Object arg0, final int y, final int x) {
    final String s = (String) arg0;
    final Readed r = readeds.get(y);
    if (x == 0)
        r.setReader(s);
    else {
        final String oldd = r.getDate();
        try {
            r.setDate(s);
        } catch (final ParseException e) {
            try {
                JOptionPane.showMessageDialog(null, s + " - " + ResourceLoader.getString("not_a_date"));
                r.setDate(oldd);
            } catch (final ParseException e1) {
                e1.printStackTrace();
            }
        }
    }
}
Also used : ParseException(java.text.ParseException) Readed(com.dsoft.pb.idef.elements.Readed)

Example 4 with Readed

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

the class ReadedModel method addReaded.

public Readed addReaded() {
    final Readed res = new Readed();
    readeds.add(res);
    return res;
}
Also used : Readed(com.dsoft.pb.idef.elements.Readed)

Aggregations

Readed (com.dsoft.pb.idef.elements.Readed)4 ProjectOptions (com.dsoft.pb.idef.elements.ProjectOptions)2 FRectangle (com.dsoft.pb.types.FRectangle)1 FloatPoint (com.dsoft.pb.types.FloatPoint)1 IEngine (com.ramussoft.common.IEngine)1 AbstractAttributeConverter (com.ramussoft.common.attribute.AbstractAttributeConverter)1 Persistent (com.ramussoft.common.persistent.Persistent)1 Function (com.ramussoft.pb.Function)1 NFunction (com.ramussoft.pb.data.negine.NFunction)1 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)1 Rectangle (java.awt.Rectangle)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Vector (java.util.Vector)1