本文整理汇总了Java中java.awt.Rectangle.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.isEmpty方法的具体用法?Java Rectangle.isEmpty怎么用?Java Rectangle.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Rectangle
的用法示例。
在下文中一共展示了Rectangle.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readTile
import java.awt.Rectangle; //导入方法依赖的package包/类
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;
}
示例2: readTile
import java.awt.Rectangle; //导入方法依赖的package包/类
@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;
}
示例3: readTile
import java.awt.Rectangle; //导入方法依赖的package包/类
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;
}
示例4: add
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* 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);
}
}
示例5: setShellNotResizable
import java.awt.Rectangle; //导入方法依赖的package包/类
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();
}
}
示例6: readTile
import java.awt.Rectangle; //导入方法依赖的package包/类
@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;
}
示例7: setData
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* 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);
}
}
示例8: repaintPeer
import java.awt.Rectangle; //导入方法依赖的package包/类
@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);
}
示例9: readTile
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
*
*/
@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;
}
示例10: setData
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* 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);
}
}
示例11: startWork
import java.awt.Rectangle; //导入方法依赖的package包/类
@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);
}
}
}
示例12: readTile
import java.awt.Rectangle; //导入方法依赖的package包/类
@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;
}
示例13: readTile
import java.awt.Rectangle; //导入方法依赖的package包/类
@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;
}
示例14: setEditorAreaState
import java.awt.Rectangle; //导入方法依赖的package包/类
/** 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));
}
示例15: JLightweightFrame
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* 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);
}