use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.
the class External method paint.
@Override
public void paint(Graphics2D g) {
DataPlugin dp = ((NFunction) function).getDataPlugin();
Row row = dp.findRowByGlobalId(function.getLink());
final class PolygonD extends Polygon {
/**
*/
private static final long serialVersionUID = 113232131232134523L;
public void addPoint(final double x, final double y) {
super.addPoint((int) x, (int) y);
}
}
g.setColor(function.getBackground());
final Rectangle2D rect = movingArea.getBounds(getBounds());
g.fill(rect);
g.setFont(function.getFont());
paintText(g);
if (row != null) {
String string = row.getKod();
movingArea.paintText(g, string, new FRectangle(myBounds.getX() + 3, myBounds.getY() + 3, myBounds.getWidth() - 3, myBounds.getHeight() - 3), Line.LEFT_ALIGN, 0, true);
}
paintBorder(g);
final Stroke tmp = g.getStroke();
g.draw(rect);
double zm = movingArea.getIDoubleOrdinate(2);
g.draw(new Line2D.Double(rect.getX() + zm, rect.getY() + zm, rect.getX() + zm, rect.getY() + rect.getHeight()));
g.draw(new Line2D.Double(rect.getX() + zm, rect.getY() + zm, rect.getX() + rect.getWidth(), rect.getY() + zm));
if (paintTriangle >= 0) {
final PolygonD p = new PolygonD();
p.addPoint(rect.getX() + rect.getWidth() / 2, rect.getY() + rect.getHeight() / 2);
int standoff2 = -1;
switch(paintTriangle) {
case Point.TOP:
{
p.addPoint(rect.getX() + standoff2, rect.getY() + standoff2);
p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + standoff2);
}
break;
case Point.LEFT:
{
p.addPoint(rect.getX() + standoff2, rect.getY() + standoff2);
p.addPoint(rect.getX() + standoff2, rect.getY() + rect.getHeight() - standoff2);
}
break;
case Point.RIGHT:
{
p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + standoff2);
p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + rect.getHeight() - standoff2);
}
break;
case Point.BOTTOM:
{
p.addPoint(rect.getX() + standoff2, rect.getY() + rect.getHeight() - standoff2);
p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + rect.getHeight() - standoff2);
}
break;
}
if (p.npoints > 1)
g.fillPolygon(p);
}
g.setStroke(tmp);
}
use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.
the class DFDSFunction method onProcessEndBoundsChange.
@Override
public void onProcessEndBoundsChange() {
FRectangle oldRec = function.getBounds();
myBounds.setTransformNetBounds(MovingArea.NET_LENGTH);
FRectangle newRect = new FRectangle(myBounds);
function.setBounds(newRect);
final SectorRefactor refactor = movingArea.getRefactor();
MemoryData memoryData = new MemoryData();
List<PaintSector> list = new ArrayList<PaintSector>();
for (int i = 0; i < refactor.getSectorsCount(); i++) {
PaintSector sector = refactor.getSector(i);
try {
setAddedSectorPos(oldRec, sector, list);
} catch (Exception e) {
e.printStackTrace();
}
}
for (PaintSector ps : list) PaintSector.save(ps, memoryData, ((NFunction) function).getEngine());
setAddedRolesPos(oldRec, newRect);
}
use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.
the class DFDSRole method onProcessEndBoundsChange.
@Override
public void onProcessEndBoundsChange() {
final FRectangle oldRec = function.getBounds();
myBounds.setTransformNetBounds(MovingArea.NET_LENGTH);
List<PaintSector> list = new ArrayList<PaintSector>();
final SectorRefactor refactor = movingArea.getRefactor();
boolean sectorReplaced = false;
DFDSFunction function = movingArea.findDFDSFunction(this.getBounds());
if (function != null) {
getFunction().setOwner(function.getFunction());
for (int i = 0; i < refactor.getSectorsCount(); i++) {
PaintSector ps = refactor.getSector(i);
Function function2 = ps.getSector().getStart().getFunction();
if (function2 != null && function2.equals(this.function)) {
replaceFunction(ps.getSector().getStart(), ps, list, ps.getStartPoint(), ps.getSector().getStart().getFunctionType(), function, refactor, true);
}
Function function3 = ps.getSector().getEnd().getFunction();
if (function3 != null && function3.equals(this.function)) {
replaceFunction(ps.getSector().getEnd(), ps, list, ps.getEndPoint(), ps.getSector().getEnd().getFunctionType(), function, refactor, false);
}
}
function.justifyRoles();
sectorReplaced = true;
} else {
if (this.getFunction().getOwner() != null) {
DFDSFunction function2 = movingArea.findDFDSFunction(this.getFunction().getOwner());
if (function2 != null && function2.getBounds().intersects(this.getBounds())) {
function2.justifyRoles();
} else
this.function.setBounds(new FRectangle(myBounds));
} else
this.function.setBounds(new FRectangle(myBounds));
}
MemoryData memoryData = new MemoryData();
if (!sectorReplaced) {
for (int i = 0; i < refactor.getSectorsCount(); i++) {
PaintSector sector = refactor.getSector(i);
setAddedSectorPos(oldRec, sector, list);
}
}
for (PaintSector ps : list) PaintSector.save(ps, memoryData, ((NFunction) this.function).getEngine());
long l = this.function.getLink();
if (l >= 0l) {
Stream stream = (Stream) movingArea.getDataPlugin().findRowByGlobalId(l);
if (stream != null) {
Row[] rows = stream.getAdded();
RectangleVisualOptions ops = new RectangleVisualOptions();
ops.bounds = this.function.getBounds();
ops.background = this.function.getBackground();
ops.font = this.function.getFont();
ops.foreground = this.function.getForeground();
for (Row row : rows) if (row != null) {
IDEF0Plugin.setDefaultRectangleVisualOptions(movingArea.getDataPlugin().getEngine(), row.getElement(), ops);
}
}
}
}
use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.
the class AbstractDataPlugin method indexOfFunction.
public int indexOfFunction(final Function function) {
if (((NFunction) function).isBase())
return 0;
class X {
private int count = 0;
private Function f;
public int getIndex(final Function f) {
this.f = f;
calc(getBaseFunction(f));
return count;
}
private boolean calc(final Function base) {
final Enumeration cs = base.children();
while (cs.hasMoreElements()) {
final Function c = (Function) cs.nextElement();
if (c.getType() >= Function.TYPE_EXTERNAL_REFERENCE)
continue;
if (c.equals(f)) {
count++;
return true;
}
if (c.isHaveRealChilds()) {
count++;
if (calc(c))
return true;
}
}
return false;
}
}
return new X().getIndex(function);
}
use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.
the class DataStore method paint.
@Override
public void paint(Graphics2D g) {
final Stroke tmp = g.getStroke();
try {
DataPlugin dp = ((NFunction) function).getDataPlugin();
Row row = dp.findRowByGlobalId(function.getLink());
final class PolygonD extends Polygon {
/**
*/
private static final long serialVersionUID = 1L;
public void addPoint(final double x, final double y) {
super.addPoint((int) x, (int) y);
}
}
;
g.setColor(function.getBackground());
final Rectangle2D rect = movingArea.getBounds(getBounds());
Rectangle2D r2d = null;
if (row != null) {
String string = row.getKod();
r2d = function.getFont().getStringBounds(string, g.getFontRenderContext());
left = movingArea.getIDoubleOrdinate(r2d.getWidth()) + 1;
} else {
left = EMPTY_LEFT;
}
g.fill(rect);
g.setFont(function.getFont());
paintText(g);
if (row != null) {
String string = row.getKod();
movingArea.paintText(g, string, new FRectangle(myBounds.getX() + 0.5, myBounds.getY(), left - 0.5, myBounds.getHeight()), Line.LEFT_ALIGN, 1, true);
}
g.draw(new Line2D.Double(rect.getX() + left, rect.getMaxY(), rect.getX() + left, rect.getY()));
paintBorder(g);
g.draw(new Line2D.Double(rect.getX(), rect.getY(), rect.getMaxX(), rect.getY()));
g.draw(new Line2D.Double(rect.getX(), rect.getMaxY(), rect.getX(), rect.getY()));
g.draw(new Line2D.Double(rect.getMaxX(), rect.getMaxY(), rect.getX(), rect.getMaxY()));
g.setStroke(new BasicStroke(2));
/*
* g.draw(new Line2D.Double(rect.getX() + rect.getWidth() - 1,
* rect.getY() + 1, rect.getX() + rect.getWidth() - 1, rect.getY() +
* rect.getHeight() - 1)); g.draw(new Line2D.Double(rect.getX() + 1,
* rect.getY() + rect.getHeight() - 1, rect.getX() + rect.getWidth()
* - 1, rect .getY() + rect.getHeight() - 1));
*/
final String string = getIDEF0Kod();
g.setFont(function.getFont());
double h = MovingArea.getWidth(0) + MovingArea.getWidth((int) function.getFont().getStringBounds(string, g.getFontRenderContext()).getHeight());
h = h * 0.7;
if (paintTriangle >= 0) {
final PolygonD p = new PolygonD();
p.addPoint(rect.getX() + rect.getWidth() / 2, rect.getY() + rect.getHeight() / 2);
int standoff2 = -1;
switch(paintTriangle) {
case Point.TOP:
{
p.addPoint(rect.getX() + standoff2, rect.getY() + standoff2);
p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + standoff2);
}
break;
case Point.LEFT:
{
p.addPoint(rect.getX() + standoff2, rect.getY() + standoff2);
p.addPoint(rect.getX() + standoff2, rect.getY() + rect.getHeight() - standoff2);
}
break;
case Point.RIGHT:
{
p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + standoff2);
p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + rect.getHeight() - standoff2);
}
break;
case Point.BOTTOM:
{
p.addPoint(rect.getX() + standoff2, rect.getY() + rect.getHeight() - standoff2);
p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + rect.getHeight() - standoff2);
}
break;
}
if (p.npoints > 1)
g.fillPolygon(p);
}
} catch (NullPointerException e) {
}
g.setStroke(tmp);
}
Aggregations