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


Java Shape类代码示例

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


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

示例1: createHexagonShape

import java.awt.Shape; //导入依赖的package包/类
/** Creates a hexagonal shape inscribed in the bounds given in the parameters. */
private Shape createHexagonShape(double x, double y, double width, double height) {
    GeneralPath result = new GeneralPath(Path2D.WIND_NON_ZERO, 5);
    double extend = height * NodeShape.HEX_EXTEND_RATIO;
    // stat at top left corner
    result.moveTo(x + extend, y);
    // to top right
    result.lineTo(x + width - extend, y);
    // to right
    result.lineTo(x + width, y + height / 2);
    // to bottom right
    result.lineTo(x + width - extend, y + height);
    // to bottom left
    result.lineTo(x + extend, y + height);
    // to left
    result.lineTo(x, y + height / 2);
    result.closePath();
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:20,代码来源:JVertexView.java

示例2: paint

import java.awt.Shape; //导入依赖的package包/类
/** This method is called by Swing to draw highlights. */
public void paint(Graphics gr, int start, int end, Shape shape, JTextComponent text) {
	Color old = gr.getColor();
	gr.setColor(color);
	try {
		Rectangle box = shape.getBounds(), a = text.getUI().modelToView(text, start),
				b = text.getUI().modelToView(text, end);
		if (a.y == b.y) {
			// same line (Note: furthermore, if start==end, then we draw all
			// the way to the right edge)
			Rectangle r = a.union(b);
			gr.fillRect(r.x, r.y, (r.width <= 1 ? (box.x + box.width - r.x) : r.width), r.height);
		} else {
			// Multiple lines; (Note: on first line we'll draw from "start"
			// and extend to rightmost)
			gr.fillRect(a.x, a.y, box.x + box.width - a.x, a.height);
			if (a.y + a.height < b.y)
				gr.fillRect(box.x, a.y + a.height, box.width, b.y - (a.y + a.height));
			gr.fillRect(box.x, b.y, b.x - box.x, b.height);
		}
	} catch (BadLocationException e) {} // Failure to highlight is not fatal
	gr.setColor(old);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:24,代码来源:OurHighlighter.java

示例3: setShape

import java.awt.Shape; //导入依赖的package包/类
/**
 * Creates the shape of the vertex given its description in a string
 * @param shapeString "square" or "circle"
 */
public void setShape(String shapeString) {
	Shape newShape;
	if (shapeString.startsWith("square")){
		Rectangle2D rectangle = new Rectangle2D.Float();
		rectangle.setFrameFromCenter(0,0,size,size);
		newShape = rectangle;
	}
	else
	{
		Ellipse2D ellipse = new Ellipse2D.Float();
		ellipse.setFrameFromCenter(0,0,size,size);
		newShape = ellipse; 
	}
	this.shape = newShape;
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:20,代码来源:Vertex.java

示例4: getMatchesList

import java.awt.Shape; //导入依赖的package包/类
private List<Shape> getMatchesList() {
    List<Shape> rMatches = new ArrayList<>();
    try {
        Iterator<?> it = getMatches();
        if (it != null) {
            Region sRegion = Region.create(shapes.get(0).getBounds());
            while (it.hasNext()) {
                Object region = it.next();
                Shape rx = ((Region) region).getRect();
                if (sRegion != null && sRegion.getRect().contains(rx.getBounds())) {
                    rMatches.add(rx);
                }
            }
        }

    } catch (FindFailed | IOException | NullPointerException ex) {
        Logger.getLogger(PropertyEditor.class.getName()).log(Level.SEVERE, null, ex);
    }
    return rMatches;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:21,代码来源:PropertyEditor.java

示例5: getPolyCoords

import java.awt.Shape; //导入依赖的package包/类
/**
 * Returns a string containing the coordinates for a given shape.  This
 * string is intended for use in an image map.
 *
 * @param shape  the shape (<code>null</code> not permitted).
 *
 * @return The coordinates for a given shape as string.
 */
private String getPolyCoords(Shape shape) {
    if (shape == null) {
        throw new IllegalArgumentException("Null 'shape' argument.");   
    }
    String result = "";
    boolean first = true;
    float[] coords = new float[6];
    PathIterator pi = shape.getPathIterator(null, 1.0);
    while (!pi.isDone()) {
        pi.currentSegment(coords);
        if (first) {
            first = false;
            result = result + (int) coords[0] + "," + (int) coords[1];
        }
        else {
            result = result + "," + (int) coords[0] + "," + (int) coords[1];
        }
        pi.next();
    }
    return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:ChartEntity.java

示例6: mapShape

import java.awt.Shape; //导入依赖的package包/类
public Shape mapShape(Shape s) {
    if (LOGMAP) LOG.format("mapshape on path: %s\n", LayoutPathImpl.SegmentPath.this);
    PathIterator pi = s.getPathIterator(null, 1); // cheap way to handle curves.

    if (LOGMAP) LOG.format("start\n");
    init();

    final double[] coords = new double[2];
    while (!pi.isDone()) {
        switch (pi.currentSegment(coords)) {
        case SEG_CLOSE: close(); break;
        case SEG_MOVETO: moveTo(coords[0], coords[1]); break;
        case SEG_LINETO: lineTo(coords[0], coords[1]); break;
        default: break;
        }

        pi.next();
    }
    if (LOGMAP) LOG.format("finish\n\n");

    GeneralPath gp = new GeneralPath();
    for (Segment seg: segments) {
        gp.append(seg.gp, false);
    }
    return gp;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:LayoutPathImpl.java

示例7: getRegiaoComentario

import java.awt.Shape; //导入依赖的package包/类
public Shape getRegiaoComentario() {
    if (Regiao == null) {

        GeneralPath pa = new GeneralPath();
        pa.setWindingRule(GeneralPath.WIND_NON_ZERO);

        Rectangle rec = getBounds();
        int tam = Math.min(rec.width / 6, rec.height / 6);
        int curv = tam / 4;
        int lw = rec.x + rec.width;
        int[] px = new int[]{rec.x, lw - tam, lw, lw, rec.x};
        int[] py = new int[]{rec.y, rec.y, rec.y + tam, rec.y + rec.height, rec.y + rec.height};
        Polygon po = new Polygon(px, py, 5);
        pa.append(po, true);
        pa.moveTo(lw - tam, rec.y);
        pa.curveTo(lw - tam, rec.y, lw - tam + curv, rec.y + curv, lw - tam, rec.y + tam - (1));
        pa.moveTo(lw - tam, rec.y + tam - (1));
        pa.lineTo(lw, rec.y + tam);
        pa.closePath();
        Regiao = pa;
    }
    return Regiao;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:24,代码来源:LivreBase.java

示例8: getRegiaoDocumento

import java.awt.Shape; //导入依赖的package包/类
public Shape getRegiaoDocumento() {
    if (Regiao == null) {
        final int v1 = getHeight() / 3;
        final int h1 = getWidth() / 2;
        final int repo = v1 / 3;
        final int L = getLeft();
        final int T = getTop();
        final int TH = T + getHeight() - repo;
        final int LW = L + getWidth();
        CubicCurve2D c = new CubicCurve2D.Double();
        c.setCurve(L, TH, L + h1, TH + v1, LW - h1, TH - v1, LW, TH);
        GeneralPath pa = new GeneralPath();

        pa.moveTo(LW, TH);
        pa.lineTo(LW, T);
        pa.lineTo(L, T);
        pa.lineTo(L, TH);
        pa.append(c, true);
        Regiao = pa;
        final int ptToMove = 3;
        this.reposicionePonto[ptToMove] = new Point(0, -repo);
        ptsToMove[ptToMove] = 1;
    }
    return Regiao;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:26,代码来源:LivreBase.java

示例9: getLegendItem

import java.awt.Shape; //导入依赖的package包/类
/**
 * Returns a legend item for a series.
 *
 * @param datasetIndex  the dataset index (zero-based).
 * @param series  the series index (zero-based).
 *
 * @return the legend item.
 */
public LegendItem getLegendItem(int datasetIndex, int series) {

    CategoryPlot cp = getPlot();
    if (cp == null) {
        return null;
    }

    CategoryDataset dataset;
    dataset = cp.getDataset(datasetIndex);
    String label = dataset.getRowKey(series).toString();
    String description = label;
    Shape shape = getSeriesShape(series);
    Paint paint = getSeriesPaint(series);
    Paint outlinePaint = getSeriesOutlinePaint(series);
    Stroke stroke = getSeriesStroke(series);

    return new LegendItem(
        label, description, shape, true, paint, stroke, outlinePaint, stroke
    );

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

示例10: Double

import java.awt.Shape; //导入依赖的package包/类
/**
 * Constructs a new double precision {@code Path2D} object
 * from an arbitrary {@link Shape} object, transformed by an
 * {@link AffineTransform} object.
 * All of the initial geometry and the winding rule for this path are
 * taken from the specified {@code Shape} object and transformed
 * by the specified {@code AffineTransform} object.
 *
 * @param s the specified {@code Shape} object
 * @param at the specified {@code AffineTransform} object
 * @since 1.6
 */
public Double(Shape s, AffineTransform at) {
    if (s instanceof Path2D) {
        Path2D p2d = (Path2D) s;
        setWindingRule(p2d.windingRule);
        this.numTypes = p2d.numTypes;
        this.pointTypes = Arrays.copyOf(p2d.pointTypes,
                                        p2d.pointTypes.length);
        this.numCoords = p2d.numCoords;
        this.doubleCoords = p2d.cloneCoordsDouble(at);
    } else {
        PathIterator pi = s.getPathIterator(at);
        setWindingRule(pi.getWindingRule());
        this.pointTypes = new byte[INIT_SIZE];
        this.doubleCoords = new double[INIT_SIZE * 2];
        append(pi, false);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:Path2D.java

示例11: createStrokedShape

import java.awt.Shape; //导入依赖的package包/类
public Shape createStrokedShape(Shape src,
                                float width,
                                int caps,
                                int join,
                                float miterlimit,
                                float dashes[],
                                float dashphase)
{
    System.out.println(name+".createStrokedShape("+
                       src.getClass().getName()+", "+
                       "width = "+width+", "+
                       "caps = "+caps+", "+
                       "join = "+join+", "+
                       "miter = "+miterlimit+", "+
                       "dashes = "+dashes+", "+
                       "dashphase = "+dashphase+")");
    return target.createStrokedShape(src,
                                     width, caps, join, miterlimit,
                                     dashes, dashphase);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:RenderingEngine.java

示例12: getBorder

import java.awt.Shape; //导入依赖的package包/类
public Shape getBorder(double size)
{
	AffineTransform at = new AffineTransform();
	at.translate(getVisualX(size), getVisualY(size));
	at.scale(size, size);
	return border.createTransformedShape(at);
}
 
开发者ID:Chroniaro,项目名称:What-Happened-to-Station-7,代码行数:8,代码来源:HexPoint.java

示例13: paintBorder

import java.awt.Shape; //导入依赖的package包/类
/**
 * Paints the border, with a given shape.
 */
private void paintBorder(Graphics2D g, Shape shape) {
    g.setColor(this.lineColor);
    g.setStroke(JAttr.createStroke(this.lineWidth, this.dash));
    g.draw(shape);
    if (this.twoLines) {
        g.setColor(this.line2color);
        g.setStroke(JAttr.createStroke(this.line2width, this.line2dash));
        g.draw(shape);
    }
    if (this.selected) {
        paintSelectionBorder(g, shape);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:17,代码来源:JVertexView.java

示例14: getOutline

import java.awt.Shape; //导入依赖的package包/类
public Shape getOutline(AffineTransform tx) {

        GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);

        for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
            TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];

            dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
        }

        if (tx != null) {
            dstShape.transform(tx);
        }
        return dstShape;
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:TextLine.java

示例15: saveState

import java.awt.Shape; //导入依赖的package包/类
/**
  * save graphics state of a PathGraphics for later redrawing
  * of part of page represented by the region in that state
  */

public void saveState(AffineTransform at, Shape clip,
                      Rectangle2D region, double sx, double sy) {
    GraphicsState gstate = new GraphicsState();
    gstate.theTransform = at;
    gstate.theClip = clip;
    gstate.region = region;
    gstate.sx = sx;
    gstate.sy = sy;
    redrawList.add(gstate);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:RasterPrinterJob.java


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