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");
}
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;
}
};
}
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;
}
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);
}
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);
}
Aggregations