List of usage examples for java.awt.geom AffineTransform AffineTransform
public AffineTransform()
From source file:org.jcurl.core.impl.ColliderBase.java
/** * Iterate over all rocks and call/* w w w. j av a 2 s . c om*/ * {@link ColliderBase#computeWC(Rock, Rock, Rock, Rock, AffineTransform)} * for each pair. * <p> * Does not change <code>pos</code>! * </p> * <p> * Does not fire {@link RockSet#fireStateChanged()}! * </p> * * @see ColliderBase#computeWC(Rock, Rock, Rock, Rock, AffineTransform) * @param pos * @param speed * @param tr * <code>null</code> creates a new instance. * @return bitmask of the changed rocks */ public int compute(final RockSet<Pos> pos, final RockSet<Vel> speed, AffineTransform tr) { if (log.isDebugEnabled()) log.debug("compute()"); int hits = 0; if (tr == null) tr = new AffineTransform(); else tr.setToIdentity(); // TUNE Parallel for (int B = 0; B < RockSet.ROCKS_PER_SET; B++) for (int A = 0; A < B; A++) { if (log.isDebugEnabled()) log.debug("Compute hit " + A + "<->" + B); if (computeWC(pos.getRock(A), pos.getRock(B), speed.getRock(A), speed.getRock(B), tr)) { // mark the rocks' bits hit hits |= 1 << A; hits |= 1 << B; } } if (log.isDebugEnabled()) log.debug("hit rocks: " + Integer.toBinaryString(hits)); return hits; }
From source file:BufferedImageThread.java
public void paintComponent(Graphics g) { super.paintComponent(g); Dimension d = getSize();//from w ww .j av a2s . c o m bi = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_ARGB); Graphics2D big = bi.createGraphics(); step(d.width, d.height); AffineTransform at = new AffineTransform(); at.setToIdentity(); at.translate(x, y); at.rotate(Math.toRadians(rotate)); at.scale(scale, scale); big.drawImage(image, at, this); Graphics2D g2D = (Graphics2D) g; g2D.drawImage(bi, 0, 0, null); big.dispose(); }
From source file:org.jcurl.demo.tactics.TrajectoryScenarioBean.java
private static Affine createSceneRock(final int i16, final int opacity) { SGNode rock = new SGRockFactory.Fancy().newInstance(i16); if (DoCacheRocks) { final SGRenderCache rc = new SGRenderCache(); rc.setChild(rock);// w ww . j av a 2 s. c o m rc.setInterpolationHint(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); rock = rc; } return SGTransform.createAffine(new AffineTransform(), rock); }
From source file:org.jcurl.core.base.Collider.java
/** * Iterate over all positions and call/* w w w. j a v a 2 s. c o m*/ * {@link Collider#computeWC(Rock, Rock, Rock, Rock, AffineTransform)} for * each pair. * * @see Collider#computeWC(Rock, Rock, Rock, Rock, AffineTransform) * @param pos * @param speed * @return bitmask of the changed positions */ public int compute(PositionSet pos, SpeedSet speed) { if (log.isDebugEnabled()) log.debug("compute()"); int hits = 0; final AffineTransform mat = new AffineTransform(); for (int B = 0; B < RockSet.ROCKS_PER_SET; B++) { for (int A = 0; A < B; A++) { if (log.isDebugEnabled()) log.debug("Compute hit " + A + "<->" + B); if (computeWC(pos.getRock(A), pos.getRock(B), speed.getRock(A), speed.getRock(B), mat)) { // mark the positions' bits hit hits |= (1 << A); hits |= (1 << B); } } } if (log.isDebugEnabled()) log.debug("hit positions: " + Integer.toBinaryString(hits)); return hits; }
From source file:Starry.java
public void paintComponent(Graphics g) { super.paintComponent(g); setBackground(Color.white);//w ww.j a v a 2 s .co m w = getSize().width; h = getSize().height; Graphics2D g2; g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); FontRenderContext frc = g2.getFontRenderContext(); Font f = new Font("Helvetica", 1, w / 10); String s = new String("The Starry Night"); TextLayout textTl = new TextLayout(s, f, frc); AffineTransform transform = new AffineTransform(); Shape outline = textTl.getOutline(null); Rectangle r = outline.getBounds(); transform = g2.getTransform(); transform.translate(w / 2 - (r.width / 2), h / 2 + (r.height / 2)); g2.transform(transform); g2.setColor(Color.blue); g2.draw(outline); g2.setClip(outline); g2.drawImage(img, r.x, r.y, r.width, r.height, this); }
From source file:org.jcurl.core.swing.WCComponent.java
private BufferedImage renderPng(final String watermark) { final BufferedImage img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB); final Graphics2D g2 = (Graphics2D) img.getGraphics(); {//from www. jav a 2s . c o m final Map<Key, Object> hints = new HashMap<Key, Object>(); hints.put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); hints.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); hints.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); hints.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); hints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); hints.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2.addRenderingHints(hints); } final Font f0 = g2.getFont(); paint(g2); g2.setTransform(new AffineTransform()); if (watermark != null) { if (log.isDebugEnabled()) log.debug(f0); g2.setFont(f0); g2.setColor(new Color(0, 0, 0, 128)); g2.drawString(watermark, 10, 20); } g2.dispose(); return img; }
From source file:ImageOps.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); int w = getSize().width; int h = getSize().height; g2.setColor(Color.black);// w w w . j av a 2s. c o m float[][] data = { { 0.1f, 0.1f, 0.1f, // low-pass filter 0.1f, 0.2f, 0.1f, 0.1f, 0.1f, 0.1f }, SHARPEN3x3_3 }; String theDesc[] = { "Convolve LowPass", "Convolve Sharpen", "LookupOp", "RescaleOp" }; for (int i = 0; i < bi.length; i++) { int iw = bi[i].getWidth(this); int ih = bi[i].getHeight(this); int x = 0, y = 0; AffineTransform at = new AffineTransform(); at.scale((w - 14) / 2.0 / iw, (h - 34) / 2.0 / ih); BufferedImageOp biop = null; BufferedImage bimg = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB); switch (i) { case 0: case 1: x = i == 0 ? 5 : w / 2 + 3; y = 15; Kernel kernel = new Kernel(3, 3, data[i]); ConvolveOp cop = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); cop.filter(bi[i], bimg); biop = new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); break; case 2: x = 5; y = h / 2 + 15; byte chlut[] = new byte[256]; for (int j = 0; j < 200; j++) chlut[j] = (byte) (256 - j); ByteLookupTable blut = new ByteLookupTable(0, chlut); LookupOp lop = new LookupOp(blut, null); lop.filter(bi[i], bimg); biop = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); break; case 3: x = w / 2 + 3; y = h / 2 + 15; RescaleOp rop = new RescaleOp(1.1f, 20.0f, null); rop.filter(bi[i], bimg); biop = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); } g2.drawImage(bimg, biop, x, y); TextLayout tl = new TextLayout(theDesc[i], g2.getFont(), g2.getFontRenderContext()); tl.draw(g2, (float) x, (float) y - 4); } }
From source file:org.jcurl.core.base.CollissionStrategy.java
/** * Iterate over all rocks and call//w ww . ja v a2 s .c om * {@link CollissionStrategy#computeWC(Rock, Rock, Rock, Rock, AffineTransform)} * for each pair. * * @see CollissionStrategy#computeWC(Rock, Rock, Rock, Rock, * AffineTransform) * @param pos * @param speed * @return bitmask of the changed rocks */ public int compute(PositionSet pos, SpeedSet speed) { if (log.isDebugEnabled()) log.debug("compute()"); int hits = 0; final AffineTransform mat = new AffineTransform(); for (int B = 0; B < RockSet.ROCKS_PER_SET; B++) { for (int A = 0; A < B; A++) { if (log.isDebugEnabled()) log.debug("Compute hit " + A + "<->" + B); if (computeWC(pos.getRock(A), pos.getRock(B), speed.getRock(A), speed.getRock(B), mat)) { // mark the rocks' bits hit hits |= (1 << A); hits |= (1 << B); } } } if (log.isDebugEnabled()) log.debug("hit rocks: " + Integer.toBinaryString(hits)); return hits; }
From source file:org.jcurl.core.base.ColliderBase.java
/** * Iterate over all rocks and call/*from w w w. ja va 2 s.co m*/ * {@link ColliderBase#computeWC(Rock, Rock, Rock, Rock, AffineTransform)} * for each pair. * <p> * Does not change <code>pos</code>! * </p> * <p> * Does not fire {@link SpeedSet#notifyChange()}! * </p> * * @see ColliderBase#computeWC(Rock, Rock, Rock, Rock, AffineTransform) * @param pos * @param speed * @param tr * <code>null</code> creates a new instance. * @return bitmask of the changed rocks */ public int compute(final PositionSet pos, final SpeedSet speed, AffineTransform tr) { if (log.isDebugEnabled()) log.debug("compute()"); int hits = 0; if (tr == null) tr = new AffineTransform(); else tr.setToIdentity(); for (int B = 0; B < RockSet.ROCKS_PER_SET; B++) for (int A = 0; A < B; A++) { if (log.isDebugEnabled()) log.debug("Compute hit " + A + "<->" + B); if (computeWC(pos.getRock(A), pos.getRock(B), speed.getRock(A), speed.getRock(B), tr)) { // mark the rocks' bits hit hits |= 1 << A; hits |= 1 << B; } } if (log.isDebugEnabled()) log.debug("hit rocks: " + Integer.toBinaryString(hits)); return hits; }
From source file:desmoj.extensions.grafic.util.Plotter.java
/** * Constructor to set the path of output directory and the size of created image. * Default are onScreen = false, locale = Locale.getDefault, timeZone = TimeZone.getdefault * @param path//from w w w . ja v a 2s. c o m * @param size */ public Plotter(String path, Dimension size) { this.paintPanel = new PaintPanel(path, size); this.onScreen = false; this.locale = Locale.getDefault(); this.timeZone = TimeZone.getDefault(); this.begin = null; this.end = null; this.frc = new FontRenderContext(new AffineTransform(), true, true); }