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

The following are Jave code examples for showing how to use getY() 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: rapidminer   File: ScrollBarUI.java   View Source Code Vote up 6 votes
@Override
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
	int x = (int) trackBounds.getX();
	int y = (int) trackBounds.getY();
	int w = (int) trackBounds.getWidth();
	int h = (int) trackBounds.getHeight();

	g.setColor(Colors.SCROLLBAR_TRACK_BACKGROUND);
	g.fillRect(x - 1, y - 1, w + 2, h + 2);

	g.setColor(Colors.SCROLLBAR_TRACK_BORDER);
	if (this.scrollbar.getOrientation() == Adjustable.HORIZONTAL) {
		g.drawLine(x, y, x + w, y);
	} else {
		g.drawLine(x, y, x, y + h);
	}
}
 
Example 2
Project: rapidminer   File: ScrollBarUI.java   View Source Code Vote up 6 votes
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
	int x = (int) thumbBounds.getX();
	int y = (int) thumbBounds.getY();
	int w = (int) thumbBounds.getWidth();
	int h = (int) thumbBounds.getHeight();

	if (c.isEnabled() && w > 0 && h > 0) {
		if (this.scrollbar.getOrientation() == Adjustable.HORIZONTAL) {
			h -= 1;
			y++;
			drawHorizThumb(g, x, y, w, h);
		} else {
			w -= 1;
			x++;
			drawVertThumb(g, x, y, w, h);
		}
	}
}
 
Example 3
Project: rapidminer   File: AnnotationsDecorator.java   View Source Code Vote up 6 votes
/**
 * Makes sure the current editor height matches its content if the annotation was never resized.
 * If the annotation has been manually resized before, does nothing.
 *
 * @param anno
 *            the annotation currently in the editor
 */
private void updateEditorHeight(final WorkflowAnnotation anno) {
	if (anno.wasResized()) {
		return;
	}

	Rectangle bounds = editPane.getBounds();
	// height is either the pref height or the current height, depending on what is bigger
	int prefHeight;
	if (anno instanceof ProcessAnnotation) {
		prefHeight = (int) Math.max(getContentHeightOfEditor((int) bounds.getWidth()), bounds.getHeight());
	} else {
		prefHeight = Math.max(getContentHeightOfEditor((int) bounds.getWidth()), OperatorAnnotation.MIN_HEIGHT);
	}
	Rectangle newBounds = new Rectangle((int) bounds.getX(), (int) bounds.getY(), (int) bounds.getWidth(), prefHeight);
	if (!bounds.equals(newBounds)) {
		editPane.setBounds(newBounds);
		updateEditPanelPosition(newBounds, true);
		view.getModel().fireAnnotationMiscChanged(anno);
	}
}
 
Example 4
Project: text-position-detector   File: UniresolutionTextPositionDetector.java   View Source Code Vote up 6 votes
private static int[] getProjection(GrayImage edgeMap,
	Rectangle region, boolean horizontal) {

	int aMin = (int) (horizontal ? region.getY() : region.getX()),
		bMin = (int) (horizontal ? region.getX() : region.getY()),
		aLen = (int) (horizontal ? region.getHeight() : region.getWidth()),
		bLen = (int) (horizontal ? region.getWidth() : region.getHeight()),
		ind = 0;

	int[] res = new int[aLen];

	for (int a = aMin; a < aMin + aLen; ++a) {
		int total = 0;
		for (int b = bMin; b < bMin + bLen; ++b) {
			// TODO other possible strategy: counting edge pixels instead of
			//      taking their value into account
			total +=
				edgeMap.getValue(horizontal ? b : a, horizontal ? a : b);
		}
		res[ind] = total;
		++ind;
	}

	return res;
}
 
Example 5
Project: geomapapp   File: XMap.java   View Source Code Vote up 6 votes
/**
 * Not Implemented.
 */
public double[] getWESN() {
	double[] wesn = new double[4];
	Rectangle r = getVisibleRect();
	if(mapBorder != null) {
		r = mapBorder.getInteriorRectangle(this, r.x, r.y, r.width, r.height);
	}
	Point2D.Double pt = new Point2D.Double( r.getX(), r.getY() );
	pt = (Point2D.Double)proj.getRefXY( getScaledPoint(pt));
	wesn[0] = pt.x;
	wesn[3] = pt.y;
	pt = new Point2D.Double( r.getX()+r.getWidth(),
				 r.getY()+r.getHeight() );
	pt = (Point2D.Double)proj.getRefXY( getScaledPoint(pt));
	wesn[1] = pt.x;
	wesn[2] = pt.y;
	return wesn;
}
 
Example 6
Project: incubator-netbeans   File: DialogBoundsPreserver.java   View Source Code Vote up 5 votes
private boolean checkBounds(Rectangle r) {
    Rectangle[] screens = getScreenBounds();
    for (Rectangle screen : screens) {
        if (r.getX() >= screen.getX() && r.getY() >= screen.getY()
                && r.getX() + r.getWidth() < screen.getX() + screen.getWidth()
                && r.getY() + r.getHeight() < screen.getY() + screen.getHeight()) {
            return true;
        }
    }
    return false;
}
 
Example 7
Project: rapidminer   File: RadioButtonUI.java   View Source Code Vote up 5 votes
@Override
protected void paintFocus(Graphics g, Rectangle textRect, Dimension d) {
	int x = 0, y = 0, w = 0, h = 0;
	x = (int) textRect.getX() - 2;
	y = (int) textRect.getY();
	w = (int) textRect.getWidth() + 4;
	h = (int) textRect.getHeight();

	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
	g2.setColor(Colors.RADIOBUTTON_BORDER_FOCUS);
	g2.setStroke(DASHED_STROKE);
	g2.drawRect(x, y, w, h);
}
 
Example 8
Project: rapidminer   File: OverviewPanel.java   View Source Code Vote up 5 votes
@Override
protected void paintComponent(Graphics graphics) {
	super.paintComponent(graphics);
	double scaleX = (double) getWidth() / (double) processRenderer.getWidth();
	double scaleY = (double) getHeight() / (double) processRenderer.getHeight();
	scale = Math.min(scaleX, scaleY);
	double scaledW = processRenderer.getWidth() * scale;
	double scaledH = processRenderer.getHeight() * scale;

	Graphics2D g = (Graphics2D) graphics.create();
	g.translate((getWidth() - scaledW) / 2d, (getHeight() - scaledH) / 2d);
	g.scale(scale, scale);

	g.setRenderingHints(ProcessDrawer.LOW_QUALITY_HINTS);
	processRenderer.getOverviewPanelDrawer().draw(g, true);

	g.setStroke(new BasicStroke((int) (1d / scale)));

	Rectangle visibleRect = processRenderer.getVisibleRect();
	Rectangle drawRect = new Rectangle((int) visibleRect.getX(), (int) visibleRect.getY(),
			(int) visibleRect.getWidth() - 1, (int) visibleRect.getHeight() - 1);

	g.setColor(FILL_COLOR);
	g.fill(drawRect);

	g.setColor(DRAW_COLOR);
	g.draw(drawRect);

	g.dispose();
}
 
Example 9
Project: dracoon-dropzone   File: ScreenModel.java   View Source Code Vote up 5 votes
public ScreenModel(GraphicsDevice device, String name, int number) {
	this.name = number + " " + name;
	this.idString = device.getIDstring();
	this.width = device.getDisplayMode().getWidth();
	this.height = device.getDisplayMode().getHeight();

	GraphicsConfiguration[] gc = device.getConfigurations();
	for (GraphicsConfiguration curGc : gc) {
		Rectangle bounds = curGc.getBounds();
		this.topLeftCorner = new Point((int) bounds.getX(), (int) bounds.getY());
	}

}
 
Example 10
Project: Logisim   File: CanvasPane.java   View Source Code Vote up 5 votes
@Override
public void propertyChange(PropertyChangeEvent e) {
	String prop = e.getPropertyName();
	if (prop.equals(ZoomModel.ZOOM)) {
		// mouse point
		Point point = getMousePosition(true);
		double oldZoom = ((Double) e.getOldValue()).doubleValue();
		Rectangle r = getViewport().getViewRect();
		double cx = (r.getX() + r.getWidth() / 2) / oldZoom;
		double cy = (r.getY() + r.getHeight() / 2) / oldZoom;

		double newZoom = ((Double) e.getNewValue()).doubleValue();
		r = getViewport().getViewRect();
		if (point != null) {// mouse is pointing something
			int newX = (int) Math
					.round(r.getX() / oldZoom * newZoom + point.getX() / oldZoom * newZoom - point.getX());
			int newY = (int) Math
					.round(r.getY() / oldZoom * newZoom + point.getY() / oldZoom * newZoom - point.getY());
			getHorizontalScrollBar().setValue(newX);
			getVerticalScrollBar().setValue(newY);
		} else {// mouse is outside from canvas panel
			int hv = (int) (cx * newZoom - r.getWidth() / 2);
			int vv = (int) (cy * newZoom - r.getHeight() / 2);
			getHorizontalScrollBar().setValue(hv);
			getVerticalScrollBar().setValue(vv);
		}
		contents.recomputeSize();
	}
}
 
Example 11
Project: openjdk-jdk10   File: JTreeOperator.java   View Source Code Vote up 5 votes
/**
 * Retuns points which can be used to click on path.
 *
 * @param path a tree path to click on.
 * @return a Point in component's coordinate system.
 */
public Point getPointToClick(TreePath path) {
    if (path != null) {
        Rectangle rect = getPathBounds(path);
        if (rect != null) {
            return (new Point((int) (rect.getX() + rect.getWidth() / 2),
                    (int) (rect.getY() + rect.getHeight() / 2)));
        } else {
            throw (new NoSuchPathException(path));
        }
    } else {
        throw (new NoSuchPathException());
    }
}
 
Example 12
Project: openjdk-jdk10   File: JTreeOperator.java   View Source Code Vote up 5 votes
/**
 * Retuns points which can be used to click on path.
 *
 * @param row a row index to click on.
 * @return a Point in component's coordinate system.
 */
public Point getPointToClick(int row) {
    Rectangle rect = getRowBounds(row);
    if (rect != null) {
        return (new Point((int) (rect.getX() + rect.getWidth() / 2),
                (int) (rect.getY() + rect.getHeight() / 2)));
    } else {
        throw (new NoSuchPathException(row));
    }
}
 
Example 13
Project: geomapapp   File: XMap.java   View Source Code Vote up 5 votes
/**
 * Gets the region currently displayed in Projection coordinates.
 * @return the region currently displayed in Projection coordinates.
 */
public Rectangle2D getClipRect2D() {
	Rectangle r = getVisibleRect();
	Dimension dim = getPreferredSize();
	r.width = Math.min(r.width, dim.width);
	r.height = Math.min(r.height, dim.height);
	AffineTransform at = new AffineTransform();
	if(rotation==1) {
		at.translate( 0., dim.getHeight() );
		at.rotate(-.5*Math.PI);
	} else if( rotation==2 ) {
		at.translate( dim.getWidth(), dim.getHeight() );
		at.rotate( Math.PI );
	} else if( rotation == 3) {
		at.translate( dim.getWidth(), 0. );
		at.rotate( .5*Math.PI );
	}
	if(rotation != 0) {
		Point2D p1 = at.transform(new Point(r.x,r.y), null);
		Point2D p2 = at.transform(new Point(r.x+r.width,r.y+r.width), null);
		r.x = (int) Math.min(p1.getX(), p2.getX());
		r.width = (int) Math.max(p1.getX(), p2.getX()) - r.x;
		r.y = (int) Math.min(p1.getY(), p2.getY());
		r.height = (int) Math.max(p1.getY(), p2.getY()) - r.y;
	}

	if(mapBorder != null) {
		Insets ins = mapBorder.getBorderInsets(this);
		r.width -= ins.left + ins.right;
		r.height -= ins.top + ins.bottom;
	}
	Rectangle2D.Double r2d = new Rectangle2D.Double(
			r.getX()/zoom, r.getY()/zoom,
			r.getWidth()/zoom, r.getHeight()/zoom);
	return r2d;
}
 
Example 14
Project: ramus   File: HTMLPrintable.java   View Source Code Vote up 4 votes
private boolean printView(final Graphics2D graphics2D,
                          final Shape allocation, final View view) {
    boolean pageExists = false;
    final Rectangle clipRectangle = new Rectangle(0, 0, (int) (pageFormat
            .getImageableWidth() / SCALE), (int) clientHeight);
    Shape childAllocation;
    View childView;

    if (view.getViewCount() > 0) {
        for (int i = 0; i < view.getViewCount(); i++) {
            childAllocation = view.getChildAllocation(i, allocation);
            if (childAllocation != null) {
                childView = view.getView(i);
                if (printView(graphics2D, childAllocation, childView)) {
                    pageExists = true;
                }
            }
        }
    } else {
        if (allocation.getBounds().getMaxY() >= clipRectangle.getY()) {

            if (allocation.getBounds().getHeight() > clipRectangle
                    .getHeight()
                    && allocation.intersects(clipRectangle)) {
                paintView(graphics2D, view, allocation);
                pageExists = true;
            } else {
                if (allocation.getBounds().getY() >= clipRectangle.getY()) {
                    if (allocation.getBounds().getMaxY() <= clipRectangle
                            .getMaxY()) {
                        paintView(graphics2D, view, allocation);
                        pageExists = true;

                    } else {
                        if (allocation.getBounds().getY() < pageEndY) {
                            pageEndY = allocation.getBounds().getY();
                        }
                    }
                }
            }
        }
    }
    return pageExists;
}
 
Example 15
Project: powertext   File: RSyntaxTextArea.java   View Source Code Vote up 4 votes
/**
 * If the caret is on a bracket, this method finds the matching bracket,
 * and if it exists, highlights it.
 */
protected final void doBracketMatching() {

	// We always need to repaint the "matched bracket" highlight if it
	// exists.
	if (match!=null) {
		repaint(match);
		if (dotRect!=null) {
			repaint(dotRect);
		}
	}

	// If a matching bracket is found, get its bounds and paint it!
	int lastCaretBracketPos = bracketInfo==null ? -1 : bracketInfo.x;
	bracketInfo = RSyntaxUtilities.getMatchingBracketPosition(this,
			bracketInfo);
	if (bracketInfo.y>-1 &&
			(bracketInfo.y!=lastBracketMatchPos ||
			 bracketInfo.x!=lastCaretBracketPos)) {
		try {
			match = modelToView(bracketInfo.y);
			if (match!=null) { // Happens if we're not yet visible
				if (getPaintMatchedBracketPair()) {
					dotRect = modelToView(bracketInfo.x);
				}
				else {
					dotRect = null;
				}
				if (getAnimateBracketMatching()) {
					bracketRepaintTimer.restart();
				}
				repaint(match);
				if (dotRect!=null) {
					repaint(dotRect);
				}

				if (getShowMatchedBracketPopup()) {
					Container parent = getParent();
					if (parent instanceof JViewport) {
						Rectangle visibleRect = this.getVisibleRect();
						if (match.y + match.height < visibleRect.getY()) {
							if (matchedBracketPopupTimer == null) {
								matchedBracketPopupTimer =
										new MatchedBracketPopupTimer();
							}
							matchedBracketPopupTimer.restart(bracketInfo.y);
						}
					}
				}

			}
		} catch (BadLocationException ble) {
			ble.printStackTrace(); // Shouldn't happen.
		}
	}
	else if (bracketInfo.y==-1) {
		// Set match to null so the old value isn't still repainted.
		match = null;
		dotRect = null;
		bracketRepaintTimer.stop();
	}
	lastBracketMatchPos = bracketInfo.y;

}
 
Example 16
Project: Java-Swing-Helper   File: SwingWindow.java   View Source Code Vote up 4 votes
/**
 * Run the render method of the given component.
 * 
 * @param comp
 */
private void doRender(Component comp) {
	if (rendered.contains(System.identityHashCode(comp))) {
		return;
	}
	rendered.add(System.identityHashCode(comp));
	if (comp instanceof Container) {
		Container cont = (Container) comp;
		for (Component comp2 : cont.getComponents()) {
			doRender(comp2);
		}
	}

	float[] scale = getScalef();

	Component originalComponent = null;
	try {
		originalComponent = deserializeObject(JComponent.class, originalComps.get(System.identityHashCode(comp)));
	} catch (ClassNotFoundException | IOException e) {
		e.printStackTrace();
	}

	if (originalComponent != null) {
		// Bounds
		if (isWindowOptionEnabled(WindowOptions.SCALE_COMPONENTS)) {
			Rectangle original = originalComponent.getBounds();
			int newX = (int) (original.getX() * scale[0]);
			int newY = (int) (original.getY() * scale[1]);
			int newW = (int) (original.getWidth() * scale[0]);
			int newH = (int) (original.getHeight() * scale[1]);
			comp.setBounds(newX, newY, newW, newH);
		}

		// Fonts
		if (isWindowOptionEnabled(WindowOptions.SCALE_FONTS)) {
			if (comp.getFont() != null && originalComponent.getFont() != null) {
				Font font = comp.getFont();
				Font newFont = font.deriveFont(font.getStyle(),
						getSuggestedFontSize(originalComponent.getFont().getSize()));
				comp.setFont(newFont);
			}
		}

		// Images
		if (isWindowOptionEnabled(WindowOptions.SCALE_IMAGES)) {
			if (comp instanceof JLabel) {
				JLabel label = (JLabel) comp;
				JLabel orig = (JLabel) originalComponent;
				label.setIcon(getScaledImageIcon(orig));
			}
		}
	}
}
 
Example 17
Project: text-position-detector   File: UniresolutionTextPositionDetector.java   View Source Code Vote up 4 votes
private static List<Rectangle> mergeSubRegions(List<Rectangle> subRegions,
	boolean horizontal, boolean wasHorizontalIndivisible) {

	List<Rectangle> res = new LinkedList<>();

	boolean mergeProgresses;

	// merge regions with negligible holes
	Rectangle previousSubRegion = null, currentSubRegion = null;
	for (Rectangle subRegion : subRegions) {

		mergeProgresses = false;
		currentSubRegion = subRegion;

		if (previousSubRegion != null) {
			if (horizontal) {
				if (subRegion.getY() - (previousSubRegion.getY()
						+ previousSubRegion.getHeight())
					<= HORIZONTAL_MERGEABLE_HOLE_SIZE) {

					mergeProgresses = true;
				}
			} else {

				double valleyWidth =
					subRegion.getX() - (previousSubRegion.getX()
					+ previousSubRegion.getWidth());
				double subRegionHeight = subRegion.getHeight();

				if (valleyWidth <= VERTICAL_MERGEABLE_HOLE_SIZE
					|| (wasHorizontalIndivisible
						&& subRegionHeight >= MIN_FONT_SIZE
						&& subRegionHeight <= MAX_FONT_SIZE
						&& valleyWidth < 1.5 * MIN_CHAR_ASPECT_RATIO
							* subRegionHeight)) {

					mergeProgresses = true;
				}
			}
		}
		if (mergeProgresses) {
			previousSubRegion =
				previousSubRegion.union(subRegion);
			currentSubRegion = previousSubRegion;
		} else if (previousSubRegion != null) {
			res.add(previousSubRegion);
		}
		previousSubRegion = currentSubRegion;
	}
	if (previousSubRegion != null) {
		res.add(previousSubRegion);
	}

	return res;

}
 
Example 18
Project: geomapapp   File: GridComposer.java   View Source Code Vote up 4 votes
public static boolean getMask(Rectangle2D rect, 
			MapOverlay overlay) {
	double zoom = overlay.getXMap().getZoom();
	int res = 1;
	while(zoom > res) {
		res *=2;
	}
	res = Math.min(res, 512);

	int scale = res;
	int x = (int)Math.floor(scale*rect.getX());
	int y = (int)Math.floor(scale*(rect.getY()-260.));
	int width = (int)Math.ceil( scale*(rect.getX()+rect.getWidth()) ) - x;
	int height = (int)Math.ceil( scale*(rect.getY()-260.+rect.getHeight()) ) - y;

	Rectangle r0 = new Rectangle( 0, -260*scale, 640*scale,
			260*2*scale);

	if (width <= 0 || height <=0) return false;

	Projection proj = ProjectionFactory.getMercator( 320*2*res );
	Rectangle bounds = new Rectangle(x, y, width, height);
	if (bounds.width <= 0 || bounds.height <= 0)
		return false;

	int iRes = res;
	int nLevel = 0;
	while (iRes >= 8) {
		iRes /= 8;
		nLevel++;
	}

	Grid2D.Boolean grid = new Grid2D.Boolean( bounds, proj);
	TileIO.Boolean tileIO = new TileIO.Boolean( proj,
			base + "mask/m_" + res,
			320, nLevel);
	TiledMask tiler = new TiledMask( proj, 
					r0,
					tileIO,
					320,
					1,
					(TiledMask)null);
	tiler.setWrap( 320*2*res );
	System.out.println("Compose Mask: " + res);
	grid = (Grid2D.Boolean)tiler.composeGrid(grid);
	BufferedImage image = new BufferedImage( bounds.width,
			bounds.height, BufferedImage.TYPE_INT_ARGB);
	for( y=0 ; y<bounds.height ; y++) {
		for( x=0 ; x<bounds.width ; x++) {
			image.setRGB( x, y, 
				grid.booleanValue(x+bounds.x, y+bounds.y) ?
					0 : 0x80000000);
		}
	}
	Point2D p0 = new Point2D.Double(bounds.getX(), bounds.getY());
	XMap map = overlay.getXMap();
	p0 = map.getProjection().getMapXY( grid.getProjection().getRefXY(p0));
	Point2D p1 = new Point2D.Double(bounds.getX()+1., bounds.getY());
	p1 = map.getProjection().getMapXY( grid.getProjection().getRefXY(p1));
	double gridScale = p1.getX()<p0.getX() ?
		p1.getX()+map.getWrap()-p0.getX() :
		p1.getX() - p0.getX();
	overlay.setMaskImage(image, 
			p0.getX(),
			p0.getY(),
			gridScale);
//	overlay.setGrid(grid, land, hasLand, hasOcean);
	return true;
}
 
Example 19
Project: geomapapp   File: PoleMapServer.java   View Source Code Vote up 4 votes
public static boolean getMaskImage(Rectangle2D rect, MapOverlay overlay, int whichPole) {
	XMap map = overlay.getMap();
	double zoom = map.getZoom();
	int res = 1;
	while(zoom > res) {
		res *=2;
	}
	int scale = res;
	int x = (int)Math.floor(scale*(rect.getX() - 320));
	int y = (int)Math.floor(scale*(rect.getY() - 320));
	int width = (int)Math.ceil( scale*(rect.getX()-320+rect.getWidth()) ) - x;
	int height = (int)Math.ceil( scale*(rect.getY()-320+rect.getHeight()) ) - y;

	Rectangle r0 = new Rectangle( -320*scale, -320*scale, 640*scale,
			320*2*scale);

	if (width <= 0 || height <=0) return false;

	Projection proj = null;
	if (whichPole == 0)
		proj = new PolarStereo( new Point(0, 0),
				180., 25600. / res, -71.,
				PolarStereo.SOUTH, PolarStereo.WGS84);
	else
		proj = new PolarStereo( new Point(0, 0),
				0.,  25600. / res, 71.,
				PolarStereo.NORTH, PolarStereo.WGS84);
	
	Rectangle bounds = new Rectangle(x, y, width, height);
	if (bounds.width <= 0 || bounds.height <= 0)
		return false;

	int iRes = res;
	int nLevel = 0;
	while (iRes >= 8) {
		iRes /= 8;
		nLevel++;
	}

	Grid2D.Boolean grid = new Grid2D.Boolean( bounds, proj);
	TileIO.Boolean tileIO = new TileIO.Boolean( proj,
			base[whichPole] + "mask/m_" + res,
			320, nLevel);
	TiledMask tiler = new TiledMask( proj, 
					r0,
					tileIO,
					320,
					1,
					(TiledMask)null);

	grid = (Grid2D.Boolean)tiler.composeGrid(grid);
	BufferedImage image = new BufferedImage( bounds.width,
			bounds.height, BufferedImage.TYPE_INT_ARGB);
	for( y=0 ; y<bounds.height ; y++) {
		for( x=0 ; x<bounds.width ; x++) {
			image.setRGB( x, y, 
				grid.booleanValue(x+bounds.x, y+bounds.y) ?
					0 : 0x80000000);
		}
	}
	Point2D p0 = new Point2D.Double(bounds.getX(), bounds.getY());
	p0 = map.getProjection().getMapXY( grid.getProjection().getRefXY(p0));
	Point2D p1 = new Point2D.Double(bounds.getX()+1., bounds.getY());
	p1 = map.getProjection().getMapXY( grid.getProjection().getRefXY(p1));
	double gridScale = p1.getX()<p0.getX() ?
		p1.getX()+map.getWrap()-p0.getX() :
		p1.getX() - p0.getX();

	x += 320*scale;
	y += 320*scale;
	overlay.setMaskImage(image, 
			p0.getX(),
			p0.getY(),
			gridScale);
	return true;
}
 
Example 20
Project: openjdk-jdk10   File: JTableOperator.java   View Source Code Vote up 2 votes
/**
 * Returns a point at the center of the cell rectangle.
 *
 * @param row a row index
 * @param column a column index
 * @return a Point in component's coordinate system.
 */
public Point getPointToClick(int row, int column) {
    Rectangle rect = getCellRect(row, column, false);
    return (new Point((int) (rect.getX() + rect.getWidth() / 2),
            (int) (rect.getY() + rect.getHeight() / 2)));
}