Need help to drag a rectangle to define a zoom level

Can some help me figure this out. I am trying to draw some graphics on a JPanel, then drag a rectangle to define a new zoom extent. I am having problems understanding how to do this with the AffineTransform. If you run the following code, you will see what I am trying to do....
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JToolBar;
public class TestCase extends JPanel implements MouseListener, MouseMotionListener {
  private Integer _startX = 0; // start x for dragging of rectangle
  private Integer _startY = 0; // start y for dragging of rectangle
  private Integer _lastX = 0; // end x for dragging of rectangle
  private Integer _lastY = 0; // end y for dragging of rectangle
  private boolean _isDragging = false;
  private Rectangle _rect = new Rectangle();
  private Rectangle[] _rects = null;
  private Color[] _colors = null;
  protected BufferedImage _imageBuffer = null;
  protected AffineTransform _xform = null;
  public TestCase() {
    _xform = new AffineTransform();
    _rects = new Rectangle[6];
    _rects[0] = new Rectangle(0, 0, 100, 100);
    _rects[1] = new Rectangle(100, 100, 100, 100);
    _rects[2] = new Rectangle(200, 200, 100, 100);
    _rects[3] = new Rectangle(300, 300, 100, 100);
    _rects[4] = new Rectangle(200, 0, 50, 50);
    _rects[5] = new Rectangle(250, 50, 50, 50);
    _colors = new Color[6];
    _colors[0] = Color.RED;
    _colors[1] = Color.WHITE;
    _colors[2] = Color.BLUE;
    _colors[3] = Color.GREEN;
    _colors[4] = Color.YELLOW;
    _colors[5] = Color.CYAN;
    setBackground(Color.LIGHT_GRAY);
    addMouseListener(this);
    addMouseMotionListener(this);
  // The next three methods enable user to drag a retangle
  // First, set the start points of the rectangle
  public void mousePressed(MouseEvent e) {
    _startX = new Integer(e.getX());
    _startY = new Integer(e.getY());
    _lastX = new Integer(e.getX());
    _lastY = new Integer(e.getY());
    _isDragging = true;
  // Second, drag the rectangle
  public void mouseDragged(MouseEvent e) {
    _lastX = new Integer(e.getX());
    _lastY = new Integer(e.getY());
    repaint();
  // Third, complete the rectangle, then zoom
  public void mouseReleased(MouseEvent event) {
    _lastX = new Integer(event.getX());
    _lastY = new Integer(event.getY());
    _lastX = new Integer(event.getX());
    _lastY = new Integer(event.getY());
    Rectangle rect = new Rectangle(_startX, _startY, _lastX - _startX, _lastY - _startY);
    Double widPanel = new Integer(this.getWidth()).doubleValue() / _xform.getScaleX();
    Double hgtPanel = new Integer(getHeight()).doubleValue() / _xform.getScaleY();
    Double widRect = rect.getWidth();
    Double hgtRect = rect.getHeight();
    Double scalex = widPanel.doubleValue() / widRect;
    Double scaley = hgtPanel.doubleValue() / hgtRect;
    Double translatex = _startX.doubleValue() * scalex;
    Double translatey = _startY.doubleValue() * scaley;
    _xform.setToScale(scalex, scaley);
    _xform.setToTranslation(translatex, translatey);
    _isDragging = false;
    repaint();
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    if(_isDragging){
      g2.drawImage(_imageBuffer, 0, 0, this);
      g2.setPaint(Color.RED);
      g2.drawRect(_startX, _startY, _lastX - _startX, _lastY - _startY);
    else{
      paintPanel(g2);
  protected void paintPanel(Graphics2D g) {
    Double width = this.getSize().getWidth();
    Double height = this.getSize().getHeight();
    Dimension size = this.getSize();
    _imageBuffer = new BufferedImage(Math.round(width.floatValue()), Math.round(height.floatValue()), BufferedImage.TYPE_INT_RGB);
    Graphics2D graphics = (Graphics2D) _imageBuffer.getGraphics();
    graphics.setColor(Color.LIGHT_GRAY);
    graphics.fillRect(0, 0, this.getWidth(), this.getHeight());
    for(int i = 0; i <= _rects.length - 1; i++){
      Rectangle rect = _rects;
Shape shape = _xform.createTransformedShape(rect);
graphics.setColor(_colors[i]);
graphics.fill(shape);
g.drawImage(_imageBuffer, 0, 0, this);
protected void zoomToExtent() {
_xform.setToIdentity();
repaint();
public void mouseClicked(MouseEvent event) {
public void mouseEntered(MouseEvent event) {
public void mouseExited(MouseEvent event) {
public void mouseMoved(MouseEvent event) {
public static void main(String[] args) {
final TestCase test = new TestCase();
JButton btnFullExtent = new JButton("Reset");
btnFullExtent.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
test.zoomToExtent();
JToolBar toolBar = new JToolBar();
toolBar.add(btnFullExtent);
final JFrame f = new JFrame();
f.getContentPane().setLayout(new BorderLayout());
f.getContentPane().add(toolBar, BorderLayout.NORTH);
f.getContentPane().add(new TestCase(), BorderLayout.CENTER);
f.setSize(600, 400);
f.setVisible(true);

I modified you code a little bit, just so I could improve my understanding. I tried to swap out the class level scale and translate variables, with an AffineTransform object, but wasn't able to get it working? Do you know why this won't work?
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Rectangle2D;
import java.util.Random;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JToolBar;
public class TestCase extends JPanel implements MouseListener, MouseMotionListener {
  private Point start;
  private Point end;
  private boolean dragging = false;
  private double zoom_x = 1.0;
  private double zoom_y = 1.0;
  private double translateX;
  private double translateY;
  private Rectangle[] _rects = null;
  private Color[] _colors = null;
  public TestCase() {
    setBackground(Color.LIGHT_GRAY);
    _rects = new Rectangle[6];
    _rects[0] = new Rectangle(0, 0, 100, 100);
    _rects[1] = new Rectangle(100, 100, 100, 100);
    _rects[2] = new Rectangle(200, 200, 100, 100);
    _rects[3] = new Rectangle(300, 300, 100, 100);
    _rects[4] = new Rectangle(200, 0, 50, 50);
    _rects[5] = new Rectangle(250, 50, 50, 50);
    _colors = new Color[6];
    _colors[0] = Color.RED;
    _colors[1] = Color.WHITE;
    _colors[2] = Color.BLUE;
    _colors[3] = Color.GREEN;
    _colors[4] = Color.YELLOW;
    _colors[5] = Color.CYAN;
    addMouseListener(this);
    addMouseMotionListener(this);
  public void mousePressed(MouseEvent e) {
    start = e.getPoint();
    dragging = true;
  public void mouseDragged(MouseEvent e) {
    end = e.getPoint();
    repaint();
  public void mouseReleased(MouseEvent e) {
    end = e.getPoint();
    double visibleWidth = getWidth();
    double visibleHeight = getHeight();
    double selectedWidth = Math.abs(end.getX() - start.getX());
    double selectedHeight = Math.abs(end.getY() - start.getY());
    double zoomFactorX = visibleWidth / selectedWidth;
    double zoomFactorY = visibleHeight / selectedHeight;
    translateX -= start.x / zoom_x;
    translateY -= start.y / zoom_y;
    zoom_x *= zoomFactorX;
    zoom_y *= zoomFactorY;
    dragging = false;
    repaint();
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    paintShapes((Graphics2D) g2.create());
    if(dragging){
      g2.setPaint(Color.RED);
      g2.drawRect(start.x, start.y, end.x - start.x, end.y - start.y);
  private void paintShapes(Graphics2D g2) {
    System.out.println("translateX=" + translateX + ", translateY=" + translateY + ", zoom_x=" + zoom_x + ", zoom_y=" + zoom_y);
    g2.scale(zoom_x, zoom_y);
    g2.translate(translateX, translateY);
    for(int i = 0; i <= _rects.length - 1; i++){
      Rectangle rect = _rects;
g2.setColor(_colors[i]);
g2.fill(rect);
public void reset() {
zoom_x = 1.0;
zoom_y = 1.0;
translateX = 0;
translateY = 0;
repaint();
public void mouseClicked(MouseEvent event) {
public void mouseEntered(MouseEvent event) {
public void mouseExited(MouseEvent event) {
public void mouseMoved(MouseEvent event) {
public static void main(String[] args) {
final TestCase test = new TestCase();
JButton btnFullExtent = new JButton("Reset");
btnFullExtent.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
test.reset();
JToolBar toolBar = new JToolBar();
toolBar.add(btnFullExtent);
final JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(new BorderLayout());
f.getContentPane().add(toolBar, BorderLayout.NORTH);
f.getContentPane().add(test, BorderLayout.CENTER);
f.setSize(600, 400);
f.setLocationRelativeTo(null);
f.setVisible(true);

Similar Messages

  • Need help about dragging a rectangle on a image

    hello
    i need to draw a rectangle on image .this is my code does this code support my requirement .
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    public class RectangleDrag extends JPanel {
    Rectangle tt=new Rectangle();
    int sx=0,sy=0,dx=0,dy=0;
    protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d=(Graphics2D)g;
    g2d.draw(tt);
    private MouseInputAdapter mia = new MouseInputAdapter() {
    public void mousePressed(MouseEvent e) {
    sx=e.getX(); //start x
    sy=e.getY(); // start y
    public void mouseDragged(MouseEvent e) {
    dx=e.getX(); //end x
    dy=e.getY(); // end y
    int width=Math.abs(dx-sx);
    int height=Math.abs(dy-sy);
    int side=Math.max(width, height);
                   int side1=Math.min(width,height);
    int x, y;
    if(sx<=dx) {
    x=sx;
    } else {
    x=sx-side;
    if(sy<=dy) {
    y=sy;
    } else {
    y=sy-side;
    tt.setRect(x,y,side,side1);
    repaint();
         private JPanel getContent(BufferedImage image) {
    JPanel panel = new JPanel(new GridLayout(1,0));
    panel.add(new JLabel(new ImageIcon(image)));
    panel.add(new JLabel(new ImageIcon(getImage(image))));
    return panel;
    public static void main(String[] args) {
    RectangleDrag test = new RectangleDrag();
    test.addMouseListener(test.mia);
    test.addMouseMotionListener(test.mia);
              String path = "C:/Documents and Settings/v.kirankumar/My Documents/jpg/32370.jpg";
    BufferedImage image = ImageIO.read(new File(path));
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.getContentPane().add(test.getContent(image));
    // f.pack();
    // f.getContentPane().add(test);
    f.setSize(400,400);
    f.setLocation(200,200);
    f.setVisible(true);
    }

    this is the modified code here am getting an image but i couldnt draw rectangle exactly on the image.
    getImage(image); isnt making any difference
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    public class RectangleDrag extends JPanel {
    Rectangle tt=new Rectangle();
    int sx=0,sy=0,dx=0,dy=0;
    protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d=(Graphics2D)g;
    g2d.draw(tt);
    private MouseInputAdapter mia = new MouseInputAdapter() {
    public void mousePressed(MouseEvent e) {
    sx=e.getX(); //start x
    sy=e.getY(); // start y
    public void mouseDragged(MouseEvent e) {
    dx=e.getX(); //end x
    dy=e.getY(); // end y
    int width=Math.abs(dx-sx);
    int height=Math.abs(dy-sy);
    int side=Math.max(width, height);
    int side1=Math.min(width,height);
    int x, y;
    if(sx<=dx) {
    x=sx;
    } else {
    x=sx-side;
    if(sy<=dy) {
    y=sy;
    } else {
    y=sy-side;
    tt.setRect(x,y,side,side1);
    repaint();
    private JPanel getContent(BufferedImage image) {
    JPanel panel = new JPanel(new GridLayout(1,0));
    panel.add(new JLabel(new ImageIcon(image)));
    return panel;
    public static void main(String[] args) {
    RectangleDrag test = new RectangleDrag();
    test.addMouseListener(test.mia);
    test.addMouseMotionListener(test.mia);
    String path = "C:/Documents and Settings/v.kirankumar/My Documents/jpg/32370.jpg";
    BufferedImage image = ImageIO.read(new File(path));
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(test.getContent(image));
    f.pack();
    f.getContentPane().add(test);
    f.setSize(400,400);
    f.setLocation(200,200);
    f.setVisible(true);
    }

  • Need help on creating a report after defining some criteria

    Hi everybody,
    I have been through some of the ebooks and got the idea of apex.
    To give an example what I would like to do is that I want to open two date picker fields and creating the report between the dates which were defined in the date pickers
    Those date picker field could be on the same page of report or they could be on another page. Once create button is pressed then the report between the defined dates should appear
    Any thoughts?
    Thanks from now

    Okay, two date pickers are date to and date from, logically date to must be equal or after date from, right?
    i defined a validation as pl/sql expressin saying that date to >= date from to the expression field
    there is no problem when I put a former date on date from and a latter date to date to.
    the problem occurs when I put same dates on the date pickers. An interesting point here is that when I put the same dates and click the submit button it gives an error BUT when I push again it works!
    it gives me the rows from the table of the date picker date. is there a problem about the caching and how can I solve it.
    Or, as you recommend you can show me an example on your workspace, that would be helpful as well

  • Need help with drag and drop game, Urgent!

    Hi I have created a drag and drop game, the drag and drop is
    working alright however once the right word has been placed in the
    box, and moves on to the next question the previous correct answer
    stays where it was placed, how can i get it to snap back to its
    original location? Also when the right word is draged in to the the
    white box i want it to snap into place in that box so it fits in
    there.
    Also if you have any other thoughts and advice on how i can
    improve on this please email me thanx
    Can someone please help, my .fla file can be found here:
    http://www.freshlemon.co.uk/timeline.fla
    http://www.freshlemon.co.uk/timeline.fla.zip
    thanx

    tellTarget is ancient
    I forget what it even used to do??? hahaha
    seriously, just put in the instance name and what you want it
    to do:
    tellTarget("movieclip"){
    play();
    is now just
    movieclip.play();

  • Newby to Flash -- need help with Drag and Drop

    I have been trying to create a drag and drop in Flash where I have five different places for an instance of a mc to be dropped. I want to be able to drop only three instances to each place and these three instances are specific to one of the five "drop places".  I also want the mc instance to go back to its original position if it is not dropped on the right place.  I've got the actionscript working to drag and drop the mc instances on the "drop places"  but I cannot figure out how to do the if statements so that if it doesn't match the correct drop place it will go back to its original position.
    Here's some of my code:
    Analyze1_mc.objName = "Analyze1";
    Analyze1_mc.val = 1;
    Design1_mc.objName = "Design1";
    Design1_mc.val = 4;
    Analyze1_mc.buttonMode = true; // sets mouse pointer to hand
    Design1_mc.buttonMode = true;
    Analyze1_mc.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    Analyze1_mc.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
    Design1_mc.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    Design1_mc.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
    var originalPosition:Point;
    function returnToOriginalPosition(): void
              originalPosition = new Point(x,y)
              x = originalPosition.x;
              y = originalPosition.y;
    // function to drag item clicked
    function fl_ClickToDrag(event:MouseEvent):void
              event.currentTarget.startDrag();
              event.target.parent.addChild(event.target);
    function fl_ReleaseToDrop(event:MouseEvent):void
              var target:MovieClip = event.currentTarget as MovieClip;
              var item:MovieClip = MovieClip(event.target);
              item.stopDrag();
    if (event.target.hitTestObject(AnalyzeTarget_mc)  && (event.target.val == 1)) {
                                            trace ("Analyze1");
                                            event.target.x = AnalyzeTarget_mc.x + 42;
                                            event.target.y = AnalyzeTarget_mc.y + 5;
                                            updateItem(Analyze1_mc);
                                  } else {
                                            returnToOriginalPosition();
    if (event.target.hitTestObject(DesignTarget_mc) && (event.target.val == 4)) {
                                            trace ("Design1");
                                            event.target.x = DesignTarget_mc.x + 42;
                                            event.target.y = DesignTarget_mc.y + 5;
                                            updateItem(Design1_mc);
                                  } else {
                                            returnToOriginalPosition();
    function updateItem(item:MovieClip):void {
              buttonMode = false;
              removeEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    I put the trace in to check the function -- and I do get the output when the mc instance is dropped on the right place -- but there is no return to original position if the instance is dropped in the wrong spot and there is no update to the mc instance. 
    Any help would be greatly appreciated. Thanks!

    That line you speak of is merely declaring a variable, nothing is being assigned to it.
    One way of assigning the original position data to each object is to just assign it like follows:
    Analyze1_mc.originalX = Analyze1_mc.x;
    Analyze1_mc.originalY = Analyze1_mc.y;
    etc...
    Another way to do it with less code is to assign it generically just before you start dragging each of them...
    function fl_ClickToDrag(event:MouseEvent):void
              event.currentTarget.originalX = event.currentTarget.x;
              event.currentTarget.originalY = event.currentTarget.y;
              event.currentTarget.startDrag();
              event.target.parent.addChild(event.target);
    One thing I noticed in your code earlier is that you switch between using event.currentTarget and event.target.  If you want to be sure that the object your code is targetiing is the object that has the listener assigned to it (your movieclips) stick with using currentTarget.   target can end up pointing to something inside that object instead of the object itself.  In the following lines...
              var target:MovieClip = event.currentTarget as MovieClip;
              var item:MovieClip = MovieClip(event.target);
    You could very well be assigning target and item as being the same object.  I don't think that is what you want.  You might wanting to have one of them be the object you drop it on, which would be the dropTarget, not the target

  • Need help: Dimensional column has assoc with more than 1 level

    Hi,
    I am trying to have multiple drill paths for a single dimension. For example, the Date dimension should be navigable by the following hierarchies:
    DateDimension
    +---- Calendar Year
    ......---- Calendar Quarter
    ............--- Calendar Month
    ..................-- Day
    +---- Calendar Year
    ......---- Day
    So, in other words, in Answers I should be able to add 'Calendar Year' to my report, display results, and then click down the path Calendar Year -> Calendar Quarter -> Calendar Month -> Day OR Calendar Year -> Day.
    However, when I model this in the Admin tool, it allows it, but then I add the column in Answers and get a runtime error:
    +[nQSError: 14064] Dimensional column [column name] has associations with more than one level+
    This is possible in BO and other tools. If it is not possible in Oracle BI EE, then one alternative would be to have two separate versions of 'Calendar Year' added to the report in Answers, each with their own drill path.
    Any ideas???
    Thanks for any help you can provide.
    Matt Warden
    Balanced Insight, Inc.

    Hi,
    You try this one .
    Create the Hierarchy Year --> Quarter--->Month-->Week-->Day in rpd as usual manner .But in Year report use navigate option in column properties add Quarterly Report (Caption it as 'Quarter')and Day level report(Caption it as 'Day') in navigate option.So when you click on Year column it i will prompt to select either Quarter or Day and when u select Quarter u will have normal drill functionality from Quarter to Month to Week and Day.Hope this helps you.
    Thanks.

  • HT2685 need help updating 4.2.1 Ipad to most current level from pc?

    i have transfered pictures.  not sure how to transfer purchased apps.  would like to update 4.2.1 ipad with pc

    Click here and follow the instructions.
    (96406)

  • Need help with date range searches for Table Sources in SES

    Hi all,
    I need help, please. I am trying to satisfy a Level 1 client requirement for the ability to search for records in crawled table sources by a date and/or date range. I have performed the following steps, and did not get accurate results from Advanced searching for date. Please help me understand what I am doing wrong, and/or if there is a way to define a date search attribute without creating a LOV for a date column. (My tables have 500,00 rows.)
    I am using SES 10.1.8.3 on Windows 32.
    My Oracle 10g Spatial Table is called REPORTS and this table has the following columns:
    TRACKNUM Varchar2
    TITLE Varchar2
    SUMMARY CLOB
    SYMBOLCODE Varchar2
    Timestamp Date
    OBSDATE Date
    GEOM SDO_GEOMETRY
    I set up the REPORTS table source in SES, using TRACKNUM as the Primary Key (unique and not null), and SUMMARY as the CONTENT Column. In the Table Column Mappings I defined TITLE as String and TITLE.
    Under Global Settings > Search Attributes I defined a new Search Attribute (type Date) called DATE OCCURRED (DD-MON-YY).
    Went back to REPORTS source previously defined and added a new Table Column Mapping - mapping OBSDATE to the newly defined DATE OCCURRED (DD-MON-YY) search attribute.
    I then modified the Schedule for the REPORTS source Crawler Policy to “Process All Documents”.
    Schedule crawls and indexes entire REPORTS table.
    In SES Advanced Search page, I enter my search keyword, select Specific Source Group as REPORTS, select All Match, and used the pick list to select the DATE OCCURRED (DD-MON-YY) Attribute Name, operator of Greater than equal, and entered the Value 01-JAN-07. Then the second attribute name of DATE_OCCURRED (DD-MON-YY), less than equals, 10-JAN-07.
    Search results gave me 38,000 documents, and the first 25 I looked at had dates NOT within the 01-JAN-07 / 10-JAN-07 range. (e.g. OBSDATE= 10-MAR-07, 22-SEP-07, 02-FEB-08, etc.)
    And, none of the results I opened had ANY dates within the SUMMARY CLOB…in case that’s what was being found in the search.
    Can someone help me figure out how to allow my client to search for specific dated records in a db table using a single column for the date? This is a major requirement and they are anxiously awaiting my solution.
    Thanks very much, in advance….

    raford,
    Thanks very much for your reply. However, from what I've read in the SES Admin Document is that (I think) the date format DD/MM/YYYY pertains only to searches on "file system" sources (e.g. Word, Excel, Powerpoint, PDF, etc.). We have 3 file system sources among our 25 total sources. The remaining 22 sources are all TABLE or DATABASE sources. The DBA here has done a great job getting the data standardized using the typical/default Oracle DATE type format in our TABLE sources (DD-MON-YY). Our tables have anywhere from 1500 rows to 2 million rows.
    I tested your theory that the dates we are entering are being changed to Strings behind the scenes and on the Advanced Page, searched for results using OBSDATE equals 01/02/2007 in an attempt to find data that I know for certain to be in the mapped OBSDATE table column as 01-FEB-07. My result set contained data that had an OBSDATE of 03-MAR-07 and none containing 01-FEB-07.
    Here is the big issue...in order for my client to fulfill his primary mission, one of the top 5 requirements is that he/she be able to find specific table rows that are contain a specific date or range of dates.
    thanks very much!

  • How do I reorder songs in a playlist in the new itunes??? I can no longer just click and drag. When I click, it doesn't move!!!! Need help ASAP- trying to prepare for an aerobics class and need songs in a specific order!

    How do I reorder songs in a playlist in the new itunes??? I can no longer just click and drag. When I click, it doesn't move!!!! Need help ASAP- trying to prepare for an aerobics class and need songs in a specific order!

    Vera,
    Use View > View Options, and set 'Sort By" to "Manual Order."
    Then you will be able to drag-n-drop songs up and down the list.

  • Need help creating a rectangle with a bunch of  text scrolling up within it

    Hey everyone, I'm using Motion 2 and want to add a large amount of text scrolling up. Which behavior would be best to use, the Scroll up or Motion Path?
    I want to create a rectangle where the text will be scrolling within it but I'm not sure how to do that. I'm I suppose to create a mask rectangle and then add the text?
    Please help
    Thank You

    As with most things there are a number of ways you could do it.
    One way is, if your making a rectangle anyway (as a bkg for the text) you can make an image mask (command shift m) on the text object and drag the rectangle into the mask well (then turn the rectangles visibility back on). This works with a filled rectangle.
    Of course you have to format the text to fit in the rectangle as it won't act as a bounding type area (like in AI, PSD).
    o| TOnyTOny |o

  • Need help defining a query

    Hi everyone...
    I need help with this query. The table 'cobros' has a primary key defined by id_cliente + id_cobro. I pretend to classify rows by COUNT(id_cobro) which are between a date range.
    A client could have 1 or 2 or 3 rows per day, no more for a specific date. I would like to get first, all clients with COUNT(id_cobro) = 1, all clients with COUNT(id_cobro) = 2, and finally all clients with COUNT(id_cobro) = 3.
    Something similar to:
    1 SELECT id_cliente, COUNT(id_cobro) FROM cobros
    2 WHERE fecha_proximo_cobro >= '2011-05-30 00:00'
    3 AND fecha_proximo_cobro <= '2011-05-30 23:59'
    4 AND COUNT(id_cobro) = 1
    5 GROUP BY id_cliente
    The fourth line is the problem. It doesn't work.
    Thanks in advance!!!
    Mario

    Maybe you are looking for something like this?
    SELECT id_cliente
         , COUNT(*)   AS cnt
    FROM   cobros
    WHERE  fecha_promixo_cobro BETWEEN TO_DATE('2011-05-30 00:00','YYYY-MM-DD HH24:MI') AND TO_DATE('2011-05-30 23:59','YYYY-MM-DD HH24:MI')
    GROUP BY id_cliente
    ORDER BY 2
           , 1Also, NEVER rely on implicit data type conversion as you have (you provide a STRING not a DATE).
    Edited by: Centinul on Jun 2, 2011 12:36 PM
    Fixed syntax error.

  • Cannot create new folders on desktop. Cannot drag new items onto desktop. Desktop in Finder opens with Terminal. Not sure if this has anything to do with upgrading to Mavericks but I need help if anyone has ideas. Thank you.

    I can no longer create new folders on my desktop. The option to do that is now light gray on the drop down menu and can't be selected.
    I cannot drag new items onto desktop any longer either.
    The Desktop in Finder opens with Terminal.
    Folders and items on Desktop open and work normally.
    Not sure if this has anything to do with upgrading to Mavericks but I need help if anyone has ideas.
    Thank you.

    Take these steps if the cursor changes from an arrow to a white "prohibited" symbol when you try to move an icon on the Desktop.
    Sometimes the problem may be solved just by logging out or rebooting. Try that first, if you haven't already done it. Otherwise, continue.
    Select the icon of your home folder (a house) in the sidebar of a Finder window and open it. The Desktop folder is one of the subfolders. Select it and open the Info window. In the General section of the window, the Kind will be either Folder  or something else, such as Anything.
    If the Kind is Folder, uncheck the box marked Locked. Close the Info window and test.
    If the Kind is not Folder, make sure the Locked box is not checked and that you have Read & Write privileges in the  Sharing & Permissions section. Then close the Info window and do as follows.
    Back up all data.
    Triple-click anywhere in the line below on this page to select it:
    xattr -d com.apple.FinderInfo Desktop
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    Launch the Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Paste into the Terminal window (command-V). You should get a new line ending in a dollar sign (“$”). Quit Terminal.
    Relaunch the Finder.
    If the problem is now resolved, and if you use iPhoto, continue.
    Quit iPhoto if it's running. Launch it while holding down the option key. It will prompt you to select a library. Choose the one you want to use (not the Desktop folder.)

  • I need help with rectangle tool size/align

    Hey there !
    i've some trouble with a specific document. I could not align any rectangle or define a specific size. For exemple, i choose 600px x600 px in the top "menu" bar, illustrator change the values by 599,641 px
    It's the same in inch, mm..ect
    The second thing it's if i choose a specific coordonate to place the rectangle , it's change by illustrator.
    Any ideas ?
    I have not the problem on other document.
    It's a 21 cm 21cm @ 300 dpi, proprotions 1
    No grid activited or anything else to force the magnetism

    It was, but it doesn't change :/
    I've tried to created a new document, but with pixel dimension. then i change it in cm, and it's work..
    but if my document is created in mm or cm, it's just not work
    So i could not have a cm or mm document and precise rectangle size.. i have to create a whole number pixel document

  • Objects outside of workspace show in SWF... Need help ASAP!

    When I export a flash movie (.swf file)And play it on full screen, the objects that are outside of the workspace show. Can anyone tell me how to fish this problem? need help ASAP! Thanks :]

    If what follows isn't sufficient for you to figure out, you'll have to spend some time learning how to work with Flash.  While you'll often get help solving problems in these forums, it's less likely you will get tutoring services.  Google is a very good resource for tutorials.
    To create a mask you draw a shape to the size you want and place it on a layer above all the content you want to mask.  A mask is actually not well named because masks normally hide things, while in the graphics world, masks define the are where things are shown... so when you apply a mask to something, only what is under the mask shows.  To finalize, you right click on the label area of the mask's layer and select Mask from the menu that appears.  You may have to drag lower layers up towards the mask layer to get them included, whicxh is why I mentioned creating the rest of the content as a movieclip (a single layer object).
    To control the visibility of objects you set their visibility to true or false (AS2: mcName._visible = true (or false),  AS3:mcName.visible = true (or false)).
    To create a frame around the stage, add a new layer atop everything and draw a rectangle big enough to hide all the content you don't want showing that is off the stage.  Then draw a rectangle that is the same size as the stage on top of that first rectangle, placing it over the stage, and then deselect anything that is selected.  Then reselect the smaller rectangle you just drew and delete it.  The larger rectangle is now framing your stage.

  • NEED HELP IN LABELLING A TRIANGLE _ VERTICES

    PLEASE HELP ______
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.text.NumberFormat;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.DefaultTableCellRenderer;
    import java.lang.*;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionListener;
    import java.awt.FileDialog;
    import java.io.*;
    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionListener;
    import javax.swing.JFrame;
    public class Geometry {
        CardLayout cards;
        JPanel panel;
        public Geometry() {
            cards = new CardLayout();
            panel = new JPanel(cards);
            addCards();
            JFrame f = new JFrame("Geometry");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setJMenuBar(getMenuBar());
            f.getContentPane().add(panel);
            f.setSize(500,500);
            f.setLocation(0,0);
            f.setVisible(true);
            f.addMouseMotionListener(
            new MouseMotionListener() { //anonymous inner class
                //handle mouse drag event
                public void mouseMoved(MouseEvent e) {
                   System.out.println("Mouse  " + e.getX() +","  + e.getY());
                public void mouseDragged(MouseEvent e) {
                    System.out.println("Draggg: x=" + e.getX() + "; y=" + e.getY());
            //            public void mouseMoved(MouseEvent me) {
            //                System.out.println("Moving: x=" + me.getX() + "; y=" + me.getY());
            //        panel.addMouseMotionListener(
            //        new MouseMotionListener() { //anonymous inner class
            //            //handle mouse drag event
            //           public void mouseDragged(MouseEvent me) {
            //               setTitle("Dragging: x=" + me.getX() + "; y=" + me.getY());
            //            public void mouseMoved(MouseEvent me) {
            //                setTitle("Moving: x=" + me.getX() + "; y=" + me.getY());
        private void addCards() {
            // card one
            TriangleModel tri = new TriangleModel(175,100,175,250,325,250);
            TriangleView view  = new TriangleView(tri);
            JPanel panelOne = new JPanel(new BorderLayout());
            panelOne.add(view.getUIPanel(), "North");
            panelOne.add(view);
            panelOne.add(view.getTablePanel(), "South");
            panelOne.setName("Pythagoras's Theorem");
            panel.add("Pythagoras's Theorem", panelOne);
                  view.addMouseMotionListener(
            new MouseMotionListener() { //anonymous inner class
                //handle mouse drag event
                 public void mouseMoved(MouseEvent e) {
                    System.out.println("Mouse at " + e.getX() +","  + e.getY());
               public void mouseDragged(MouseEvent e) {
                   System.out.println("Dragging: x=" + e.getX() + "; y=" + e.getY());
            // card two
            TestModel trin = new TestModel(175,100,175,250,325,250);
            TestView viewn  = new TestView(trin);
            JPanel panelTwo = new JPanel(new BorderLayout());
            panelTwo.add(viewn.getUIPanel(), "North");
          // panelTwo.setBackground(Color.blue);
            panelTwo.setName("Similar Triangles");
            panelTwo.add(viewn);
            panelTwo.add(viewn.getTablePanel(), "South");
                  viewn.addMouseMotionListener(
            new MouseMotionListener() { //anonymous inner class
                //handle mouse drag event
                 public void mouseMoved(MouseEvent e) {
                    System.out.println("Mouse at " + e.getX() +","  + e.getY());
               public void mouseDragged(MouseEvent e) {
                   System.out.println("Dragging: x=" + e.getX() + "; y=" + e.getY());
            panel.add("Similar Triangles", panelTwo);
            JPanel panelThree = new JPanel();
            panelThree.setBackground(Color.white);
            panelThree.setName("Circle Theorem1");
            panel.add("Circle Theorem1", panelThree);
        private JMenuBar getMenuBar() {
            JMenu File = new JMenu("File");
            JSeparator separator1 = new JSeparator();
            JMenuItem Open = new JMenuItem("Open");
    //         Open.addActionListener(new java.awt.event.ActionListener() {
    //            public void actionPerformed(java.awt.event.ActionEvent evt) {
    //                openActionPerformed(evt);
            JMenuItem Save = new JMenuItem("Save");
            JMenuItem Print = new JMenuItem("Print");
            JMenuItem Exit = new JMenuItem("Exit");
            Exit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ExitActionPerformed(evt);
            JMenu theorem = new JMenu("Theorem");
            ActionListener l = new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    JMenuItem item = (JMenuItem)e.getSource();
                    String name = item.getActionCommand();
                    cards.show(panel, name);
            Component[] c = panel.getComponents();
            for(int j = 0; j < panel.getComponentCount(); j++) {
                String name = c[j].getName();
                JMenuItem item = new JMenuItem(name);
                item.setActionCommand(name);
                item.addActionListener(l);
                theorem.add(item);
            JMenuBar menuBar = new JMenuBar();
            JMenuBar menuBar1 = new JMenuBar();
            menuBar.add(File);
            File.add(Open);
            File.add(separator1);
            File.add(Save);
            File.add(Print);       
            File.add(Exit);
            menuBar.add(theorem);
            return menuBar;
    //    private void openActionPerformed(java.awt.event.ActionEvent evt) {
    //        FileDialog fileDialog = new FileDialog(this, "Open...", FileDialog.LOAD);
    //        fileDialog.show();
    //        if (fileDialog.getFile() == null)
    //            return;
    //        fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile();
    //        FileInputStream fis = null;
    //        String str = null;
    //        try {
    //            fis = new FileInputStream(fileName);
    //            int size = fis.available();
    //            byte[] bytes = new byte [size];
    //            fis.read(bytes);
    //            str = new String(bytes);
    //        } catch (IOException e) {
    //        } finally {
    //            try {
    //                fis.close();
    //            } catch (IOException e2) {
    //        if (str != null)
    //            textBox.setText(str);
        private void ExitActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
            System.exit(0);
        public static void main(String[] args) {
            new Geometry();
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.text.NumberFormat;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.DefaultTableCellRenderer;
    public class Triangle
    public Triangle()
    TriangleModel tri = new TriangleModel(175,100,175,250,325,250);
    TriangleView view = new TriangleView(tri);
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(view.getUIPanel(), "North");
    f.getContentPane().add(view);
    f.getContentPane().add(view.getTablePanel(), "South");
    f.setSize(500,500);
    f.setLocation(200,200);
    f.setVisible(true);
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.awt.event.MouseEvent;
    import javax.swing.JTable;
    import javax.swing.event.MouseInputAdapter;
    * TriangleControl.java
    * Created on 06 February 2005, 01:19
    * @author  Rahindra Naidoo
    public class TriangleControl extends MouseInputAdapter
        TriangleView view;
        TriangleModel model;
        Point start;
        boolean dragging, altering;
        Rectangle lineLens;            // used for line selection
        public TriangleControl(TriangleView tv)
            view = tv;
            model = view.getModel();
            dragging = altering = false;
            lineLens = new Rectangle(0, 0, 6, 6);
        public void mousePressed(MouseEvent e)
            Point p = e.getPoint();
            lineLens.setLocation(p.x - 3, p.y - 3);
            // are we over a line
            if(model.isLineSelected(lineLens))
                start = p;
                altering = true;
            // or are we within the triangle
            else if(model.contains(p))
                start = p;
                dragging = true;
        public void mouseReleased(MouseEvent e)
            altering = false;
            dragging = false;
            view.getCentroidLabel().setText("centroid location: " +
                                             model.findCentroid());
            view.repaint();  // for the construction lines
        public void mouseDragged(MouseEvent e)
            Point p = e.getPoint();
            if(altering)
                int x = p.x - start.x;
                int y = p.y - start.y;
                model.moveSide(x, y, p);
                updateTable();
                view.repaint();
                start = p;
            else if(dragging)
                int x = p.x - start.x;
                int y = p.y - start.y;
                model.translate(x, y);
                view.repaint();
                start = p;
        private void updateTable()
            String[] lengths = model.getLengths();
            String[] squares = model.getSquares();
            String[] angles  = model.getAngles();
            JTable table = view.getTable();
            for(int j = 0; j < angles.length; j++)
                table.setValueAt(lengths[j], 1, j + 1);
                table.setValueAt(squares[j], 2, j + 1);
                table.setValueAt(angles[j],  3, j + 1);
            view.getCentroidLabel().setText("centroid location: " +
                                             model.findCentroid());
    * TriangleModel.java
    * Created on 06 February 2005, 01:18
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.text.NumberFormat;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.DefaultTableCellRenderer;
    * @author  Rahindra Naidoo
    public class TriangleModel                      //  (x1, y1)
    {                                         //      |\
        static final int SIDES = 3;         //      | \
        private int cx, cy;                  //      |  \
        Polygon triangle;                     //      |_ _\ (x3, y3)
        int selectedIndex;                   //  (x2, y2)
        NumberFormat nf;
        Line2D[] medians;
        Point2D centroid;
        public TriangleModel(int x1, int y1, int x2, int y2, int x3, int y3)
            int[] x = new int[] { x1, x2, x3 };
            int[] y = new int[] { y1, y2, y3 };
            triangle = new Polygon(x, y, SIDES);
            nf = NumberFormat.getNumberInstance();
            nf.setMaximumFractionDigits(1);
        public boolean contains(Point p)
            // Polygon.contains doesn't work well enough
            return (new Area(triangle)).contains(p);
        public boolean isLineSelected(Rectangle r)
            Line2D line = new Line2D.Double();
            for(int j = 0; j < SIDES; j++)
                int[] x = triangle.xpoints;
                int[] y = triangle.ypoints;
                int x1 = x[j];
                int y1 = y[j];
                int x2 = x[(j + 1) % SIDES];
                int y2 = y[(j + 1) % SIDES];
                line.setLine(x1, y1, x2, y2);
                if(line.intersects(r))
                    selectedIndex = j;
                    return true;
            selectedIndex = -1;
            return false;
         * Only works for right triangle with right angle at (x2, y2)
        public void moveSide(int dx, int dy, Point p)
            int[] x = triangle.xpoints;
            int[] y = triangle.ypoints;
            switch(selectedIndex)
                case 0:
                    x[0] += dx;
                    x[1] += dx;
                    break;
                case 1:
                    y[1] += dy;
                    y[2] += dy;
                    break;
                case 2:
                    double rise  = y[2] - y[0];
                    double run   = x[2] - x[0];
                    double slope = rise/run;
                    // rise / run == (y[2] - p.y) / (x[2] - p.x)
                    x[2] = p.x + (int)((y[2] - p.y) / slope);
                    // rise / run == (p.y - y[0]) / (p.x - x[0])
                    y[0] = p.y - (int)((p.x - x[0]) * slope);
        public void translate(int dx, int dy)
            triangle.translate(dx, dy);
        public Polygon getTriangle()
            return triangle;
        public String findCentroid()
            int[] x = triangle.xpoints;
            int[] y = triangle.ypoints;
            // construct the medians defined as the line from
            // any vertex to the midpoint of the opposite line
            medians = new Line2D[x.length];
            for(int j = 0; j < x.length; j++)
                int next = (j + 1) % x.length;
                int last = (j + 2) % x.length;
                Point2D vertex = new Point2D.Double(x[j], y[j]);
                // get midpoint of line opposite vertex
                double dx = ((double)x[last] - x[next])/2;
                double dy = ((double)y[last] - y[next])/2;
                Point2D oppLineCenter = new Point2D.Double(x[next] + dx,
                                                           y[next] + dy);
                medians[j] = new Line2D.Double(vertex, oppLineCenter);
            // centroid is located on any median 2/3 the way from the
            // vertex (P1) to the midpoint (P2) on the opposite side
            double[] lengths = getSideLengths();
            double dx = (medians[0].getX2() - medians[0].getX1())*2/3;
            double dy = (medians[0].getY2() - medians[0].getY1())*2/3;
            double px = medians[0].getX1() + dx;
            double py = medians[0].getY1() + dy;
            //System.out.println("px = " + nf.format(px) +
            //                 "\tpy = " + nf.format(py));
            centroid = new Point2D.Double(px, py);
            return "(" + nf.format(px) + ",  " + nf.format(py) + ")";
        public String[] getAngles()
            double[] lengths = getSideLengths();
            String[] vertices = new String[lengths.length];
            for(int j = 0; j < lengths.length; j++)
                int opp  = (j + 1) % lengths.length;
                int last = (j + 2) % lengths.length;
                double top = lengths[j] * lengths[j] +
                             lengths[last] * lengths[last] -
                             lengths[opp] * lengths[opp];
                double divisor = 2 * lengths[j] * lengths[last];
                double vertex = Math.acos(top / divisor);
                vertices[j] = nf.format(Math.toDegrees(vertex));
            return vertices;
        public String[] getLengths()
            double[] lengths = getSideLengths();
            String[] lengthStrs = new String[lengths.length];
            for(int j = 0; j < lengthStrs.length; j++)
                lengthStrs[j] = nf.format(lengths[j]);
            return lengthStrs;
        public String[] getSquares()
            double[] lengths = getSideLengths();
            String[] squareStrs = new String[lengths.length];
            for(int j = 0; j < squareStrs.length; j++)
                squareStrs[j] = nf.format(lengths[j] * lengths[j]);
            return squareStrs;
        private double[] getSideLengths()
            int[] x = triangle.xpoints;
            int[] y = triangle.ypoints;
            double[] lengths = new double[SIDES];
            for(int j = 0; j < SIDES; j++)
                int next = (j + 1) % SIDES;
                lengths[j] = Point.distance(x[j], y[j], x[next], y[next]);
            return lengths;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.text.NumberFormat;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.DefaultTableCellRenderer;
    * TriangleView.java
    * Created on 06 February 2005, 01:21
    public class TriangleView extends JPanel
        private TriangleModel model;
        private Polygon triangle;
        private JTable table;
        private JLabel centroidLabel;
        private boolean showConstruction;
        TriangleControl control;
        public TriangleView(TriangleModel model)
            this.model = model;
            triangle = model.getTriangle();
            showConstruction = false;
            control = new TriangleControl(this);
            addMouseListener(control);
            addMouseMotionListener(control);
        public void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.draw(triangle);
            if(model.medians == null)
                centroidLabel.setText("centroid location: " + model.findCentroid());
            // draw medians and centroid point
            if(showConstruction && !control.dragging)
                g2.setPaint(Color.red);
                for(int j = 0; j < 3; j++)
                    g2.draw(model.medians[j]);
                g2.setPaint(Color.blue);
                g2.fill(new Ellipse2D.Double(model.centroid.getX() - 2,
                                             model.centroid.getY() - 2, 4, 4));
        public TriangleModel getModel()
            return model;
        public JTable getTable()
            return table;
        public JLabel getCentroidLabel()
            return centroidLabel;
        public JPanel getUIPanel()
            JCheckBox showCon = new JCheckBox("show construction");
            showCon.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    boolean state = ((JCheckBox)e.getSource()).isSelected();
                    showConstruction = state;
                    repaint();
            JPanel panel = new JPanel();
            panel.add(showCon);
            return panel;
        public JPanel getTablePanel()
            String[] headers = new String[] { "", "", "", "" };
            // row and column data labels
            String[] rowHeaders = {
                "sides", "lengths", "squares", "angles", "degrees"
            String[] sidesRow = { "vertical", "horizontal", "hypotenuse" };
            String[] anglesRow = { "hyp to ver", "ver to hor", "hor to hyp" };
            // collect data from model
            String[] angles  = model.getAngles();
            String[] lengths = model.getLengths();
            String[] squares = model.getSquares();
            String[][] allData = { sidesRow, lengths, squares, anglesRow, angles };
            int rows = 5;
            int cols = 4;
            Object[][] data = new Object[rows][cols];
            for(int row = 0; row < rows; row++)
                data[row][0] = rowHeaders[row];
                for(int col = 1; col < cols; col++)
                    data[row][col] = allData[row][col - 1];
            table = new JTable(data, headers)
                public boolean isCellEditable(int row, int col)
                    return false;
            DefaultTableCellRenderer renderer =
                (DefaultTableCellRenderer)table.getDefaultRenderer(String.class);
            renderer.setHorizontalAlignment(JLabel.CENTER);
            centroidLabel = new JLabel("centroid location:  ", JLabel.CENTER);
            Dimension d = centroidLabel.getPreferredSize();
            d.height = table.getRowHeight();
            centroidLabel.setPreferredSize(d);
            JPanel panel = new JPanel(new BorderLayout());
            panel.setBorder(BorderFactory.createTitledBorder("triangle data"));
            panel.add(table);
            panel.add(centroidLabel, "South");
            return panel;
    }PLEASE HELP ME TO LABEL THE TRIANGLE AND CHANGE THE VALUES OF THE JTABLE - to SHOW ASquare b Square and C square as well as a label on the bottom of the screen to show A^2 + B^2 = C^2 ...
    ThANKS

        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
            g2.drawPolygon(triangle);
            // label the triangle
            String[] lengths = model.getLengths();
            String[] squares = model.getSquares();
            String[] angles  = model.getAngles();
            int[] x = triangle.xpoints;
            int[] y = triangle.ypoints;
            for(int j = 0; j < x.length; j++) {
                Point2D vertex = new Point2D.Double(x[j], y[j]);
                int next = (j + 0) % x.length;
                int last = (j + 1) % x.length;
                double dx = ((double)x[last] - x[next])/2;
                double dy = ((double)y[last] - y[next])/2;
                Point2D center = new Point2D.Double(x[next] + dx, y[next] + dy);
                g2.drawString(angles[j],(int)vertex.getX(),(int)vertex.getY());
                g2.drawString(lengths[j],(int)center.getX(),(int)center.getY());
            g2.drawString(squares[0],100, getHeight());
            g2.drawString(" + "+squares[1],150, getHeight());
            g2.drawString(" = "+squares[2],200, getHeight());
            if(model.medians == null)
                centroidLabel.setText("centroid location: " + model.findCentroid());
            // draw medians and centroid point
            if(showConstruction && !control.dragging) {
                g2.setPaint(Color.red);
                for(int j = 0; j < 3; j++)
                    g2.draw(model.medians[j]);
                g2.setPaint(Color.blue);
                g2.fill(new Ellipse2D.Double(model.centroid.getX() - 2,
                        model.centroid.getY() - 2, 4, 4));
        }

Maybe you are looking for

  • Added gift card but WON'T work!  Please help!

    Hi all, I hope someone can help me here. I added a $20 iTunes card to the account and it shows the credit beside my username "[email protected]" but whenever I go to buy something it says it is going to charge my credit card and if I click ok then it

  • Customer report in Multi currency

    Hi, my client has customers in different country , so he want to see multicurrency report . i.e as well as indian curreny and customers country currency,please can any help me in this issue, does in sap there are standard reports or else we need to d

  • Very New To Java

    Hi, I'm very new to java - 2nd day. Trying to move from Visual FoxPro. In testing statements to learn java, I can't seem to get java.util.Scanner.nextInt or nextDouble ... etc. to wait for a keyborad input. Is there something I have to configure befo

  • IconURL in JavaPortlet

    Hi. I am getting the following error while trying to specify an iconUrl in a JSR 168 portlet. Any clues? <Mar 1, 2004 11:57:55 AM PST> <Error> <netuix> <BEA-421519> <One or more validat ion error(s) occurred during parsing /portlets/MarketWatchPortle

  • Assigning user roles in my application in a programatic way

    Hi, How can I assign user roles in a programatic way when I am using the Sun One 7 server? Is that possible? Thanks, Wanderley.