Example usage for java.awt Rectangle getX

List of usage examples for java.awt Rectangle getX

Introduction

In this page you can find the example usage for java.awt Rectangle getX.

Prototype

public double getX() 

Source Link

Document

Returns the X coordinate of the bounding Rectangle in double precision.

Usage

From source file:net.sqs2.omr.session.logic.PageImageRenderer.java

private static void drawFormAreas(int pageIndex, float densityThreshold, FormMaster master,
        PageTaskResult pageTaskResult, Graphics2D g, MarkRecognitionConfig markRecognizationConfig,
        DeskewedImageSource pageSource, int focusedColumnIndex, Rectangle scope) {
    int formAreaIndexInPage = 0;

    int minX = Integer.MAX_VALUE;
    int minY = Integer.MAX_VALUE;
    int maxX = Integer.MIN_VALUE;
    int maxY = Integer.MIN_VALUE;

    for (FormArea formArea : master.getFormAreaListByPageIndex(pageIndex)) {
        FormAreaResult result = (FormAreaResult) pageTaskResult.getPageAreaResultList()
                .get(formAreaIndexInPage);
        if (formArea.isMarkArea()) {
            if (focusedColumnIndex == formArea.getQuestionIndex()) {

                Rectangle rect = formArea.getRect();

                Point2D p1 = pageSource.getPoint((int) rect.getX(), (int) rect.getY());
                Point2D p2 = pageSource.getPoint((int) (rect.getX() + rect.getWidth()),
                        (int) (rect.getY() + rect.getHeight()));

                minX = Math.min(minX, (int) p1.getX());
                minY = Math.min(minY, (int) p1.getY());
                maxX = Math.max(maxX, (int) p2.getX());
                maxY = Math.max(maxY, (int) p2.getY());

                if (result.getDensity() < densityThreshold) {
                    g.setColor(FOCUSED_MARKED_COLOR);
                } else {
                    g.setColor(FOCUSED_NO_MARKED_COLOR);
                }/*from  w  w  w.j  av a  2  s. com*/

            } else {
                if (result.getDensity() < densityThreshold) {
                    g.setColor(MARKED_COLOR);
                } else {
                    g.setColor(NO_MARKED_COLOR);
                }
            }

            g.fillPolygon(pageSource.createRectPolygon(
                    getExtendedRectangle(formArea.getRect(), markRecognizationConfig.getHorizontalMargin(),
                            markRecognizationConfig.getVerticalMargin())));
            g.drawPolygon(pageSource.createRectPolygon(
                    getExtendedRectangle(formArea.getRect(), markRecognizationConfig.getHorizontalMargin() + 3,
                            markRecognizationConfig.getVerticalMargin() + 3)));

        } else {
            g.setColor(TEXTAREA_COLOR);
            g.fillPolygon(pageSource.createRectPolygon(formArea.getRect()));
        }
        formAreaIndexInPage++;
    }

    if (scope != null) {
        int borderMarginX = 20;
        int borderMarginY = 3;
        int margin = 40;

        int x = minX - borderMarginX;
        int y = minY - borderMarginY;
        int width = maxX - minX + borderMarginX * 2;
        int height = maxY - minY + borderMarginY * 2;

        scope.x = minX - margin;
        scope.y = minY - margin;
        scope.width = maxX - minX + margin * 2;
        scope.height = maxY - minY + margin * 2;

        Stroke stroke = new BasicStroke(4.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 2.0f,
                new float[] { 4.0f, 8.0f }, 0.0f);
        g.setStroke(stroke);
        g.setColor(FOCUSED_SCOPE_COLOR);
        g.drawRoundRect(x, y, width, height, 20, 20);
    }

}

From source file:org.apache.fop.render.pdf.pdfbox.PDFBoxImageHandler.java

public void handleImage(RenderingContext context, Image image, Rectangle pos) throws IOException {
    assert context instanceof PDFRenderingContext;
    PDFRenderingContext pdfContext = (PDFRenderingContext) context;
    PDFContentGenerator generator = pdfContext.getGenerator();
    assert image instanceof ImagePDF;
    ImagePDF pdfImage = (ImagePDF) image;

    float x = (float) pos.getX() / 1000f;
    float y = (float) pos.getY() / 1000f;
    //        float w = (float)pos.getWidth() / 1000f;
    float h = (float) pos.getHeight() / 1000f;

    AffineTransform pageAdjust = new AffineTransform();
    AffineTransform at = generator.getAffineTransform();
    if (at != null) {
        pageAdjust.setToTranslation((float) (generator.getState().getTransform().getTranslateX()),
                (float) (generator.getState().getTransform().getTranslateY() - h - y));
    }/* ww  w.  java2s. c o m*/
    FontInfo fontinfo = (FontInfo) context.getHint("fontinfo");
    String stream = createStreamForPDF(pdfImage, pdfContext.getPage(), pdfContext.getUserAgent(), pageAdjust,
            fontinfo, pos, pdfContext.getPageNumbers(), pdfContext.getPdfLogicalStructureHandler(),
            pdfContext.getCurrentSessionStructElem());

    if (stream == null) {
        return;
    }
    if (pageAdjust.getScaleX() != 0) {
        pageAdjust.translate(x * (1 / pageAdjust.getScaleX()), -y * (1 / -pageAdjust.getScaleY()));
    }
    generator.placeImage(pageAdjust, stream);
}

From source file:org.apache.fop.render.ps.PSImageHandlerEPS.java

/** {@inheritDoc} */
public void handleImage(RenderingContext context, Image image, Rectangle pos) throws IOException {
    PSRenderingContext psContext = (PSRenderingContext) context;
    PSGenerator gen = psContext.getGenerator();
    ImageRawEPS eps = (ImageRawEPS) image;

    float x = (float) pos.getX() / 1000f;
    float y = (float) pos.getY() / 1000f;
    float w = (float) pos.getWidth() / 1000f;
    float h = (float) pos.getHeight() / 1000f;

    ImageInfo info = image.getInfo();//w ww  .  j  a  v  a 2  s. co  m
    Rectangle2D bbox = eps.getBoundingBox();
    if (bbox == null) {
        bbox = new Rectangle2D.Double();
        bbox.setFrame(new Point2D.Double(), info.getSize().getDimensionPt());
    }
    InputStream in = eps.createInputStream();
    try {
        String resourceName = info.getOriginalURI();
        if (resourceName == null) {
            resourceName = "inline image";
        }
        PSImageUtils.renderEPS(in, resourceName, new Rectangle2D.Float(x, y, w, h), bbox, gen);
    } finally {
        IOUtils.closeQuietly(in);
    }
}

From source file:org.broad.igv.renderer.SpliceJunctionRenderer.java

/**
 * Note:  assumption is that featureList is sorted by pStart position.
 *
 * @param featureList/*  w  w w  .  j a v  a2  s  . co m*/
 * @param context
 * @param trackRectangle
 * @param track
 */
@Override
public void render(List<IGVFeature> featureList, RenderContext context, Rectangle trackRectangle, Track track) {

    double origin = context.getOrigin();
    double locScale = context.getScale();

    // TODO -- use enum instead of string "Color"
    if ((featureList != null) && !featureList.isEmpty()) {

        // Create a graphics object to draw font names.  Graphics are not cached
        // by font, only by color, so its neccessary to create a new one to prevent
        // affecting other tracks.
        Font font = FontManager.getFont(track.getFontSize());
        Graphics2D fontGraphics = (Graphics2D) context.getGraphic2DForColor(Color.BLACK).create();

        if (PreferenceManager.getInstance().getAsBoolean(PreferenceManager.ENABLE_ANTIALISING)) {
            fontGraphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                    RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        }
        fontGraphics.setFont(font);

        //determine whether to show flanking regions
        PreferenceManager prefs = PreferenceManager.getInstance();
        boolean shouldShowFlankingRegions = prefs
                .getAsBoolean(PreferenceManager.SAM_SHOW_JUNCTION_FLANKINGREGIONS);

        // Track coordinates
        double trackRectangleX = trackRectangle.getX();
        double trackRectangleMaxX = trackRectangle.getMaxX();

        SpliceJunctionFeature selectedFeature = (SpliceJunctionFeature) ((FeatureTrack) track)
                .getSelectedFeature();

        // Start of Roche-Tessella modification
        if (track.getAutoScale()) {
            Frequency f = new Frequency();
            List<Integer> scores = new ArrayList<Integer>();

            for (IGVFeature feature : featureList) {
                SpliceJunctionFeature junctionFeature = (SpliceJunctionFeature) feature;
                f.addValue(junctionFeature.getScore());
                scores.add((int) junctionFeature.getScore());
            }

            Collections.sort(scores);
            Collections.reverse(scores);
            for (int s : scores) {
                if (f.getCumPct(s) < 0.99) {
                    maxDepth = s;
                    break;
                }
            }

        }
        // End of Roche-Tessella modification

        for (IGVFeature feature : featureList) {
            SpliceJunctionFeature junctionFeature = (SpliceJunctionFeature) feature;
            //if same junction as selected feature, highlight
            boolean shouldHighlight = false;
            if (selectedFeature != null && selectedFeature.isSameJunction(junctionFeature)) {
                setHighlightFeature(junctionFeature);
                shouldHighlight = true;
            }

            // Get the pStart and pEnd of the entire feature.  at extreme zoom levels the
            // virtual pixel value can be too large for an int, so the computation is
            // done in double precision and cast to an int only when its confirmed its
            // within the field of view.
            int flankingStart = junctionFeature.getStart();
            int flankingEnd = junctionFeature.getEnd();

            int junctionStart = junctionFeature.getJunctionStart();
            int junctionEnd = junctionFeature.getJunctionEnd();

            double virtualPixelStart = Math.round((flankingStart - origin) / locScale);
            double virtualPixelEnd = Math.round((flankingEnd - origin) / locScale);

            double virtualPixelJunctionStart = Math.round((junctionStart - origin) / locScale);
            double virtualPixelJunctionEnd = Math.round((junctionEnd - origin) / locScale);

            // If the any part of the feature fits in the
            // Track rectangle draw it
            if ((virtualPixelEnd >= trackRectangleX) && (virtualPixelStart <= trackRectangleMaxX)) {

                //
                int displayPixelEnd = (int) Math.min(trackRectangleMaxX, virtualPixelEnd);
                int displayPixelStart = (int) Math.max(trackRectangleX, virtualPixelStart);

                float depth = junctionFeature.getJunctionDepth();
                Color color = feature.getColor();

                drawFeature((int) virtualPixelStart, (int) virtualPixelEnd, (int) virtualPixelJunctionStart,
                        (int) virtualPixelJunctionEnd, depth, trackRectangle, context, feature.getStrand(),
                        junctionFeature, shouldHighlight, color, shouldShowFlankingRegions);
            }
        }

        //draw a central horizontal line
        Graphics2D g2D = context.getGraphic2DForColor(COLOR_CENTERLINE);
        g2D.drawLine((int) trackRectangleX, (int) trackRectangle.getCenterY(), (int) trackRectangleMaxX,
                (int) trackRectangle.getCenterY());

    }
}

From source file:org.executequery.gui.erd.ErdTable.java

public void selected(MouseEvent e) {
    super.selected(e);

    Rectangle bounds = getBounds();
    Rectangle titleBar = new Rectangle((int) bounds.getX(), (int) bounds.getY(), FINAL_WIDTH, TITLE_BAR_HEIGHT);

    if (titleBar.contains(xDifference, yDifference)) {
        dragging = true;/*ww w . j a v a 2 s . com*/
    } else {
        dragging = false;
    }

    // need to repaint layered pane to show
    // selected border on tables
    parent.repaintLayeredPane();
}

From source file:org.opencastproject.metadata.mpeg7.Mpeg7Test.java

/**
 * Tests the contents of the sample catalog mpeg7.xml.
 *///from  www .j  a  v a  2  s  .  c  o  m
@SuppressWarnings("unchecked")
protected void testContent(Mpeg7Catalog mpeg7) {
    // Check presence of content
    assertTrue(mpeg7.hasAudioContent());
    assertTrue(mpeg7.hasVideoContent());
    assertFalse(mpeg7.hasAudioVisualContent());

    // Check content size
    assertTrue(mpeg7.getMultimediaContent(MultimediaContent.Type.AudioType).size() == 1);
    assertTrue(mpeg7.getMultimediaContent(MultimediaContent.Type.VideoType).size() == 2);

    // Check tracks
    assertNotNull(mpeg7.getAudioById("track-1"));
    assertNotNull(mpeg7.getVideoById("track-2"));
    assertNotNull(mpeg7.getVideoById("track-3"));

    //
    // Check audio track (track-1)
    //

    MultimediaContentType track1 = mpeg7.getAudioById("track-1");
    MediaTime audioMediaTime = track1.getMediaTime();

    // Media locator
    assertEquals(track1.getMediaLocator().getMediaURI(), URI.create("file:tracks/audio.pcm"));
    // Media time point
    assertEquals(0, audioMediaTime.getMediaTimePoint().getDay());
    assertEquals(0, audioMediaTime.getMediaTimePoint().getHour());
    assertEquals(0, audioMediaTime.getMediaTimePoint().getMinutes());
    assertEquals(0, audioMediaTime.getMediaTimePoint().getSeconds());
    assertEquals(25, audioMediaTime.getMediaTimePoint().getFractionsPerSecond());
    assertEquals(0, audioMediaTime.getMediaTimePoint().getNFractions());
    // Media duration
    assertEquals(0, audioMediaTime.getMediaDuration().getDays());
    assertEquals(1, audioMediaTime.getMediaDuration().getHours());
    assertEquals(30, audioMediaTime.getMediaDuration().getMinutes());
    assertEquals(0, audioMediaTime.getMediaDuration().getSeconds());
    // Segments
    assertFalse(track1.getTemporalDecomposition().segments().hasNext());

    //
    // Check video track (track-2)
    //

    MultimediaContentType track2 = mpeg7.getVideoById("track-2");
    MediaTime v1MediaTime = track2.getMediaTime();

    // Media locator
    assertEquals(track2.getMediaLocator().getMediaURI(), URI.create("file:tracks/presentation.mp4"));
    // Media time point
    assertEquals(0, v1MediaTime.getMediaTimePoint().getDay());
    assertEquals(0, v1MediaTime.getMediaTimePoint().getHour());
    assertEquals(0, v1MediaTime.getMediaTimePoint().getMinutes());
    assertEquals(0, v1MediaTime.getMediaTimePoint().getSeconds());
    assertEquals(25, v1MediaTime.getMediaTimePoint().getFractionsPerSecond());
    assertEquals(0, v1MediaTime.getMediaTimePoint().getNFractions());
    // Media duration
    assertEquals(0, v1MediaTime.getMediaDuration().getDays());
    assertEquals(1, v1MediaTime.getMediaDuration().getHours());
    assertEquals(30, v1MediaTime.getMediaDuration().getMinutes());
    assertEquals(0, v1MediaTime.getMediaDuration().getSeconds());
    // Segments
    TemporalDecomposition<VideoSegment> v1Decomposition = (TemporalDecomposition<VideoSegment>) track2
            .getTemporalDecomposition();
    assertFalse(v1Decomposition.hasGap());
    assertFalse(v1Decomposition.isOverlapping());
    assertEquals(v1Decomposition.getCriteria(), TemporalDecomposition.DecompositionCriteria.Temporal);
    assertTrue(v1Decomposition.segments().hasNext());
    // Segment track-2.segment-1
    VideoSegment v1Segment1 = v1Decomposition.getSegmentById("track-2.segment-1");
    assertNotNull(v1Segment1);
    MediaTime segment1MediaTime = v1Segment1.getMediaTime();
    // Media time point
    assertEquals(0, segment1MediaTime.getMediaTimePoint().getDay());
    assertEquals(0, segment1MediaTime.getMediaTimePoint().getHour());
    assertEquals(0, segment1MediaTime.getMediaTimePoint().getMinutes());
    assertEquals(0, segment1MediaTime.getMediaTimePoint().getSeconds());
    assertEquals(25, segment1MediaTime.getMediaTimePoint().getFractionsPerSecond());
    assertEquals(0, segment1MediaTime.getMediaTimePoint().getNFractions());
    // Media duration
    assertEquals(0, segment1MediaTime.getMediaDuration().getDays());
    assertEquals(1, segment1MediaTime.getMediaDuration().getHours());
    assertEquals(7, segment1MediaTime.getMediaDuration().getMinutes());
    assertEquals(35, segment1MediaTime.getMediaDuration().getSeconds());
    // Text annotations
    assertTrue(v1Segment1.hasTextAnnotations());
    assertTrue(v1Segment1.hasTextAnnotations(0.4f, 0.5f));
    assertFalse(v1Segment1.hasTextAnnotations(0.8f, 0.8f));
    assertTrue(v1Segment1.hasTextAnnotations("de"));
    assertFalse(v1Segment1.hasTextAnnotations("fr"));
    // Keywords
    TextAnnotation textAnnotation = v1Segment1.textAnnotations().next();
    assertEquals("Armin", textAnnotation.keywordAnnotations().next().getKeyword());
    assertEquals("Hint Armin", textAnnotation.freeTextAnnotations().next().getText());
    // Spaciotemporal decomposition
    SpatioTemporalDecomposition stdecomposition = v1Segment1.getSpatioTemporalDecomposition();
    assertNotNull(stdecomposition);
    assertTrue(stdecomposition.hasGap());
    assertFalse(stdecomposition.isOverlapping());
    // VideoText
    assertEquals(1, stdecomposition.getVideoText().length);
    VideoText videoText = stdecomposition.getVideoText("text1");
    assertNotNull(videoText);
    SpatioTemporalLocator locator = videoText.getSpatioTemporalLocator();
    assertNotNull(locator);
    MediaTime locatorMediaTime = locator.getMediaTime();
    assertNotNull(locatorMediaTime);
    assertEquals(MediaRelTimePointImpl.parseTimePoint("T00:00:00:0F25"), locatorMediaTime.getMediaTimePoint());
    assertEquals(MediaDurationImpl.parseDuration("PT01H07M35S"), locatorMediaTime.getMediaDuration());
    Textual textual = videoText.getText();
    assertNotNull(textual);
    assertEquals("Text", textual.getText());
    assertEquals("en", textual.getLanguage());
    Rectangle boundingBox = videoText.getBoundary();
    assertNotNull(boundingBox);
    assertEquals(10, (int) boundingBox.getX());
    assertEquals(150, (int) boundingBox.getWidth());
    assertEquals(20, (int) boundingBox.getY());
    assertEquals(15, (int) boundingBox.getHeight());

    //
    // Check video track (track-3)
    //

    MultimediaContentType track3 = mpeg7.getVideoById("track-3");
    MediaTime v2MediaTime = track3.getMediaTime();

    // Media locator
    assertEquals(track3.getMediaLocator().getMediaURI(), URI.create("file:tracks/presenter.mpg"));
    // Media time point
    assertEquals(0, v2MediaTime.getMediaTimePoint().getDay());
    assertEquals(0, v2MediaTime.getMediaTimePoint().getHour());
    assertEquals(0, v2MediaTime.getMediaTimePoint().getMinutes());
    assertEquals(0, v2MediaTime.getMediaTimePoint().getSeconds());
    assertEquals(25, v2MediaTime.getMediaTimePoint().getFractionsPerSecond());
    assertEquals(0, v2MediaTime.getMediaTimePoint().getNFractions());
    // Media duration
    assertEquals(0, v2MediaTime.getMediaDuration().getDays());
    assertEquals(1, v2MediaTime.getMediaDuration().getHours());
    assertEquals(30, v2MediaTime.getMediaDuration().getMinutes());
    assertEquals(0, v2MediaTime.getMediaDuration().getSeconds());
    // Segments
    TemporalDecomposition<VideoSegment> v2Decomposition = (TemporalDecomposition<VideoSegment>) track3
            .getTemporalDecomposition();
    assertFalse(v2Decomposition.segments().hasNext());

}

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Sets the location of the specified child relative to the location
 * of the specified parent and then makes it visible, and size to fill window.
 * This method is mainly useful for windows, frames and dialogs. 
 * /*from   ww w. j a va2 s .  c o  m*/
 * @param parentBounds    The bounds of the visible parent.
 * @param child     The child to display.
 * @param max      The maximum size of the window.
 */
public static void setLocationRelativeToAndSizeToWindow(Rectangle parentBounds, Component child,
        Dimension max) {
    if (child == null)
        return;
    if (parentBounds == null)
        parentBounds = new Rectangle(0, 0, 5, 5);
    if (max == null)
        max = new Dimension(5, 5);
    int x = (int) (parentBounds.getX() + parentBounds.getWidth());
    int y = (int) parentBounds.getY();
    int childWidth = child.getWidth();
    int childHeight = child.getHeight();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    if (x + childWidth > screenSize.getWidth()) {
        if (childWidth < parentBounds.getX())
            x = (int) (parentBounds.getX()) - childWidth;
        else
            x = (int) (screenSize.getWidth() - childWidth);
    }
    child.setLocation(x, y);
    int newHeight = (int) screenSize.getHeight() - y - 10;
    int newWidth = (int) screenSize.getWidth() - x - 10;

    if (newWidth > childWidth)
        childWidth = newWidth;
    if (newHeight > childHeight)
        childHeight = newHeight;

    if (childWidth > max.getWidth())
        childWidth = (int) max.getWidth();
    if (childHeight > max.getHeight())
        childHeight = (int) max.getHeight();

    child.setSize(childWidth, childHeight);
    child.setVisible(true);
}

From source file:org.openstreetmap.josm.Main.java

static public void saveGuiGeometry() {
    // save the current window geometry
    String newGeometry = "";
    try {/*from  ww w . j a va  2  s  .co m*/
        if (((JFrame) parent).getExtendedState() == JFrame.NORMAL) {
            Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
            Rectangle bounds = parent.getBounds();
            int width = (int) bounds.getWidth();
            int height = (int) bounds.getHeight();
            int x = (int) bounds.getX();
            int y = (int) bounds.getY();
            if (width > screenDimension.width)
                width = screenDimension.width;
            if (height > screenDimension.height)
                width = screenDimension.height;
            if (x < 0)
                x = 0;
            if (y < 0)
                y = 0;
            newGeometry = width + "x" + height + "+" + x + "+" + y;
        }
    } catch (Exception e) {
        System.out.println("Failed to save GUI geometry: " + e);
    }
    pref.put("gui.geometry", newGeometry);
}

From source file:org.pentaho.reporting.libraries.designtime.swing.LibSwingUtil.java

public static String rectangleToString(final Rectangle rectangle) {
    final StringBuilder buffer = new StringBuilder();
    buffer.append(rectangle.getX());
    buffer.append(",");
    buffer.append(rectangle.getY());//w  w w.  j a  v a2  s .  com
    buffer.append(",");
    buffer.append(rectangle.getWidth());
    buffer.append(",");
    buffer.append(rectangle.getHeight());
    return buffer.toString();
}

From source file:org.photovault.swingui.PhotoCollectionThumbView.java

/**
 * /* w w  w . j a  va  2  s  .  com*/
 *
 * @param mouseEvent a <code>MouseEvent</code> value
 */
public void mouseReleased(MouseEvent mouseEvent) {
    firstMouseEvent = null;
    if (dragType == DRAG_TYPE_SELECT && photos != null) {

        // Find out thumbails inside the selection rectangle

        // First lets restrict search to those rows that intersect with selection
        int topRow = (int) dragSelectionRect.getMinY() / rowHeight;
        int bottomRow = ((int) dragSelectionRect.getMaxY() / rowHeight) + 1;
        int startPhoto = topRow * columnsToPaint;
        int endPhoto = bottomRow * columnsToPaint;
        if (endPhoto > photos.size()) {
            endPhoto = photos.size();
        }

        // Find out which photos are selected
        for (int n = startPhoto; n < endPhoto; n++) {
            /*
             Performance optimization: Since getPhotoBounds() needs access 
             to photo thumbnail which may not yet be loaded we will do first 
             a rough check of if the table cell is in the selection area.
             */
            Rectangle cellRect = getPhotoCellBounds(n);
            if (dragSelectionRect.intersects(cellRect)) {
                Rectangle photoRect = getPhotoBounds(n);
                if (dragSelectionRect.intersects(photoRect)) {
                    selection.add(photos.get(n));
                    repaintPhoto(photos.get(n));
                }
            }
        }
        fireSelectionChangeEvent();
        // Redrw the selection area so that the selection rectangle is not shown anymore
        Rectangle repaintRect = dragSelectionRect;
        if (lastDragSelectionRect != null) {
            repaintRect = dragSelectionRect.union(lastDragSelectionRect);
        }
        repaint((int) repaintRect.getX() - 1, (int) repaintRect.getY() - 1, (int) repaintRect.getWidth() + 2,
                (int) repaintRect.getHeight() + 2);

        dragSelectionRect = null;
        lastDragSelectionRect = null;
        // Notify the mouse click handler that it has to do nothing
        dragJustEnded = true;
    }
}