Search in sources :

Example 16 with Rectangle

use of java.awt.Rectangle in project darkFunction-Editor by darkFunction.

the class SpriteImagePanel method drawStack.

@Override
public void drawStack(Graphics g) {
    Rectangle r = convertRectToViewRect(_graphicBounds);
    g.clipRect(r.x, r.y, r.width, r.height);
    super.drawStack(g);
    g.setClip(null);
}
Also used : Rectangle(java.awt.Rectangle)

Example 17 with Rectangle

use of java.awt.Rectangle in project darkFunction-Editor by darkFunction.

the class GraphicPanel method addGraphic.

public void addGraphic(GraphicObject aGraphic) {
    if (aGraphic.getAnchor() == GraphicObject.Anchor.CENTRE) {
        Rectangle r = aGraphic.getRect();
        r.x -= r.width / 2;
        r.y -= r.height / 2;
        aGraphic.saveRect();
    }
    // add to top
    _drawStack.add(0, aGraphic);
    aGraphic.setBounds(_graphicBounds);
    repaint();
    _lastAddedGraphic = aGraphic;
    for (int i = 0; i < _changeListeners.size(); ++i) {
        _changeListeners.get(i).graphicAdded(this, aGraphic);
    }
}
Also used : Rectangle(java.awt.Rectangle) Point(java.awt.Point)

Example 18 with Rectangle

use of java.awt.Rectangle in project darkFunction-Editor by darkFunction.

the class GridGraphicPanel method dropGraphic.

@Override
protected void dropGraphic(GraphicObject aGraphic, boolean aUndoable) {
    Rectangle bounds = this.getGraphicsBounds();
    if (bounds == null) {
        bounds = new Rectangle(0, 0, this.getSize().width, this.getSize().height);
    }
    Dimension padding = this.padding;
    if (padding == null)
        padding = new Dimension(0, 0);
    Rectangle r = aGraphic.getRect();
    if (this.tileSize != null) {
        Dimension total = new Dimension(tileSize.width + padding.width, tileSize.height + padding.height);
        Point currentCentre = new Point(r.x + r.width / 2, r.y + r.height / 2);
        Point closestPoint = new Point((currentCentre.x - (Math.abs(currentCentre.x) % total.width)) + (total.width / 2), (currentCentre.y - (Math.abs(currentCentre.y) % total.height)) + (total.height / 2));
        aGraphic.setRect(new Rectangle(closestPoint.x - r.width / 2, closestPoint.y - r.height / 2, r.width, r.height));
    }
    super.dropGraphic(aGraphic, aUndoable);
}
Also used : Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension) Point(java.awt.Point)

Example 19 with Rectangle

use of java.awt.Rectangle in project darkFunction-Editor by darkFunction.

the class GraphicPanel method mouseDragged.

public void mouseDragged(MouseEvent evt) {
    if (_lastClickPoint == null)
        return;
    Point p = evt.getPoint();
    Point dist = new Point(p.x - _lastClickPoint.x, p.y - _lastClickPoint.y);
    switch(_mouseButtonPressed) {
        case DRAG_BUTTON:
        case DRAG_BUTTON_2:
            {
                moveContent(dist, _lastOrigin);
            }
            break;
        case SELECT_BUTTON:
            {
                if (System.getProperty("os.name").startsWith("Mac OS X") && (evt.getModifiers() & ActionEvent.META_MASK) != 0) {
                    moveContent(dist, _lastOrigin);
                    break;
                }
                if (!_bAllowsEditing)
                    break;
                if (_resizingGraphic != null && _resizeDirection != Compass.NONE) {
                    Point resizeDist = MathUtil.dividePoint(dist, _zoom);
                    _resizingGraphic.resizeFromSavedPoint(resizeDist, _resizeDirection);
                } else if (_multiSelectRect != null) {
                    int topX = Math.min(p.x, _lastClickPoint.x);
                    int topY = Math.min(p.y, _lastClickPoint.y);
                    int bottomX = Math.max(p.x, _lastClickPoint.x);
                    int bottomY = Math.max(p.y, _lastClickPoint.y);
                    _multiSelectRect = new Rectangle(topX, topY, bottomX - topX, bottomY - topY);
                } else {
                    for (int i = 0; i < _drawStack.size(); ++i) {
                        GraphicObject graphic = _drawStack.get(i);
                        if (graphic.isSelected()) {
                            graphic.moveFromSavedPoint(MathUtil.dividePoint(dist, _zoom));
                        }
                    }
                }
            }
            break;
    }
    repaint();
}
Also used : Rectangle(java.awt.Rectangle) Point(java.awt.Point) Point(java.awt.Point)

Example 20 with Rectangle

use of java.awt.Rectangle in project darkFunction-Editor by darkFunction.

the class GraphicPanel method topGraphicAtPosition.

protected GraphicObject topGraphicAtPosition(Point aPoint) {
    for (int i = 0; i < _drawStack.size(); ++i) {
        GraphicObject graphic = _drawStack.get(i);
        Rectangle r = convertRectToViewRect(graphic.getRect());
        if (MathUtil.pointRectCollide(aPoint, r)) {
            return graphic;
        }
    }
    return null;
}
Also used : Rectangle(java.awt.Rectangle) Point(java.awt.Point)

Aggregations

Rectangle (java.awt.Rectangle)654 Point (java.awt.Point)147 BufferedImage (java.awt.image.BufferedImage)61 Dimension (java.awt.Dimension)49 Graphics2D (java.awt.Graphics2D)48 Insets (java.awt.Insets)36 Color (java.awt.Color)31 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)28 GraphicsConfiguration (java.awt.GraphicsConfiguration)21 IOException (java.io.IOException)21 Robot (java.awt.Robot)19 PeakResult (gdsc.smlm.results.PeakResult)18 File (java.io.File)18 Font (java.awt.Font)17 FontMetrics (java.awt.FontMetrics)17 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)16 SampleModel (java.awt.image.SampleModel)15 Component (java.awt.Component)14 ImagePlus (ij.ImagePlus)13