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


Java Rectangle2D.getY方法代码示例

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


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

示例1: getRectCoords

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Returns a string containing the coordinates (x1, y1, x2, y2) for a given
 * rectangle.  This string is intended for use in an image map.
 *
 * @param rectangle  the rectangle (<code>null</code> not permitted).
 *
 * @return Upper left and lower right corner of a rectangle.
 */
private String getRectCoords(Rectangle2D rectangle) {
    if (rectangle == null) {
        throw new IllegalArgumentException("Null 'rectangle' argument.");   
    }
    int x1 = (int) rectangle.getX();
    int y1 = (int) rectangle.getY();
    int x2 = x1 + (int) rectangle.getWidth();
    int y2 = y1 + (int) rectangle.getHeight();
    //      fix by rfuller
    if (x2 == x1) {
        x2++;
    }
    if (y2 == y1) {
        y2++;
    }
    //      end fix by rfuller
    
    return x1 + "," + y1 + "," + x2 + "," + y2;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:ChartEntity.java

示例2: paint

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Paint the glyphs for the given view.  This is implemented
 * to only render if the Graphics is of type Graphics2D which
 * is required by TextLayout (and this should be the case if
 * running on the JDK).
 */
public void paint(GlyphView v, Graphics g, Shape a, int p0, int p1) {
    if (g instanceof Graphics2D) {
        Rectangle2D alloc = a.getBounds2D();
        Graphics2D g2d = (Graphics2D)g;
        float y = (float) alloc.getY() + layout.getAscent() + layout.getLeading();
        float x = (float) alloc.getX();
        if( p0 > v.getStartOffset() || p1 < v.getEndOffset() ) {
            try {
                //TextLayout can't render only part of it's range, so if a
                //partial range is required, add a clip region.
                Shape s = v.modelToView(p0, Position.Bias.Forward,
                                        p1, Position.Bias.Backward, a);
                Shape savedClip = g.getClip();
                g2d.clip(s);
                layout.draw(g2d, x, y);
                g.setClip(savedClip);
            } catch (BadLocationException e) {}
        } else {
            layout.draw(g2d, x, y);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:GlyphPainter2.java

示例3: paint

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
@Override
public void paint(Graphics g) {

    if (component == null) {
        return;
    }

    int dot = getDot();
    Rectangle2D r = null;
    try {
        r = component.modelToView2D(dot);
    } catch (BadLocationException e) {
        return;
    }

    if (r == null) {
        return;
    }

    Rectangle2D cr = getCaretRectangle(r);
    repaint(cr.getBounds());

    g.setColor(component.getCaretColor());
    float cx = (float) cr.getX();
    float cy = (float) cr.getY();
    float cw = (float) cr.getWidth();
    float ch = (float) cr.getHeight();
    float c = cx + cw / 2;

    Graphics2D g2d = (Graphics2D) g;
    g2d.draw(new Line2D.Float(c, cy, c, cy + ch));
    g2d.draw(new Line2D.Float(cx, cy, cx + cw, cy));
    g2d.draw(new Line2D.Float(cx, cy + ch, cx + cw, cy + ch));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:CaretFloatingPointAPITest.java

示例4: setZoomHistoryPast

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public void setZoomHistoryPast(XMap mapSource) {
	Rectangle2D r = null;
	r = mapSource.getClipRect2D();
	Point2D.Double p2 = new Point2D.Double(
			r.getX()+.5*r.getWidth(),
			r.getY()+.5*r.getHeight() );
	p2 = (Point2D.Double)mapSource.getProjection().getRefXY(p2);

	double zoom = mapSource.getZoom();
	NumberFormat fmtZoom1 = NumberFormat.getInstance();
	fmtZoom1.setMinimumFractionDigits(1);
	fmtZoom1.format(zoom);
	// set zoom
	if (getZoomHistoryPast().contentEquals("0")) {
		pastZoom = "past, " + p2.getX() + ", " + p2.getY() + ", " + zoom;
		zoomActionTrack.selectAll();
		zoomActionTrack.replaceSelection(pastZoom);
		//System.out.println("jtext " + zoomActionTrack.getText());
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:21,代码来源:XMap.java

示例5: applyPathMargin

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
protected Rectangle2D applyPathMargin(final ICollisionEntity entity, final Rectangle2D rectangle) {
  // calculate offset in order to prevent collision
  final double newX = rectangle.getX() - (entity.getCollisionBox().getWidth() * 0.5 + PATH_MARGIN);
  final double newY = rectangle.getY() - (entity.getCollisionBox().getHeight() * 0.5 + PATH_MARGIN);
  final double newWidth = rectangle.getWidth() + entity.getCollisionBox().getWidth() + PATH_MARGIN * 2;
  final double newHeight = rectangle.getHeight() + entity.getCollisionBox().getHeight() + PATH_MARGIN * 2;
  return new Rectangle2D.Double(newX, newY, newWidth, newHeight);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:9,代码来源:PathFinder.java

示例6: saveEdit

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Saves the content of the comment editor as the new comment for the given
 * {@link WorkflowAnnotation}.
 *
 * @param selected
 *            the annotation for which the content of the editor pane should be saved as new
 *            comment
 */
private void saveEdit(final WorkflowAnnotation selected) {
	if (editPane == null) {
		return;
	}
	HTMLDocument document = (HTMLDocument) editPane.getDocument();
	StringWriter writer = new StringWriter();
	try {
		editPane.getEditorKit().write(writer, document, 0, document.getLength());
	} catch (IndexOutOfBoundsException | IOException | BadLocationException e1) {
		// should not happen
		LogService.getRoot().log(Level.WARNING,
				"com.rapidminer.gui.flow.processrendering.annotations.AnnotationsDecorator.cannot_save");
	}
	String comment = writer.toString();
	comment = AnnotationDrawUtils.removeStyleFromComment(comment);
	Rectangle2D loc = selected.getLocation();
	Rectangle2D newLoc = new Rectangle2D.Double(loc.getX(), loc.getY(), editPane.getBounds().getWidth(), editPane
			.getBounds().getHeight());
	selected.setLocation(newLoc);

	boolean overflowing = false;
	int prefHeight = AnnotationDrawUtils.getContentHeight(
			AnnotationDrawUtils.createStyledCommentString(comment, selected.getStyle()), (int) newLoc.getWidth());
	if (prefHeight > newLoc.getHeight()) {
		overflowing = true;
	}
	selected.setOverflowing(overflowing);

	model.setAnnotationComment(selected, comment);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:39,代码来源:AnnotationsDecorator.java

示例7: toRectangle

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Converts a {@link Rectangle2D} to a {@link Rectangle}.
 */
static public Rectangle toRectangle(Rectangle2D r) {
    if (r != null) {
        return new Rectangle((int) r.getX(), (int) r.getY(), (int) r.getWidth(),
            (int) r.getHeight());
    }
    return null;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:11,代码来源:Groove.java

示例8: handleGetVisualBounds

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public Rectangle2D handleGetVisualBounds() {

        Rectangle2D bounds = graphic.getBounds();

        float width = (float) bounds.getWidth() +
                                 graphicAdvance * (graphicCount-1);

        return new Rectangle2D.Float((float) bounds.getX(),
                                     (float) bounds.getY(),
                                     width,
                                     (float) bounds.getHeight());
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:GraphicComponent.java

示例9: fill

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public void fill(SunGraphics2D sg2d, Shape s) {
    if (s instanceof Rectangle2D) {
        Rectangle2D r2d = (Rectangle2D) s;
        double w = r2d.getWidth();
        double h = r2d.getHeight();
        if (w > 0 && h > 0) {
            double x = r2d.getX();
            double y = r2d.getY();
            fillRectangle(sg2d, x, y, w, h);
        }
        return;
    }

    outpipe.fill(sg2d, s);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:PixelToParallelogramConverter.java

示例10: version1RelativePos

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Calculates the relative position of a label from version 1 label position
 * info. The info is that both x and y of the label are given as permilles
 * of the vector.
 * @param label the version 1 label position info
 * @param points the list of points comprising the edge
 */
private static Point2D version1RelativePos(Point2D label, List<Point2D> points) {
    // we're trying to reconstruct the label position from the JGraph 5.2
    // method,
    // but at this point we don't have the view available which means we
    // don't
    // have precisely the same information
    Rectangle2D tmp = version1PaintBounds(points);
    int unit = GraphConstants.PERMILLE;
    Point2D p0 = points.get(0);
    Point2D p1 = points.get(1);
    Point2D pe = points.get(points.size() - 1);
    // Position is direction-dependent
    double x0 = tmp.getX();
    int xdir = 1;
    // take right bound if end point is to the right, or equal and first
    // slope directed left
    if (p0.getX() > pe.getX() || (p0.getX() == pe.getX() && p1.getX() > p0.getX())) {
        x0 += tmp.getWidth();
        xdir = -1;
    }
    double y0 = tmp.getY();
    int ydir = 1;
    // take lower bound if end point is below, or equal and first slope
    // directed up
    if (p0.getY() > pe.getY() || (p0.getY() == pe.getY() && p1.getY() > p0.getY())) {
        y0 += tmp.getHeight();
        ydir = -1;
    }
    double x = x0 + xdir * (tmp.getWidth() * label.getX() / unit);
    double y = y0 + ydir * (tmp.getHeight() * label.getY() / unit);
    return new Point2D.Double(x - p0.getX(), y - p0.getY());
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:40,代码来源:LayoutIO.java

示例11: getAdornBounds

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/** Returns the cell bounds including the parameter adornment, if any. */
private Rectangle2D getAdornBounds() {
    Rectangle2D result = null;
    String adornment = getCellVisuals().getAdornment();
    if (adornment != null) {
        result = getBounds();
        MyRenderer renderer =
            ((MyRenderer) getRendererComponent(this.jGraph, false, false, false));
        result = new Rectangle2D.Double(result.getX(), result.getY(), renderer.adornWidth,
            renderer.adornHeight);
    }
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:14,代码来源:JVertexView.java

示例12: TexturePaint

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Constructs a <code>TexturePaint</code> object.
 * @param txtr the <code>BufferedImage</code> object with the texture
 * used for painting
 * @param anchor the <code>Rectangle2D</code> in user space used to
 * anchor and replicate the texture
 */
public TexturePaint(BufferedImage txtr,
                    Rectangle2D anchor) {
    this.bufImg = txtr;
    this.tx = anchor.getX();
    this.ty = anchor.getY();
    this.sx = anchor.getWidth() / bufImg.getWidth();
    this.sy = anchor.getHeight() / bufImg.getHeight();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:TexturePaint.java

示例13: zoomTo

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Zooms and centres a given portion of the JGraph, as
 * defined by a certain rectangle.
 */
public void zoomTo(Rectangle2D bounds) {
    Rectangle2D viewBounds = getViewPortBounds();
    double widthScale = viewBounds.getWidth() / bounds.getWidth();
    double heightScale = viewBounds.getHeight() / bounds.getHeight();
    double scale = Math.min(widthScale, heightScale);
    double oldScale = getScale();
    setScale(oldScale * scale);
    int newX = (int) (bounds.getX() * scale);
    int newY = (int) (bounds.getY() * scale);
    int newWidth = (int) (scale * bounds.getWidth());
    int newHeight = (int) (scale * bounds.getHeight());
    Rectangle newBounds = new Rectangle(newX, newY, newWidth, newHeight);
    scrollRectToVisible(newBounds);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:19,代码来源:JGraph.java

示例14: getVisualBounds

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public Rectangle2D getVisualBounds(Label label) {

            Rectangle2D visBounds = label.handleGetVisualBounds();

            if (swapColors || bgPaint != null || strikethrough
                        || stdUnderline != null || imUnderline != null) {

                float minX = 0;
                Rectangle2D lb = label.getLogicalBounds();

                float minY = 0, maxY = 0;

                if (swapColors || bgPaint != null) {

                    minY = (float)lb.getY();
                    maxY = minY + (float)lb.getHeight();
                }

                maxY = Math.max(maxY, getUnderlineMaxY(label.getCoreMetrics()));

                Rectangle2D ab = new Rectangle2D.Float(minX, minY, (float)lb.getWidth(), maxY-minY);
                visBounds.add(ab);
            }

            return visBounds;
        }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:Decoration.java

示例15: plot

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
void plot( Graphics2D g,
			Rectangle2D bounds,
			double xScale, double yScale,
			int dataIndex) {
	if( data[dataIndex]==null) return;

	float x0 = (float)bounds.getX();
	float y0 = (float)bounds.getY();
	float x1 = x0;
	float x2 = x1+(float)bounds.getWidth();
	if(x1>x2) {
		x1 = x2;
		x2 = x0;
	}
	setXInterval(x1, x2);
	int i=0;
	while( i<x.length && x[i]<x1 ) {
		i++;
	}
	if( i!=0 && !Float.isNaN(data[dataIndex][i-1] )) i--;
	while( i<x.length && x[i]<x2 && Float.isNaN(data[dataIndex][i]) ) i++;
	if( i==x.length || x[i]>x2 ) {
		return;
	}
	currentRange[0] = i;
	GeneralPath path = new GeneralPath();
	float sy = (float)yScale;
	float sx = (float)xScale;
	path.moveTo( (x[i]-x0)*sx, (data[dataIndex][i]-y0)*sy);
	float lastX = x[i];
	while( i<x.length && x[i]<x2 ) {
		if( Float.isNaN(data[dataIndex][i])) {
			i++;
			continue;
		}
		//only plot the section of the track that is currently displayed on the map
		Point2D p = map.getProjection().getMapXY(lon[i], lat[i]);
		if (!inDisplayedMap(p)) {
			i++;
			continue;
		}
		if( !connect[i] || x[i]-lastX>25 ) {
			path.moveTo( (x[i]-x0)*sx, (data[dataIndex][i]-y0)*sy);
		} else {
			path.lineTo( (x[i]-x0)*sx, (data[dataIndex][i]-y0)*sy);
		}
		lastX = x[i];
		i++;
	}
	currentRange[1] = i--;
	g.draw( path );
	currentPoint = null;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:54,代码来源:MGGData.java


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