List of usage examples for java.awt.geom Area Area
public Area(Shape s)
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(e1); Area a2 = new Area(e2); a1.subtract(a2);/*from www . j ava 2s .c om*/ a1.transform(new AffineTransform()); g2.setColor(Color.orange); g2.fill(a1); g2.setColor(Color.black); g2.drawString("subtract", 20, 140); }
From source file:AreaSubtracting.java
public AreaSubtracting() { canvas = new DrawingCanvas(); add(canvas); canvas.area1 = new Area(canvas.gp); canvas.area1.subtract(canvas.area2); canvas.repaint(); }
From source file:AreaExclusiveOr.java
public AreaExclusiveOr() { canvas = new DrawingCanvas(); add(canvas);/*from w w w . j a v a 2s. c o m*/ canvas.area1 = new Area(canvas.gp); canvas.area1.exclusiveOr(canvas.area2); canvas.repaint(); }
From source file:AreaIntersecting.java
public AreaIntersecting() { canvas = new DrawingCanvas(); add(canvas);/*from w w w . j a v a 2 s .c om*/ canvas.area1 = new Area(canvas.gp); canvas.area1.intersect(canvas.area2); canvas.repaint(); }
From source file:AreaIntersect.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; double halfWdith = getSize().width / 2; double halfHeight = getSize().height / 2; g2.setColor(Color.green);/* w w w .j a va2s . c om*/ leaf.setFrame(halfWdith - 16, halfHeight - 29, 15.0, 15.0); leaf1 = new Area(leaf); leaf.setFrame(halfWdith - 14, halfHeight - 47, 30.0, 30.0); leaf2 = new Area(leaf); leaf1.intersect(leaf2); g2.fill(leaf1); }
From source file:AreaSubtract.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; double halfWdith = getSize().width / 2; double halfHeight = getSize().height / 2; stem.setFrame(halfWdith, halfHeight - 42, 40.0, 40.0); st1 = new Area(stem); stem.setFrame(halfWdith + 3, halfHeight - 47, 50.0, 50.0); st2 = new Area(stem); st1.subtract(st2);//from w w w . ja va 2s . com g2.fill(st1); g2.setColor(Color.yellow); }
From source file:AreaAdd.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; double halfWdith = getSize().width / 2; double halfHeight = getSize().height / 2; circle.setFrame(halfWdith - 25, halfHeight, 50.0, 50.0); oval.setFrame(halfWdith - 19, halfHeight - 20, 40.0, 70.0); circ = new Area(circle); ov = new Area(oval); circ.add(ov);/*from w ww. j av a 2 s. c o m*/ g2.fill(circ); }
From source file:CombiningShapes.java
public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); String option = (String) mOptions.getSelectedItem(); if (option.equals("outline")) { // draw the outlines and return. g2.draw(mShapeOne);//from ww w .ja v a 2 s . com g2.draw(mShapeTwo); return; } // Create Areas from the shapes. Area areaOne = new Area(mShapeOne); Area areaTwo = new Area(mShapeTwo); // Combine the Areas according to the selected option. if (option.equals("add")) areaOne.add(areaTwo); else if (option.equals("intersection")) areaOne.intersect(areaTwo); else if (option.equals("subtract")) areaOne.subtract(areaTwo); else if (option.equals("exclusive or")) areaOne.exclusiveOr(areaTwo); // Fill the resulting Area. g2.setPaint(Color.orange); g2.fill(areaOne); // Draw the outline of the resulting Area. g2.setPaint(Color.black); g2.draw(areaOne); }
From source file:Main.java
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Graphics2D g2 = (Graphics2D) g; int bottomLineY = height - thickness - shadowPad; RoundRectangle2D.Double bubble = new RoundRectangle2D.Double(0 + strokePad, 0 + strokePad, width - thickness - shadowPad, bottomLineY, radius, radius); Area area = new Area(bubble); g2.setRenderingHints(hints);//from www. j a v a 2 s. c o m g2.setColor(color); g2.setStroke(stroke); g2.draw(area); Area shadowArea = new Area(new Rectangle(0, 0, width, height)); shadowArea.subtract(area); g.setClip(shadowArea); Color shadow = new Color(color.getRed(), color.getGreen(), color.getBlue(), 128); g2.setColor(shadow); g2.translate(shadowPad, shadowPad); g2.draw(area); }
From source file:Pear.java
public void init() { circle = new Ellipse2D.Double(); oval = new Ellipse2D.Double(); leaf = new Ellipse2D.Double(); stem = new Ellipse2D.Double(); circ = new Area(circle); ov = new Area(oval); leaf1 = new Area(leaf); leaf2 = new Area(leaf); st1 = new Area(stem); st2 = new Area(stem); setBackground(Color.white);//www. j a v a2 s .co m }