use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.
the class DFDFunctionEllipse method paint.
@Override
public void paint(Graphics2D g) {
g.setColor(function.getBackground());
final Rectangle2D rect = movingArea.getBounds(getBounds());
Ellipse2D ellipse = new Ellipse2D.Double(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
g.fill(ellipse);
g.setFont(function.getFont());
paintText(g);
paintBorder(g);
final Stroke tmp = g.getStroke();
g.draw(ellipse);
if (!function.isHaveChilds()) {
FRectangle fr = new FRectangle(rect);
double y1 = rect.getY() + rect.getHeight() / 2.5;
double x1 = getX(rect.getY() + rect.getHeight() / 2.5, true, fr);
double x2 = rect.getX() + rect.getWidth() / 2.5;
double y2 = getY(x2, true, fr);
g.draw(new Line2D.Double(x1, y1, x2, y2));
}
g.setStroke(new BasicStroke(2));
final String string = Integer.toString(function.getId());
g.setFont(function.getFont());
double h = MovingArea.getWidth(0) + MovingArea.getWidth((int) function.getFont().getStringBounds(string, g.getFontRenderContext()).getHeight());
h = h * 0.7;
paintTringle(g);
g.setStroke(tmp);
movingArea.paintText(g, string, new FRectangle(getBounds().getX(), getBounds().getBottom() - h, getBounds().getWidth(), h), com.ramussoft.pb.print.old.Line.RIGHT_ALIGN, 1, true);
}
use of com.dsoft.pb.types.FRectangle 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.dsoft.pb.types.FRectangle 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.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.
the class DFDSFunction method justifyRoles.
public void justifyRoles(List<Function> roles1) {
FRectangle bounds = getBounds();
List<Function> roles = new ArrayList<Function>();
for (Function role : roles1) if (bounds.intersects(role.getBounds()))
roles.add(role);
List<List<FRectangle>> lines = new ArrayList<List<FRectangle>>();
lines.add(new ArrayList<FRectangle>());
List<double[]> maxHights = new ArrayList<double[]>();
maxHights.add(new double[] { 0 });
int line = 0;
double x = bounds.getX() + 2;
double maxX = bounds.getX() + bounds.getWidth() * ROLES_PERCENT;
for (Function role : roles) {
FRectangle rectangle = role.getBounds();
if (x + rectangle.getWidth() > maxX) {
line++;
lines.add(new ArrayList<FRectangle>());
x = bounds.getX() + 2;
maxHights.add(new double[] { 0 });
}
List<FRectangle> list = lines.get(line);
FRectangle rect = role.getBounds();
list.add(rect);
rect.setX(x);
if (rect.getHeight() > maxHights.get(line)[0])
maxHights.get(line)[0] = rect.getHeight();
x += rect.getWidth() + 3;
}
double d = maxHights.get(line)[0];
double y = bounds.getBottom() - d - 2;
for (int i = line; i >= 0; --i) {
List<FRectangle> rectangles = lines.get(i);
for (FRectangle rectangle : rectangles) rectangle.setY(y);
if (i > 0)
y -= maxHights.get(i - 1)[0];
}
int i = 0;
for (List<FRectangle> list : lines) for (FRectangle rectangle : list) {
roles.get(i).setBounds(new FRectangle(rectangle));
i++;
}
}
use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.
the class DFDSFunction method justifyByDFDSRoles.
public void justifyByDFDSRoles(List<DFDSRole> roles1) {
FRectangle bounds = getBounds();
List<DFDSRole> roles = new ArrayList<DFDSRole>();
for (DFDSRole role : roles1) if (bounds.intersects(role.getBounds()))
roles.add(role);
List<List<FRectangle>> lines = new ArrayList<List<FRectangle>>();
lines.add(new ArrayList<FRectangle>());
List<double[]> maxHights = new ArrayList<double[]>();
maxHights.add(new double[] { 0 });
int line = 0;
double x = bounds.getX() + 2;
double maxX = bounds.getX() + bounds.getWidth() * ROLES_PERCENT;
for (DFDSRole role : roles) {
FRectangle rectangle = role.getBounds();
if (x + rectangle.getWidth() > maxX) {
line++;
lines.add(new ArrayList<FRectangle>());
x = bounds.getX() + 2;
maxHights.add(new double[] { 0 });
}
List<FRectangle> list = lines.get(line);
FRectangle rect = role.getBounds();
list.add(rect);
rect.setX(x);
if (rect.getHeight() > maxHights.get(line)[0])
maxHights.get(line)[0] = rect.getHeight();
x += rect.getWidth() + 3;
}
double d = maxHights.get(line)[0];
double y = bounds.getBottom() - d - 2;
for (int i = line; i >= 0; --i) {
List<FRectangle> rectangles = lines.get(i);
for (FRectangle rectangle : rectangles) rectangle.setY(y);
if (i > 0)
y -= maxHights.get(i - 1)[0];
}
int i = 0;
for (List<FRectangle> list : lines) for (FRectangle rectangle : list) {
roles.get(i).getFunction().setBounds(new FRectangle(rectangle));
i++;
}
}
Aggregations