Java 类java.awt.Shape 实例源码

项目:JavaGraph    文件:JVertexView.java   
/** 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;
}
项目:org.alloytools.alloy    文件:OurHighlighter.java   
/** 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);
}
项目:cuttlefish    文件:Vertex.java   
/**
 * 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;
}
项目:Cognizant-Intelligent-Test-Scripter    文件:PropertyEditor.java   
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;
}
项目:parabuild-ci    文件:ChartEntity.java   
/**
 * 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;
}
项目:jdk8u-jdk    文件:LayoutPathImpl.java   
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;
}
项目:brModelo    文件:LivreBase.java   
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;
}
项目:brModelo    文件:LivreBase.java   
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;
}
项目:parabuild-ci    文件:AbstractCategoryItemRenderer.java   
/**
 * 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
    );

}
项目:OpenJSharp    文件:Path2D.java   
/**
 * 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);
    }
}
项目:jdk8u-jdk    文件:RenderingEngine.java   
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);
}
项目:What-Happened-to-Station-7    文件:HexPoint.java   
public Shape getBorder(double size)
{
    AffineTransform at = new AffineTransform();
    at.translate(getVisualX(size), getVisualY(size));
    at.scale(size, size);
    return border.createTransformedShape(at);
}
项目:JavaGraph    文件:JVertexView.java   
/**
 * 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);
    }
}
项目:jdk8u-jdk    文件:TextLine.java   
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;
    }
项目:jdk8u-jdk    文件:RasterPrinterJob.java   
/**
  * 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);
}
项目:jdk8u-jdk    文件:SunGraphics2D.java   
protected static Shape transformShape(AffineTransform tx, Shape clip) {
    if (clip == null) {
        return null;
    }

    if (clip instanceof Rectangle2D &&
        (tx.getType() & NON_RECTILINEAR_TRANSFORM_MASK) == 0)
    {
        Rectangle2D rect = (Rectangle2D) clip;
        double matrix[] = new double[4];
        matrix[0] = rect.getX();
        matrix[1] = rect.getY();
        matrix[2] = matrix[0] + rect.getWidth();
        matrix[3] = matrix[1] + rect.getHeight();
        tx.transform(matrix, 0, matrix, 0, 2);
        fixRectangleOrientation(matrix, rect);
        return new Rectangle2D.Double(matrix[0], matrix[1],
                                      matrix[2] - matrix[0],
                                      matrix[3] - matrix[1]);
    }

    if (tx.isIdentity()) {
        return cloneShape(clip);
    }

    return tx.createTransformedShape(clip);
}
项目:incubator-netbeans    文件:DocumentViewChildren.java   
Shape getChildAllocation(DocumentView docView, int index, Shape docViewAlloc) {
    Rectangle2D.Double mutableBounds = ViewUtils.shape2Bounds(docViewAlloc);
    double startYR = startVisualOffset(index); // relative i.e. not shifted by baseY
    double endYR = endVisualOffset(index); // relative i.e. not shifted by baseY
    mutableBounds.y += baseY + startYR;
    mutableBounds.height = endYR - startYR;
    // Leave mutableBounds.width
    return mutableBounds;
}
项目:openjdk-jdk10    文件:SunGraphics2D.java   
protected static Shape transformShape(AffineTransform tx, Shape clip) {
    if (clip == null) {
        return null;
    }

    if (clip instanceof Rectangle2D &&
        (tx.getType() & NON_RECTILINEAR_TRANSFORM_MASK) == 0)
    {
        Rectangle2D rect = (Rectangle2D) clip;
        double matrix[] = new double[4];
        matrix[0] = rect.getX();
        matrix[1] = rect.getY();
        matrix[2] = matrix[0] + rect.getWidth();
        matrix[3] = matrix[1] + rect.getHeight();
        tx.transform(matrix, 0, matrix, 0, 2);
        fixRectangleOrientation(matrix, rect);
        return new Rectangle2D.Double(matrix[0], matrix[1],
                                      matrix[2] - matrix[0],
                                      matrix[3] - matrix[1]);
    }

    if (tx.isIdentity()) {
        return cloneShape(clip);
    }

    return tx.createTransformedShape(clip);
}
项目:jdk8u-jdk    文件:TextMeasureTests.java   
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    Shape s;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            s = gv.getGlyphLogicalBounds(i);
        }
    } while (--numReps >= 0);
}
项目:WordnetLoom    文件:ViwnNodeCand.java   
@Override
public Shape getShape() {
    if (ext.isWeak()) {
        return geom.shape;
    } else {
        return super.getShape();
    }
}
项目:rapidminer    文件:RapidLookTools.java   
/**
 * Creates the default {@link Shape} for the given button.
 *
 * @param b
 *            the button to create the shape for
 * @return the shape instance
 */
public static Shape createShapeForButton(AbstractButton b) {
    int w = b.getWidth();
    int h = b.getHeight();

    return new RoundRectangle2D.Double(1, 1, w - 2, h - 2, RapidLookAndFeel.CORNER_DEFAULT_RADIUS,
            RapidLookAndFeel.CORNER_DEFAULT_RADIUS);
}
项目:Tarski    文件:mxHexagonShape.java   
/**
 * 
 */
public Shape createShape(mxGraphics2DCanvas canvas, mxCellState state) {
  Rectangle temp = state.getRectangle();
  int x = temp.x;
  int y = temp.y;
  int w = temp.width;
  int h = temp.height;
  String direction = mxUtils.getString(state.getStyle(), mxConstants.STYLE_DIRECTION,
      mxConstants.DIRECTION_EAST);
  Polygon hexagon = new Polygon();

  if (direction.equals(mxConstants.DIRECTION_NORTH)
      || direction.equals(mxConstants.DIRECTION_SOUTH)) {
    hexagon.addPoint(x + (int) (0.5 * w), y);
    hexagon.addPoint(x + w, y + (int) (0.25 * h));
    hexagon.addPoint(x + w, y + (int) (0.75 * h));
    hexagon.addPoint(x + (int) (0.5 * w), y + h);
    hexagon.addPoint(x, y + (int) (0.75 * h));
    hexagon.addPoint(x, y + (int) (0.25 * h));
  } else {
    hexagon.addPoint(x + (int) (0.25 * w), y);
    hexagon.addPoint(x + (int) (0.75 * w), y);
    hexagon.addPoint(x + w, y + (int) (0.5 * h));
    hexagon.addPoint(x + (int) (0.75 * w), y + h);
    hexagon.addPoint(x + (int) (0.25 * w), y + h);
    hexagon.addPoint(x, y + (int) (0.5 * h));
  }

  return hexagon;
}
项目:OpenJSharp    文件:LoopPipe.java   
public void draw(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
        Path2D.Float p2df;
        int transX;
        int transY;
        if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
            if (s instanceof Path2D.Float) {
                p2df = (Path2D.Float)s;
            } else {
                p2df = new Path2D.Float(s);
            }
            transX = sg2d.transX;
            transY = sg2d.transY;
        } else {
            p2df = new Path2D.Float(s, sg2d.transform);
            transX = 0;
            transY = 0;
        }
        sg2d.loops.drawPathLoop.DrawPath(sg2d, sg2d.getSurfaceData(),
                                         transX, transY, p2df);
        return;
    }

    if (sg2d.strokeState == SunGraphics2D.STROKE_CUSTOM) {
        fill(sg2d, sg2d.stroke.createStrokedShape(s));
        return;
    }

    ShapeSpanIterator sr = getStrokeSpans(sg2d, s);

    try {
        fillSpans(sg2d, sr);
    } finally {
        sr.dispose();
    }
}
项目:gemini.blueprint    文件:TypeFactoryTest.java   
@Test
public void testSuperList() throws Exception {
    ReifiedType tp = getReifiedTypeFor("superList");
    assertEquals(1, tp.size());
    assertEquals(LinkedList.class, tp.getRawClass());
    assertEquals(Shape.class, tp.getActualTypeArgument(0).getRawClass());
}
项目:parabuild-ci    文件:SWTGraphics2D.java   
/**
 * Converts an AWT <code>Shape</code> into a SWT <code>Path</code>.
 * 
 * @param shape  the shape.
 * 
 * @return The path.
 */
private Path toSwtPath(Shape shape) {
    int type;
    float[] coords = new float[6];
    Path path = new Path(this.gc.getDevice());
    PathIterator pit = shape.getPathIterator(null);
    while (!pit.isDone()) {
        type = pit.currentSegment(coords);
        switch (type) {
            case (PathIterator.SEG_MOVETO):
                path.moveTo(coords[0], coords[1]);
                break;
            case (PathIterator.SEG_LINETO):
                path.lineTo(coords[0], coords[1]);
                break;
            case (PathIterator.SEG_QUADTO):
                path.quadTo(coords[0], coords[1], coords[2], coords[3]);
                break;
            case (PathIterator.SEG_CUBICTO):
                path.cubicTo(coords[0], coords[1], coords[2], 
                        coords[3], coords[4], coords[5]);
                break;
            case (PathIterator.SEG_CLOSE):
                path.close();
                break;
            default:
                break;
        }
        pit.next();
    }
    return path;
}
项目:rapidminer    文件:SeriesFormat.java   
public static Shape createDiamond() {
    final float s = SHAPE_SIZE;
    double d = Math.round(Math.sqrt(2 * s * s) / 2.0);
    final GeneralPath p = new GeneralPath();
    p.moveTo(0, d);
    p.lineTo(d, 0);
    p.lineTo(0, -d);
    p.lineTo(-d, 0);
    p.closePath();
    return p;

    // final float s = shapeSize;
    // final float l = s / 4.0f;
    // final float t = s / 4.0f;
    //
    // final float SQRT2 = (float) Math.pow(2.0, 0.5);
    // final GeneralPath p0 = new GeneralPath();
    // p0.moveTo(-l - t, -l + t);
    // p0.lineTo(-l + t, -l - t);
    // p0.lineTo(0.0f, -t * SQRT2);
    // p0.lineTo(l - t, -l - t);
    // p0.lineTo(l + t, -l + t);
    // p0.lineTo(t * SQRT2, 0.0f);
    // p0.lineTo(l + t, l - t);
    // p0.lineTo(l - t, l + t);
    // p0.lineTo(0.0f, t * SQRT2);
    // p0.lineTo(-l + t, l + t);
    // p0.lineTo(-l - t, l - t);
    // p0.lineTo(-t * SQRT2, 0.0f);
    // p0.closePath();
    // return p0;
}
项目:jdk8u-jdk    文件:SunGraphics2D.java   
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);
}
项目:incubator-netbeans    文件:ViewHierarchyImpl.java   
public Shape modelToView(DocumentView docView, int offset, Position.Bias bias) {
    if (docView != null) {
        return docView.modelToViewNeedsLock(offset, docView.getAllocation(), bias);
    } else {
        TextUI ui = textComponent.getUI();
        try {
            return (ui != null) ? ui.modelToView(textComponent, offset, bias) : null;
        } catch (BadLocationException ex) {
            return null;
        }
    }
}
项目:parabuild-ci    文件:CategoryItemEntity.java   
/**
 * Creates a new category item entity.
 *
 * @param area  the area.
 * @param toolTipText  the tool tip text.
 * @param urlText  the URL text for HTML image maps.
 * @param dataset  the dataset.
 * @param series  the series (zero-based index).
 * @param category  the category.
 * @param categoryIndex  the category index.
 */
public CategoryItemEntity(Shape area, String toolTipText, String urlText,
                          CategoryDataset dataset,
                          int series, Object category, int categoryIndex) {

    super(area, toolTipText, urlText);
    this.dataset = dataset;
    this.series = series;
    this.category = category;
    this.categoryIndex = categoryIndex;

}
项目:parabuild-ci    文件:XYTextAnnotation.java   
/**
 * Draws the annotation.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param rendererIndex  the renderer index.
 * @param info  an optional info object that will be populated with
 *              entity information.
 */
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
                 ValueAxis domainAxis, ValueAxis rangeAxis, 
                 int rendererIndex,
                 PlotRenderingInfo info) {

    PlotOrientation orientation = plot.getOrientation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
            plot.getDomainAxisLocation(), orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
            plot.getRangeAxisLocation(), orientation);

    float anchorX = (float) domainAxis.valueToJava2D(
            this.x, dataArea, domainEdge);
    float anchorY = (float) rangeAxis.valueToJava2D(
            this.y, dataArea, rangeEdge);

    if (orientation == PlotOrientation.HORIZONTAL) {
        float tempAnchor = anchorX;
        anchorX = anchorY;
        anchorY = tempAnchor;
    }

    g2.setFont(getFont());
    g2.setPaint(getPaint());
    TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY,
            getTextAnchor(), getRotationAngle(), getRotationAnchor());
    Shape hotspot = TextUtilities.calculateRotatedStringBounds(
            getText(), g2, anchorX, anchorY, getTextAnchor(), 
            getRotationAngle(), getRotationAnchor());

    String toolTip = getToolTipText();
    String url = getURL();
    if (toolTip != null || url != null) {
        addEntity(info, hotspot, rendererIndex, toolTip, url);
    }

}
项目:incubator-netbeans    文件:DocumentView.java   
@Override
public void paint(Graphics2D g, Shape alloc, Rectangle clipBounds) {
    if (lock()) {
        try {
            checkDocumentLockedIfLogging();
            op.checkViewsInited();
            if (op.isActive()) {
                op.updateFontRenderContext(g, true); // Includes setting of rendering hints
                children.paint(this, g, alloc, clipBounds);
            }
        } finally {
            unlock();
        }
    }
}
项目:jdk8u-jdk    文件:StandardGlyphVector.java   
/**
 * Used by getOutline, getGlyphsOutline
 */
private Shape getGlyphsOutline(int start, int count, float x, float y) {
    setFRCTX();
    initPositions();

    GeneralPath result = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    for (int i = start, e = start + count, n = start * 2; i < e; ++i, n += 2) {
        float px = x + positions[n];
        float py = y + positions[n+1];

        getGlyphStrike(i).appendGlyphOutline(glyphs[i], result, px, py);
    }

    return result;
}
项目:incubator-netbeans    文件:EditorView.java   
/**
 * {@inheritDoc}
 */
@Override
public final Shape modelToView(int offset, Shape alloc, Position.Bias bias) throws BadLocationException {
    checkBounds(offset);
    checkBias(bias);
    if (alloc != null) {
        return modelToViewChecked(offset, alloc, bias);
    } else {
        return null;
    }
}
项目:rapidminer    文件:RenderFormatDelegate.java   
/**
 * Scales a shape according to the scaling factor for value (given by the sizeProvider if one
 * such exists). If no sizeProvider exists, the shape is returned unmodified.
 */
private Shape scaleShape(Shape shape, double scalingFactor) {
    // scale shape if necessary
    if (scalingFactor != 1) {
        AffineTransform t = new AffineTransform();
        t.scale(scalingFactor, scalingFactor);
        shape = t.createTransformedShape(shape);
    }
    return shape;
}
项目:OpenJSharp    文件:TextLayout.java   
/**
 * Returns a <code>Shape</code> representing the outline of this
 * <code>TextLayout</code>.
 * @param tx an optional {@link AffineTransform} to apply to the
 *     outline of this <code>TextLayout</code>.
 * @return a <code>Shape</code> that is the outline of this
 *     <code>TextLayout</code>.  This is in standard coordinates.
 */
public Shape getOutline(AffineTransform tx) {
    ensureCache();
    Shape result = textLine.getOutline(tx);
    LayoutPathImpl lp = textLine.getLayoutPath();
    if (lp != null) {
        result = lp.mapShape(result);
    }
    return result;
}
项目:OpenJSharp    文件:SunGraphics2D.java   
protected static Shape transformShape(AffineTransform tx, Shape clip) {
    if (clip == null) {
        return null;
    }

    if (clip instanceof Rectangle2D &&
        (tx.getType() & NON_RECTILINEAR_TRANSFORM_MASK) == 0)
    {
        Rectangle2D rect = (Rectangle2D) clip;
        double matrix[] = new double[4];
        matrix[0] = rect.getX();
        matrix[1] = rect.getY();
        matrix[2] = matrix[0] + rect.getWidth();
        matrix[3] = matrix[1] + rect.getHeight();
        tx.transform(matrix, 0, matrix, 0, 2);
        fixRectangleOrientation(matrix, rect);
        return new Rectangle2D.Double(matrix[0], matrix[1],
                                      matrix[2] - matrix[0],
                                      matrix[3] - matrix[1]);
    }

    if (tx.isIdentity()) {
        return cloneShape(clip);
    }

    return tx.createTransformedShape(clip);
}
项目:jdk8u-jdk    文件:TextMeasureTests.java   
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    Shape s;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            s = gv.getGlyphVisualBounds(i);
        }
    } while (--numReps >= 0);
}
项目:brModelo    文件:LivreBase.java   
public Shape getRegiaoLosanglo() {
    if (Regiao == null) {
        Rectangle r = new Rectangle(getLeft(), getTop(), getWidth(), getHeight()); //getBounds();
        Polygon los = new Polygon();
        los.addPoint(r.x, r.y + r.height / 2);
        los.addPoint(r.x + r.width / 2, r.y);
        los.addPoint(r.x + r.width, r.y + r.height / 2);
        los.addPoint(r.x + r.width / 2, r.y + r.height);

        Regiao = los;
    }
    return Regiao;
}
项目:openjdk-jdk10    文件:SpanShapeRenderer.java   
public void draw(SunGraphics2D sg, Shape s) {
    if (sg.stroke instanceof BasicStroke) {
        ShapeSpanIterator sr = LoopPipe.getStrokeSpans(sg, s);
        try {
            renderSpans(sg, sg.getCompClip(), s, sr);
        } finally {
            sr.dispose();
        }
    } else {
        fill(sg, sg.stroke.createStrokedShape(s));
    }
}
项目:brModelo    文件:EstadoAtividade.java   
@Override
public Shape getRegiao() {
    if (Regiao == null) {
        Regiao = new RoundRectangle2D.Float(getLeft(), getTop(), getWidth(), getHeight(), getWidth()/3, getHeight());
    }
    return Regiao;
}