Scaling, Rotating Components

Was just working on a personal project in which I needed to scale a component, and this lead me to finding some bugs in code I'd posted here to rotate components. So I just thought I'd post the new PERFECT (for now) superclass to both of these problems, which you can find [here in TUS|http://tus.svn.sourceforge.net/viewvc/tus/tjacobs/ui/mod/] Enjoy!
package tjacobs.ui.mod;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.AffineTransform;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.SwingUtilities;
public abstract class ModPanel extends JLayeredPane {
     private static final long serialVersionUID = 1L;
     protected Component glass;
     private Component lastComponent;
     @SuppressWarnings("serial")
     public ModPanel() {
          final JComponent mouseCatcher = new JComponent() {
               public void setCursor(Cursor c) {
               public Cursor getCursor() {
                    if (lastComponent != null) return lastComponent.getCursor();
                    return super.getCursor();
          glass = mouseCatcher;
          this.add(mouseCatcher);
          mouseCatcher.setLocation(new Point(0,0));
          this.setLayer(mouseCatcher, JLayeredPane.POPUP_LAYER + 100);
          addComponentListener(new ComponentAdapter() {
               public void componentResized(ComponentEvent ev) {
                    mouseCatcher.setSize(getSize());
          MyMouseListener listener = new MyMouseListener();
          mouseCatcher.addMouseListener(listener);
          mouseCatcher.addMouseMotionListener(listener);
          mouseCatcher.setFocusable(false);
     abstract protected Point modifyPoint(MouseEvent me);
     public void paint(Graphics g) {
          Graphics2D g2 = modifyGraphics(g);
          super.paint((Graphics) g2);
     public Graphics getGraphics() {
          return modifyGraphics(super.getGraphics());
     protected abstract Graphics2D modifyGraphics(Graphics g);
     private class MyMouseListener implements MouseListener, MouseMotionListener {
          @Override
          public void mouseClicked(MouseEvent arg0) {
               handle(arg0);
               arg0.consume();
          @Override
          public void mouseEntered(MouseEvent arg0) {
               //arg0.consume();
          @Override
          public void mouseExited(MouseEvent arg0) {
               //arg0.consume();
          @Override
          public void mousePressed(MouseEvent arg0) {
               handle(arg0);
               arg0.consume();
          @Override
          public void mouseReleased(MouseEvent arg0) {
               handle(arg0);
               arg0.consume();
          private void handle(MouseEvent me) {
               Point loc = me.getPoint();
               loc = modifyPoint(me);
               remove(glass);
               Component c = null;
               if (me.getID() == MouseEvent.MOUSE_RELEASED && lastComponent != null) {
                    c = lastComponent;
               } else {
                    c = SwingUtilities.getDeepestComponentAt(ModPanel.this, loc.x, loc.y);
               add(glass);
               if (c != null) {
                    MouseEvent ev = createNewMouseEvent(me, me.getID(), c, loc);
                    c.dispatchEvent(ev);
          private void handleMove(MouseEvent me) {
               Point loc = me.getPoint();
               Point loc2 = modifyPoint(me);
               remove(glass);
               Component c = null;
               if (me.getID() == MouseEvent.MOUSE_DRAGGED) c = lastComponent;
               else {
                    c = SwingUtilities.getDeepestComponentAt(ModPanel.this, loc2.x, loc2.y);
               if (c instanceof ZoomPanel) c= null;
               add(glass);
               if (c == glass || c== ModPanel.this) c = null;
               if (lastComponent != c && me.getID() != MouseEvent.MOUSE_DRAGGED) {
                    if (lastComponent != null) {
                         MouseEvent me1 = createNewMouseEvent(me, MouseEvent.MOUSE_EXITED, lastComponent, loc);
                         lastComponent.dispatchEvent(me1);
                    lastComponent = c;
                    if (c != null) {
                         MouseEvent me1 = createNewMouseEvent(me, MouseEvent.MOUSE_ENTERED, c, loc2);
                         c.dispatchEvent(me1);
               if (c != null && c != ModPanel.this) {
                    MouseEvent me1 = createNewMouseEvent(me, me.getID(), c, loc2);
                    c.dispatchEvent(me1);
          private MouseEvent createNewMouseEvent(MouseEvent me, int type, Component newComp, Point newPoint) {
               Point pt = SwingUtilities.convertPoint(ModPanel.this, newPoint, newComp);
               MouseEvent me2 = new MouseEvent(newComp, type, me.getWhen(), me.getModifiers() | me.getModifiersEx(), pt.x, pt.y, me.getClickCount(), me.isPopupTrigger(), me.getButton());
               return me2;
          @Override
          public void mouseDragged(MouseEvent arg0) {
               handleMove(arg0);
                arg0.consume();
          @Override
          public void mouseMoved(MouseEvent arg0) {
               handleMove(arg0);
               arg0.consume();
}Edited by: tjacobs01 on Jan 16, 2010 6:40 PM

Thanks for the great code. It is not perfect yet though, but that is easy to fix. You pass the modified mouse coordinates to 'getDeepestComponentAt'. This does not work. I am scaling down a slider to 50% and it only received events for the top-left rectangle. If you pass in the original coordinates, the mouse events will get through to the underlying component.
Regards,
Johan
Edited by: jstuyts on Feb 11, 2010 3:42 PM. Removed code block so the method name is inline in the text.

Similar Messages

  • Rotating components and text

    Is there a way to rotate components and pieces of text in the AWT?
    In other words: is it possible to turn a button or label on it's side or to paint a string onto screen so that the base line is vertical?
    thanks very much

    Hi
    I tried to save jtable component and all text from
    JTextPane to file
    file is created but it's containing only text.
    please if you have any idea to solve that problemWhat is the problem? Was it supposed to contain something other than text? Do you have images somewhere? Did you want to take a screenshot of the table? etc. Please be more descriptive.

  • Scaling of components

    I have a panel (with components) which needs to be printed,given on the a4 size the component(panel) does'nt fit. Is there any api that scale the panel and its inner components according to the size of the page.
    Thanks a ton in advance

    Hi Bob,
    Can you try adding this to the project's compiler argument? This should fix the scaling issue that you're seeing.
    -includes=mx.managers.systemClasses.MarshallingSupport
    Joe

  • How the heck to I copy and paste keyframes (scaling, rotation, etc.) in motion 5?

    Trying to figure out how to copy keyframes from one object to another obejct in Motion 5, and I'm left screaming pulling my hair out.
    It USED to be so easy... where is the paste attributes option here?
    Or can I duplicate the object and relink it to another object? Going crazy here. Any help would be great.

    There are several ways to copy and paste keyframes:
    1. Select the "source object" and go to the animated parameter in the Inspector (position for example).
    2. Click and drag the parameter name you want to copy to the destination layer in the layer list via drag and drop. The values (including keyframes) will be copied to the appropriate channels.
    OR
    1. Select the source object.
    2. For each channel that is animated (position, rotation, scale) go to the far right side of the parameter in the Inspector and select "Show in keyframe editor."
    3. Select all the keyframes you want (I use a simple click and drag to create a box an select all of the keyframes) and then copy (command-c).
    4. Now select the destination layer, position the playhead where you want the keyframes to start from and paste (command-v).
    http://help.apple.com/motion/mac/5.0/en/motion/usermanual/#chapter=12%26section= 12
    If you just need to match the animation of another layer (Position, Rotation, Scale) try using the Match Move behavior.
    http://help.apple.com/motion/mac/5.0/en/motion/usermanual/#chapter=22%26section= 7 (See the section: "To apply the transformation of a source object to a destination object")

  • Scaling UI Components

    Hi,
    I wonder if anyone has tried doing this. I have several coordinates  here as here:
    <region name="triangle">
    <perimeter>
    <x>8</x><y>10</y>
    <x>2</x><y>10</y>
    <x>2</x><y>5</y>
    <x>8</x><y>5</y>
    </perimeter>
    </region>
    <region name="rect">
    <perimeter>
    <x>30</x><y>1</y>
    <x>20</x><y>1</y>
    <x>20</x><y>2</y>
    <x>30</x><y>2</y>
    </perimeter>
    </region>
    I am trying to use some simple way of finding out what the width and  height of the objects that I draw on the canvas. I call up the main app using this:
    drawThematicMap.setCanvas(100,100,300,500);            
       drawThematicMap.draw(regions);
    This is what is in the drawThematicMap class:
        public var canvas:Canvas;
            public function setCanvas(x:Number,y:Number,width:Number,height:Number):void{
                canvas.setActualSize(width,height);
                canvas.x = x;
                canvas.y = y;  
            public function draw(arr:Array):void{
             regions = arr;    
             var shape:UIComponent;
                     var gr:Graphics;
                     var coords:Array;
                 for (var s:String in regions) {
                    trace("\n" + s);
                    shape = new UIComponent();  
                    gr = shape.graphics;
                    gr.lineStyle(3);//Define line style                   
                    coords = regions[s];
                    gr.moveTo(coords[0],coords[1]);
                 for (var i:int = 2; i < coords.length; i += 2) gr.lineTo(coords[i],coords[i + 1]);                  
                     gr.lineTo(coords[0],coords[1]);  
                     gr.endFill(); //Put this in if there is a color
                     canvas.addChild(shape);  
    I am trying to  use the information so I can possibly use it for rescaling the image so I  don't have to calculate all my coordinates one by one.
    Is there a simple way to do this?
    Thanks for your help.
    Alice

    Hi,
      I looked at http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/geom/Transform.html#pixelBounds, and looks like that it may work if my shape is "rectangle". What happens if it is not a rectangle, like a triangle, for example?
      I am trying to find out the "max width and height of the numbered shapes that I may be reading from an external file, so I could use that data to decide how much I need to "scale" to the desired "canvas size." Is this possible?
      As a side note, I do have import flash.geom.*; at the beginning of my class.
    Thanks for your help.
    Alice

  • Performance issues with Motion (position, scale, rotate) and GTX 590

    I'm experiencing performance issues with my Premiere Pro CC when I scale, position or rotate a clip in the program monitor.
    I have no performance issues with playback! It's only, when i move something with the mouse or by changing the x,y-values of Position in the Motion-Dialog in video effects.
    Premiere then lags terribly and updates the program monitor only about once per second - this makes it very difficult and cumbersome to work and position things.
    On a second Premiere installation on my laptop, performance is fine and fluid - allthough it doesn't have GPU support and is a much slower computer.
    I'm pretty sure this has somehow to do with my graphic card, which is a Nvidia GTX 590.
    I was told by the support, that it is actually a dual graphic card, which is not supported/liked by Premiere.
    The thing is, until the latest Premiere update, I did not have performance issues at all with this card.
    I also read on the forum that others with the GTX 590 did not experience any problems with it
    So where does this come from?
    There is no change in performance whether or not I activate Mercury Playback Engine GPU acceleration.
    I also tried deactivating one of the 2 gpus, but there also was no change.
    Does anyone else know this problem and has anyone a solution?
    I'm running Premiere CC on a Win 7 64bit engine, Nvidia GTX 590, latest driver (of today),

    I am suffering from the same phenomenon since I updated just before christmas, I think.
    I am hardly able to do scaling, rotating and translating in the program monitor itslef - whil motion has been highlighted in teh effect controls.
    In the effect controls I can scale, rotate etc however.
    Also I have noticed there is a yellow box with handles in teh program monitor. I remember it was white before.
    I cannot figure out what to change in my preferences. What has happened?
    best,
    Hans Wessels
    Premiere CC
    Mac Pro OSX 10.7.5
    16 GB 1066 MHz DD3
    2 X NVIDIA GeForce GT 120 512 MB

  • BitmapData, get/setPixel on scaled data. Real get/setPixel exist?

    Ok... I've been staring at this all day long, so the answer might be screaming at me and I just don't see it....
    Summary:  I need an Image to "show through" to the background, cutting through any other images that may be in it's way -- but not images on top of it (only below).
    [Edit: Is there an on-screen get/setPixel alternative?  As it seems BitmapData's only let's you edit the raw (un-transformed) data.  I'd like to just write the actual pixels on the screen.  There has to be something that keeps track of all the pixels when the item is scaled.  ]
    A picture is worth a thousand words, so I whipped up some examples in PS:
    Imagine this is the app that consists of four Images.  The background (skyline), and the three layers stacked on top.  The smiley is the backmost, the heart is the frontmost, and the snowman is in the middle.
    Notice how the snowman knocks out the smiley, but not the heart.  I'm achieving this by painting BitmapData with the background pixels wherever the clipart is not transparent. Also, if there was an additional layer (or any number of layers) "behind" the smiley, it would also be "knocked out" by the snowman.  This is why I'm pretty sure I have to do it this way with the BitmapData and manual get/setPixel. (Open to suggestions?)
    This method does work perfectly... as long as the snowman isn't scaled or rotated.
    Here, the snowman has been scaled up and rotated.  The problem is that the background image pixels get scaled up right along with the art. The outline of the snowman should only be visible when it knocks out the smiley, but instead you can see it clearly because the background pixels do not match, and are actually scaled/rotated along with the snowman.
    This is how it should look even with the scaling and rotating.
    Here is the code that is doing the "reverse mask":
    this == Image
    var thisWidth:uint      = this.width;
    var thisHeight:uint      = this.height;
    var targetWidth:uint      = this.x + thisWidth;
    var targetHeight:uint      = this.y + thisHeight;
    var data:BitmapData = Bitmap(backgroundImage.content).bitmapData;
    var newdata:BitmapData = new BitmapData(thisWidth, thisHeight, true, 0);
    newdata.draw(this);
    this.content.visible = false;
    newdata.lock();
    for ( var x:uint = this.x, drawX:uint=0; x < targetWidth; x++,drawX++ ) {
         for ( var y:uint = this.y, drawY:uint=0; y < targetHeight; y++,drawY++ ) {
              color = data.getPixel(x, y);
              newdata.setPixel( drawX, drawY, color );
    newdata.unlock();
    this.addChild( new Bitmap(newdata) );
    Anyone have any suggestions?
    My current direction is....
    1)  Is there a way to rasterize a transformed layer?  By that I mean make the current transformation permanent.  So, if an image was scale(1.5, 2)  you could function rasterize(image) and it would still stay scaled, but have scale(1, 1)
    2) Do the calculations to figure out the inverse matrix and apply it to the bitmapdata before adding it as a child of the image.  This way, when the background pixels get scaled/rotated, they will end up in the right place.
    3) Give up, quit my job, buy a sailboat and a lifetime supply of rum.

    Winston, don't know how I missed this earlier, but in case you're still looking for some kind of insight, here's what I would suggest:
    Keep your movies as .mov files, do not use .mp4
    For 4:3 moves, use 768x576 or 720x540 as your size
    For 16:9 movies, resize your movies to 1024x576 or 720x404
    (Exactly what you use is more about how large you want your file sizes to be)
    I know you've attempted very similar steps under the MPEG-4 options, but have you tried this:
    Open Movie in QuickTime Pro
    Press Command-E to bring up the Export dialog
    Under Export: leave as Movie To QuickTime Movie but press the Options... buttons
    In the Video pane, select the Settings... button, then set:
       Compression Type: H.264
       Frame Rate: Current
       Key Frames: Automatic
       Frame Reordering should be checked (this is crucial)
       Data Rate: Restrict to 3500 kbits/sec
       Optimized for Download
       Under Encoding, make sure Best Quality (Multi-Pass) is selected
       ... then click OK to exit this Compression Settings dialog
    Now, back in the Movie Settings dialog, select Size and adjust that accordingly. (If you're using QT 7.1 or later, you can select whether or not you'd like to Deinterlace your video as well in this dialog. If you're restricting your use of these files to your computer via Front Row, you just might want to deinterlace DV-sourced material.) Then click OK.
    Back in the Movie Settings dialog, deselect the Prepare for Internet Streaming option, then click OK to jump back to the QT Export dialog
    Export your file (this is not a speedy process)
    Or were you doing .mp4 files because .mov files weren't working out for you?
    Dual 1.42 G4, 2GB RAM, 9800 Pro, 20" Cinema;   Mac OS X (10.4.6)   Final Cut Studio 5.1

  • Scaling HTML Preview

    Hy,
    For the programm I'm building right now I need a scaleable preview for simple HTML (mostly Text). I got this to work with a HTMLEditorKit & some hacks (such as creating a View that works without a parent view). It scaled just fine using an AffineTransform applied to the Graphics object and had no problems (after some heavy debugging).
    The real problems started when I needed to preview a <form> in this preview. The HTMLEditorKit (or more precisely the Views) use Swing components to draw the form-elements (which is reasonable, of course). Sadly Swing Components seem to work really bad with scaling. As soon as I have a Checkbox in my Preview and do Scaling at the same time it just throws the following exception.
    java.lang.IllegalStateException: constrain(xywh) is not supported for complex transform.
         at sun.java2d.SunGraphics2D.constrain(SunGraphics2D.java:287)
         at sun.awt.SunGraphicsCallback.constrainGraphics(SunGraphicsCallback.java:25)
         at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:51)
         at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
         at java.awt.Container.paint(Container.java:1123)
    The only instance of scaled Swing components I've found was Jazz (at http://www.cs.umd.edu/hcil/jazz/ ). It would be a solution, but it seems like overkill. I don't have to be able to actually use the components. They only have to display.
    regards
    Joachim Sauer

    If you are talking about "drilling", like clicking on Assets as a line item and having the report show additional lines, I have not seen that. The only expansion that I have found is when you build it into the report design. This expansion is only displayed one way on the report and is not interactive.

  • Rotate a Cylinder within the x,y,z axis

    I want to set a Point3d object as an argument in the method and then the cylinder to orientate accordingly to that point (maybe vector). Is this possible?

    It worked, now i want to rotate a TruncatedCone like this
    package shape;
    import shape.*;
    import java.io.*;
    import java.util.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    Truncated Cone is a geometry primitive defined with two radius and a height.
    It is a truncated cone centered at the origin with its central axis
    aligned along the Y-axis.
    <p>
    When a texture is applied to a truncated cone, the texture is applied to the
    caps and the body different. A texture is mapped CCW from the back of the
    body. The top and bottom caps are mapped such that the texture appears
    front facing when the caps are rotated 90 degrees toward the viewer.
    <p>
    This class hs been copied from the Cylinder class and was then modified to
    match the needs of a runcated cone.
    @author <a href="http://www.gressly.ch/rene/" target="_top">Rene Gressly</a>
    public class TruncatedCone extends Primitive
        float radius1, radius2, height;
        int xdivisions, ydivisions;
        boolean bDrawCaps=true;
        static final int MID_REZ_DIV_X = 10;
        static final int MID_REZ_DIV_Y = 1;
         * Designates the body of the truncated cone.  Used by <code>getShape</code>.
        public static final int BODY = 0;
         * Designates the top end-cap of the truncated cone.
         * Used by <code>getShape</code>.
        public static final int TOP = 1;
         * Designates the bottom end-cap of the truncated cone.
         * Used by <code>getShape</code>.
        public static final int BOTTOM = 2;
         *   Constructs a default truncated cone of bottom radius of 1.0, top radius 0.5 and height
         *   of 2.0. Resolution defaults to 15 divisions along X axis and
         *   1 along the Y axis.
        public TruncatedCone()
              this(1.0f, 0.5f, 2.0f, GENERATE_NORMALS, MID_REZ_DIV_X, MID_REZ_DIV_Y, null/*,true*/);
         *   Constructs a default truncated cone of two given radius and height.
         *   @param radius1          Bottom Radius
         *   @param radius2      Top Radius
         *   @param height           Height
        public TruncatedCone (float radius1, float radius2, float height)
              this(radius1, radius2, height, GENERATE_NORMALS, MID_REZ_DIV_X, MID_REZ_DIV_Y, null/*, true*/);
         *   Constructs a default truncated cone of two given radius, height height and appearance.
         *   @param radius1          Bottom Radius
         *   @param radius2      Top Radius
         *   @param height           Height
         *   @param ap                Appearance
         *      @param bDrawCaps     Indicates if top and bottom caps shall be drawn
        public TruncatedCone (float radius1, float radius2, float height, Appearance ap/*, boolean bDrawCaps*/)
              this(radius1, radius2, height, GENERATE_NORMALS, MID_REZ_DIV_X, MID_REZ_DIV_Y, ap/*, bDrawCaps*/);
         *   Constructs a default truncated cone of two given radius, height, primitive flags and appearance.
         *   @param radius1          Bottom Radius
         *   @param radius2      Top Radius
         *   @param height           Height
         *   @param primflags      Flags
         *   @param ap                Appearance
         *      @param bDrawCaps     Indicates if top and bottom caps shall be drawn.
        public TruncatedCone (float radius1, float radius2, float height, int primflags, Appearance ap/*, boolean bDrawCaps*/)
              this(radius1, radius2, height, primflags, MID_REZ_DIV_X, MID_REZ_DIV_Y, ap/*, bDrawCaps*/);
         *  Obtains the Shape3D node associated with a given part of the truncated cone.
         *  This allows users to modify the appearance or geometry of individual parts.
         *  @param partId The part to return (BODY, TOP, or BOTTOM).
         *  @return The Shape3D object associated with the partID.  If an
         *  invalid partId is passed in, null is returned.
        public Shape3D getShape(int partId)
            if (partId == BODY)
                return (Shape3D) ( (Group)getChild(0) ).getChild(BODY);
            else if (partId == TOP)
                return (Shape3D) ( (Group)( (Group)getChild(0) ).getChild(TOP) ).getChild(0);
            else if (partId == BOTTOM)
                return (Shape3D) ( (Group)( (Group)getChild(0) ).getChild(BOTTOM) ).getChild(0);
            return null;
        /** Sets appearance of the truncated cone. This will set each part of the
         *  truncated cone (TOP,BOTTOM,BODY) to the same appearance. To set each
         *  part's appearance separately, use getShape(partId) to get the
         *  individual shape and call shape.setAppearance(ap).
        public void setAppearance(Appearance ap)
              ((Shape3D)((Group)getChild(0)).getChild(BODY)).setAppearance(ap);
              ((Shape3D)((Group)((Group)getChild(0)).getChild(TOP)).getChild(0)).setAppearance(ap);
              ((Shape3D)((Group)((Group)getChild(0)).getChild(BOTTOM)).getChild(0)).setAppearance(ap);
         *   Constructs a customized truncated cone of two given radius, height,
         *   resolution (X and Y dimensions), and appearance. The
         *   resolution is defined in terms of number of subdivisions
         *   along the object's X axis (width) and Y axis (height). More divisions
         *   lead to more finely tesselated objects.
         *   @param radius           Radius
         *   @param height           Height
         *   @param xdivision      Number of divisions along X direction.
         *   @param ydivision      Number of divisions along height of cylinder.
         *   @param primflags      Primitive flags.
         *   @param ap                Appearance
         *      @param bDrawCaps     Indicates if top and bottom caps shall be drawn.
         public TruncatedCone(float radius1, float radius2, float height, int primflags,
                                  int xdivision, int ydivision, Appearance ap/*, boolean bDrawCaps*/)
              super();
              this.radius1 = radius1;
              this.radius2 = radius2;
              this.height = height;
              this.xdivisions = xdivision;
              this.ydivisions = ydivision;
              flags = primflags;
              this.bDrawCaps = bDrawCaps;
              boolean outside = (flags & GENERATE_NORMALS_INWARD) == 0;
              // Create many body of the cylinder.
              Quadrics q = new Quadrics();
              GeomBuffer gbuf = null;
              Shape3D shape[] = new Shape3D[3];
              GeomBuffer cache = getCachedGeometry(Primitive.CYLINDER, radius1, radius2, height, xdivision, ydivision, primflags);
              if (cache != null)
                   shape[BODY] = new Shape3D(cache.getComputedGeometry());
                   numVerts += cache.getNumVerts();
                   numTris += cache.getNumTris();
              else
                   gbuf = q.cylinder((double)radius1, (double)radius2, (double)height, xdivision, ydivision, outside);
                   shape[BODY] = new Shape3D(gbuf.getGeom(flags));
                   numVerts += gbuf.getNumVerts();
                   numTris += gbuf.getNumTris();
                   if ((primflags & Primitive.GEOMETRY_NOT_SHARED) == 0)
                   cacheGeometry(Primitive.CYLINDER, radius1, radius2, height, xdivision, ydivision, primflags, gbuf);
              if ((flags & ENABLE_APPEARANCE_MODIFY) != 0)
                   (shape[BODY]).setCapability(Shape3D.ALLOW_APPEARANCE_READ);
                   (shape[BODY]).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
              (shape[BODY]).setCapability(Shape3D.ALLOW_GEOMETRY_READ);    
           (shape[BODY]).setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);   
             ((GeometryArray)(shape[BODY]).getGeometry()).setCapability(GeometryArray.ALLOW_COORDINATE_READ);
                  ((GeometryArray)(shape[BODY]).getGeometry()).setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);    
              if ( bDrawCaps )
              {          Appearance a = new Appearance();
      Material mat = new Material();
      PolygonAttributes polyAtt= new
    PolygonAttributes(PolygonAttributes.POLYGON_FILL,PolygonAttributes.CULL_BACK
    , 0.0f);
      a.setMaterial(mat);
      a.setPolygonAttributes(polyAtt);
                   // Create top of cylinder
                   gbuf = q.disk((double)radius2, xdivision, outside);
                   shape[TOP] = new Shape3D(gbuf.getGeom(flags));
                   shape[TOP].setAppearance(a);
                   if ((flags & ENABLE_APPEARANCE_MODIFY) != 0)
                        (shape[TOP]).setCapability(Shape3D.ALLOW_APPEARANCE_READ);
                        (shape[TOP]).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
                   numVerts += gbuf.getNumVerts();
                   numTris += gbuf.getNumTris();
                   //move it up
                   Transform3D t2 = new Transform3D();
                   Vector3d vec = new Vector3d(0.0, 0.0, (double)height);
                   t2.setTranslation(vec);
                   TransformGroup objTrans2 = new TransformGroup();
                   objTrans2.setTransform(t2);
                   objTrans2.addChild(shape[TOP]);
                   objTrans.addChild(objTrans2);
              (shape[TOP]).setCapability(Shape3D.ALLOW_GEOMETRY_READ);    
           (shape[TOP]).setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);   
             ((GeometryArray)(shape[TOP]).getGeometry()).setCapability(GeometryArray.ALLOW_COORDINATE_READ);
                  ((GeometryArray)(shape[TOP]).getGeometry()).setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);   
                   // Create bottom
                   gbuf = q.disk((double)radius1, xdivision, !outside);
                   shape[BOTTOM] = new Shape3D(gbuf.getGeom(flags));
                   shape[BOTTOM].setAppearance(a);
                   if ((flags & ENABLE_APPEARANCE_MODIFY) != 0)
                        (shape[BOTTOM]).setCapability(Shape3D.ALLOW_APPEARANCE_READ);
                        (shape[BOTTOM]).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
                   numVerts += gbuf.getNumVerts();
                   numTris += gbuf.getNumTris();
                   // Flip the cap so that texture coords are right.
                   Transform3D t3 = new Transform3D();
                   rotMat = new Matrix4d();
                   objectMat = new Matrix4d();
                   rotMat.setIdentity();
                   objectMat.setIdentity();
                   // rotMat.rotZ(Math.PI);
                   objectMat.mul(objectMat, rotMat);
                   t3.set(objectMat);
                   // Move it down
                   vec = new Vector3d(0.0, 0.0, 0.0);
                   t3.setTranslation(vec);
                   TransformGroup objTrans3 = new TransformGroup();
                   objTrans3.setTransform(t3);
                   objTrans3.addChild(shape[BOTTOM]);
                   objTrans.addChild(objTrans3);
                        (shape[BOTTOM]).setCapability(Shape3D.ALLOW_GEOMETRY_READ);    
           (shape[BOTTOM]).setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);   
             ((GeometryArray)(shape[BOTTOM]).getGeometry()).setCapability(GeometryArray.ALLOW_COORDINATE_READ);
                  ((GeometryArray)(shape[BOTTOM]).getGeometry()).setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);    
              // Set Appearance
              if (ap == null){
              setAppearance();
              else setAppearance(ap);
                     transformCylinder(new Point3f(-5f,-5f,-5f), new Point3f(5f,5f,5f),new TruncatedCone());
         * Used to create a new instance of the node.  This routine is called
         * by <code>cloneTree</code> to duplicate the current node.
         * <code>cloneNode</code> should be overridden by any user subclassed
         * objects.  All subclasses must have their <code>cloneNode</code>
         * method consist of the following lines:
         * <P><blockquote><pre>
         *     public Node cloneNode(boolean forceDuplicate) {
         *         UserSubClass usc = new UserSubClass();
         *         usc.duplicateNode(this, forceDuplicate);
         *         return usc;
         * </pre></blockquote>
         * @param forceDuplicate when set to <code>true</code>, causes the
         *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
         *  <code>false</code>, the value of each node's
         *  <code>duplicateOnCloneTree</code> variable determines whether
         *  NodeComponent data is duplicated or copied.
         * @see Node#cloneTree
         * @see Node#duplicateNode
         * @see NodeComponent#setDuplicateOnCloneTree
        public Node cloneNode(boolean forceDuplicate)
            TruncatedCone c = new TruncatedCone(radius1, radius2, height, flags, xdivisions, ydivisions, getAppearance()/*, bDrawCaps*/);
            c.duplicateNode(this, forceDuplicate);
            return c;
         * Copies all node information from <code>originalNode</code> into
         * the current node.  This method is called from the
         * <code>cloneNode</code> method which is, in turn, called by the
         * <code>cloneTree</code> method.
         * <P>
         * For any <i>NodeComponent</i> objects
         * contained by the object being duplicated, each <i>NodeComponent</i>
         * object's <code>duplicateOnCloneTree</code> value is used to determine
         * whether the <i>NodeComponent</i> should be duplicated in the new node
         * or if just a reference to the current node should be placed in the
         * new node.  This flag can be overridden by setting the
         * <code>forceDuplicate</code> parameter in the <code>cloneTree</code>
         * method to <code>true</code>.
         * @param originalNode the original node to duplicate.
         * @param forceDuplicate when set to <code>true</code>, causes the
         *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
         *  <code>false</code>, the value of each node's
         *  <code>duplicateOnCloneTree</code> variable determines whether
         *  NodeComponent data is duplicated or copied.
         * @see Node#cloneTree
         * @see Node#cloneNode
         * @see NodeComponent#setDuplicateOnCloneTree
        public void duplicateNode(Node originalNode, boolean forceDuplicate)
            super.duplicateNode(originalNode, forceDuplicate);
         Retrieves the height of the truncated cone.
         @return     The height of the truncated cone.
         public float getHeight()
              return height;
         Retrieves the bottom radius of the truncated cone.
         @return     The bottom radius of the truncated cone.
         public float getRadius1()
              return radius1;
         Retrieves the upper radius of the truncated cone.
         @return     The upper radius of the truncated cone.
         public float getRadius2()
              return radius2;
           public void transformCylinder(Point3f pointA, Point3f pointB, TruncatedCone c) {
              Point3f a=pointA;  
              Point3f b=pointB;   
              //rotation components   
              double za=Math.atan(Math.abs((b.x-a.x)/(b.y-a.y)));   
              System.out.println("RZ: "+Math.toDegrees(za));   
              double ya=Math.atan(Math.abs((b.z-a.z)/(b.x-a.x)));   
              System.out.println("RY: "+Math.toDegrees(ya));   
              Transform3D rotY=new Transform3D();   
              rotY.rotY(-ya);   
              Transform3D rotZ=new Transform3D();   
              rotZ.rotZ(-za);   
              rotY.mul(rotZ);   
              Transform3D upT=new Transform3D();   
              upT.setTranslation(new Vector3f(b));  
               Transform3D downT=new Transform3D();   
               downT.setTranslation(new Vector3f(a));   
               GeometryArray top=(GeometryArray)c.getShape(TruncatedCone.TOP).getGeometry();   
               GeometryArray bottom=(GeometryArray)c.getShape(TruncatedCone.BOTTOM).getGeometry();   
               GeometryArray body=(GeometryArray)c.getShape(TruncatedCone.BODY).getGeometry();   
               for(int i=0;i<top.getVertexCount();i++) {     
               Point3f p=new Point3f();     
               top.getCoordinate(i,p);     
               if(p.y<0) {       
               p.y += c.getHeight() / 2;      }    
                if(p.y>0) {        p.y -= c.getHeight() / 2;      }    
                 rotY.transform(p);     
                 upT.transform(p);     
                 top.setCoordinate(i,p);    }   
                 for(int i=0;i<body.getVertexCount();i++) {    
                  Point3f p=new Point3f();     
                  body.getCoordinate(i,p);     
                  float ly=p.y;     
                  if(ly>0f) {       
                  p.y-=c.getHeight()/2;      
                   rotY.transform(p);       
                   upT.transform(p);      }
                   else {       
                   p.y+=c.getHeight()/2;       
                   rotY.transform(p);       
                   downT.transform(p);      }     
                   body.setCoordinate(i,p);    }   
                   for(int i=0;i<bottom.getVertexCount();i++) {     
                   Point3f p=new Point3f();     
                   bottom.getCoordinate(i,p);     
                   if(p.y<0) {       
                   p.y += c.getHeight() / 2;      }     
                   if(p.y>0) {        p.y -= c.getHeight() / 2;      }     
                   rotY.transform(p);     
                   downT.transform(p);     
                   bottom.setCoordinate(i,p);   
    }i recieve no errors but it doesn't work.
    It requires the shape package. Please write your mail if you want me to send the package to you in order to test the whole class himself.
    Thanks in advance

  • Scaling rectangles making my head hurt-

    I’ve got four rectangles: the main stage, a sprite (an
    LDM), the stage within the LDM, and a boundingRect of objects
    within the LDM (so the coordinates are relative to the LDM stage,
    not the main stage). I need a transform (scale, rotate, and
    translate) that when applied to the LDM sprite produces a best fit
    between the boundingRect within the LDM and the main stage. The
    rotation will either be 0 or 90. The following code gets the scale
    and rotation but I’m having trouble figuring out the
    translation once a scale has been applied. It looks like the map()
    method should help but so far I haven’t been able to make use
    of it.

    I’m sure I’ll get this if I just work through it
    methodically but maybe someone will beat me to it. The following
    two links show the pre-scale and post-scale arrangement of
    rectangles drawn at 25% scale. Some notes:
    The small colored boxes represent sprites within the LDM.
    The bounding box around these sprites is calculated on the
    fly (the sprites are positioned by the user)
    The main stage size is fixed.
    The LDM sprite starting size is fixed but its position on the
    main stage is not (it can be scrolled by the user).
    The LDM sprite must be scaled, rotated, and translated such
    that the bounding box (which scales within the LDM) achieves a best
    fit on the main stage.
    http://www.appliedcd.com/FTP-Guest/pre_scale.jpg
    http://www.appliedcd.com/FTP-Guest/post_scale.jpg
    PS: <soapbox>It would be nice if Adobe enabled inline
    picts or attachements. There have been a couple of times when I
    thought an illustration would help.</soapbox>

  • Unable to open ANY file in Photoshop CS2

    I was working on pretty big files. Lots of layers. I decided to restart the Computer in order to speed up the process. Once the computer booted up again i double clicked on one of the images and I got the lovely beach ball for quite some time...after well...about 2 minutes or so...NO sign of ANYTHING happenning i decided to close the program using the Command + Tab and then Quitting from there instead of force quit. USUALLY when I do that it takes a while to regroup and close, this time it does it instantly. NO files are opening it just stays there... "thinking" and when I quit it quites instantly. Has anyone else experienced this in the past? How could I solve this problem I am going NUTS! lol
    Thank you for your time. Hope I can get some help soon.

    Hello there,
    I hope what im trying to say will be quite clear, well im still an amateur in photoshop, had some tutorial lessons, which were a bit worth it....but my problem is iv been trying to use photoshop 7.0 to edit some of my images but there is this grid appearing on the foreground of every image and it appears as if each image has been locked. I cant do any scaling, rotation, etc, as this grid doesnt want to go anywhere..
    can somebody please help me...your help can be appreciated..
    thanks,
    peppy

  • Can I scale an oam file in Muse?

    It would seem not, as I can't do it.   If anyone knows, please reply.
    The pixel preview of an oam does not even match in Muse.  This makes it hard to place the animation with any accuracy.

    Thanks Darrell.
    I am still new to Edge. Can an Edge file be converted to a Symbol and that file placed and transformed (ie: scaled, rotated etc) in another
    Edge file?
    Let me know if there any links to learn about Symbols in Edge.
    On the off-chance that something obvious in the code below let me know. This is in the Edit HTML window in Muse:
    <iframe src="http://www.first-image.com/_anim/MSF_anim_Edge/index.html" width="600" height="600" scale="20%"  frameborder="0" scrolling="no">
    </iframe>
    I had tried the "scale="20%" but the size didn't change. It seems like a loop function should be able to be entered in code here too.
    Thanks, David

  • I want to update forms in the response file and save it. Sometimes it works, but often I need to save the response file in another name. Very inconsequent! How come?

    I have a form that I am sending out and compiling in the response file. These forms I also want to be able to update after receiving them (when I have them in the response file).
    But when I do the updates I need to re-save the response file with another name? The strange thing is that sometimes I can just update and save exactly the way I want it. But most of the time I get the message "This file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder."
    Can someone please help me to figure out how to solve this issue. I know that I am the only one that has the file open. I am encountering the same issue in both Acrobat Pro 9 and Acrobat Pro X. (File was created in Acrobat Pro 9)

    Good day!
    A simple Paste does not work for you?
    It should place the clipboard content as a new Layer which you can then move around.
    If there is any chance that the elements need to be scaled, rotated etc. I would prefer to place them as Smart Objects (File > Place …) and do the masking that is specific to the images themselves in those.
    Regards,
    Pfaffenbichler

  • Using the content aware move tool, I want to move an item from one image to another image but it does not seem to work. I think I need two layers on one document so how do I do this

    Using the content aware move tool, I want to move an item from one image to another image but it does not seem to work. I think I need two layers on one document so how do I do this

    Good day!
    A simple Paste does not work for you?
    It should place the clipboard content as a new Layer which you can then move around.
    If there is any chance that the elements need to be scaled, rotated etc. I would prefer to place them as Smart Objects (File > Place …) and do the masking that is specific to the images themselves in those.
    Regards,
    Pfaffenbichler

  • How to make type flow with the shape of an object?

    Hi there,
    I am a bit of an Illustrator newbie. I am needing some help to work out how to wrap or manipulate type to fit the shape and flow of an object? I have attached an image to show you what I am trying to do. I want the "shop by measure" text to be in the yellow blank space of the tape measure but flowing with the shape of the tape. Any help appreciated! Be gentle please lol.

    See online help. Read about Envelope Distortion. Then keep things simple as you experiment. This takes about 2 minutes.
    When doing "ribbon distortions," selecting corresponding top and bottom MeshPoints as pairs and moving/scaling/rotating them together helps avoid things getting all distorted out of control. See this PDF for an example. The example was done using a 1 Row, 2 Column Mesh.
    JET

Maybe you are looking for