Search in sources :

Example 21 with Rectangle

use of java.awt.Rectangle in project gephi by gephi.

the class SplineDisplay method resetSelection.

private void resetSelection() {
    Point2D oldSelected = selected;
    selected = null;
    if (oldSelected != null) {
        Rectangle bounds = getDraggableArea(oldSelected).getBounds();
        repaint(bounds.x, bounds.y, bounds.width, bounds.height);
    }
}
Also used : Point2D(java.awt.geom.Point2D) Rectangle(java.awt.Rectangle)

Example 22 with Rectangle

use of java.awt.Rectangle in project binnavi by google.

the class JHexView method drawMouseOverHighlighting.

/**
   * Draws highlighting of bytes when the mouse hovers over them.
   * 
   * @param g The graphics context where the highlighting is drawn.
   */
private void drawMouseOverHighlighting(final Graphics g) {
    g.setColor(m_colorHighlight);
    m_lastHighlightedNibble = getNibbleAtCoordinate(m_lastMouseX, m_lastMouseY);
    if (m_lastHighlightedNibble == -1) {
        return;
    }
    // Find out in which view the mouse currently resides.
    final Views lastHighlightedView = m_lastMouseX >= getAsciiViewLeft() ? Views.ASCII_VIEW : Views.HEX_VIEW;
    if (lastHighlightedView == Views.HEX_VIEW) {
        // If the mouse is in the hex view just one nibble must be highlighted.
        final Rectangle r = getNibbleBoundsHex(m_lastHighlightedNibble);
        g.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight());
    } else if (lastHighlightedView == Views.ASCII_VIEW) {
        // If the mouse is in the ASCII view it is necessary
        // to highlight two nibbles.
        // Don't change.
        final int first = (2 * m_lastHighlightedNibble) / 2;
        Rectangle r = getNibbleBoundsHex(first);
        g.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight());
        r = getNibbleBoundsHex(first + 1);
        g.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight());
    }
    // Highlight the byte in the ASCII panel too.
    final Rectangle r = getByteBoundsAscii(m_lastHighlightedNibble);
    g.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight());
}
Also used : Rectangle(java.awt.Rectangle)

Example 23 with Rectangle

use of java.awt.Rectangle in project processing by processing.

the class EditorState method defaultLocation.

/**
   * Figure out the next location by sizing up the last editor in the list.
   * If no editors are opened, it'll just open on the main screen.
   * @param editors List of editors currently opened
   */
void defaultLocation(List<Editor> editors) {
    int defaultWidth = Toolkit.zoom(Preferences.getInteger("editor.window.width.default"));
    int defaultHeight = Toolkit.zoom(Preferences.getInteger("editor.window.height.default"));
    defaultWidth = Math.min(defaultWidth, deviceBounds.width);
    defaultHeight = Math.min(defaultHeight, deviceBounds.height);
    if (editors.size() == 0) {
        // If no current active editor, use default placement.
        // Center the window on ths screen, taking into account that the
        // upper-left corner of the device may have a non (0, 0) origin.
        int editorX = deviceBounds.x + (deviceBounds.width - defaultWidth) / 2;
        int editorY = deviceBounds.y + (deviceBounds.height - defaultHeight) / 2;
        editorBounds = new Rectangle(editorX, editorY, defaultWidth, defaultHeight);
        dividerLocation = 0;
    } else {
        // dimensions and divider location, but offset slightly.
        synchronized (editors) {
            Editor lastOpened = editors.get(editors.size() - 1);
            isMaximized = (lastOpened.getExtendedState() == Frame.MAXIMIZED_BOTH);
            editorBounds = lastOpened.getBounds();
            editorBounds.x += WINDOW_OFFSET;
            editorBounds.y += WINDOW_OFFSET;
            dividerLocation = lastOpened.getDividerLocation();
            if (!deviceBounds.contains(editorBounds)) {
                // Warp the next window to a randomish location on screen.
                editorBounds.x = deviceBounds.x + (int) (Math.random() * (deviceBounds.width - defaultWidth));
                editorBounds.y = deviceBounds.y + (int) (Math.random() * (deviceBounds.height - defaultHeight));
            }
            if (isMaximized) {
                editorBounds.width = defaultWidth;
                editorBounds.height = defaultHeight;
            }
        }
    }
}
Also used : Rectangle(java.awt.Rectangle)

Example 24 with Rectangle

use of java.awt.Rectangle in project processing by processing.

the class CompositionTextManager method getCaretRectangle.

private Rectangle getCaretRectangle(int x, int y) {
    TextAreaPainter painter = textArea.getPainter();
    Point origin = painter.getLocationOnScreen();
    int height = painter.getFontMetrics().getHeight();
    return new Rectangle(origin.x + x, origin.y + y, 0, height);
}
Also used : TextAreaPainter(processing.app.syntax.TextAreaPainter) Rectangle(java.awt.Rectangle) Point(java.awt.Point) Point(java.awt.Point)

Example 25 with Rectangle

use of java.awt.Rectangle in project processing by processing.

the class CompositionTextPainter method draw.

/**
   * Draw text via input method with composed text information.
   * This method can draw texts with some underlines to illustrate converting characters.
   *
   * This method is workaround for TextAreaPainter.
   * Because, TextAreaPainter can't treat AttributedCharacterIterator directly.
   * AttributedCharacterIterator has very important information when composing text.
   * It has a map where are converted characters and committed characters.
   * Ideally, changing TextAreaPainter method can treat AttributedCharacterIterator is better. But it's very tough!!
   * So I choose to write some code as a workaround.
   *
   * This draw method is proceeded with the following steps.
   * 1. Original TextAreaPainter draws characters.
   * 2. CompositionTextPainter.draw method paints composed text. It was actually drawn by TextLayout.
   *
   * @param gfx set TextAreaPainter's Graphics object.
   * @param fillBackGroundColor set textarea's background.
   */
//  public void draw(Graphics gfx, Color fillBackGroundColor) {
//	assert(composedTextLayout != null);
//	Point composedLoc = getCaretLocation();
//	//refillComposedArea(fillBackGroundColor, composedLoc.x, composedLoc.y);
//	composedTextLayout.draw((Graphics2D) gfx, composedLoc.x, composedLoc.y);
//  }
public void draw(Graphics gfx, Color fillBackGroundColor) {
    //assert(composedTextLayout != null);
    if (composedTextLayout != null) {
        Point composedLoc = getCaretLocation();
        //refillComposedArea(fillBackGroundColor, composedLoc.x, composedLoc.y);
        composedTextLayout.draw((Graphics2D) gfx, composedLoc.x, composedLoc.y);
        // draw caret.
        if (this.caret != null) {
            int caretLocation = Math.round(composedTextLayout.getCaretInfo(caret)[0]);
            Rectangle rect = new Rectangle(composedLoc.x + caretLocation, composedLoc.y - (int) composedTextLayout.getAscent(), 1, (int) composedTextLayout.getAscent() + (int) composedTextLayout.getDescent());
            // save
            Color c = gfx.getColor();
            if (caretColorFlag) {
                caretColorFlag = false;
                gfx.setColor(Color.WHITE);
            } else {
                caretColorFlag = true;
                gfx.setColor(Color.BLACK);
            }
            gfx.fillRect(rect.x, rect.y, rect.width, rect.height);
            // restore
            gfx.setColor(c);
        }
    }
}
Also used : Color(java.awt.Color) Rectangle(java.awt.Rectangle) Point(java.awt.Point) Point(java.awt.Point)

Aggregations

Rectangle (java.awt.Rectangle)809 Point (java.awt.Point)201 Dimension (java.awt.Dimension)81 BufferedImage (java.awt.image.BufferedImage)68 Graphics2D (java.awt.Graphics2D)65 Color (java.awt.Color)48 Insets (java.awt.Insets)47 ArrayList (java.util.ArrayList)37 Font (java.awt.Font)29 Test (org.junit.Test)28 IOException (java.io.IOException)27 GraphicsConfiguration (java.awt.GraphicsConfiguration)23 Paint (java.awt.Paint)23 GradientPaint (java.awt.GradientPaint)22 FontMetrics (java.awt.FontMetrics)21 Graphics (java.awt.Graphics)21 Rectangle2D (java.awt.geom.Rectangle2D)21 Robot (java.awt.Robot)19 File (java.io.File)19 PeakResult (gdsc.smlm.results.PeakResult)18