Java Code Examples for java.awt.geom.AffineTransform#quadrantRotate()
The following examples show how to use
java.awt.geom.AffineTransform#quadrantRotate() .
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: MainPanel.java From java-swing-tips with MIT License | 6 votes |
private Icon makeVerticalTabIcon(String title, Icon icon, boolean clockwise) { JLabel label = new JLabel(title, icon, SwingConstants.LEADING); label.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); Dimension d = label.getPreferredSize(); int w = d.height; int h = d.width; BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = (Graphics2D) bi.getGraphics(); AffineTransform at = clockwise ? AffineTransform.getTranslateInstance(w, 0) : AffineTransform.getTranslateInstance(0, h); at.quadrantRotate(clockwise ? 1 : -1); g2.setTransform(at); SwingUtilities.paintComponent(g2, label, this, 0, 0, d.width, d.height); g2.dispose(); return new ImageIcon(bi); }
Example 2
Source File: VisualContact.java From workcraft with MIT License | 6 votes |
public AffineTransform getTransform() { AffineTransform result = new AffineTransform(); switch (this) { case WEST: result.quadrantRotate(2); break; case NORTH: result.quadrantRotate(3); break; case EAST: result.setToIdentity(); break; case SOUTH: result.quadrantRotate(1); break; } return result; }
Example 3
Source File: VisualContact.java From workcraft with MIT License | 6 votes |
@Override public boolean hitTestInLocalSpace(Point2D pointInLocalSpace) { Shape shape = getShape(); if (shape != null) { Point2D p2 = new Point2D.Double(); p2.setLocation(pointInLocalSpace); if (!(getParent() instanceof VisualCircuitComponent)) { AffineTransform rotateTransform = getDirection().getTransform(); if (isInput()) { rotateTransform.quadrantRotate(2); } rotateTransform.transform(pointInLocalSpace, p2); } return shape.contains(p2); } return false; }
Example 4
Source File: VisualContact.java From workcraft with MIT License | 5 votes |
@Override public void rotateClockwise() { if (getParent() instanceof VisualFunctionComponent) { VisualFunctionComponent component = (VisualFunctionComponent) getParent(); if (component.getRenderType() == RenderType.BOX) { AffineTransform rotateTransform = new AffineTransform(); rotateTransform.quadrantRotate(1); Point2D pos = rotateTransform.transform(getPosition(), null); setPosition(pos); } } setDirection(getDirection().rotateClockwise()); super.rotateClockwise(); }
Example 5
Source File: HiCChromosomeFigPanel.java From Juicebox with MIT License | 5 votes |
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Graphics2D g2D = (Graphics2D) g; try { hic.getZd(); } catch (Exception e) { return; } if (context == null) return; g.setColor(Color.black); AffineTransform t = g2D.getTransform(); if (orientation == Orientation.VERTICAL) { AffineTransform rotateTransform = new AffineTransform(); rotateTransform.quadrantRotate(-1); g2D.transform(rotateTransform); } // Clear panel drawChr(g2D); g2D.setTransform(t); }
Example 6
Source File: HiCChromosomeFigPanel.java From JuiceboxLegacy with MIT License | 5 votes |
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Graphics2D g2D = (Graphics2D) g; try { hic.getZd(); } catch (Exception e) { return; } if (context == null) return; g.setColor(Color.black); AffineTransform t = g2D.getTransform(); if (orientation == Orientation.VERTICAL) { AffineTransform rotateTransform = new AffineTransform(); rotateTransform.quadrantRotate(-1); g2D.transform(rotateTransform); } // Clear panel drawChr(g2D); g2D.setTransform(t); }
Example 7
Source File: LCDStretch.java From ev3dev-lang-java with MIT License | 5 votes |
private BufferedImage java_lejos_flip(BufferedImage in, BufferedImage out) { AffineTransform tf = new AffineTransform(); tf.quadrantRotate(1); tf.scale(-1.0, +1.0); AffineTransformOp op = new AffineTransformOp(tf, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); return op.filter(in, out); }
Example 8
Source File: VisualContact.java From workcraft with MIT License | 5 votes |
@Override public void rotateCounterclockwise() { if (getParent() instanceof VisualFunctionComponent) { VisualFunctionComponent component = (VisualFunctionComponent) getParent(); if (component.getRenderType() == RenderType.BOX) { AffineTransform rotateTransform = new AffineTransform(); rotateTransform.quadrantRotate(-1); Point2D pos = rotateTransform.transform(getPosition(), null); setPosition(pos); } } setDirection(getDirection().rotateCounterclockwise()); super.rotateCounterclockwise(); }
Example 9
Source File: DefaultTransformModel.java From darklaf with MIT License | 5 votes |
/** * Apply the prescribed transformations, excluding the scale. * * @param centerX a center X * @param centerY a center Y * @return a new {@link AffineTransform} */ protected AffineTransform transformNoScale(final double centerX, final double centerY) { AffineTransform at = new AffineTransform(); at.translate(centerX, centerY); at.rotate(getRotation()); at.quadrantRotate(getQuadrantRotation()); at.shear(getShearX(), getShearY()); at.translate(-centerX, -centerY); return at; }
Example 10
Source File: VisualContact.java From workcraft with MIT License | 5 votes |
@Override public Rectangle2D getNameBoundingBox() { Rectangle2D bb = super.getNameBoundingBox(); if (bb != null) { AffineTransform rotateTransform = new AffineTransform(); if (getDirection() == Direction.NORTH || getDirection() == Direction.SOUTH) { rotateTransform.quadrantRotate(-1); } bb = BoundingBoxHelper.transform(bb, rotateTransform); } return bb; }
Example 11
Source File: VisualXmasComponent.java From workcraft with MIT License | 5 votes |
public Shape transformShape(Shape shape) { AffineTransform rotateTransform = new AffineTransform(); if (orientation != null) { rotateTransform.quadrantRotate(orientation.getQuadrant()); } return rotateTransform.createTransformedShape(shape); }
Example 12
Source File: VisualXmasComponent.java From workcraft with MIT License | 5 votes |
public void setOrientation(Orientation value) { if (orientation != value) { for (VisualXmasContact contact: getContacts()) { AffineTransform rotateTransform = new AffineTransform(); rotateTransform.quadrantRotate(value.getQuadrant() - getOrientation().getQuadrant()); TransformHelper.applyTransform(contact, rotateTransform); } orientation = value; sendNotification(new PropertyChangedEvent(this, PROPERTY_ORIENTATION)); } }
Example 13
Source File: TestRotateMethods.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static AffineTransform makeQuadAT(Mode mode, Point2D txpt, int quads) { AffineTransform at; double tx = (txpt == null) ? 0.0 : txpt.getX(); double ty = (txpt == null) ? 0.0 : txpt.getY(); switch (mode) { case GET: if (txpt != null) { at = AffineTransform.getQuadrantRotateInstance(quads, tx, ty); } else { at = AffineTransform.getQuadrantRotateInstance(quads); } break; case SET: at = makeRandomAT(); if (txpt != null) { at.setToQuadrantRotation(quads, tx, ty); } else { at.setToQuadrantRotation(quads); } break; case MOD: at = makeRandomAT(); at.setToIdentity(); if (txpt != null) { at.quadrantRotate(quads, tx, ty); } else { at.quadrantRotate(quads); } break; default: throw new InternalError("unrecognized mode: "+mode); } return at; }
Example 14
Source File: LCDStretch.java From ev3dev-lang-java with MIT License | 4 votes |
@Deprecated @Override public void drawRegionRop( Image src, int sx, int sy, int w, int h, int transform, int x, int y, int anchor, int rop) { x = adjustX(x, w, anchor); y = adjustY(y, h, anchor); BufferedImage srcI = any2rgb(src); double midx = srcI.getWidth() / 2.0; double midy = srcI.getHeight() / 2.0; AffineTransform tf = new AffineTransform(); tf.translate(midx, midy); int h0 = h; switch (transform) { case TRANS_MIRROR: tf.scale(-1.0, 1.0); break; case TRANS_MIRROR_ROT90: tf.scale(-1.0, 1.0); tf.quadrantRotate(1); h = w; w = h0; break; case TRANS_MIRROR_ROT180: tf.scale(-1.0, 1.0); tf.quadrantRotate(2); break; case TRANS_MIRROR_ROT270: tf.scale(-1.0, 1.0); tf.quadrantRotate(3); h = w; w = h0; break; case TRANS_NONE: break; case TRANS_ROT90: tf.quadrantRotate(1); h = w; w = h0; break; case TRANS_ROT180: tf.quadrantRotate(2); break; case TRANS_ROT270: tf.quadrantRotate(3); h = w; w = h0; break; default: throw new RuntimeException("Bad Option"); } tf.translate(-midx, -midy); AffineTransformOp op = new AffineTransformOp(tf, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); BufferedImage transformed = ImageUtils.createXRGBImage(w, h); transformed = op.filter(srcI, transformed); BufferedImage dstI = any2rgb(image); bitBlt(srcI, sx, sy, dstI, x, y, w, h, rop); g2d.drawImage(dstI, 0, 0, null); }
Example 15
Source File: VisualContact.java From workcraft with MIT License | 4 votes |
@Override public void draw(DrawRequest r) { Graphics2D g = r.getGraphics(); Decoration d = r.getDecoration(); Color colorisation = d.getColorisation(); Color fillColor = d.getBackground(); if (fillColor == null) { fillColor = getFillColor(); } AffineTransform savedTransform = g.getTransform(); AffineTransform rotateTransform = getDirection() != null ? getDirection().getTransform() : new AffineTransform(); if (isInput()) { rotateTransform.quadrantRotate(2); } g.transform(rotateTransform); boolean showContact = CircuitSettings.getShowContacts() || (d instanceof StateDecoration) || (d.getColorisation() != null) || (d.getBackground() != null); if (showContact || isPort()) { boolean showForcedInit = (d instanceof StateDecoration) && ((StateDecoration) d).showForcedInit(); Shape shape = showForcedInit && isForcedDriver() ? getForcedShape() : getShape(); float width = (float) CircuitSettings.getBorderWidth(); g.setStroke(new BasicStroke(width)); g.setColor(fillColor); g.fill(shape); g.setColor(ColorUtils.colorise(getForegroundColor(), colorisation)); g.draw(shape); } else if (r.getModel().getConnections(this).size() > 1) { g.setColor(ColorUtils.colorise(getForegroundColor(), colorisation)); g.fill(VisualJoint.shape); } if (!(getParent() instanceof VisualCircuitComponent)) { g.setTransform(savedTransform); rotateTransform.setToIdentity(); if (getDirection() == Direction.NORTH || getDirection() == Direction.SOUTH) { rotateTransform.quadrantRotate(-1); } g.transform(rotateTransform); drawNameInLocalSpace(r); } g.setTransform(savedTransform); d.decorate(g); }
Example 16
Source File: HiCRulerPanel.java From JuiceboxLegacy with MIT License | 3 votes |
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Graphics2D g2D = (Graphics2D) g; try { hic.getZd(); } catch (Exception e) { return; } if (context == null) return; g.setColor(Color.black); AffineTransform t = g2D.getTransform(); if (orientation == Orientation.VERTICAL) { AffineTransform rotateTransform = new AffineTransform(); rotateTransform.quadrantRotate(-1); g2D.transform(rotateTransform); } // Clear panel drawTicks(g2D); drawChr(g2D); g2D.setTransform(t); }
Example 17
Source File: HiCRulerPanel.java From Juicebox with MIT License | 3 votes |
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Graphics2D g2D = (Graphics2D) g; try { hic.getZd(); } catch (Exception e) { return; } if (context == null) return; g.setColor(Color.black); AffineTransform t = g2D.getTransform(); if (orientation == Orientation.VERTICAL) { AffineTransform rotateTransform = new AffineTransform(); rotateTransform.quadrantRotate(-1); g2D.transform(rotateTransform); } // Clear panel drawTicks(g2D); // TODO ms3 drawChr(g2D); g2D.setTransform(t); }