List of usage examples for java.awt Rectangle Rectangle
public Rectangle(int x, int y, int width, int height)
From source file:com.imag.nespros.gui.transformers.CustomVertexShapeTransformer.java
@Override public Shape transform(Device device) { Image img;//w w w . j av a2 s. c om int w, h; w = device.getIcon().getIconWidth(); h = device.getIcon().getIconHeight(); return new Rectangle(-w / 2, -h / 2, w, h); /* switch(device.getDeviceType()){ case AMI: img = new ImageIcon("icons"+File.separator+"meter.jpeg").getImage(); w = img.getWidth(null); h = img.getHeight(null); return new Rectangle(-w/2, -h/2, w, h); case DC: img = new ImageIcon("icons"+File.separator+"dc.jpeg").getImage(); w = img.getWidth(null); h = img.getHeight(null); return new Rectangle(-w/2, -h/2, w, h); case HTA_COORD: img = new ImageIcon("icons"+File.separator+"htaCoord.jpg").getImage(); w = img.getWidth(null); h = img.getHeight(null); return new Rectangle(-w/2, -h/2, w, h); case SACOMUT: img = new ImageIcon("icons"+File.separator+"sacomut.jpg").getImage(); w = img.getWidth(null); h = img.getHeight(null); return new Rectangle(-w/2, -h/2, w, h); default: System.out.println("default"); return null; } */ }
From source file:BasicDraw.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; int x = 10;/*w w w . j a v a2 s .c o m*/ int y = 10; int width = 50; int height = 25; BufferedImage bi = new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB); TexturePaint texture = new TexturePaint(bi, new Rectangle(x, y, width, height)); g2d.setPaint(texture); }
From source file:TexturePaintDemo.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; BufferedImage bi = new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB); Graphics2D big = bi.createGraphics(); big.setColor(Color.blue);/*from ww w. j a va2 s .co m*/ big.fillRect(0, 0, 5, 5); big.setColor(Color.lightGray); big.fillOval(0, 0, 5, 5); Rectangle r = new Rectangle(0, 0, 5, 5); g2.setPaint(new TexturePaint(bi, r)); Rectangle rect = new Rectangle(5, 5, 200, 200); g2.fill(rect); }
From source file:TexturedText.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font font = new Font("Times New Roman", Font.PLAIN, 72); g2.setFont(font);/*from ww w . ja v a 2s .co m*/ String s = "Java Source and Support"; Dimension d = getSize(); float x = 20, y = 100; BufferedImage bi = getTextureImage(); Rectangle r = new Rectangle(0, 0, bi.getWidth(), bi.getHeight()); TexturePaint tp = new TexturePaint(bi, r); g2.setPaint(tp); g2.drawString(s, x, y); }
From source file:Textures.java
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(new Color(212, 212, 212)); g2d.drawRect(10, 15, 90, 60);// ww w .j ava2 s . c om BufferedImage bimage1 = null; URL url1 = ClassLoader.getSystemResource("a.png"); try { bimage1 = ImageIO.read(url1); } catch (IOException ioe) { ioe.printStackTrace(); } Rectangle rect1 = new Rectangle(0, 0, bimage1.getWidth(), bimage1.getHeight()); TexturePaint texture1 = new TexturePaint(bimage1, rect1); g2d.setPaint(texture1); g2d.fillRect(10, 15, 90, 60); }
From source file:BasicDraw.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; float strokeThickness = 5.0f; float miterLimit = 10f; float[] dashPattern = { 10f }; float dashPhase = 5f; BasicStroke stroke = new BasicStroke(strokeThickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, miterLimit, dashPattern, dashPhase); g2d.setStroke(stroke);/*from www . j a va 2s.com*/ g2d.draw(new Rectangle(20, 20, 200, 200)); }
From source file:BasicDraw.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; Color startColor = Color.red; Color endColor = Color.blue; int startX = 10, startY = 20, endX = 30, endY = 40; GradientPaint gradient = new GradientPaint(startX, startY, startColor, endX, endY, endColor); g2d.setPaint(gradient);/*from www .ja v a2s . c om*/ g2d.draw(new Rectangle(20, 20, 200, 200)); }
From source file:ScrollPaneWatermark.java
public void setBackgroundTexture(URL url) throws IOException { bgimage = ImageIO.read(url);// w w w .j a v a2 s .co m Rectangle rect = new Rectangle(0, 0, bgimage.getWidth(null), bgimage.getHeight(null)); texture = new TexturePaint(bgimage, rect); }
From source file:Main.java
public WatermarkTextField(URL file) { super();//from w ww . jav a2 s. c om try { img = ImageIO.read(file); } catch (IOException e) { e.printStackTrace(); } Rectangle rect = new Rectangle(0, 0, img.getWidth(null), img.getHeight(null)); texture = new TexturePaint(img, rect); setOpaque(false); }
From source file:Main.java
private JTextArea getJTextArea_content() { if (jTextArea_content == null) { jTextArea_content = new JTextArea(3, 30); jTextArea_content.setBounds(new Rectangle(75, 224, 678, 47)); }//from w w w. j av a2s. c o m return jTextArea_content; }