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


Java Rectangle2D.getHeight方法代码示例

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


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

示例1: getRowEnd

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Determines the ending row model position of the row that contains
 * the specified model position.  The component given must have a
 * size to compute the result.  If the component doesn't have a size
 * a value of -1 will be returned.
 *
 * @param c the editor
 * @param offs the offset in the document >= 0
 * @return the position >= 0 if the request can be computed, otherwise
 *  a value of -1 will be returned.
 * @exception BadLocationException if the offset is out of range
 */
@SuppressWarnings("deprecation")
public static final int getRowEnd(JTextComponent c, int offs) throws BadLocationException {
    Rectangle2D r = c.modelToView2D(offs);
    if (r == null) {
        return -1;
    }
    int n = c.getDocument().getLength();
    int lastOffs = offs;
    double y = r.getY();
    while ((r != null) && (y == r.getY())) {
        // Skip invisible elements
        if (r.getHeight() !=0) {
            offs = lastOffs;
        }
        lastOffs += 1;
        r = (lastOffs <= n) ? c.modelToView(lastOffs) : null;
    }
    return offs;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:Utilities.java

示例2: getGlyphInfo

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * For each glyph return posx, posy, advx, advy, visx, visy, visw, vish.
 */
public float[] getGlyphInfo() {
    setFRCTX();
    initPositions();
    float[] result = new float[glyphs.length * 8];
    for (int i = 0, n = 0; i < glyphs.length; ++i, n += 8) {
        float x = positions[i*2];
        float y = positions[i*2+1];
        result[n] = x;
        result[n+1] = y;

        int glyphID = glyphs[i];
        GlyphStrike s = getGlyphStrike(i);
        Point2D.Float adv = s.strike.getGlyphMetrics(glyphID);
        result[n+2] = adv.x;
        result[n+3] = adv.y;

        Rectangle2D vb = getGlyphVisualBounds(i).getBounds2D();
        result[n+4] = (float)(vb.getMinX());
        result[n+5] = (float)(vb.getMinY());
        result[n+6] = (float)(vb.getWidth());
        result[n+7] = (float)(vb.getHeight());
    }
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:StandardGlyphVector.java

示例3: calculateCategorySize

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Calculates the size (width or height, depending on the location of the axis) of a category.
 *
 * @param categoryCount  the number of categories.
 * @param area  the area within which the categories will be drawn.
 * @param edge  the axis location.
 *
 * @return the category size.
 */
protected double calculateCategorySize(int categoryCount, Rectangle2D area,
                                       RectangleEdge edge) {

    double result = 0.0;
    double available = 0.0;

    if ((edge == RectangleEdge.TOP) || (edge == RectangleEdge.BOTTOM)) {
        available = area.getWidth();
    }
    else if ((edge == RectangleEdge.LEFT) || (edge == RectangleEdge.RIGHT)) {
        available = area.getHeight();
    }
    if (categoryCount > 1) {
        result = available * (1 - getLowerMargin() - getUpperMargin() - getCategoryMargin());
        result = result / categoryCount;
    }
    else {
        result = available * (1 - getLowerMargin() - getUpperMargin());
    }
    return result;

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

示例4: leftShape

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private GeneralPath leftShape(Rectangle2D bounds) {

        double[] path0;
        if (isVerticalLine) {
            path0 = new double[] { bounds.getX(), bounds.getY(),
                                       bounds.getX() + bounds.getWidth(),
                                       bounds.getY() };
        } else {
            path0 = new double[] { bounds.getX(),
                                       bounds.getY() + bounds.getHeight(),
                                       bounds.getX(), bounds.getY() };
        }

        double[] path1 = getCaretPath(0, bounds, true);

        return boundingShape(path0, path1);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:TextLayout.java

示例5: 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

示例6: drawViewButton

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private RoundRectangle2D drawViewButton(double x, double y, Graphics2D g2d, boolean draw, boolean clicked) {
	Rectangle2D dvR;
	RoundRectangle2D dvRR;
	Color tmp;
	Color fg = Color.BLACK;
	Color bg = Color.LIGHT_GRAY;

	if (clicked) {
		tmp = fg;
		fg = bg;
		bg = tmp;
	}

	if (nCpu > 2) {
		fg = Color.DARK_GRAY.brighter().brighter();
		bg = Color.LIGHT_GRAY;
	}

	dvR = drawCenteredText("change view", fg, bg, x, y, g2d, false, false);
	dvRR = new RoundRectangle2D.Double(x, y, dvR.getWidth(), dvR.getHeight(), 5.0, 5.0);
	if (draw) {
		tmp = g2d.getColor();
		g2d.setColor(bg);
		g2d.fill(dvRR);
		g2d.setColor(fg);
		g2d.draw(dvRR);
		drawCenteredText("change view", fg, bg, x + dvR.getWidth() / 2.0, y + dvR.getHeight() / 2.0, g2d, false, true);
		g2d.setColor(tmp);
	}
	return dvRR;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:32,代码来源:QueueDrawer.java

示例7: drawLegend

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * drawing the legend
 * @param ca colors of the legend
 * @param sa comments respectivily
 * @param f font
 * @param x initial abscissa
 * @param y initial ordinate
 * @param g2d
 * @return panel size
 */
private double drawLegend(Color[] ca, String[] sa, Font f, double x, double y, Graphics2D g2d) {
	Rectangle2D[] ra = new Rectangle2D[ca.length];
	Rectangle2D[] tba = new Rectangle2D[ca.length];
	double maxw = 0.0, gap = 5.0;
	String ts = "Legenda";
	//backup
	Color ctmp = g2d.getColor();
	Font ftmp = g2d.getFont();

	g2d.setFont(f);
	Rectangle2D tr = f.getStringBounds(ts, g2d.getFontRenderContext());
	maxw = tr.getWidth();
	for (int i = 0; i < ca.length; i++) {
		tba[i] = f.getStringBounds(sa[i], g2d.getFontRenderContext());
		ra[i] = new Rectangle2D.Double(x + gap, y + gap + (tr.getHeight() + gap) * (i + 1), tr.getHeight(), tr.getHeight());
		g2d.setColor(ca[i]);
		g2d.fill(ra[i]);
		g2d.setColor(Color.BLACK);
		g2d.draw(ra[i]);
		g2d.drawString(sa[i], (float) (x + gap * 2 + tr.getHeight()),
				(float) (y + gap + (tr.getHeight() + gap) * (i + 1) + tr.getHeight() / 2.0 - tr.getY() / 2.0));
		if (maxw < tba[i].getWidth()) {
			maxw = tba[i].getWidth();
		}
	}
	g2d.drawRect((int) x, (int) y, (int) (maxw + 3.0 * gap + tr.getHeight()), (int) (y + (tr.getHeight() + gap) * (ca.length + 1) + gap));
	g2d.drawRect((int) x, (int) y, (int) (maxw + 3.0 * gap + tr.getHeight()), (int) (tr.getHeight() + gap));
	g2d.fillRect((int) x, (int) y, (int) (maxw + 3.0 * gap + tr.getHeight()), (int) (tr.getHeight() + gap));
	g2d.setColor(Color.WHITE);
	g2d.drawString(ts, (float) (x + gap + (maxw - tr.getWidth() + tr.getHeight()) / 2.0), (float) (y + tr.getY() / 2.0 + tr.getHeight()));

	//restore
	g2d.setFont(ftmp);
	g2d.setColor(ctmp);
	return (maxw + 3.0 * gap + tr.getHeight());

}
 
开发者ID:max6cn,项目名称:jmt,代码行数:48,代码来源:StatiDrawer.java

示例8: arrangeNN

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Performs the layout with no constraint, so the content size is 
 * determined by the bounds of the shape and/or line drawn to represent 
 * the series.
 * 
 * @param g2  the graphics device.
 * 
 * @return  The content size.
 */
protected Size2D arrangeNN(Graphics2D g2) {
    Rectangle2D contentSize = new Rectangle2D.Double();
    if (this.line != null) {
        contentSize.setRect(this.line.getBounds2D());
    }
    if (this.shape != null) {
        contentSize = contentSize.createUnion(this.shape.getBounds2D());
    }
    return new Size2D(contentSize.getWidth(), contentSize.getHeight());
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:LegendGraphic.java

示例9: calculateBarWidth

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Calculates the bar width and stores it in the renderer state.
 * 
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param rendererIndex  the renderer index.
 * @param state  the renderer state.
 */
protected void calculateBarWidth(CategoryPlot plot, 
                                 Rectangle2D dataArea, 
                                 int rendererIndex,
                                 CategoryItemRendererState state) {

    // calculate the bar width
    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    CategoryDataset dataset = plot.getDataset(rendererIndex);
    if (dataset != null) {
        int columns = dataset.getColumnCount();
        int rows = dataset.getRowCount();
        double space = 0.0;
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            space = dataArea.getHeight();
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            space = dataArea.getWidth();
        }
        double categoryMargin = 0.0;
        double currentItemMargin = 0.0;
        if (columns > 1) {
            categoryMargin = domainAxis.getCategoryMargin();
        }
        if (rows > 1) {
            currentItemMargin = getItemMargin();
        }
        double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin()
                                 - categoryMargin - currentItemMargin);
        if ((rows * columns) > 0) {
            state.setBarWidth(used / (dataset.getColumnCount()));
        } 
        else {
            state.setBarWidth(used);
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:46,代码来源:LayeredBarRenderer.java

示例10: 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

示例11: renderGraph

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
@Override
public void renderGraph(JGraph<?> graph, File file) throws PortException {
    // Get graph bounds. If not available, do nothing (probably empty graph)
    Rectangle2D bounds = graph.getGraphBounds();
    if (bounds == null) {
        return;
    }
    Rectangle bound = new Rectangle((float) bounds.getWidth(), (float) bounds.getHeight());

    try (FileOutputStream fos = new FileOutputStream(file)) {
        Document document = new Document(bound);
        // Open file, create PDF document
        PdfWriter writer = PdfWriter.getInstance(document, fos);
        // Set some metadata
        document.addCreator(Version.getAbout());

        // Open document, get graphics
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        boolean onlyShapes = true;
        //The embedded fonts most likely do not contain all necessary glyphs, so using outlines instead
        // onlyShapes makes PDF considerably bigger, but no alternative at the moment
        PdfGraphics2D pdf2d =
            new PdfGraphics2D(cb, (float) bounds.getWidth(), (float) bounds.getHeight(),
                new DefaultFontMapper(), onlyShapes, false, (float) 100.0);

        // Render
        toGraphics(graph, pdf2d);

        // Cleanup
        pdf2d.dispose();
        document.close();
    } catch (DocumentException | IOException e) {
        throw new PortException(e);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:37,代码来源:GraphToPDF.java

示例12: GraphEdge

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
/**
 * Construct an edge from "from" to "to" with the given arrow head settings,
 * then add the edge to the graph.
 */
GraphEdge(GraphNode from, GraphNode to, Object uuid, String label, boolean drawArrowHeadOnFrom,
		boolean drawArrowHeadOnTo, DotStyle style, Color color, Object group) {
	if (group instanceof GraphNode)
		throw new IllegalArgumentException("group cannot be a GraphNode");
	if (group instanceof GraphEdge)
		throw new IllegalArgumentException("group cannot be a GraphEdge");
	if (group == null) {
		group = new Object();
	}
	a = from;
	b = to;
	if (a.graph != b.graph)
		throw new IllegalArgumentException("You cannot draw an edge between two different graphs.");
	if (a == b) {
		a.selfs.add(this);
	} else {
		a.outs.add(this);
		b.ins.add(this);
	}
	a.graph.edgelist.add(this);
	this.uuid = uuid;
	this.group = group;
	this.label = (label == null) ? "" : label;
	this.ahead = drawArrowHeadOnFrom;
	this.bhead = drawArrowHeadOnTo;
	if (style != null)
		this.style = style;
	if (color != null)
		this.color = color;
	if (this.label.length() > 0) {
		Rectangle2D box = getBounds(false, label);
		labelbox = new AvailableSpace.Box(0, 0, (int) box.getWidth(), (int) box.getHeight());
	} else {
		labelbox = new AvailableSpace.Box(0, 0, 0, 0);
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:41,代码来源:GraphEdge.java

示例13: drawToolTip

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private void drawToolTip(Graphics2D g) {
	if (currentToolTip != null) {
		g.setFont(LABEL_FONT);
		Rectangle2D stringBounds = LABEL_FONT.getStringBounds(currentToolTip, g.getFontRenderContext());
		g.setColor(TOOLTIP_COLOR);
		Rectangle2D bg = new Rectangle2D.Double(toolTipX - stringBounds.getWidth() / 2 - 4, toolTipY
				- stringBounds.getHeight() / 2 - 2, stringBounds.getWidth() + 5, Math.abs(stringBounds.getHeight()) + 3);
		g.fill(bg);
		g.setColor(Color.black);
		g.draw(bg);
		g.drawString(currentToolTip, (float) (toolTipX - stringBounds.getWidth() / 2) - 2, (float) (toolTipY + 3));
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:BoundDiagram.java

示例14: toString

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public static String toString(Rectangle2D r) {
    return "XYWH[" + r.getX() + ';' + r.getY() + ';' + r.getWidth() + ';' + r.getHeight() + ']'; // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:ViewUtils.java

示例15: getScaleY

import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public double getScaleY() {
    Rectangle2D rect = getRectangle();
    return (rect.getHeight() + getAddSize().getHeight()) / rect.getHeight();
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:5,代码来源:Group.java


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