Package eas.math.geometry

Examples of eas.math.geometry.Rectangle2D


     * <code>getImgPos(...)</code>.
     *
     * @return  An image view of the current environment state.
     */
    public synchronized BufferedImage getOutsideView(Graphics2D g2) {
        Rectangle2D visibleBox;

        if (this.isPerfectFit() && this.zoomBox == null) {
            this.createBoundingBox();
        }

        if (this.redrawField) {
            this.field = new BufferedImage(
                    (int) this.screenWidth,
                    (int) this.screenHeight,
                    BufferedImage.TYPE_4BYTE_ABGR);
        } else {
            return this.field;
        }

        visibleBox = this.getCurrentViewBox();
        Graphics2D g;
       
        if (g2 == null) {
            g = this.field.createGraphics();
        } else {
            g = g2;
        }
       
        Polygon2D shape;
        int id;
       
        g.setBackground(this.backgroundColor);
        g.clearRect(0, 0, this.field.getWidth(), this.field.getHeight());

        double globalScale = this.globalScale();
        Polygon2D b = visibleBox.toPol2D();
        b.scale(Vector2D.NULL_VECTOR, new Vector2D(globalScale, globalScale));
        Vector2D midTranslation = new Vector2D(screenWidth / 2, screenHeight / 2);
        midTranslation.sub(b.centerPoint());
        Rectangle2D border = new Rectangle2D(
                new Vector2D(screenLeft, screenUp),
                new Vector2D(screenWidth - screenLeft, screenHeight - screenUp));
        Polygon2D bound = visibleBox.toPol2D();
        bound.scale(Vector2D.NULL_VECTOR, new Vector2D(globalScale, globalScale));
        bound.translate(midTranslation);
        g.setColor(Color.red);
        g.drawPolygon(border.toPol());
       
        if (this.pars.getParValueBoolean("PaintPinkBoundingBox?")) {
            g.setColor(Color.pink);
            g.drawPolygon(bound.toPol());
            g.drawString(
                    visibleBox.upperLeftCorner().toString(),
                    (int) bound.getBoundingBox().upperLeftCorner().x,
                    (int) bound.getBoundingBox().upperLeftCorner().y - 10);
            String rechtsunten = visibleBox.lowerRightCorner().toString();
            g.drawString(
                    rechtsunten,
                    (int) Math.min(bound.getBoundingBox().lowerRightCorner().x,
                            this.screenWidth - rechtsunten.length() * 8),
                    (int) bound.getBoundingBox().lowerRightCorner().y + 20);
        }
       
        Rectangle2D clip = this.getClippingRectangle();
       
        g.clipRect(
                (int) clip.upperLeftCorner().x,
                (int) clip.upperLeftCorner().y,
                (int) clip.lowerRightCorner().x,
                (int) clip.lowerRightCorner().y);
       
        Rectangle2D visibleRedBox = new Rectangle2D(
//                visibleBox.liObEcke(),
                this.getRealPosFromScreenPos(new Vector2D(0, 0)),
//                visibleBox.rechtUntEcke(),
                this.getRealPosFromScreenPos(new Vector2D(screenWidth, screenHeight)));
       
View Full Code Here


            }
        }
    }

    public Rectangle2D getClippingRectangle() {
        return new Rectangle2D(
                new Vector2D(screenLeft, screenUp),
                new Vector2D(
                        screenWidth - 2 * screenLeft,
                        screenHeight - 2 * screenUp));
    }
View Full Code Here

            final double screenWidthOneTime,
            final double screenHeightOneTime,
            final double screenAngleRADOneTime,
            final Vector2D screenAngleCenterPointOneTime,
            final Rectangle2D zoomBoxOneTime) {
        Rectangle2D oldZoom = null;
        Vector2D oldCenterPoint = this.getVisualizationAngleCenterPoint();
        double oldAngle = this.getVisualizationAngleRAD();
        if (this.zoomBox != null) {
            oldZoom = new Rectangle2D(this.zoomBox.upperLeftCorner(), this.zoomBox.lowerRightCorner());
        }
        double oldWidth = this.getScreenWidth();
        double oldHeight = this.getScreenHeight();
       
        this.setZoomBox(zoomBoxOneTime);
View Full Code Here

            Vector2D direction,
            List<AgentType> ignore) {
       
        double maxdist = 0;
        double distanz;
        Rectangle2D bound;
       
        /*
         * Find a point that is clearly beyond the last point occupied
         * by a part of an agent in ray direction. Determine by this a
         * maximal possible distance of a ray collision.
         */
        for (AbstractAgent2D<?> a : this.agents2D.values()) {
            bound = a.getAgentShape().getBoundingBox();
            distanz = position.distance(
                    this.getAgentPosition(a.id()))
                        + bound.getWidth()
                        + bound.getHeight();
            if (distanz > maxdist) {
                maxdist = distanz;
            }
        }
       
View Full Code Here

            return;
        }

        this.redrawGrid = true;
       
        Rectangle2D bound = pol.getBoundingBox();

        if (this.boundingBox == null) {
            this.boundingBox = new Rectangle2D(bound.upperLeftCorner(),
                    bound.lowerRightCorner());
            return;
        }

        if (bound.upperLeftCorner().x < this.boundingBox.upperLeftCorner().x) {
            this.boundingBox.setLeft(bound.upperLeftCorner().x);
        }
        if (bound.upperLeftCorner().y < this.boundingBox.upperLeftCorner().y) {
            this.boundingBox.setTop(bound.upperLeftCorner().y);
        }
        if (bound.lowerRightCorner().x > this.boundingBox.lowerRightCorner().x) {
            this.boundingBox.setRight(bound.lowerRightCorner().x);
        }
        if (bound.lowerRightCorner().y > this.boundingBox.lowerRightCorner().y) {
            this.boundingBox.setBottom(bound.lowerRightCorner().y);
        }
    }
View Full Code Here

            this.zoomBox = null;
            this.forceRecalculation();
            return;
        }

        this.zoomBox = new Rectangle2D(
                newZoomBox.upperLeftCorner(),
                newZoomBox.lowerRightCorner());
       
        this.forceRecalculation();
    }
View Full Code Here

        }
        this.requestRedraw();
    }
   
    public void setZoomScale(double scale) {
        Rectangle2D zb;
        Rectangle2D currentBound = this.getCurrentViewBox();
        Vector2D middle = new Vector2D(this.getZoomBoxMiddle());
       
        zb = new Rectangle2D(
                new Vector2D(currentBound.upperLeftCorner()),
                new Vector2D(currentBound.lowerRightCorner()));
       
        zb.scale(Vector2D.NULL_VECTOR, new Vector2D(scale, scale));
       
        this.setZoomBox(zb);
        this.setZoomBoxMiddle(middle);
View Full Code Here

     *
     * @return  The bounding box of this scene (null if no agent has been
     *          placed so far).
     */
    public synchronized Rectangle2D getBoundingBox(final boolean recalculate) {
        Rectangle2D oldBoundingBox = null;
        Rectangle2D newBoundingBox;
        boolean newlyCreated = false;
       
        if (this.boundingBox == null) {
            this.createBoundingBox();
            newlyCreated = true;
        }
       
        if (this.boundingBox != null) {
            oldBoundingBox = new Rectangle2D(this.boundingBox);
        }
       
        if (recalculate) {
            if (!newlyCreated) {
                this.createBoundingBox();
View Full Code Here

     * @return  The current bounding box of the field view, i.e., the zoom box
     *          if it is not <code>null</code> or else the automatically
     *          calculated bounding box.
     */
    public Rectangle2D getCurrentViewBox() {
        Rectangle2D box;
       
        if (this.zoomBox == null) {
            box = this.boundingBox;
        } else {
            box = this.zoomBox;
        }
       
        if (box == null) {
            return new Rectangle2D(new Vector2D(0, 0), new Vector2D(100, 100));
        }
       
        return box;
    }
View Full Code Here

    public synchronized Polygon2D getAgentShapeInVisualization(
            final int agentID,
            final double screenWidthOneTime,
            final double screenHeightOneTime,
            final Rectangle2D zoomBoxOneTime) {
        Rectangle2D oldZoom = null;
        if (this.zoomBox != null) {
            oldZoom = new Rectangle2D(this.zoomBox.upperLeftCorner(), this.zoomBox.lowerRightCorner());
        }
        double oldWidth = this.getScreenWidth();
        double oldHeight = this.getScreenHeight();

        this.setZoomBox(zoomBoxOneTime);
View Full Code Here

TOP

Related Classes of eas.math.geometry.Rectangle2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.