A better way to rotate a shape

I need a way to easily rotate several Ellipse2D objects. The approach I'm using is not working because it's rotating the entire coordinate system in my Canvas object:
public void paint(Graphics g) {     
Graphics2D g2 = (Graphics2D) g;          
Ellipse2D.Double e = new Ellipse2D.Double(220.0, 75.0, 47.0, 30.0);
AffineTransform rotate45 =
AffineTransform.getRotateInstance(Math.toRadians(161.5),
220.0, 75.0);
g2.setTransform(rotate45);
g2.draw(e);
} // end paint
Is there something better to use other than AffineTransform that will allow me to rotate just the shape itself?
thanks,
Eric

You can still use AffineTransform. There is a method called createTransformedShape and it does what you want.
http://java.sun.com/j2se/1.4.1/docs/api/java/awt/geom/AffineTransform.html#createTransformedShape(java.awt.Shape)
Ellipse2D e = ...
AffineTransform rotate45 = ...
e = (Ellipse2D) rotate45.createTransformedShape(e);
...

Similar Messages

  • Stop rotating in shape tween

    Hi,
    I have made a rectangle in cs6 actionscript 2.0
    Now I want to make it a Liquified shape, that keeps moving. So am planning to do, is to make keyframes and then change the shape with the envelop tool or the pen tool. And between the keyframes I want to use the shape tween to make it a smooth transition. Problem is, that when the shape then changes, it automaticly rotates 90 degrees. I just want it to change to the shape in the next keyframe, not make a rotation while doing so.
    If there are other better ways of doing this, please feel free sharing tips!
    Thanks a lot!
    Patrick

    use shape hints: modify>shape>add shape hints.

  • Is there a way to rotate canvas in FCP?

    I've been told there is now way to rotate the cavas window 90 degrees. I'm assuming that is true. Anyone, have a solution. I'm editing 9x16 and I've been just turning my monitor on it's side. I'd like another way. I might not get it.
    Any suggestions?

    Brigham,
    A friend of mine did this for a jeweler, so I called him to get the lowdown. He shot the whole thing with the camera at 90 degrees using a dutch head, just like Jim suggested. They edited the whole thing with the monitor on it's side just like you are doing. The Jeweler encased a number of 16x9 flat panels hung length-wise in the store and it looks fabulous. To Bogie's concern though, when they went to put it on the website they needed to change the QT dimensions and even that still came out pretty nice. I never saw the web stuff but saw the other stuff and I can tell you most of the footage was extreme close-up stuff on rings and watches and I bet that's why it was able to transfer okay for the web.

  • Is there a way to make polygone shapes/buttons?

    Greetz peepz,
    Is there a way to make polygone shapes and/or buttons? I would like to make more accurate dropshadows and imagemap-like buttons.

    Aaah, so it's part of the plan to make it posible in the future? To make dropshadows in PNG is ok, but when you want to use the dropshadow option on a transparent PNG it will put a dropshadow on the outer boarders of the imagesquare, that's kind of annoying. I want to animate a rotation of a polygone shape, but I'll skip the dropshadow for now then.

  • Is there an easier way to draw a shape in 3d to match X,Y, Z of photo?

    I usually start a project in 2d and import photos, draw shapes and text in this 2d environment. I find it easier this way because they all start out on the same plane, and when manipulating in 3d later, this initial plane acts as a reference plane that I can shift X,Y,Z and rotation paramaters from. I then add a new camera and turn everything into 3d. However, as I work further in the timeline, I sometimes want to add a rectangle that overlaps exactly on top of a photo lying in 3d space as to cover it. When I start the shape command in the active camera view and draw the rectangle to match the outline of the photo, it seems like the photo and rectangle are on the same plane in this view. However, when I check this by going to the perspective view and checking from other angles I see that the rectangle was placed on an arbitrary plane and the rectangle is not overlapping the photo.
    To correct this, I open the inspector of the photo and write down it's X,Y,Z positions and also it's X,Y,Z rotation parameters. Then I go to the rectangle that I have already drawn and in the wrong plane, open it's inspector properties, and replace with the X,Y,Z and rotation parameters of the photos. Then fine tune the orthogonal positions and scaling within the plane with the 3d tranform tool. This seems like a lot of work, especially when I have to do it a 100 times. Looking for an easier way to draw a shape on the same plane of a photo in 3d space.
    Thanks

    Howdy,
    This is a really good question about one of the bigger challenges of building a 3D project. When you add objects to the Canvas (including drawing), they get added in the camera's viewspace, facing the camera and sharing the same up-vector (i.e. positive Y is up). This is all well and good, but what about doing what you ask, where you want to add an object in the localspace of another object? Let's look at your example: adding a shape that is coplanar to a photo, with the camera not necessarily aligned with the photo.
    As Mark suggested, you can draw the shape in the camera's viewspace and then drag-and-drop the Position and Rotation channels from the photo onto the shape. This will replace the shape's Position and Rotation values with that of the photo, making them coplanar and located in the same place. The shortcoming of this method is that you draw the shape at a size that seems correct in the Canvas, but once it's moved to the same place as the photo, it will often turn out to be too small or large. Then you have to make further tweaks.
    Another solution is to use the Isolate command. Isolate temporarily aligns the current view to the selected object and solos that object. So you could isolate the photo and then draw the shape in the Canvas and it will be coplanar with the photo. The only caveat is that the moment you finish drawing the shape, it will disappear. This is because the photo is still isolated (and soloed). As soon as you de-isolate the photo, everything will reappear.
    The easiest way to use Isolate for new photos—not ones already in the project—is to place the photo in a 3D group, position the group where you want the photo and shape to be, then isolate the group and add anything you want to it (shapes, image, text, etc).

  • [iPhone Beta 6] Text Rotation Slow

    I have a Landscape application that uses "UILabel" and "UITextField", and all was fine till Beta 6 came out. Since then if I rotate text and there are say 2-3 on the screen the frame rate goes down like crazy.
    To make the UILabel or UITextField rotate I did for example:
    1) via .transform
    =================
    // Set Bot Value
    textBottom = [[[UITextField alloc] initWithFrame:frameText]];
    textBottom.borderStyle = UITextBorderStyleNone;
    textBottom.adjustsFontSizeToFitWidth = YES;
    textBottom.textColor = [[UIColor blackColor]];
    textBottom.font = [[UIFont boldSystemFontOfSize:17.0]];
    textBottom.placeholder = @"";
    textBottom.backgroundColor = nil;
    textBottom.enabled = NO;
    textBottom.textAlignment = UITextAlignmentLeft;
    textBottom.center = CGPointMake( imageRect.size.width - 25, imageRect.size.height - 20 );
    CGAffineTransform transformFlip = CGAffineTransformMakeRotation( -1.571 );
    textBottom.transform = CGAffineTransformConcat ( textBottom.transform, transformFlip );
    [[self addSubview:textBottom]];
    and/or
    2) via setTransform
    ===================
    // Set Bot Value
    textBottom = [[[UITextField alloc] initWithFrame:frameText]];
    textBottom.borderStyle = UITextBorderStyleNone;
    textBottom.adjustsFontSizeToFitWidth = YES;
    textBottom.textColor = [UIColor blackColor];
    textBottom.font = [[UIFont boldSystemFontOfSize:17.0]];
    textBottom.placeholder = @"";
    textBottom.backgroundColor = nil;
    textBottom.enabled = NO;
    textBottom.textAlignment = UITextAlignmentLeft;
    textBottom.center = CGPointMake( imageRect.size.width - 25, imageRect.size.height - 20 );
    [[self addSubview:textBottom]];
    CGAffineTransform transformFlip = CGAffineTransformMakeRotation( -1.571 );
    [[textBottom setTransform:transformFlip]];
    This problem is only on the device (not the simulator) the application now starts running VERY VERY VERY VERY slow if there is say 3 or more UILabel or UITextFields on the display.
    In Beta 5 and below all worked great. (also on the simulator)
    Is there a better way to draw text rotated that does not slow the iPhone/iPod device down to a crawl? (i.e. get 2-3 FPS instead of the 30 or so before).
    Thanks in advance for any help.

    Figured it out, can no longer transform UILabel as it is slow. Need to drawtext text yourself.

  • Rotate dragged shape on button click

    Hi guys,
    I need help here. I want to do a drawing application where user can resize and rotate a shape. I have created a shape which I can drag around but how to make it rotate upon clicking on button?? Let say when I select the shape and click on 'rotate' button my shape will be rotate by 90 degree. After that the rotated shape can still be drag. Any help would be appreciated.

    Hi Darryl.Burke,
    Thanks for your reply, yes I use AffineTransform methods to rotate the shape. Is there any different with other rotation method?? Ok when I use setToRotation, the shape indeed rotate to the correct position but when I click the shape return back to its original and other weird things happen. Below is the code. Can you please point out the part that I done it wrong please. Thanks.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import java.util.Vector;
    import javax.swing.border.CompoundBorder;
    import java.io.*;
    public class RotateShape
         private static void createAndShowGUI() {
            //Create and set up the window.
           JFrame.setDefaultLookAndFeelDecorated(true);      
           Viewer frame = new Viewer();
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frame.setVisible(true);
        public static void main(String[] args)
             javax.swing.SwingUtilities.invokeLater(new Runnable() {
              public void run() {
                   createAndShowGUI();
    class Viewer extends JFrame implements ActionListener
         JMenuBar menuBar;
         drawRect buildDesign;
        public Viewer()
           Toolkit kit = Toolkit.getDefaultToolkit();
            Dimension screenSize = kit.getScreenSize();
            int screenHeight = screenSize.height;
            int screenWidth = screenSize.width;
            // center frame in screen
              setSize(700, 600);
              setLocation(screenWidth / 4, screenHeight / 4);
              setResizable(false);
            buildDesign = new drawRect();
            buildDesign.setBorder(BorderFactory.createEmptyBorder(0, 2, 3, 3));
            JTabbedPane tabbed = new JTabbedPane();
            tabbed.addTab("Design", buildDesign);
            //tabbed.addTab("Viewer", buildViewer());
            tabbed.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6),
                                                tabbed.getBorder()));
            //------------------------End of Tabbed Pane----------------------------------------------------//
          JPanel pane = new JPanel();
          Button rectButton = new Button("Rect");
          rectButton.addActionListener(this);
          pane.add(rectButton);
          Button deleteButton = new Button("Delete");
          deleteButton.addActionListener(this);
          pane.add(deleteButton);
          Button rotateButton = new Button("Rotate");
          rotateButton.addActionListener(this);
          pane.add(rotateButton);
          JScrollPane scroller = new JScrollPane(pane);
          scroller.setOpaque(false);
          scroller.getViewport().setOpaque(false);
          scroller.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6),
                                                  scroller.getBorder()));
               //------------------------End of Build Item list----------------------------------------------//
          JPanel content = new JPanel(new BorderLayout());
          content.setOpaque(false);
          content.add(tabbed, BorderLayout.CENTER);
          content.add(scroller, BorderLayout.WEST);
          add (content, BorderLayout.CENTER);
          //------------------------End of add content----------------------------------------------//
              public void actionPerformed(ActionEvent evt) {
               // Respond to a command from one of the window's menu.
          String command = evt.getActionCommand();
          if (command.equals("Rect"))
             buildDesign.addShape(new RectShape());
          else if (command.equals("Delete"))
             buildDesign.delete();
          else if (command.equals("Rotate"))
             buildDesign.rotate();
    class drawRect extends JPanel implements ActionListener, MouseListener, MouseMotionListener
             Image offScreenCanvas = null;   // off-screen image used for double buffering
                 Graphics offScreenGraphics;     // graphics context for drawing to offScreenCanvas
                 Vector shapes = new Vector();   // holds a list of the shapes that are displayed on the canvas
                 Color currentColor = Color.black; // current color; when a shape is created, this is its color
                 float alpha;
            drawRect() {
            // Constructor: set background color to white set up listeners to respond to mouse actions
          setBackground(Color.white);
          addMouseListener(this);
          addMouseMotionListener(this);
       synchronized public void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D) g;
            // In the paint method, everything is drawn to an off-screen canvas, and then
            // that canvas is copied onto the screen.
          g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
          g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
          makeOffScreenCanvas();
          g2.drawImage(offScreenCanvas,0,0,this); 
          AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OUT,alpha);
              g2.setComposite(composite);
          g2.setColor(Color.GRAY);
          drawGrid(g, 20); 
       public void update(Graphics g) {
            // Update method is called when canvas is to be redrawn.
            // Just call the paint method.
          super.paintComponent(g);
       void makeOffScreenCanvas() {
             // Erase the off-screen canvas and redraw all the shapes in the list.
             // (First, if canvas has not yet been created, then create it.)
          if (offScreenCanvas == null) {
             offScreenCanvas = createImage(getSize().width,getSize().height);
             offScreenGraphics = offScreenCanvas.getGraphics();
          offScreenGraphics.setColor(getBackground());
          offScreenGraphics.fillRect(0,0,getSize().width,getSize().height);
          int top = shapes.size();
          for (int i = 0; i < top; i++) {
             Shape s = (Shape)shapes.elementAt(i);
             s.draw(offScreenGraphics);
            private void drawGrid(Graphics g, int gridSpace) {
          Insets insets = getInsets();
          int firstX = insets.left;
          int firstY = insets.top;
          int lastX = getWidth() - insets.right;
          int lastY = getHeight() - insets.bottom;
          //Draw vertical lines.
          int x = firstX;
          while (x < lastX) {
            g.drawLine(x, firstY, x, lastY);
            x += gridSpace;
          //Draw horizontal lines.
          int y = firstY;
          while (y < lastY) {
            g.drawLine(firstX, y, lastX, y);
            y += gridSpace;
        public void actionPerformed(ActionEvent evt)
         synchronized void addShape(Shape shape) {
              // Add the shape to the canvas, and set its size/position and color.
              // The shape is added at the top-left corner, with size 50-by-30.
              // Then redraw the canvas to show the newly added shape.
          shape.setColor(Color.red);
          shape.setColor(currentColor);
           shape.reshape(3,3,70,10);
          shapes.addElement(shape);
          repaint();
         void clear() {
             // remove all shapes
           shapes.setSize(0);
           repaint();
        void delete() {
             // remove selected shapes
                  shapes.removeElement(selectedShape);
                   repaint();
       void rotate() {     
                     //shapes.addElement(selectedShape);
                  selectedShape.setToRotate(true);
                  //shapes.removeElement(selectedShape);
                   repaint();
       Shape selectedShape = null;
       Shape shapeBeingDragged = null;  // This is null unless a shape is being dragged.
                                        // A non-null value is used as a signal that dragging
                                        // is in progress, as well as indicating which shape
                                        // is being dragged.
       int prevDragX;  // During dragging, these record the x and y coordinates of the
       int prevDragY;  //    previous position of the mouse.
        Shape clickedShape(int x, int y) {
             // Find the frontmost shape at coordinates (x,y); return null if there is none.
          for ( int i = shapes.size() - 1; i >= 0; i-- ) {  // check shapes from front to back
             Shape s = (Shape)shapes.elementAt(i);
             if (s.containsPoint(x,y))
                  s.tickSelected(true);
                  selectedShape = s;
                return s;
                else
                s.tickSelected(false);
                repaint();
          return null;
       synchronized public void mousePressed(MouseEvent evt) {
             // User has pressed the mouse.  Find the shape that the user has clicked on, if
             // any.  If there is a shape at the position when the mouse was clicked, then
             // start dragging it.  If the user was holding down the shift key, then bring
             // the dragged shape to the front, in front of all the other shapes.
          int x = evt.getX();  // x-coordinate of point where mouse was clicked
          int y = evt.getY();  // y-coordinate of point                                  
             shapeBeingDragged = clickedShape(x,y);
             if (shapeBeingDragged != null) {
                prevDragX = x;
                prevDragY = y;
                if (evt.isShiftDown()) {                 // Bring the shape to the front by moving it to
                   shapes.removeElement(shapeBeingDragged);  //       the end of the list of shapes.
                   shapes.addElement(shapeBeingDragged);
                   repaint();  // repaint canvas to show shape in front of other shapes
       synchronized public void mouseDragged(MouseEvent evt) {
              // User has moved the mouse.  Move the dragged shape by the same amount.
          int x = evt.getX();
          int y = evt.getY();
          if (shapeBeingDragged != null) {
             shapeBeingDragged.moveBy(x - prevDragX, y - prevDragY);
             prevDragX = x;
             prevDragY = y;
             repaint();      // redraw canvas to show shape in new position
       synchronized public void mouseReleased(MouseEvent evt) {
              // User has released the mouse.  Move the dragged shape, then set
              // shapeBeingDragged to null to indicate that dragging is over.
              // If the shape lies completely outside the canvas, remove it
              // from the list of shapes (since there is no way to ever move
              // it back onscreen).
          int x = evt.getX();
          int y = evt.getY();
          if (shapeBeingDragged != null) {
             shapeBeingDragged.moveBy(x - prevDragX, y - prevDragY);
             if ( shapeBeingDragged.left >= getSize().width || shapeBeingDragged.top >= getSize().height ||
                     shapeBeingDragged.left + shapeBeingDragged.width < 0 ||
                     shapeBeingDragged.top + shapeBeingDragged.height < 0 ) {  // shape is off-screen
                shapes.removeElement(shapeBeingDragged);  // remove shape from list of shapes
             shapeBeingDragged = null;
             repaint();
       public void mouseEntered(MouseEvent evt) { }   // Other methods required for MouseListener and
       public void mouseExited(MouseEvent evt) { }    //              MouseMotionListener interfaces.
       public void mouseMoved(MouseEvent evt) { }
       public void mouseClicked(MouseEvent evt) { }
       abstract class Shape implements Serializable{
          // A class representing shapes that can be displayed on a ShapeCanvas.
          // The subclasses of this class represent particular types of shapes.
          // When a shape is first constucted, it has height and width zero
          // and a default color of white.
       int left, top;      // Position of top left corner of rectangle that bounds this shape.
       int width, height;  // Size of the bounding rectangle.
       Color color = Color.white;  // Color of this shape.
       boolean isSelected;
       boolean isRotate;
       AffineTransform t;
       AffineTransform origTransform;
       void reshape(int left, int top, int width, int height) {
             // Set the position and size of this shape.
          this.left = left;
          this.top = top;
          this.width = width;
          this.height = height;
       void moveTo(int x, int y) {
              // Move upper left corner to the point (x,y)
          this.left = x;
          this.top = y;
       void moveBy(int dx, int dy) {
              // Move the shape by dx pixels horizontally and dy pixels veritcally
              // (by changing the position of the top-left corner of the shape).
          left += dx;
          top += dy;
       void setColor(Color color) {
              // Set the color of this shape
          this.color = color;
       void tickSelected (boolean draw) {
                 // If true, a red outline is drawn around this shape.
             isSelected = draw;
       void setToRotate (boolean draw) {
                 // If true, the shape will rotate 90 deg
             isRotate = draw;
       boolean containsPoint(int x, int y) {
             // Check whether the shape contains the point (x,y).
             // By default, this just checks whether (x,y) is inside the
             // rectangle that bounds the shape.  This method should be
             // overridden by a subclass if the default behaviour is not
             // appropriate for the subclass.
          if (x >= left && x < left+width && y >= top && y < top+height)
             return true;
          else
                      return false;
       abstract void draw(Graphics g); 
             // Draw the shape in the graphics context g.
             // This must be overriden in any concrete subclass.
         }  // end of class Shape
    class RectShape extends Shape {
          // This class represents rectangle shapes.
       void draw(Graphics g) {
            Graphics2D g2 = (Graphics2D) g;
            Rectangle2D wall = new Rectangle2D.Double(left,top,width,height);
            Rectangle2D border = new Rectangle2D.Double(left-2,top-2,width+3,height+3);
            origTransform = g2.getTransform();
            if ((isRotate) && (isSelected))
                   t = new AffineTransform();
                      t.setToRotation ((Math.toRadians (90)),(left+width/2) , (top+height/2) );
                      g2.transform(t);
                      g2.setColor(color);
                   g2.fill(wall);
                   g2.setColor(Color.red);
                    g2.draw(border);
                    g2.setTransform( origTransform );
                    return;
            else
                 g2.setColor(color);
              g2.fill(wall);
            if ((isSelected)&& !(isRotate))
                         g2.setColor(Color.red);
                         g2.draw(border);
                              else
                                   g2.setColor(Color.black);
                                   g2.draw(wall);
    }

  • Need help to get alternate or better way to write query

    Hi,
    I am on Oracle 11.2
    DDL and sample data
    create table tab1 -- 1 millions rows at any given time
    id       number       not null,
    ref_cd   varchar2(64) not null,
    key      varchar2(44) not null,
    ctrl_flg varchar2(1),
    ins_date date
    create table tab2 -- close to 100 million rows
    id       number       not null,
    ref_cd   varchar2(64) not null,
    key      varchar2(44) not null,
    ctrl_flg varchar2(1),
    ins_date date,
    upd_date date
    insert into tab1 values (1,'ABCDEFG', 'XYZ','Y',sysdate);
    insert into tab1 values (2,'XYZABC', 'DEF','Y',sysdate);
    insert into tab1 values (3,'PORSTUVW', 'ABC','Y',sysdate);
    insert into tab2 values (1,'ABCDEFG', 'WYZ','Y',sysdate);
    insert into tab2 values (2,'tbVCCmphEbOEUWbxRKczvsgmzjhROXOwNkkdxWiPqDgPXtJhVl', 'ABLIOWNdj','Y',sysdate);
    insert into tab2 values (3,'tbBCFkphEbOEUWbxATczvsgmzjhRQWOwNkkdxWiPqDgPXtJhVl', 'MQLIOWNdj','Y',sysdate);I need to get all rows from tab1 that does not match tab2 and any row from tab1 that matches ref_cd in tab2 but key is different.
    Expected Query output
    'ABCDEFG',  'WYZ'
    'XYZABC',   'DEF'
    'PORSTUVW', 'ABC'Existing Query
    select
       ref_cd,
       key
    from
        select
            ref_cd,
            key
        from
            tab1, tab2
        where
            tab1.ref_cd = tab2.ref_cd and
            tab1.key    <> tab2.key
        union
        select
            ref_cd,
            key
        from
            tab1
        where
            not exists
               select 1
               from
                   tab2
               where
                   tab2.ref_cd = tab1.ref_cd
        );I am sure there will be an alternate way to write this query in better way. Appreciate if any of you gurus suggest alternative solution.
    Thanks in advance.

    Hi,
    user572194 wrote:
    ... DDL and sample data ...
    create table tab2 -- close to 100 million rows
    id       number       not null,
    ref_cd   varchar2(64) not null,
    key      varchar2(44) not null,
    ctrl_flg varchar2(1),
    ins_date date,
    upd_date date
    insert into tab2 values (1,'ABCDEFG', 'WYZ','Y',sysdate);
    insert into tab2 values (2,'tbVCCmphEbOEUWbxRKczvsgmzjhROXOwNkkdxWiPqDgPXtJhVl', 'ABLIOWNdj','Y',sysdate);
    insert into tab2 values (3,'tbBCFkphEbOEUWbxATczvsgmzjhRQWOwNkkdxWiPqDgPXtJhVl', 'MQLIOWNdj','Y',sysdate);
    Thanks for posting the CREATE TABLE and INSERT statments. Remember why you go to all that trouble: so the people whop want to help you can re-create the problem and test their ideas. When you post statemets that don't work, it's just a waste of time.
    None of the INSERT statements for tab2 work. Tab2 has 6 columns, but the INSERT statements only have 5 values.
    Please test your code before you post it.
    I need to get all rows from tab1 that does not match tab2 WHat does "match" mean in this case? Does it mean that tab1.ref_cd = tab2.ref_cd?
    and any row from tab1 that matches ref_cd in tab2 but key is different.
    Existing Query
    select
    ref_cd,
    key
    from
    select
    ref_cd,
    key
    from
    tab1, tab2
    where
    tab1.ref_cd = tab2.ref_cd and
    tab1.key    <> tab2.key
    union
    select
    ref_cd,
    key
    from
    tab1
    where
    not exists
    select 1
    from
    tab2
    where
    tab2.ref_cd = tab1.ref_cd
    Does that really work? In the first branch of the UNION, you're referencing a column called key, but both tables involved have columns called key. I would expect that to cause an error.
    Please test your code before you post it.
    Right before UNION, did you mean
    tab1.key    != tab2.key? As you may have noticed, this site doesn't like to display the &lt;&gt; inequality operator. Always use the other (equivalent) inequality operator, !=, when posting here.
    I am sure there will be an alternate way to write this query in better way. Appreciate if any of you gurus suggest alternative solution.Avoid UNION; it can be very inefficient.
    Maybe you want something like this:
    SELECT       tab1.ref_cd
    ,       tab1.key
    FROM           tab1
    LEFT OUTER JOIN  tab2  ON  tab2.ref_cd     = tab1.ref_cd
    WHERE       tab2.ref_cd  IS NULL
    OR       tab2.key     != tab1.key
    ;

  • Can some one tell me a better way...

    Hi All..
    I work on a web application. I create user ids for people logging into my application. here I have a small problem.. This is what I am currently doing...
    When I create a new user, I assign a new user id to the user and store all hi info.
    All our user ids are stored in User_ID table and user info in User_Info table.
    First I get the max user id from the User_Id table.
    int iuserid = select max(User_ID) from User_ID;
    Then I add ' 1 ' to this and assign it to new user.
    iuserid = iuserid+1;
    insert into User_id values(iuserid, <ssn> );
    Then I store all user info in User_info table..
    insert into User_info(iuserid, <first_name>, <last_name>,...);
    Both these SQLs are executed as a transaction.
    The problem that I have...
    It works fine in a normal environment and in my testing.
    But when the load inceases, before I insert into the User_info, another user tries to get the max User_id from User_ID table, then it conflicts..
    I have seen occurences of User_Info storing the info of a different user against the User_id when many people are accessing the app at the same time.
    Can some one tell me a better way to handle this scenario..
    Appreciate all you help..
    TIA..
    CK

    Hi,
    assuming that the requirement for user_id is only for uniqueness (primary key requirement) not continuosly.
    perhaps can try this,
    1) create a table to keep the max id for each table's key.
    e.g.
    create table key_id_lookup
    key_name char(n),
    current_value number(m)
    where n & m is the size of the field
    2) for each creation of entry in the user_id table, lookup the value in the key_id_table and increment it after retrieval.
    e.g. current_id = select current_value from key_id_lookup where key_name = 'user_id_key';
    current_id+=1;
    update key_id_lookup set current_value = current_id where key_name = 'user_id_key';
    something similar to use of sequence if your database support it.
    3) continue with the creation of record in other tables. now obtain the time stamp of creation and append with the current_id obtained. e.g. timestamp = 132456872; size of m is 5, user_id = 132456872 x 100000 + current_id;
    this should give you a unique key at creation time.
    There should be other better ways of resolving this(like locking the table for the update operation but affect performance, etc), depending on the feature supported by the database in use.
    Hope this can help as last resort if other options not available.

  • A better way to execute a series of external commands?

    Hi,
    Consider the code snippet...
    Process proc1 = rt.exec("Some external command");
    Vector vecOutput = outputGobbler.getOutput() ;
    String[] strAlterCmds = new String[vecOutput.size()];
    for ( int k = 0 ; k < vecOutput.size() ; k++ )
    strAlterCmds[k] = new String();
    strAlterCmds[k] = "cmd.exe /c blah.... " +(String) vecOutput.elementAt( k )+ " ;
    Process proc2 = rt.exec(strAlterCmds[k], null);
    StreamGobbler errorG = new
    StreamGobbler( proc2.getErrorStream(), "Error") ;
    StreamGobbler outputG = new
    StreamGobbler( proc2.getInputStream(), "Output") ;
    errorG.start() ;
    outputG.start() ;
    int exitVal1 = proc2.waitFor();
    The second part of the execution is taking AGES and I am not sure forking a new process for runtime execution is the best alternative here.
    I would be glad if someone can point me to a smarter solution.
    In short: I intend to execute a series of commands using RTE depending on the values I get in the loop.
    Thanks.

    Jared,
    Thank you for responding to my posted message. Rendezvous is a new concept to me, maybe
    it's the solution to my problem. I have been trying to read the on line manual and
    example VIs from National Instruments website. I still have a hard time to understand
    the concept.
    One of the example I saw is using rendezvous to run some sub VIs. But in my case, I have
    only one VI that is a while loop. Inside the while loop, there are a few tasks running
    simultaneously. I don't know whether it will serve my purpose.
    Guangde Wang
    Jared O'Mara wrote:
    > Guangde,
    >
    > Referring to your 2nd method, use rendezvous (under advanced>>synchronize
    > on function palette) to synchronize two processes. There are good examples
    > that come with labview. basically, you cre
    ate a rendezvous, giving it a
    > size. Using the wait on rendezvous vi, a function will not continue until
    > all rendezvous have reached that point. Using this method, you can synchronize
    > your 2 while loops.
    >
    > Jared
    >
    > Guangde Wang wrote:
    > >I tried two ways to control the tempo of my program.>>One is to use the
    > While Loop's counter and a wait. The drawback of this>method is the cycle
    > length is dependent on the measuring load. So if the>program runs for days,
    > it will be significent off the real time.>>The other way is to use the difference
    > of the Tick Count. It provides>accurate timing but the problem is the sychronization
    > of the clock cycle>and the While Loop cycle. I can try to put a little bit
    > wait but still>can not sychronize them very well. So after a while, there
    > will be two>measures get together.>>I don't know whether there are some better
    > ways to control the program>or whether we have some ways to improve either
    > or both of the above
    two>methods to make them work better. Please let me
    > know if you have any>suggestion.>>Thank you in advance,>>Guangde Wang>

  • A better way to activate an LOV

    I want to allow users to activate the LOVs and run queries from them without having to press the enter query button, then move their cursor to the appropriate text box, then press Ctrl+L, then press the execute query button. Is there some way to fire an LOV from a button press or some simpler way than I have right now?

    Thats really a good way.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Steven Lietuvnikas ([email protected]):
    i follow what you're saying but i think i found a better way to do it
    i made a button that says search on it and the whenbuttonpressed trigger is simply enter_query
    this then moves the focus to the first item in the record block
    i then made a whennewiteminstance trigger on the first item in the record block that says:
    DECLARE
    DUMMY BOOLEAN;
    BEGIN
    If (:system.Mode = 'ENTER-QUERY') Then
    DUMMY := SHOW_LOV('LOV_PERSONS',15,10);
    EXECUTE_QUERY;
    END IF;
    END;
    this works good<HR></BLOCKQUOTE>
    null

  • A better way to poll

    When my Start button is clicked it changes a member variable from false to true.
    Here is a simplified version of my code:
    public class gdvdhomevideo
       private boolean blnBegin;
       public static void main(String[] args)
          while(blnBegin == false){}
          //perform operations
       public void actionPerformed(ActionEvent e)
          String command = e.getActionCommand();
          if(command.equals("Start"))
             blnBegin = true;
    }So when the user clicks start it exits the while loop and the program starts performing other functions. The problem is that this approach is 100% CPU intensive and I know that there must be a better way?

    1) Code executed in the main() is NOT running on the event thread. Don't do any GUI code from the main thread... You know, stuff like showing windows, attaching event listeners etc.. You need to wrap all that stuff in a Runnable and pass that Runnable to SwingUtilities.invokeLater().
    2) Assuming the stuff you're doing in the main() is actually thread safe and doesn't touch the GUI, you can simply startup a new Thread and put your code in there. (see below)
    3) You class name is named badly. Please check out sun's java coding conventions. It is very nice to have coding conventions. Use them! ;-)
    4) if you want to setup your program as a loop rather than simply relying on user actions to fire events, then I'd suggest you use a timer that notifies on the event thread every X where X is a non-zero polling interval. I think there's a class is called SwingTimer that does this sort of thing for you.
    What you're attempting to do is non-trivial.. so.. ummm.. have fun..
    public class gdvdhomevideo
       private boolean blnBegin;
       public static void main(String[] args) throws Exception
            SwingUtilities.invokeLater( new Runnable() {
                  public void run() {
                       //setup stuff in here.
       public void actionPerformed(ActionEvent e)
          String command = e.getActionCommand();
          if(command.equals("Start"))
             new Thread(new Runnable() {
                public void run() {
                     //perform operations but don't touch the GUI.
              }.start();
    }

  • A better way to run .FMX from hyperlink

    Dear all,
    I am finding ways to execute .FMX from hyperlink in HTML. I tried to create a shortcut file (.LNK) that runs the .FMX and then using a hyperlink to refer that shortcut file. However, the browser prompts me for whether to run or to save the file every time. How can I suppress the dialog or is there any better way to do so?
    Regards,
    Derek.

    How you created a shortcut file(.LNK)
    How to call a form within a form using Hyperlink
    I am new to Java and could anybody help.

  • A better way to wake up from sleep?

    When my mac pro goes to sleep, I cannot wake it up by clicking mouse, hit keyboard, etc. I have to push the machine's power on/off button to wake it up. I assume there is a better way. Thank you in advance.

    Also, try a SMC reset.
    The following will help you with the repair Hatter is telling you about;
    Try using Disk Utility to do a Disk Repair, as shown in this link, while booted up on your install disk.
    You could have some directory corruption. Let us know what errors Disk Utility reports and if DU was able to repair them.
     DALE

  • A better way to run a 7 day report?

    Using Crystal Reports 11
    I am hoping there is a better way of running a seven day report that i have to run weekly
    In the report i have it set when refreshing the document, the "Prompt for new parameter values" comes up and there is a date field for start and end
    This is how i did it
    I made a formula called "Date" this comes from the closed date of our accounts
    I made a Parameter Field "Start Date" with the TYPE field is "Date"
    I made a Parameter Field "End Date" with the TYPE field is "Date"
    I made a Select Expert Using data from the "ClosedDate" in the first drop down I picked "Formula" and used this as the formula
    {WH_ACCTCOMMON.CLOSEDATE} in {?Start Date} to {?End Date}
    Two things
    1. Is there a way to have "Prompt for new parameters values" as the default checked off box when clicking "Refresh"?
    2. Is there a way to only enter a start date and the refresh would just run 7 days without entering a end date?

    Hi,
    Here's a suggestion for question 1:
    When you preview the report for 1st time there is no prompt window that asks you to select whether you wish to 'Use current values' or 'Prompt for new values'.
    If the Preview window is open and you hit refresh again, this is when you get the pop-up with the above options. If you close the Preview window and refresh again, you would not get a pop-up and it will show the Prompt window instead.
    For question 1, you can follow Alun's sugestions.
    -Abhilash

Maybe you are looking for

  • How to override strings in ww_strings.xlf

    Hi, I am facing an issue with overriding ww_strings.xlf which is available at <Middleware_Home> / Oracle_ECM1/ucm/idc/components/Localization/lang / <language code >. In general we can create a resource for strings in a custom component and we overri

  • Ping and download slow in Firefox/ not IE or Chrome

    I've reinstalled, created new profile, tried safe mode, ran virus checks and malware checks, disabled Protected Mode in Flash. The first try after shutting off ProtedtedMode gave good results. But now it's back to twice the numbers I get from Chrome

  • PONAPPRV - Sourcing process stuck in draft negotiation approval

    In sourcing while creating RFQ, the draft negotiation (before review and publish the negotiation) was submitted for approval to a collaboration team member. This was done by mistake, the workflow was not setup for this. In system administrator login,

  • Returns Delivery Reversal

    Hello Everyone, I have a returns delivery which I need to reverse. However, in VL09, I am encountering this error: "Deficit of BA Ret.blocked prev. 37,941.000 EA : <Material> <Plant> <Stor Location> <Batch> Shortfall below the specified stock level o

  • How to access class members in jsp??

    i m working in jsp and i make a class Student having attribute name and id and i store it at tomcat\classes\Student.java and i store a jsp page at tomcat\webapps\root\student\index.jsp now i create object of class Student in jsp page it works but whe