Java Code Examples for java.awt.Stroke#createStrokedShape()
The following examples show how to use
java.awt.Stroke#createStrokedShape() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShapeCreationUI.java From pumpernickel with MIT License | 6 votes |
/** * Return a Selection for a shape. This takes into account * <code>getStroke(scp, shapeIndex)</code> and should be consulted after * possible matches for handles have been ruled out. * * @param mouseLoc * an un-transformed mouse location (that is: this comes directly * from a MouseEvent and is relative to the ShapeCreationPanel's * coordinates). */ protected Selection getSelectedShape(ShapeCreationPanel scp, Point2D mouseLoc) { Shape[] shapes = scp.getDataModel().getShapes(); for (int shapeIndex = shapes.length - 1; shapeIndex >= 0; shapeIndex--) { Stroke stroke = getStroke(scp, shapeIndex); GeneralPath transformedShape = new GeneralPath(); transformedShape.append(shapes[shapeIndex], false); transformedShape.transform(scp.getTransform()); // If we invoke stroke.createStrokedShape on an invalid // shape the JVM might crash. The data model already put safeguards // in to help prevent this condition, but since this involves // crashing let's be doubly safe: if (!ShapeUtils.isValid(transformedShape)) { continue; } Shape strokedShape = stroke.createStrokedShape(transformedShape); if (strokedShape.intersects(mouseLoc.getX() - .5, mouseLoc.getY() - .5, 1, 1)) { return new Selection(shapeIndex, -1, null); } } return new Selection(); }
Example 2
Source File: Underline.java From hottub with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 3
Source File: PerspectiveFilter.java From osp with GNU General Public License v3.0 | 5 votes |
public void draw(DrawingPanel panel, Graphics g) { if (!PerspectiveFilter.super.isEnabled()) return; VideoPanel vidPanel = (VideoPanel)panel; Corner[] corners = PerspectiveFilter.this.isEnabled()? outCorners: inCorners; for (int i=0; i<4; i++) { screenPts[i] = corners[i].getScreenPosition(vidPanel); transform.setToTranslation(screenPts[i].getX(), screenPts[i].getY()); Shape s = corners[i]==selectedCorner? selectionShape: cornerShape; Stroke sk = corners[i]==selectedCorner? stroke: cornerStroke; hitShapes[i] = transform.createTransformedShape(s); drawShapes[i] = sk.createStrokedShape(hitShapes[i]); } path.reset(); path.moveTo((float)screenPts[0].getX(), (float)screenPts[0].getY()); path.lineTo((float)screenPts[1].getX(), (float)screenPts[1].getY()); path.lineTo((float)screenPts[2].getX(), (float)screenPts[2].getY()); path.lineTo((float)screenPts[3].getX(), (float)screenPts[3].getY()); path.closePath(); drawShapes[4] = stroke.createStrokedShape(path); Graphics2D g2 = (Graphics2D)g; Color gcolor = g2.getColor(); g2.setColor(color); Font gfont = g.getFont(); g2.setFont(font); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); for (int i=0; i< drawShapes.length; i++) { g2.fill(drawShapes[i]); } for (int i=0; i<textLayouts.length; i++) { p.setLocation(screenPts[i].getX()-4-font.getSize(), screenPts[i].getY()-6); textLayouts[i].draw(g2, p.x, p.y); } g2.setFont(gfont); g2.setColor(gcolor); }
Example 4
Source File: Underline.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 5
Source File: Underline.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 6
Source File: Underline.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 7
Source File: ShapeCreationUI.java From pumpernickel with MIT License | 5 votes |
/** * This paints an individual shape. Subclasses may override this to control * the color/stroke of shapes. * <p> * The default implementation here paints a 2-pixel focus ring around a * shape if it is the currently selected shape. * * @see #getStroke(ShapeCreationPanel, int) */ protected void paintShape(Graphics2D g, ShapeCreationPanel panel, int shapeIndex, Shape transformedShape) { Selection selection = panel.getSelectionModel().getSelection(); Stroke stroke = getStroke(panel, shapeIndex); if (selection.getShapeIndex() == shapeIndex && panel.hasFocus()) { Shape strokedShape = stroke.createStrokedShape(transformedShape); PlafPaintUtils.paintFocus(g, strokedShape, 2); } g.setStroke(stroke); g.setColor(Color.black); g.draw(transformedShape); }
Example 8
Source File: Underline.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 9
Source File: Underline.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 10
Source File: Underline.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 11
Source File: Underline.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 12
Source File: Underline.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 13
Source File: Underline.java From Bytecoder with Apache License 2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 14
Source File: Underline.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 15
Source File: Underline.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 16
Source File: Underline.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 17
Source File: Underline.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
Shape getUnderlineShape(float thickness, float x1, float x2, float y) { Stroke ulStroke = getStroke(thickness); Line2D line = new Line2D.Float(x1, y + shift, x2, y + shift); return ulStroke.createStrokedShape(line); }
Example 18
Source File: CrashNaNTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static void testStrokedShapes() { final Stroke stroke = new BasicStroke(); final Path2D.Double path = new Path2D.Double(); Shape s; // Check filtering NaN values: path.reset(); path.moveTo(100, NaN); path.lineTo(NaN, 100); path.lineTo(NaN, NaN); path.quadTo(NaN, 100, NaN, 100); path.quadTo(100, NaN, 100, NaN); path.quadTo(NaN, NaN, NaN, NaN); path.curveTo(NaN, 100, NaN, 100, NaN, 100); path.curveTo(100, NaN, 100, NaN, 100, NaN); path.curveTo(NaN, NaN, NaN, NaN, NaN, NaN); path.closePath(); s = stroke.createStrokedShape(path); checkEmptyPath(s); // Check filtering +Infinity values: path.reset(); path.moveTo(100, POSITIVE_INFINITY); path.lineTo(POSITIVE_INFINITY, 100); path.lineTo(POSITIVE_INFINITY, POSITIVE_INFINITY); path.quadTo(POSITIVE_INFINITY, 100, POSITIVE_INFINITY, 100); path.quadTo(100, POSITIVE_INFINITY, 100, POSITIVE_INFINITY); path.quadTo(POSITIVE_INFINITY, POSITIVE_INFINITY, POSITIVE_INFINITY, POSITIVE_INFINITY); path.curveTo(POSITIVE_INFINITY, 100, POSITIVE_INFINITY, 100, POSITIVE_INFINITY, 100); path.curveTo(100, POSITIVE_INFINITY, 100, POSITIVE_INFINITY, 100, POSITIVE_INFINITY); path.curveTo(POSITIVE_INFINITY, POSITIVE_INFINITY, POSITIVE_INFINITY, POSITIVE_INFINITY, POSITIVE_INFINITY, POSITIVE_INFINITY); path.closePath(); s = stroke.createStrokedShape(path); checkEmptyPath(s); // Check filtering -Infinity values: path.reset(); path.moveTo(100, NEGATIVE_INFINITY); path.lineTo(NEGATIVE_INFINITY, 100); path.lineTo(NEGATIVE_INFINITY, NEGATIVE_INFINITY); path.quadTo(NEGATIVE_INFINITY, 100, NEGATIVE_INFINITY, 100); path.quadTo(100, NEGATIVE_INFINITY, 100, NEGATIVE_INFINITY); path.quadTo(NEGATIVE_INFINITY, NEGATIVE_INFINITY, NEGATIVE_INFINITY, NEGATIVE_INFINITY); path.curveTo(NEGATIVE_INFINITY, 100, NEGATIVE_INFINITY, 100, NEGATIVE_INFINITY, 100); path.curveTo(100, NEGATIVE_INFINITY, 100, NEGATIVE_INFINITY, 100, NEGATIVE_INFINITY); path.curveTo(NEGATIVE_INFINITY, NEGATIVE_INFINITY, NEGATIVE_INFINITY, NEGATIVE_INFINITY, NEGATIVE_INFINITY, NEGATIVE_INFINITY); path.closePath(); s = stroke.createStrokedShape(path); checkEmptyPath(s); }
Example 19
Source File: MkeSeparateMovableType_Bolder.java From han3_ji7_tsoo1_kian3 with GNU Affero General Public License v3.0 | 3 votes |
/** * 給定筆劃加寬度,取得物件活字外框 * * @param rectangularArea * 物件活字 * @param strokeWidth * 筆劃加寬度 * @return 物件活字外框 */ protected PlaneGeometry getBoldSurface(PlaneGeometry rectangularArea, double strokeWidth) { if (strokeWidth < getPrecision()) return new PlaneGeometry(); Stroke stroke = chineseCharacterTypeBolder.getStroke(strokeWidth); return new PlaneGeometry(stroke.createStrokedShape(rectangularArea)); }