use of com.ramussoft.idef0.attribute.SectorPropertiesPersistent in project ramus by Vitaliy-Yakovchuk.
the class PaintSector method loadFromSector.
public static PaintSector loadFromSector(final int version, final MovingArea area, final DataLoader.MemoryData memoryData, final DataPlugin dataPlugin, Sector llsector) throws IOException {
final PaintSector sector = new PaintSector(area);
sector.sector = llsector;
SectorPropertiesPersistent spp = sector.sector.getSectorProperties();
sector.showTilda = spp.getShowTilda() == 1;
sector.sector.reload();
loadPoints(memoryData, dataPlugin, sector);
sector.loadVisuals();
sector.setSectorPoints();
if (spp.getShowText() == 0)
sector.text = null;
else {
sector.createText();
if (sector.text != null) {
FRectangle bounds = new FRectangle();
bounds.setBounds(spp.getTextX(), spp.getTextY(), spp.getTextWidth(), spp.getTextHieght());
sector.text.setBounds(bounds);
sector.text.setTransparent(spp.getTransparent() == 1);
if (sector.showTilda)
sector.tildaPos.setPos(spp.getTildaPos());
}
}
return sector;
}
use of com.ramussoft.idef0.attribute.SectorPropertiesPersistent in project ramus by Vitaliy-Yakovchuk.
the class PaintSector method save.
/**
* Зберігає сектор в потік.
*
* @param stream Потік даних.
* @param sector Сектор, який буде збережений.
* @throws IOException Виникає, якщо виникла помилка запису.
*/
public static void save(final PaintSector sector, final DataLoader.MemoryData memoryData, Engine engine) {
// sector.saveVisual();
SectorPropertiesPersistent spp = new SectorPropertiesPersistent();
spp.setShowTilda((sector.showTilda) ? 1 : 0);
savePoints(sector, engine);
if (sector.text == null)
spp.setShowText(0);
else {
spp.setShowText(1);
FRectangle bounds = sector.text.getBounds();
spp.setTextX(bounds.getX());
spp.setTextY(bounds.getY());
spp.setTextWidth(bounds.getWidth());
spp.setTextHieght(bounds.getHeight());
spp.setTransparent(sector.text.isTransparent() ? 1 : 0);
spp.setShowTilda(sector.showTilda ? 1 : 0);
if (sector.showTilda)
spp.setTildaPos(sector.tildaPos.getPos());
}
if (sector.sector.getCreateState() >= 0)
sector.sector.setCreateState(-1, 0);
sector.sector.setSectorProperties(spp);
}
use of com.ramussoft.idef0.attribute.SectorPropertiesPersistent in project ramus by Vitaliy-Yakovchuk.
the class UserTemplate method createChilds.
public void createChilds(final Function function, final DataPlugin dataPlugin) {
Hashtable<Long, Long> trans = new Hashtable<Long, Long>();
final MovingArea ma = new MovingArea(dataPlugin);
ma.setDataPlugin(dataPlugin);
ma.setActiveFunction(function);
final SectorRefactor refactor = ma.getRefactor();
try {
final ByteArrayInputStream streamr = new ByteArrayInputStream(data);
final ObjectInputStream stream = new ObjectInputStream(streamr);
final MemoryData data = new MemoryData();
int l = DataLoader.readInteger(stream);
for (int i = 0; i < l; i++) {
final Function c = (Function) dataPlugin.createRow(function, true);
c.setName(functionNames.get(i));
if (i < functionTypes.size())
c.setType(functionTypes.get(i));
if (i < functionLinks.size()) {
Row r = dataPlugin.findRowByGlobalId(functionLinks.get(i));
if (r != null) {
if (r instanceof Stream) {
Stream st = (Stream) r;
Stream s = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
s.setAttachedStatus(st.getAttachedStatus());
s.setEmptyName(st.isEmptyName());
s.setRows(st.getAdded());
c.setLink(s.getElement().getId());
}
}
}
final long id = DataLoader.readLong(stream);
trans.put(id, c.getElement().getId());
c.setBounds(DataLoader.readFRectangle(stream));
c.setFont(DataLoader.readFont(stream, data));
c.setBackground(DataLoader.readColor(stream, data));
c.setForeground(DataLoader.readColor(stream, data));
}
// Read version of
final int ver = DataLoader.readInteger(stream);
// Paint
// Sector format
l = DataLoader.readInteger(stream);
HashMap<Sector, List<SectorPointPersistent>> pointsCache = new HashMap<Sector, List<SectorPointPersistent>>();
HashMap<Long, Long> pointIds = new HashMap<Long, Long>();
for (int i = 0; i < l; i++) {
final Sector s = dataPlugin.createSector();
s.setFunction(function);
final long id = DataLoader.readLong(stream);
trans.put(id, ((NSector) s).getElementId());
final byte[] va = DataLoader.readBytes(stream);
s.setVisualAttributes(va);
List<SectorPointPersistent> points = (List) stream.readObject();
pointsCache.put(s, points);
normalize(points, dataPlugin.getEngine(), pointIds);
s.setSectorPointPersistents(points);
s.setSectorProperties((SectorPropertiesPersistent) stream.readObject());
// final byte bs[] = DataLoader.readBytes(stream);
// final ByteArrayInputStream ba = new ByteArrayInputStream(bs);
final PaintSector ps = PaintSector.loadFromSector(ver, ma, data, dataPlugin, s);
refactor.addSector(ps);
Crosspoint c;
if (DataLoader.readBoolean(stream)) {
c = getCrosspoint(dataPlugin, trans, stream);
s.getStart().setCrosspointA(c);
}
loadBorder(s.getStart(), stream, trans, dataPlugin, refactor, ps, true);
s.getStart().commit();
if (DataLoader.readBoolean(stream)) {
c = getCrosspoint(dataPlugin, trans, stream);
s.getEnd().setCrosspointA(c);
}
loadBorder(s.getEnd(), stream, trans, dataPlugin, refactor, ps, false);
s.getEnd().commit();
if (DataLoader.readBoolean(stream)) {
int count = DataLoader.readInteger(stream);
List<Row> rows = new ArrayList<Row>();
for (int j = 0; j < count; j++) {
Row row = loadRow(stream, dataPlugin);
if (row != null)
rows.add(row);
}
if (rows.size() > 0) {
Stream stream2 = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
stream2.setRows(rows.toArray(new Row[rows.size()]));
((NSector) s).setThisStream(stream2);
}
}
}
setPoints(pointsCache);
refactor.saveToFunction();
} catch (final Exception e) {
e.printStackTrace();
}
}
Aggregations