当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle2D.contains方法代码示例

本文整理汇总了Java中java.awt.geom.Rectangle2D.contains方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle2D.contains方法的具体用法?Java Rectangle2D.contains怎么用?Java Rectangle2D.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.geom.Rectangle2D的用法示例。


在下文中一共展示了Rectangle2D.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleClick

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Handles a 'click' on the plot by updating the anchor value.
 *
 * @param x  x-coordinate of the click (in Java2D space).
 * @param y  y-coordinate of the click (in Java2D space).
 * @param info  information about the plot's dimensions.
 *
 */
public void handleClick(int x, int y, PlotRenderingInfo info) {

    Rectangle2D dataArea = info.getDataArea();
    if (dataArea.contains(x, y)) {
        // set the anchor value for the range axis...
        double java2D = 0.0;
        if (this.orientation == PlotOrientation.HORIZONTAL) {
            java2D = x;
        }
        else if (this.orientation == PlotOrientation.VERTICAL) {
            java2D = y;
        }
        RectangleEdge edge = Plot.resolveRangeAxisLocation(
                getRangeAxisLocation(), this.orientation);
        double value = getRangeAxis().java2DToValue(
                java2D, info.getDataArea(), edge);
        setAnchorValue(value);
        setRangeCrosshairValue(value);
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:CategoryPlot.java

示例2: handleClick

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Handles a 'click' on the plot by updating the anchor values.
 *
 * @param x  the x-coordinate, where the click occurred, in Java2D space.
 * @param y  the y-coordinate, where the click occurred, in Java2D space.
 * @param info  object containing information about the plot dimensions.
 */
public void handleClick(int x, int y, PlotRenderingInfo info) {

    Rectangle2D dataArea = info.getDataArea();
    if (dataArea.contains(x, y)) {
        // set the anchor value for the horizontal axis...
        ValueAxis da = getDomainAxis();
        if (da != null) {
            double hvalue = da.java2DToValue(x, info.getDataArea(), 
                    getDomainAxisEdge());
            setDomainCrosshairValue(hvalue);
        }

        // set the anchor value for the vertical axis...
        ValueAxis ra = getRangeAxis();
        if (ra != null) {
            double vvalue = ra.java2DToValue(y, info.getDataArea(), 
                    getRangeAxisEdge());
            setRangeCrosshairValue(vvalue);
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:29,代码来源:XYPlot.java

示例3: updateTraceInfosIfPossible

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private void updateTraceInfosIfPossible(int dataOffset) {
    // Do we have a valid mainTraceInfo?
    if (this.mainTraceInfo.point == null) {
        // Nope. Returns early.
        return;
    }
    final int newDataIndex = dataOffset + this.mainTraceInfo.dataIndex;
    if (newDataIndex < 0) {
        // We try to offset beyond chart boundary. Returns early.
    }
    
    /* Try to get correct main chart area. */
    final ChartPanel chartPanel = this.chartJDialog.getChartPanel();
    final Rectangle2D _plotArea = chartPanel.getChartRenderingInfo().getPlotInfo().getSubplotInfo(0).getDataArea();

    final Point2D tmpPoint = this.getPoint(0, 0, newDataIndex);
    if (tmpPoint == null || _plotArea.contains(tmpPoint) == false) {
        return;
    }

    this.mainTraceInfo = TraceInfo.newInstance(tmpPoint, 0, 0, newDataIndex);
    this.updateTraceInfos();
}
 
开发者ID:lead4good,项目名称:open-java-trade-manager,代码行数:24,代码来源:ChartLayerUI.java

示例4: handleMousePressed

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Handles a mouse pressed event by recording the initial mouse pointer
 * location.
 * 
 * @param canvas  the JavaFX canvas ({@code null} not permitted).
 * @param e  the mouse event ({@code null} not permitted).
 */
@Override
public void handleMousePressed(ChartCanvas canvas, MouseEvent e) {
    Plot plot = canvas.getChart().getPlot();
    if (!(plot instanceof Pannable)) {
        canvas.clearLiveHandler();
        return;
    }
    Pannable pannable = (Pannable) plot;
    if (pannable.isDomainPannable() || pannable.isRangePannable()) {
        Point2D point = new Point2D.Double(e.getX(), e.getY());
        Rectangle2D dataArea = canvas.findDataArea(point);
        if (dataArea != null && dataArea.contains(point)) {
            this.panW = dataArea.getWidth();
            this.panH = dataArea.getHeight();
            this.panLast = point;
            canvas.setCursor(javafx.scene.Cursor.MOVE);
        }
    }
    // the actual panning occurs later in the mouseDragged() method
}
 
开发者ID:jfree,项目名称:jfreechart-fx,代码行数:28,代码来源:PanHandlerFX.java

示例5: handleClick

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Handles a 'click' on the plot by updating the anchor values...
 *
 * @param x  the x-coordinate, where the click occurred, in Java2D space.
 * @param y  the y-coordinate, where the click occurred, in Java2D space.
 * @param info  object containing information about the plot dimensions.
 */
public void handleClick(int x, int y, PlotRenderingInfo info) {

    Rectangle2D dataArea = info.getDataArea();
    if (dataArea.contains(x, y)) {
        // set the anchor value for the horizontal axis...
        ValueAxis da = getDomainAxis();
        if (da != null) {
            double hvalue = da.java2DToValue(x, info.getDataArea(), getDomainAxisEdge());

            setDomainCrosshairValue(hvalue);
        }

        // set the anchor value for the vertical axis...
        ValueAxis ra = getRangeAxis();
        if (ra != null) {
            double vvalue = ra.java2DToValue(y, info.getDataArea(), getRangeAxisEdge());
            setRangeCrosshairValue(vvalue);
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:XYPlot.java

示例6: handleClick

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Handles a 'click' on the plot by updating the anchor value.
 *
 * @param x  x-coordinate of the click (in Java2D space).
 * @param y  y-coordinate of the click (in Java2D space).
 * @param info  information about the plot's dimensions.
 *
 */
public void handleClick(int x, int y, PlotRenderingInfo info) {

    Rectangle2D dataArea = info.getDataArea();
    if (dataArea.contains(x, y)) {
        // set the anchor value for the range axis...
        double java2D = 0.0;
        if (this.orientation == PlotOrientation.HORIZONTAL) {
            java2D = x;
        }
        else if (this.orientation == PlotOrientation.VERTICAL) {
            java2D = y;
        }
        RectangleEdge edge = Plot.resolveRangeAxisLocation(getRangeAxisLocation(), 
                                                           this.orientation);
        double value = getRangeAxis().java2DToValue(java2D, info.getDataArea(), edge);
        setAnchorValue(value);
        setRangeCrosshairValue(value);
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:29,代码来源:CategoryPlot.java

示例7: mouseReleased

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public void mouseReleased(MouseEvent event) {
    if (getAction() != null ? getAction().isEnabled() : isEnabled()) {
        // do a hit test to make sure the mouse is being released inside the button
        Rectangle2D buttonRect = BorderlessImageToggleButton.this.getBounds();
        if (buttonRect.contains(event.getPoint())) {
            BorderlessImageToggleButton.this.setBackground(BorderlessUtility.ON_MOUSE_OVER_BACKGROUND);
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:BorderlessImageToggleButton.java

示例8: handleClick

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Handles a 'click' on the plot by updating the anchor values...
 *
 * @param x  x-coordinate, where the click occured.
 * @param y  y-coordinate, where the click occured.
 * @param info  object containing information about the plot dimensions.
 */
public void handleClick(int x, int y, PlotRenderingInfo info) {

    Rectangle2D dataArea = info.getDataArea();
    if (dataArea.contains(x, y)) {
        for (int i = 0; i < this.subplots.size(); i++) {
            XYPlot subplot = (XYPlot) this.subplots.get(i);
            PlotRenderingInfo subplotInfo = info.getSubplotInfo(i);
            subplot.handleClick(x, y, subplotInfo);
        }
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:CombinedRangeXYPlot.java

示例9: handleClick

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Handles a 'click' on the plot by updating the anchor value.
 *
 * @param x  x-coordinate of the click.
 * @param y  y-coordinate of the click.
 * @param info  information about the plot's dimensions.
 *
 */
public void handleClick(int x, int y, PlotRenderingInfo info) {

    Rectangle2D dataArea = info.getDataArea();
    if (dataArea.contains(x, y)) {
        for (int i = 0; i < this.subplots.size(); i++) {
            CategoryPlot subplot = (CategoryPlot) this.subplots.get(i);
            PlotRenderingInfo subplotInfo = info.getSubplotInfo(i);
            subplot.handleClick(x, y, subplotInfo);
        }
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:CombinedRangeCategoryPlot.java

示例10: selectLasso

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
	Selects the area represented by poly
*/	
void selectLasso(XYGraph xyg) {
	GeneralPath path = new GeneralPath();

	for (int i=0; i<poly.npoints; i++){
		Point2D p2 = new Point2D.Float (poly.xpoints[i], poly.ypoints[i]);
		Point2D point = new Point2D.Double (xyg.getXAt(p2), xyg.getYAt(p2));
		if (i==0) path.moveTo((float)point.getX(), (float) point.getY());
		else path.lineTo((float)point.getX(), (float) point.getY());
	}
	path.closePath();
	Rectangle2D r = path.getBounds();

	int n = 0;
	while (n<x.length&&(Float.isNaN(x[n])||Float.isNaN(y[n]))) {
		n++;
	}
	if (n>=x.length) return;
	
	table.getSelectionModel().setValueIsAdjusting(true);
	table.clearSelection();
	for (int i = n; i < x.length; i++) {
		if (Float.isNaN(x[i])||Float.isNaN(y[i])) continue;
		if (r.contains(x[i], y[i]) && path.contains(x[i], y[i])) {
			table.getSelectionModel().addSelectionInterval(i, i);
		}
	}
	table.getSelectionModel().setValueIsAdjusting(false);

	unDrawLasso(xyg);
	if (table.getSelectedRow() != -1)
		table.ensureIndexIsVisible(table.getSelectedRow());
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:36,代码来源:PDBDataSetGraph.java

示例11: handleClick

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Handles a 'click' on the plot.
 *
 * @param x  x-coordinate of the click.
 * @param y  y-coordinate of the click.
 * @param info  information about the plot's dimensions.
 *
 */
public void handleClick(int x, int y, PlotRenderingInfo info) {

    Rectangle2D dataArea = info.getDataArea();
    if (dataArea.contains(x, y)) {
        for (int i = 0; i < this.subplots.size(); i++) {
            CategoryPlot subplot = (CategoryPlot) this.subplots.get(i);
            PlotRenderingInfo subplotInfo = info.getSubplotInfo(i);
            subplot.handleClick(x, y, subplotInfo);
        }
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:CombinedDomainCategoryPlot.java

示例12: handleClick

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Handles a 'click' on the plot by updating the anchor values.
 *
 * @param x  x-coordinate, where the click occured.
 * @param y  y-coordinate, where the click occured.
 * @param info  object containing information about the plot dimensions.
 */
public void handleClick(int x, int y, PlotRenderingInfo info) {
    Rectangle2D dataArea = info.getDataArea();
    if (dataArea.contains(x, y)) {
        for (int i = 0; i < this.subplots.size(); i++) {
            XYPlot subplot = (XYPlot) this.subplots.get(i);
            PlotRenderingInfo subplotInfo = info.getSubplotInfo(i);
            subplot.handleClick(x, y, subplotInfo);
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:CombinedDomainXYPlot.java

示例13: intersectRectShape

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
Shape intersectRectShape(Rectangle2D r, Shape s,
                         boolean keep1, boolean keep2) {
    if (s instanceof Rectangle2D) {
        Rectangle2D r2 = (Rectangle2D) s;
        Rectangle2D outrect;
        if (!keep1) {
            outrect = r;
        } else if (!keep2) {
            outrect = r2;
        } else {
            outrect = new Rectangle2D.Float();
        }
        double x1 = Math.max(r.getX(), r2.getX());
        double x2 = Math.min(r.getX()  + r.getWidth(),
                             r2.getX() + r2.getWidth());
        double y1 = Math.max(r.getY(), r2.getY());
        double y2 = Math.min(r.getY()  + r.getHeight(),
                             r2.getY() + r2.getHeight());

        if (((x2 - x1) < 0) || ((y2 - y1) < 0))
            // Width or height is negative. No intersection.
            outrect.setFrameFromDiagonal(0, 0, 0, 0);
        else
            outrect.setFrameFromDiagonal(x1, y1, x2, y2);
        return outrect;
    }
    if (r.contains(s.getBounds2D())) {
        if (keep2) {
            s = cloneShape(s);
        }
        return s;
    }
    return intersectByArea(r, s, keep1, keep2);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:SunGraphics2D.java

示例14: selectLasso

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
		Selects the area represented by poly
	*/
	void selectLasso(XYGraph xyg) {
		GeneralPath path = new GeneralPath();

		for (int i=0; i<poly.npoints; i++){
			Point2D p2 = new Point2D.Float (poly.xpoints[i], poly.ypoints[i]);
			Point2D point = new Point2D.Double (xyg.getXAt(p2), xyg.getYAt(p2));
			if (i==0) path.moveTo((float)point.getX(), (float) point.getY());
			else path.lineTo((float)point.getX(), (float) point.getY());
		}
		path.closePath();
		Rectangle2D r = path.getBounds();

		ds.dataT.getSelectionModel().setValueIsAdjusting(true);
		if (scatter) {
			int n = 0;
			while (n<x.length&&(Float.isNaN(x[n])||Float.isNaN(y[n]))) {
				n++;
			}
			if (n>=x.length) return;
			for (int i = n; i < x.length; i++) {
				if (Float.isNaN(x[i])||Float.isNaN(y[i])) continue;
				if (r.contains(x[i], y[i]) && path.contains(x[i], y[i])) {
					ds.dataT.getSelectionModel().addSelectionInterval(i, i);
				}
			}
		}

		unDrawLasso(xyg);
//		selectionChangedRedraw(ds.selected);

		ds.dataT.getSelectionModel().setValueIsAdjusting(false);

		if (ds.dataT.getSelectedRow() != -1)
			ds.dataT.ensureIndexIsVisible(ds.dataT.getSelectedRow());
	}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:39,代码来源:DataSetGraph.java

示例15: getSubplotIndex

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Returns the index of the subplot that contains the specified
 * (x, y) point (the "source" point).  The source point will usually
 * come from a mouse click on a {@link org.jfree.chart.ChartPanel},
 * and this method is then used to determine the subplot that 
 * contains the source point.
 * 
 * @param source  the source point (in Java2D space).
 * 
 * @return The subplot index (or -1 if no subplot contains the point).
 */
public int getSubplotIndex(Point2D source) {
    int subplotCount = getSubplotCount();
    for (int i = 0; i < subplotCount; i++) {
        PlotRenderingInfo info = getSubplotInfo(i);
        Rectangle2D area = info.getDataArea();
        if (area.contains(source)) {
            return i;
        }
    }
    return -1;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:PlotRenderingInfo.java


注:本文中的java.awt.geom.Rectangle2D.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。