Search in sources :

Example 31 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class HTMLHelper method getPinCoords.

private String getPinCoords(final Pin pin, final MovingArea area) {
    final double d = 2;
    final FRectangle bounds = new FRectangle();
    if (pin.getType() == PaintSector.PIN_TYPE_X) {
        double x1 = pin.getStart().getX();
        double x2 = pin.getEnd().getX();
        final double y = pin.getEnd().getY();
        if (x2 < x1) {
            final double x = x1;
            x1 = x2;
            x2 = x;
        }
        bounds.setX(x1);
        bounds.setWidth(x2 - x1);
        bounds.setY(y - d);
        bounds.setHeight(d * 2);
    } else {
        double y1 = pin.getStart().getY();
        double y2 = pin.getEnd().getY();
        final double x = pin.getEnd().getX();
        if (y2 < y1) {
            final double y = y1;
            y1 = y2;
            y2 = y;
        }
        bounds.setY(y1);
        bounds.setHeight(y2 - y1);
        bounds.setX(x - d);
        bounds.setWidth(d * 2);
    }
    return getAreaCoords(bounds, area);
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle)

Example 32 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class DFDSMovingLabel method resetBounds.

@Override
public void resetBounds() {
    final FRectangle old = getBounds();
    final Rectangle2D r = getResetsBounds(old);
    double w = r.getWidth();
    double h = r.getHeight();
    if (w < old.getWidth())
        w = old.getWidth();
    if (h < old.getHeight())
        h = old.getHeight();
    setBounds(old.getX(), /*-((r.getWidth()-old.getWidth())/2)*/
    old.getY(), /*
                         * -(r.getHeight()-old.getHeight())/2
						 */
    w, h);
// myBounds.setTransformNetBoundsMax(MovingArea.NET_LENGTH);
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle) Rectangle2D(java.awt.geom.Rectangle2D)

Example 33 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class DFDSMovingLabel method paint.

@Override
public void paint(Graphics2D g) {
    final Rectangle2D rec = movingArea.getBounds(getBounds());
    FRectangle textBounds = new FRectangle(getTextBounds());
    textBounds.setX(textBounds.getX() + 0.5d);
    double mx = movingArea.getIDoubleOrdinate(4);
    double my = movingArea.getIDoubleOrdinate(2);
    double sx = movingArea.getIDoubleOrdinate(2);
    double sy = movingArea.getIDoubleOrdinate(1);
    double maxX = rec.getMaxX() + movingArea.getIDoubleOrdinate(0.5);
    double xm = maxX - mx;
    if (rec.getX() > xm - sx)
        xm = maxX;
    double ym = rec.getMaxY() - my;
    double maxY = rec.getMaxY();
    if (rec.getY() > ym - sy)
        ym = maxY;
    int c = 1;
    if (!transparent && sector.getStream() != null && sector.getStream().getAdded() != null)
        c = sector.getStream().getAdded().length;
    if (!transparent || isNegative()) {
        g.setColor(fiterColor(Color.WHITE));
        GeneralPath gp = new GeneralPath(GeneralPath.WIND_NON_ZERO);
        gp.moveTo(maxX, ym);
        gp.lineTo(maxX, rec.getY());
        gp.lineTo(rec.getX(), rec.getY());
        gp.lineTo(rec.getX(), maxY);
        gp.lineTo(xm, maxY);
        gp.lineTo(maxX, ym);
        g.fill(gp);
    }
    for (int i = c - 1; i > 0; i--) {
        AffineTransform translateInstance = AffineTransform.getTranslateInstance(movingArea.getIDoubleOrdinate(i) * 2d, movingArea.getIDoubleOrdinate(i) * 2d);
        if (!transparent || isNegative()) {
            g.setColor(fiterColor(Color.WHITE));
            GeneralPath gp = new GeneralPath(GeneralPath.WIND_NON_ZERO);
            gp.moveTo(maxX, ym);
            gp.lineTo(maxX, rec.getY());
            gp.lineTo(rec.getX(), rec.getY());
            gp.lineTo(rec.getX(), maxY);
            gp.lineTo(xm, maxY);
            gp.lineTo(maxX, ym);
            g.fill(gp.createTransformedShape(translateInstance));
        }
        g.setColor(fiterColor(getColor()));
        GeneralPath gp = new GeneralPath(GeneralPath.WIND_NON_ZERO);
        gp.moveTo(xm, maxY);
        gp.lineTo(xm, ym);
        gp.lineTo(maxX, ym);
        gp.lineTo(maxX, rec.getY());
        gp.lineTo(rec.getX(), rec.getY());
        gp.lineTo(rec.getX(), maxY);
        gp.lineTo(xm, maxY);
        gp.lineTo(maxX, ym);
        g.draw(gp.createTransformedShape(translateInstance));
    }
    if (!transparent || isNegative()) {
        g.setColor(fiterColor(Color.WHITE));
        GeneralPath gp = new GeneralPath(GeneralPath.WIND_NON_ZERO);
        gp.moveTo(maxX, ym);
        gp.lineTo(maxX, rec.getY());
        gp.lineTo(rec.getX(), rec.getY());
        gp.lineTo(rec.getX(), maxY);
        gp.lineTo(xm, maxY);
        gp.lineTo(maxX, ym);
        g.fill(gp);
    }
    GeneralPath gp = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    gp.moveTo(xm, maxY);
    gp.lineTo(xm, ym);
    gp.lineTo(maxX, ym);
    gp.lineTo(maxX, rec.getY());
    gp.lineTo(rec.getX(), rec.getY());
    gp.lineTo(rec.getX(), maxY);
    gp.lineTo(xm, maxY);
    gp.lineTo(maxX, ym);
    g.setColor(fiterColor(getColor()));
    g.draw(gp);
    g.setFont(getFont());
    movingArea.paintText(g, getText(), textBounds, getAlign(), 0, true);
    paintBorder(g);
}
Also used : GeneralPath(java.awt.geom.GeneralPath) FRectangle(com.dsoft.pb.types.FRectangle) Rectangle2D(java.awt.geom.Rectangle2D) AffineTransform(java.awt.geom.AffineTransform)

Example 34 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class DFDSRole method compareTo.

@Override
public int compareTo(DFDSRole obj) {
    FRectangle my = getBounds();
    FRectangle o = obj.getBounds();
    if (my.getX() < o.getX())
        return -1;
    if (my.getX() > o.getX())
        return 1;
    return 0;
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle)

Example 35 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class AbstractTemplate method createChilds.

private synchronized void createChilds(final Rectangle rectangle) {
    // final IdGenerator g = GlobalId.getGenerator();
    // GlobalId.setGenerator(generator);
    dataPlugin = NDataPluginFactory.getTemplateDataPlugin();
    Function f = dataPlugin.getBaseFunction();
    final ProjectOptions po = f.getProjectOptions();
    po.setChangeDate(po.getDateChangeDate());
    po.setProjectAutor(po.getProjectAutor());
    po.setProjectName(po.getProjectName());
    po.setUsedAt(po.getUsedAt());
    f.setProjectOptions(po);
    final Attribute attribute = dataPlugin.getEngine().createAttribute(new com.ramussoft.common.AttributeType("Core", "Text", true));
    Qualifier q = dataPlugin.getBaseFunctionQualifier();
    q.getAttributes().add(attribute);
    q.setAttributeForName(attribute.getId());
    dataPlugin.getEngine().updateQualifier(q);
    f = (Function) dataPlugin.createRow(f, true);
    diagram = f;
    f.setDecompositionType(decompositionType);
    final FRectangle rect = f.getBounds();
    rect.setX(rectangle.getWidth() / 2 - rect.getWidth() / 2);
    rect.setY(rectangle.getHeight() / 2 - rect.getHeight() / 2);
    f.setBounds(rect);
    createChilds(f, dataPlugin);
    base = f;
// GlobalId.setGenerator(g);
}
Also used : Function(com.ramussoft.pb.Function) Attribute(com.ramussoft.common.Attribute) FRectangle(com.dsoft.pb.types.FRectangle) Qualifier(com.ramussoft.common.Qualifier) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Aggregations

FRectangle (com.dsoft.pb.types.FRectangle)39 FloatPoint (com.dsoft.pb.types.FloatPoint)11 NFunction (com.ramussoft.pb.data.negine.NFunction)11 Rectangle2D (java.awt.geom.Rectangle2D)10 Function (com.ramussoft.pb.Function)9 Point (com.ramussoft.pb.idef.elements.Point)7 BasicStroke (java.awt.BasicStroke)6 Stroke (java.awt.Stroke)6 Line2D (java.awt.geom.Line2D)6 ArrayList (java.util.ArrayList)6 Crosspoint (com.ramussoft.pb.Crosspoint)5 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)5 Row (com.ramussoft.pb.Row)4 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)4 Font (java.awt.Font)4 MemoryData (com.dsoft.utils.DataLoader.MemoryData)3 Stream (com.ramussoft.pb.Stream)3 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)3 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)3 Status (com.dsoft.pb.idef.elements.Status)2