Java Code Examples for java.awt.Rectangle.isEmpty()

The following are Jave code examples for showing how to use isEmpty() of the java.awt.Rectangle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: sumo   File: TiledBufferedImage.java   View Source Code Vote up 6 votes
public int[] readTile(int x, int y, int width, int height, int[] tile,int band) {
    Rectangle rect = new Rectangle(x, y, width, height);
    rect = rect.intersection(bounds);
    if (rect.isEmpty()) {
        return tile;
    }
    if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1]) {
        preloadLineTile(rect.y, rect.height,band);
    }
    int xinit = rect.x - x;
    int yinit = rect.y - y;
    for (int i = 0; i < rect.height; i++) {
        for (int j = 0; j < rect.width; j++) {
            int temp = i * xSize + j + rect.x;
            tile[(i + yinit) * width + j + xinit] = preloadedData[temp];
        }
    }
    return tile;
}
 
Example 2
Project: sumo   File: EnvisatImage_SLC.java   View Source Code Vote up 6 votes
@Override
public int[] readTile(int x, int y, int width, int height, int[] tile,int band) {
    Rectangle rect = new Rectangle(x, y, width, height);
    rect = rect.intersection(bounds);
    if (rect.isEmpty()) {
        return tile;
    }
    if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1]) {
        preloadLineTile(rect.y, rect.height,band);
    }
    int yOffset = xOffset + 4 * xSize;
    int xinit = rect.x - x;
    int yinit = rect.y - y;
    for (int i = 0; i < rect.height; i++) {
        for (int j = 0; j < rect.width; j++) {
            int temp = i * yOffset + j*4 + 4 * rect.x + xOffset;
            long real=(preloadedData[temp+0] << 8) | (preloadedData[temp+1]&0xff );
            long img=((preloadedData[temp+2]) << 8) | (preloadedData[temp+3]&0xff);
            tile[(i + yinit) * width + j + xinit] = (int)Math.sqrt(real*real+img*img);
        }
    }
    return tile;
}
 
Example 3
Project: sumo   File: EnvisatImage.java   View Source Code Vote up 6 votes
public int[] readTile(int x, int y, int width, int height, int[] tile, int band) {
    Rectangle rect = new Rectangle(x, y, width, height);
    rect = rect.intersection(bounds);
    if (rect.isEmpty()) {
        return tile;
    }
    if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1]) {
        preloadLineTile(rect.y, rect.height,band);
    }
    int yOffset = xOffset + 2 * xSize;
    int xinit = rect.x - x;
    int yinit = rect.y - y;
    for (int i = 0; i < rect.height; i++) {
        for (int j = 0; j < rect.width; j++) {
            int temp = i * yOffset + 2 * j + 2 * rect.x + xOffset;
            tile[(i + yinit) * width + j + xinit] = ((preloadedData[temp + 0]) << 8) | (preloadedData[temp + 1] & 0xff);
        }
    }
    return tile;
}
 
Example 4
Project: openjdk-jdk10   File: RepaintArea.java   View Source Code Vote up 6 votes
/**
 * Adds a {@code Rectangle} to this {@code RepaintArea}.
 * PAINT Rectangles are divided into mostly vertical and mostly horizontal.
 * Each group is unioned together.
 * UPDATE Rectangles are unioned.
 *
 * @param   r   the specified {@code Rectangle}
 * @param   id  possible values PaintEvent.UPDATE or PaintEvent.PAINT
 * @since   1.3
 */
public synchronized void add(Rectangle r, int id) {
    // Make sure this new rectangle has positive dimensions
    if (r.isEmpty()) {
        return;
    }
    int addTo = UPDATE;
    if (id == PaintEvent.PAINT) {
        addTo = (r.width > r.height) ? HORIZONTAL : VERTICAL;
    }
    if (paintRects[addTo] != null) {
        paintRects[addTo].add(r);
    } else {
        paintRects[addTo] = new Rectangle(r);
    }
}
 
Example 5
Project: OpenJSharp   File: XWM.java   View Source Code Vote up 6 votes
static void setShellNotResizable(XDecoratedPeer window, WindowDimensions newDimensions, Rectangle shellBounds,
                                 boolean justChangeSize)
{
    if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
        insLog.fine("Setting non-resizable shell " + window + ", dimensions " + newDimensions +
                    ", shellBounds " + shellBounds +", just change size: " + justChangeSize);
    }
    XToolkit.awtLock();
    try {
        /* Fix min/max size hints at the specified values */
        if (!shellBounds.isEmpty()) {
            window.updateSizeHints(newDimensions);
            requestWMExtents(window.getWindow());
            XToolkit.XSync();
            XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), window.getShell(),
                                          shellBounds.x, shellBounds.y, shellBounds.width, shellBounds.height);
        }
        if (!justChangeSize) {  /* update decorations */
            setShellDecor(window);
        }
    } finally {
        XToolkit.awtUnlock();
    }
}
 
Example 6
Project: sumo   File: Radarsat2Image_SLCGDAL.java   View Source Code Vote up 5 votes
@Override
public int[] readTile(int x, int y, int width, int height,int band) {

    Rectangle rect = new Rectangle(x, y, width, height);
    rect = rect.intersection(bounds);
    int[] tile = new int[height * width];
    if (rect.isEmpty()) {
        return tile;
    }
    if (rect.y != preloadedInterval[0] | rect.y + rect.height != preloadedInterval[1]) {
        preloadLineTile(rect.y, rect.height,band);
    }
    int yOffset =  getImage(band).getxSize();
    int xinit = rect.x - x;
    int yinit = rect.y - y;
    int temp =0;
    try{
     for (int i = 0; i < rect.height; i++) {
         for (int j = 0; j < rect.width; j++) {
             temp = (i * yOffset + j + rect.x);
             long real=preloadedDataReal[temp];
             long img=preloadedDataImg[temp];
             tile[(i + yinit) * width + j + xinit] = (int)Math.sqrt(real*real+img*img);
         }
     }
    }catch(Exception e ){
    	e.printStackTrace();
    }    
    return tile;
}
 
Example 7
Project: openjdk-jdk10   File: BufferedImage.java   View Source Code Vote up 5 votes
/**
 * Sets a rectangular region of the image to the contents of the
 * specified {@code Raster r}, which is
 * assumed to be in the same coordinate space as the
 * {@code BufferedImage}. The operation is clipped to the bounds
 * of the {@code BufferedImage}.
 * @param r the specified {@code Raster}
 * @see #getData
 * @see #getData(Rectangle)
*/
public void setData(Raster r) {
    int width = r.getWidth();
    int height = r.getHeight();
    int startX = r.getMinX();
    int startY = r.getMinY();

    int[] tdata = null;

    // Clip to the current Raster
    Rectangle rclip = new Rectangle(startX, startY, width, height);
    Rectangle bclip = new Rectangle(0, 0, raster.width, raster.height);
    Rectangle intersect = rclip.intersection(bclip);
    if (intersect.isEmpty()) {
        return;
    }
    width = intersect.width;
    height = intersect.height;
    startX = intersect.x;
    startY = intersect.y;

    // remind use get/setDataElements for speed if Rasters are
    // compatible
    for (int i = startY; i < startY+height; i++)  {
        tdata = r.getPixels(startX,i,width,1,tdata);
        raster.setPixels(startX,i,width,1, tdata);
    }
}
 
Example 8
Project: OpenJSharp   File: LWContainerPeer.java   View Source Code Vote up 5 votes
@Override
final void repaintPeer(final Rectangle r) {
    final Rectangle toPaint = getSize().intersection(r);
    if (!isShowing() || toPaint.isEmpty()) {
        return;
    }
    // First, post the PaintEvent for this peer
    super.repaintPeer(toPaint);
    // Second, handle all the children
    // Use the straight order of children, so the bottom
    // ones are painted first
    repaintChildren(toPaint);
}
 
Example 9
Project: jdk8u-jdk   File: LWContainerPeer.java   View Source Code Vote up 5 votes
@Override
final void repaintPeer(final Rectangle r) {
    final Rectangle toPaint = getSize().intersection(r);
    if (!isShowing() || toPaint.isEmpty()) {
        return;
    }
    // First, post the PaintEvent for this peer
    super.repaintPeer(toPaint);
    // Second, handle all the children
    // Use the straight order of children, so the bottom
    // ones are painted first
    repaintChildren(toPaint);
}
 
Example 10
Project: sumo   File: Sentinel1GRD.java   View Source Code Vote up 5 votes
/**
 * 
 */
@Override
public int[] readTile(int x, int y, int width, int height,int band) {
    Rectangle rect = new Rectangle(x, y, width, height);
    rect = rect.intersection(getImage(band).getBounds());
    int[] tile = new int[height * width];
    if (rect.isEmpty()) {
        return tile;
    }

    if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1]||preloadedData.length<(getImage(band).getxSize()*rect.height-1)) {
        preloadLineTile(rect.y, rect.height,band);
    }else{
    	//logger.debug("using preloaded data");
    }

    int yOffset = getImage(band).getxSize();
    int xinit = rect.x - x;
    int yinit = rect.y - y;
    for (int i = 0; i < rect.height; i++) {
        for (int j = 0; j < rect.width; j++) {
            int temp = i * yOffset + j + rect.x;
            try{
            	tile[(i + yinit) * width + j + xinit] = preloadedData[temp];
            }catch(ArrayIndexOutOfBoundsException e ){
            	logger.warn("readTile function:"+e.getMessage());
            }	
        }
        }
    return tile;
}
 
Example 11
Project: OpenJSharp   File: BufferedImage.java   View Source Code Vote up 5 votes
/**
 * Sets a rectangular region of the image to the contents of the
 * specified <code>Raster</code> <code>r</code>, which is
 * assumed to be in the same coordinate space as the
 * <code>BufferedImage</code>. The operation is clipped to the bounds
 * of the <code>BufferedImage</code>.
 * @param r the specified <code>Raster</code>
 * @see #getData
 * @see #getData(Rectangle)
*/
public void setData(Raster r) {
    int width = r.getWidth();
    int height = r.getHeight();
    int startX = r.getMinX();
    int startY = r.getMinY();

    int[] tdata = null;

    // Clip to the current Raster
    Rectangle rclip = new Rectangle(startX, startY, width, height);
    Rectangle bclip = new Rectangle(0, 0, raster.width, raster.height);
    Rectangle intersect = rclip.intersection(bclip);
    if (intersect.isEmpty()) {
        return;
    }
    width = intersect.width;
    height = intersect.height;
    startX = intersect.x;
    startY = intersect.y;

    // remind use get/setDataElements for speed if Rasters are
    // compatible
    for (int i = startY; i < startY+height; i++)  {
        tdata = r.getPixels(startX,i,width,1,tdata);
        raster.setPixels(startX,i,width,1, tdata);
    }
}
 
Example 12
Project: jdk8u-jdk   File: BufferedImage.java   View Source Code Vote up 5 votes
/**
 * Sets a rectangular region of the image to the contents of the
 * specified <code>Raster</code> <code>r</code>, which is
 * assumed to be in the same coordinate space as the
 * <code>BufferedImage</code>. The operation is clipped to the bounds
 * of the <code>BufferedImage</code>.
 * @param r the specified <code>Raster</code>
 * @see #getData
 * @see #getData(Rectangle)
*/
public void setData(Raster r) {
    int width = r.getWidth();
    int height = r.getHeight();
    int startX = r.getMinX();
    int startY = r.getMinY();

    int[] tdata = null;

    // Clip to the current Raster
    Rectangle rclip = new Rectangle(startX, startY, width, height);
    Rectangle bclip = new Rectangle(0, 0, raster.width, raster.height);
    Rectangle intersect = rclip.intersection(bclip);
    if (intersect.isEmpty()) {
        return;
    }
    width = intersect.width;
    height = intersect.height;
    startX = intersect.x;
    startY = intersect.y;

    // remind use get/setDataElements for speed if Rasters are
    // compatible
    for (int i = startY; i < startY+height; i++)  {
        tdata = r.getPixels(startX,i,width,1,tdata);
        raster.setPixels(startX,i,width,1, tdata);
    }
}
 
Example 13
Project: AspriseOCR   File: PairWorker.java   View Source Code Vote up 5 votes
@Override
public void startWork()
{

	Rectangle captureRect = Setting.getInstance().getCaptureRect();
	if (!mPriceGetter.isEnableRun() && captureRect != null && !captureRect.isEmpty())
	{
		PriceHolder.getInstance().resetPrice();
		mPriceGetter.enableRun(true);
		mImgWriter = new Thread(new ImgWriter(mPriceGetter), "ImgWriter");
		mImgReader = new Thread(new ImgReader(mPriceGetter), "ImgReader");
		mImgWriter.start();
		mImgReader.start();
		super.startWork();
		Logger.p("Price Getter has started");
	}
	else
	{
		if (mPriceGetter.isEnableRun())
		{
			Logger.p("Price Getter is always Working");
		}
		else
		{
			Logger.p("CapureRect is valid:" + captureRect);
		}
	}
}
 
Example 14
Project: sumo   File: GDALAlosCeos.java   View Source Code Vote up 5 votes
@Override
public int[] readTile(int x, int y, int width, int height, int band) {
	Rectangle rect = new Rectangle(x, y, width, height);
	rect = rect.intersection(getImage(band).getBounds());
	int[] tile = new int[height * width];
	if (rect.isEmpty()) {
		return tile;
	}

	if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1]
			|| preloadedData.length < (rect.y * rect.height - 1)) {
		preloadLineTile(rect.y, rect.height, band);
	} else {
		 //logger.debug("using preloaded data");
	}

	int yOffset = getImage(band).getxSize();
	int xinit = rect.x - x;
	int yinit = rect.y - y;
	for (int i = 0; i < rect.height; i++) {
		for (int j = 0; j < rect.width; j++) {
			int temp = i * yOffset + j + rect.x;
			try {
				tile[(i + yinit) * width + j + xinit] =(int) preloadedData[temp];
			} catch (ArrayIndexOutOfBoundsException e) {
				logger.warn("readTile function:" + e.getMessage());
			}
		}
	}
	return tile;
}
 
Example 15
Project: sumo   File: Radarsat2ImageGDAL.java   View Source Code Vote up 5 votes
@Override
public int[] readTile(int x, int y, int width, int height,int band) {
    Rectangle rect = new Rectangle(x, y, width, height);
    rect = rect.intersection(bounds);
    int[] tile= new int[height*width];
    if (rect.isEmpty()) {
        return tile;
    }
    if (rect.y != preloadedInterval[0] | rect.y + rect.height != preloadedInterval[1]) {
        preloadLineTile(rect.y, rect.height,band);
    }
    int yOffset = getImage(band).getxSize();
    int xinit = rect.x - x;
    int yinit = rect.y - y;
    for (int i = 0; i < rect.height; i++) {
        for (int j = 0; j < rect.width; j++) {
            int temp = i * yOffset + j + rect.x;
            	if(preloadedData.length>=temp){
            		tile[(i + yinit) * width + j + xinit] = preloadedData[temp];
            	}else{
            		
                	//logger.debug("");
            	}	
        }
    }
    return tile;
}
 
Example 16
Project: sumo   File: Radarsat2Image_SLC.java   View Source Code Vote up 5 votes
@Override
public int[] readTile(int x, int y, int width, int height,int band) {

    Rectangle rect = new Rectangle(x, y, width, height);
    rect = rect.intersection(bounds);
    int[] tile = new int[height * width];
    if (rect.isEmpty()) {
        return tile;
    }
    if (rect.y != preloadedInterval[0] | rect.y + rect.height != preloadedInterval[1]) {
        preloadLineTile(rect.y, rect.height,band);
    }
    int yOffset =  getImage(band).getxSize();
    int xinit = rect.x - x;
    int yinit = rect.y - y;
    int temp =0;
    try{
     for (int i = 0; i < rect.height; i++) {
         for (int j = 0; j < rect.width; j++) {
             temp = (i * yOffset + j + rect.x);
             long real=preloadedDataReal[temp];
             long img=preloadedDataImg[temp];
             tile[(i + yinit) * width + j + xinit] = (int)Math.sqrt(real*real+img*img);
         }
     }
    }catch(Exception e ){
    	e.printStackTrace();
    }    
    return tile;
}
 
Example 17
Project: incubator-netbeans   File: Central.java   View Source Code Vote up 4 votes
/** Sets editor area state into model and requests view (if needed). */
public void setEditorAreaState(int editorAreaState) {
    int old = getEditorAreaState();
    if(editorAreaState == old) {
        return;
    }
    
    int requiredState = editorAreaState == Constants.EDITOR_AREA_JOINED
                                            ? Constants.MODE_STATE_JOINED
                                            : Constants.MODE_STATE_SEPARATED;
                                            
    for(Iterator it = getModes().iterator(); it.hasNext(); ) {
        ModeImpl mode = (ModeImpl)it.next();
        if(mode.getKind() == Constants.MODE_KIND_VIEW
        && mode.getState() != requiredState) {
            model.setModeState(mode, requiredState);
            // Adjust bounds if necessary.
            if(editorAreaState == Constants.EDITOR_AREA_SEPARATED) {
                Rectangle bounds = model.getModeBounds(mode);
                if(bounds.isEmpty()) {
                    model.setModeBounds(mode, model.getModeBoundsSeparatedHelp(mode));
                }
            }
        }
        // when switching to SDI, undock sliding windows
        // #51992 -start
        if (mode.getKind() == Constants.MODE_KIND_SLIDING && editorAreaState == Constants.EDITOR_AREA_SEPARATED) {
            TopComponent[] tcs = mode.getTopComponents();
            for (int i = 0; i < tcs.length;i++) {
                String tcID = WindowManagerImpl.getInstance().findTopComponentID(tcs[i]);
                ModeImpl targetMode = model.getModeTopComponentPreviousMode(mode, tcID);
                if ((targetMode == null) || !model.getModes().contains(targetMode)) {
                    SplitConstraint[] constraints = model.getModeTopComponentPreviousConstraints(mode, tcID);
                    constraints = constraints == null ? new SplitConstraint[0] : constraints;
                    // create mode to dock topcomponent back into
                    targetMode = WindowManagerImpl.getInstance().createModeImpl(
                        ModeImpl.getUnusedModeName(), Constants.MODE_KIND_VIEW, false);
                    model.setModeState(targetMode, requiredState);
                    model.addMode(targetMode, constraints);
                }
                moveTopComponentIntoMode(targetMode, tcs[i] );                    
            }
        }
        // #51992 - end
    }
                                            
    if(editorAreaState == Constants.EDITOR_AREA_SEPARATED) {
        Rectangle editorAreaBounds = model.getEditorAreaBounds();
        // Adjust bounds if necessary.
        if(editorAreaBounds.isEmpty()) {
            model.setEditorAreaBounds(model.getEditorAreaBoundsHelp());
        }
        
        // Adjust bounds if necessary.
        Rectangle mainWindowBoundsSeparated = model.getMainWindowBoundsSeparated();
        if(mainWindowBoundsSeparated.isEmpty()) {
            model.setMainWindowBoundsSeparated(model.getMainWindowBoundsSeparatedHelp());
        }
    }
    
    model.setEditorAreaState(editorAreaState);
    
    if(isVisible()) {
        viewRequestor.scheduleRequest(
            new ViewRequest(null, View.CHANGE_EDITOR_AREA_STATE_CHANGED,
                    Integer.valueOf(old), Integer.valueOf(editorAreaState)));
    }
    
    WindowManagerImpl.getInstance().doFirePropertyChange(
        WindowManagerImpl.PROP_EDITOR_AREA_STATE, Integer.valueOf(old), Integer.valueOf(editorAreaState));
}
 
Example 18
Project: jdk8u-jdk   File: JLightweightFrame.java   View Source Code Vote up 4 votes
/**
 * Constructs a new, initially invisible {@code JLightweightFrame}
 * instance.
 */
public JLightweightFrame() {
    super();
    copyBufferEnabled = "true".equals(AccessController.
        doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true")));

    add(rootPane, BorderLayout.CENTER);
    setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
    if (getGraphicsConfiguration().isTranslucencyCapable()) {
        setBackground(new Color(0, 0, 0, 0));
    }

    layoutSizeListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent e) {
            Dimension d = (Dimension)e.getNewValue();

            if ("preferredSize".equals(e.getPropertyName())) {
                content.preferredSizeChanged(d.width, d.height);

            } else if ("maximumSize".equals(e.getPropertyName())) {
                content.maximumSizeChanged(d.width, d.height);

            } else if ("minimumSize".equals(e.getPropertyName())) {
                content.minimumSizeChanged(d.width, d.height);
            }
        }
    };

    repaintListener = (JComponent c, int x, int y, int w, int h) -> {
        Window jlf = SwingUtilities.getWindowAncestor(c);
        if (jlf != JLightweightFrame.this) {
            return;
        }
        Point p = SwingUtilities.convertPoint(c, x, y, jlf);
        Rectangle r = new Rectangle(p.x, p.y, w, h).intersection(
                new Rectangle(0, 0, bbImage.getWidth() / scaleFactor,
                              bbImage.getHeight() / scaleFactor));

        if (!r.isEmpty()) {
            notifyImageUpdated(r.x, r.y, r.width, r.height);
        }
    };

    SwingAccessor.getRepaintManagerAccessor().addRepaintListener(
        RepaintManager.currentManager(this), repaintListener);
}
 
Example 19
Project: Sikulix2tesseract   File: Tesseract.java   View Source Code Vote up 3 votes
/**
 * Sets image to be processed.
 *
 * @param xsize width of image
 * @param ysize height of image
 * @param buf pixel data
 * @param rect the bounding rectangle defines the region of the image to be
 * recognized. A rectangle of zero dimension or <code>null</code> indicates
 * the whole image.
 * @param bpp bits per pixel, represents the bit depth of the image, with 1
 * for binary bitmap, 8 for gray, and 24 for color RGB.
 */
protected void setImage(int xsize, int ysize, ByteBuffer buf, Rectangle rect, int bpp) {
    int bytespp = bpp / 8;
    int bytespl = (int) Math.ceil(xsize * bpp / 8.0);
    api.TessBaseAPISetImage(handle, buf, xsize, ysize, bytespp, bytespl);

    if (rect != null && !rect.isEmpty()) {
        api.TessBaseAPISetRectangle(handle, rect.x, rect.y, rect.width, rect.height);
    }
}
 
Example 20
Project: Sikulix2tesseract   File: Tesseract1.java   View Source Code Vote up 3 votes
/**
 * Sets image to be processed.
 *
 * @param xsize width of image
 * @param ysize height of image
 * @param buf pixel data
 * @param rect the bounding rectangle defines the region of the image to be
 * recognized. A rectangle of zero dimension or <code>null</code> indicates
 * the whole image.
 * @param bpp bits per pixel, represents the bit depth of the image, with 1
 * for binary bitmap, 8 for gray, and 24 for color RGB.
 */
protected void setImage(int xsize, int ysize, ByteBuffer buf, Rectangle rect, int bpp) {
    int bytespp = bpp / 8;
    int bytespl = (int) Math.ceil(xsize * bpp / 8.0);
    TessBaseAPISetImage(handle, buf, xsize, ysize, bytespp, bytespl);

    if (rect != null && !rect.isEmpty()) {
        TessBaseAPISetRectangle(handle, rect.x, rect.y, rect.width, rect.height);
    }
}