use of com.ramussoft.pb.idef.elements.PaintSector in project ramus by Vitaliy-Yakovchuk.
the class DFDSFunction method getTriangle.
@Override
protected int getTriangle(FloatPoint point) {
int changingState = getMovingArea().getPointChangingType();
PaintSector activeSector = getMovingArea().getRefactor().getSector();
if (activeSector != null)
if (changingState == SectorRefactor.TYPE_START) {
Crosspoint crosspoint = activeSector.getStart();
Function function2 = activeSector.getSector().getStart().getFunction();
if (crosspoint != null && crosspoint.isDLevel() && function2 != null && function2.getType() == Function.TYPE_DFDS_ROLE)
return -1;
} else if (changingState == SectorRefactor.TYPE_END) {
Crosspoint crosspoint = activeSector.getEnd();
Function function2 = activeSector.getSector().getEnd().getFunction();
if (crosspoint != null && crosspoint.isDLevel() && function2 != null && function2.getType() == Function.TYPE_DFDS_ROLE)
return -1;
}
return super.getTriangle(point);
}
use of com.ramussoft.pb.idef.elements.PaintSector in project ramus by Vitaliy-Yakovchuk.
the class IDLImporter method setSegment.
private void setSegment(Arrowseg seg, MovingArea area) {
if (seg.seted)
return;
List<Arrowseg> source = loadConnected(seg.source);
List<Arrowseg> sink = loadConnected(seg.sink);
if (source != null) {
for (Arrowseg s : source) {
if (!s.seted)
setSegment(s, area);
}
Crosspoint c = null;
for (Arrowseg s : source) {
if (s.sector.getEnd() != null) {
c = (NCrosspoint) s.sector.getEnd();
}
}
if (c == null)
c = dataPlugin.createCrosspoint();
seg.sector.getSector().getStart().setCrosspointA(c);
seg.sector.getSector().getStart().commit();
for (Arrowseg s : source) {
if (s.sector.getEnd() == null) {
s.sector.getSector().getEnd().setCrosspointA(c);
s.sector.getSector().getEnd().commit();
}
}
}
PaintSector ps = seg.sector;
Point[] points = new Point[seg.pointsList.size()];
int type = seg.getFirstPinType();
Ordinate x = null;
Ordinate y = null;
if (source != null) {
for (Arrowseg arrowseg : source) {
int sType = arrowseg.getLastPinType();
if (type == sType) {
if (arrowseg.sector.getLastPin().getType() == Ordinate.TYPE_X) {
y = arrowseg.sector.getLastPin().getOrdinate();
x = arrowseg.sector.getLastPin().getPOrdinate();
} else {
x = arrowseg.sector.getLastPin().getOrdinate();
y = arrowseg.sector.getLastPin().getPOrdinate();
}
} else {
if (arrowseg.sector.getLastPin().getType() == Ordinate.TYPE_Y) {
x = arrowseg.sector.getLastPin().getOrdinate();
y = arrowseg.sector.getLastPin().getPOrdinate();
} else {
y = arrowseg.sector.getLastPin().getOrdinate();
x = arrowseg.sector.getLastPin().getPOrdinate();
}
}
}
}
if (x == null) {
x = new Ordinate(Ordinate.TYPE_X);
x.setPosition(seg.pointsList.get(0).getX());
}
if (y == null) {
y = new Ordinate(Ordinate.TYPE_Y);
y.setPosition(seg.pointsList.get(0).getY());
}
points[0] = new Point(x, y);
for (int i = 1; i < seg.pointsList.size(); i++) {
FloatPoint point = seg.pointsList.get(i);
type = seg.getPinType(i - 1);
if (type == Ordinate.TYPE_X) {
x = new Ordinate(Ordinate.TYPE_X);
x.setPosition(point.getX());
} else {
y = new Ordinate(Ordinate.TYPE_Y);
y.setPosition(point.getY());
}
if ((i == seg.pointsList.size() - 1) && (sink != null) && (sink.size() == 1)) {
Arrowseg s = sink.get(0);
List<Arrowseg> list = loadConnected(s.source);
for (Arrowseg arrowseg : list) {
if (arrowseg.seted) {
Point point2 = arrowseg.sector.getLastPin().getEnd();
Ordinate xo = point2.getXOrdinate();
for (Point point3 : xo.getPoints()) {
point3.setXOrdinate(x);
}
Ordinate yo = point2.getYOrdinate();
for (Point point3 : yo.getPoints()) {
point3.setYOrdinate(y);
}
}
}
}
points[i] = new Point(x, y);
}
ps.setPoints(points);
if (source == null)
initCrosspoint(seg.sector.getSector().getStart(), seg.source, area, seg.sector, true, seg);
if (sink == null) {
initCrosspoint(seg.sector.getSector().getEnd(), seg.sink, area, seg.sector, false, seg);
}
seg.seted = true;
}
use of com.ramussoft.pb.idef.elements.PaintSector in project ramus by Vitaliy-Yakovchuk.
the class ClassicTemplate method createChilds.
@Override
public synchronized void createChilds(final Function function, final DataPlugin dataPlugin) {
final MovingArea movingArea = new MovingArea(dataPlugin);
movingArea.setDataPlugin(dataPlugin);
movingArea.setActiveFunction(function);
movingArea.setArrowAddingState();
super.createChilds(function, dataPlugin, movingArea);
int num = count / 2;
if (2 * num == count)
num--;
createSimpleArrow(function, movingArea, num);
PaintSector s;
final Function f = (Function) function.getChildAt(num);
createFrom(movingArea, f, top);
createInPoint(movingArea, TOP, (Function) function.getChildAt(count - 1));
s = movingArea.getRefactor().getSector();
for (int i = count - 2; i > num; i--) {
final Function fS = (Function) function.getChildAt(i);
createFrom(movingArea, fS, s, getX(fS), POS);
createInPoint(movingArea, TOP, fS);
}
createFrom(movingArea, f, bottom);
createInPoint(movingArea, BOTTOM, (Function) function.getChildAt(count - 1));
s = movingArea.getRefactor().getSector();
for (int i = count - 2; i > num; i--) {
final Function fS = (Function) function.getChildAt(i);
createFrom(movingArea, fS, s, getX(fS), movingArea.CLIENT_HEIGHT - POS);
createInPoint(movingArea, BOTTOM, fS);
}
if (num > 0) {
createFrom(movingArea, f, top, getX(f), POS - 1);
createInPoint(movingArea, TOP, (Function) function.getChildAt(0));
s = movingArea.getRefactor().getSector();
for (int i = 1; i < num; i++) {
final Function fS = (Function) function.getChildAt(i);
createFrom(movingArea, fS, s, getX(fS), POS);
createInPoint(movingArea, TOP, fS);
}
createFrom(movingArea, f, bottom);
createInPoint(movingArea, BOTTOM, (Function) function.getChildAt(0));
s = movingArea.getRefactor().getSector();
for (int i = 1; i < num; i++) {
final Function fS = (Function) function.getChildAt(i);
createFrom(movingArea, fS, s, getX(fS), movingArea.CLIENT_HEIGHT - POS);
createInPoint(movingArea, BOTTOM, fS);
}
}
movingArea.getRefactor().saveToFunction();
}
use of com.ramussoft.pb.idef.elements.PaintSector in project ramus by Vitaliy-Yakovchuk.
the class IDLExporter method loadFonts.
private void loadFonts() throws IOException {
addFont(new Font("Arial", 0, 13));
addFont(new Font("Arial", 0, 24));
addFont(new Font("Courier New", 0, 11));
rec(new FunctionCallback() {
@Override
public void call(Function f) {
addFont(f.getFont());
SectorRefactor sr = new SectorRefactor(new MovingArea(dataPlugin));
sr.loadFromFunction(f, false);
for (int i = 0; i < sr.getSectorsCount(); i++) {
PaintSector ps = sr.getSector(i);
addFont(ps.getFont());
}
}
}, false);
}
use of com.ramussoft.pb.idef.elements.PaintSector in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method addLevel.
/**
* Метод, який додає рівень до активного функціонального блоку на моделі,
* контекст функціонального блоку заміняється на новий функціональний блок з
* контекстом, який мав активний функціональний блок.
*/
public synchronized void addLevel() {
final Function f = ((MovingFunction) getActiveObject()).getFunction();
if (f.isLocked()) {
JOptionPane.showMessageDialog(this, ResourceLoader.getString("MovingArea.functionIsLocked"));
return;
}
if (JOptionPane.showConfirmDialog(this, ResourceLoader.getString("MovingArea.addingLevelWarning"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
return;
f.lock();
final Vector<Row> childs = dataPlugin.getChilds(f, true);
final Function n = (Function) dataPlugin.createRow(f, true);
n.setSectorData(f.getSectorData());
n.setBounds(f.getBounds());
n.setBackground(f.getBackground());
n.setForeground(f.getForeground());
n.setName(f.getName());
n.setDecompositionType(f.getDecompositionType());
n.setType(f.getType());
f.setName(f.getName() + " (" + ResourceLoader.getString("MovingArea.context") + ")");
n.setFont(f.getFont());
f.setSectorData(new byte[0]);
final SectorRefactor r = new SectorRefactor(this);
// .getBounds().getHeight()));
for (int i = 0; i < childs.size(); i++) {
final Function c = (Function) childs.get(i);
c.setParentRow(n);
}
Vector srs = new Vector(f.getSectors());
for (int i = 0; i < srs.size(); i++) {
final Sector sector = (Sector) srs.get(i);
sector.setFunction(n);
// System.out.println(sector.getFunction());
}
final Function p = (Function) f.getParent();
srs = p.getSectors();
final int[] cnts = new int[4];
final double[] poses = new double[4];
final double[] hs = new double[4];
for (int i = 0; i < cnts.length; i++) cnts[i] = 0;
for (int i = 0; i < srs.size(); i++) {
final Sector sector = (Sector) srs.get(i);
if (f.equals(sector.getStart().getFunction())) {
cnts[MovingPanel.RIGHT]++;
}
if (f.equals(sector.getEnd().getFunction())) {
cnts[sector.getEnd().getFunctionType()]++;
}
}
for (int i = 0; i < cnts.length; i++) {
if (cnts[i] > 0) {
if (i == MovingPanel.LEFT || i == MovingPanel.RIGHT)
hs[i] = n.getBounds().getHeight() / cnts[i];
else
hs[i] = n.getBounds().getWidth() / cnts[i];
}
poses[i] = hs[i] / 2.0d;
}
for (int i = 0; i < srs.size(); i++) {
final Sector sector = (Sector) srs.get(i);
if (f.equals(sector.getStart().getFunction())) {
final Crosspoint c = sector.getStart().getCrosspoint();
final Sector[] ss = c.getOppozite(sector);
Sector so = null;
for (final Sector element : ss) {
so = element;
}
final Sector s = dataPlugin.createSector();
((AbstractSector) s).setThisStream(SectorRefactor.cloneStream(sector.getStream(), dataPlugin, s));
s.setVisualAttributes(sector.getVisualAttributes());
s.setFunction(f);
final Ordinate x1 = new Ordinate(Ordinate.TYPE_X);
final Ordinate x2 = new Ordinate(Ordinate.TYPE_X);
x1.setPosition(n.getBounds().getX() + n.getBounds().getWidth());
x2.setPosition(getDoubleWidth() - PART_SPACE);
final Ordinate y = new Ordinate(Ordinate.TYPE_Y);
y.setPosition(n.getBounds().getY() + poses[MovingPanel.RIGHT]);
poses[MovingPanel.RIGHT] += hs[MovingPanel.RIGHT];
final Point p1 = new Point(x1, y);
final Point p2 = new Point(x2, y);
final PaintSector ps = new PaintSector(s, p1, p2, this);
r.addSector(ps);
final Crosspoint cp = dataPlugin.createCrosspoint();
if (so != null) {
so.getEnd().setCrosspointA(cp);
so.getEnd().commit();
}
s.getEnd().setCrosspointA(c);
s.getStart().setCrosspointA(cp);
s.getStart().setFunctionA(n);
s.getStart().setFunctionTypeA(MovingPanel.RIGHT);
s.getEnd().setBorderTypeA(MovingPanel.RIGHT);
s.getStart().commit();
s.getEnd().commit();
}
if (f.equals(sector.getEnd().getFunction())) {
final int et = sector.getEnd().getFunctionType();
final Crosspoint c = sector.getEnd().getCrosspoint();
final Sector[] ss = c.getOppozite(sector);
Sector so = null;
for (final Sector element : ss) {
so = element;
so.setFunction(n);
}
final Sector s = dataPlugin.createSector();
((AbstractSector) s).setThisStream(SectorRefactor.cloneStream(sector.getStream(), dataPlugin, s));
s.setVisualAttributes(sector.getVisualAttributes());
s.setFunction(f);
if (et == MovingPanel.LEFT) {
final Ordinate x1 = new Ordinate(Ordinate.TYPE_X);
final Ordinate x2 = new Ordinate(Ordinate.TYPE_X);
x2.setPosition(n.getBounds().getX());
x1.setPosition(PART_SPACE);
final Ordinate y = new Ordinate(Ordinate.TYPE_Y);
y.setPosition(n.getBounds().getY() + poses[et]);
final Point p1 = new Point(x1, y);
final Point p2 = new Point(x2, y);
final PaintSector ps = new PaintSector(s, p1, p2, this);
r.addSector(ps);
} else if (et == MovingPanel.TOP) {
final Ordinate y1 = new Ordinate(Ordinate.TYPE_Y);
final Ordinate y2 = new Ordinate(Ordinate.TYPE_Y);
y2.setPosition(n.getBounds().getY());
y1.setPosition(PART_SPACE);
final Ordinate x = new Ordinate(Ordinate.TYPE_X);
x.setPosition(n.getBounds().getX() + poses[et]);
final Point p1 = new Point(x, y1);
final Point p2 = new Point(x, y2);
final PaintSector ps = new PaintSector(s, p1, p2, this);
r.addSector(ps);
} else if (et == MovingPanel.BOTTOM) {
final Ordinate y1 = new Ordinate(Ordinate.TYPE_Y);
final Ordinate y2 = new Ordinate(Ordinate.TYPE_Y);
y2.setPosition(n.getBounds().getY() + n.getBounds().getHeight());
y1.setPosition(PART_SPACE + getDoubleHeight());
final Ordinate x = new Ordinate(Ordinate.TYPE_X);
x.setPosition(n.getBounds().getX() + poses[et]);
final Point p1 = new Point(x, y1);
final Point p2 = new Point(x, y2);
final PaintSector ps = new PaintSector(s, p1, p2, this);
r.addSector(ps);
}
poses[et] += hs[et];
final Crosspoint cp = dataPlugin.createCrosspoint();
if (so != null) {
so.getStart().setCrosspointA(cp);
so.setFunction(n);
so.getStart().commit();
}
s.getStart().setCrosspointA(c);
s.getEnd().setCrosspointA(cp);
s.getEnd().setFunctionA(n);
s.getEnd().setFunctionTypeA(et);
s.getStart().setBorderTypeA(et);
s.getStart().commit();
s.getEnd().commit();
}
}
r.saveToFunction(f);
if (panel != null)
panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, dataPlugin.getBaseFunction());
((NFunction) f).clearSectorsBuffer();
f.unlock();
}
Aggregations